instantsearch.js 4.49.0 → 4.49.2

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 (376) hide show
  1. package/README.md +3 -3
  2. package/cjs/components/Answers/Answers.js +6 -16
  3. package/cjs/components/Breadcrumb/Breadcrumb.js +5 -12
  4. package/cjs/components/ClearRefinements/ClearRefinements.js +4 -11
  5. package/cjs/components/CurrentRefinements/CurrentRefinements.js +5 -12
  6. package/cjs/components/GeoSearchControls/GeoSearchButton.js +4 -6
  7. package/cjs/components/GeoSearchControls/GeoSearchControls.js +11 -20
  8. package/cjs/components/GeoSearchControls/GeoSearchToggle.js +4 -6
  9. package/cjs/components/Highlight/Highlight.js +3 -11
  10. package/cjs/components/Hits/Hits.js +8 -20
  11. package/cjs/components/InfiniteHits/InfiniteHits.js +13 -25
  12. package/cjs/components/InternalHighlight/InternalHighlight.js +0 -3
  13. package/cjs/components/MenuSelect/MenuSelect.js +9 -19
  14. package/cjs/components/Pagination/Pagination.js +10 -17
  15. package/cjs/components/Panel/Panel.js +7 -26
  16. package/cjs/components/PoweredBy/PoweredBy.js +4 -5
  17. package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +2 -6
  18. package/cjs/components/RangeInput/RangeInput.js +16 -48
  19. package/cjs/components/RefinementList/RefinementList.js +19 -73
  20. package/cjs/components/RefinementList/RefinementListItem.js +8 -14
  21. package/cjs/components/RelevantSort/RelevantSort.js +4 -8
  22. package/cjs/components/ReverseHighlight/ReverseHighlight.js +3 -11
  23. package/cjs/components/ReverseSnippet/ReverseSnippet.js +3 -11
  24. package/cjs/components/SearchBox/SearchBox.js +25 -69
  25. package/cjs/components/Selector/Selector.js +3 -6
  26. package/cjs/components/Slider/Pit.js +3 -10
  27. package/cjs/components/Slider/Rheostat.js +63 -131
  28. package/cjs/components/Slider/Slider.js +28 -65
  29. package/cjs/components/Snippet/Snippet.js +3 -11
  30. package/cjs/components/Stats/Stats.js +7 -20
  31. package/cjs/components/Template/Template.js +8 -37
  32. package/cjs/components/ToggleRefinement/ToggleRefinement.js +4 -10
  33. package/cjs/components/VoiceSearch/VoiceSearch.js +8 -15
  34. package/cjs/connectors/answers/connectAnswers.js +21 -36
  35. package/cjs/connectors/autocomplete/connectAutocomplete.js +8 -25
  36. package/cjs/connectors/breadcrumb/connectBreadcrumb.js +17 -48
  37. package/cjs/connectors/clear-refinements/connectClearRefinements.js +27 -45
  38. package/cjs/connectors/configure/connectConfigure.js +6 -20
  39. package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +11 -36
  40. package/cjs/connectors/current-refinements/connectCurrentRefinements.js +18 -57
  41. package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +17 -37
  42. package/cjs/connectors/geo-search/connectGeoSearch.js +17 -47
  43. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +38 -74
  44. package/cjs/connectors/hits/connectHits.js +10 -26
  45. package/cjs/connectors/hits/connectHitsWithInsights.js +0 -4
  46. package/cjs/connectors/hits-per-page/connectHitsPerPage.js +15 -38
  47. package/cjs/connectors/index.js +62 -96
  48. package/cjs/connectors/infinite-hits/connectInfiniteHits.js +26 -62
  49. package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +0 -4
  50. package/cjs/connectors/menu/connectMenu.js +28 -66
  51. package/cjs/connectors/numeric-menu/connectNumericMenu.js +24 -78
  52. package/cjs/connectors/pagination/Paginator.js +3 -20
  53. package/cjs/connectors/pagination/connectPagination.js +8 -25
  54. package/cjs/connectors/powered-by/connectPoweredBy.js +4 -13
  55. package/cjs/connectors/query-rules/connectQueryRules.js +32 -56
  56. package/cjs/connectors/range/connectRange.js +41 -101
  57. package/cjs/connectors/rating-menu/connectRatingMenu.js +23 -79
  58. package/cjs/connectors/refinement-list/connectRefinementList.js +37 -70
  59. package/cjs/connectors/relevant-sort/connectRelevantSort.js +4 -14
  60. package/cjs/connectors/search-box/connectSearchBox.js +7 -23
  61. package/cjs/connectors/sort-by/connectSortBy.js +11 -21
  62. package/cjs/connectors/stats/connectStats.js +4 -11
  63. package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +29 -63
  64. package/cjs/connectors/voice-search/connectVoiceSearch.js +13 -35
  65. package/cjs/helpers/components/Highlight.js +4 -12
  66. package/cjs/helpers/components/ReverseHighlight.js +7 -19
  67. package/cjs/helpers/components/ReverseSnippet.js +7 -19
  68. package/cjs/helpers/components/Snippet.js +4 -12
  69. package/cjs/helpers/components/index.js +0 -8
  70. package/cjs/helpers/get-insights-anonymous-user-token.js +7 -12
  71. package/cjs/helpers/highlight.js +10 -16
  72. package/cjs/helpers/index.js +17 -31
  73. package/cjs/helpers/insights.js +5 -17
  74. package/cjs/helpers/reverseHighlight.js +10 -16
  75. package/cjs/helpers/reverseSnippet.js +10 -16
  76. package/cjs/helpers/snippet.js +10 -16
  77. package/cjs/index.js +3 -18
  78. package/cjs/lib/InstantSearch.js +79 -180
  79. package/cjs/lib/createHelpers.js +4 -11
  80. package/cjs/lib/formatNumber.js +0 -1
  81. package/cjs/lib/infiniteHitsCache/index.js +0 -2
  82. package/cjs/lib/infiniteHitsCache/sessionStorage.js +9 -18
  83. package/cjs/lib/insights/client.js +8 -34
  84. package/cjs/lib/insights/index.js +7 -13
  85. package/cjs/lib/insights/listener.js +4 -20
  86. package/cjs/lib/routers/history.js +63 -102
  87. package/cjs/lib/routers/index.js +0 -2
  88. package/cjs/lib/stateMappings/index.js +0 -3
  89. package/cjs/lib/stateMappings/simple.js +6 -13
  90. package/cjs/lib/stateMappings/singleIndex.js +1 -7
  91. package/cjs/lib/suit.js +2 -5
  92. package/cjs/lib/templating/index.js +0 -4
  93. package/cjs/lib/templating/prepareTemplateProps.js +8 -19
  94. package/cjs/lib/templating/renderTemplate.js +9 -24
  95. package/cjs/lib/utils/capitalize.js +0 -1
  96. package/cjs/lib/utils/checkIndexUiState.js +15 -43
  97. package/cjs/lib/utils/checkRendering.js +0 -2
  98. package/cjs/lib/utils/clearRefinements.js +2 -9
  99. package/cjs/lib/utils/concatHighlightedParts.js +1 -3
  100. package/cjs/lib/utils/createConcurrentSafePromise.js +0 -3
  101. package/cjs/lib/utils/createSendEventForFacet.js +7 -14
  102. package/cjs/lib/utils/createSendEventForHits.js +9 -33
  103. package/cjs/lib/utils/debounce.js +0 -3
  104. package/cjs/lib/utils/defer.js +0 -11
  105. package/cjs/lib/utils/detect-insights-client.js +0 -2
  106. package/cjs/lib/utils/documentation.js +2 -5
  107. package/cjs/lib/utils/escape-highlight.js +5 -22
  108. package/cjs/lib/utils/escape-html.js +9 -7
  109. package/cjs/lib/utils/escapeFacetValue.js +1 -5
  110. package/cjs/lib/utils/find.js +2 -5
  111. package/cjs/lib/utils/findIndex.js +0 -3
  112. package/cjs/lib/utils/geo-search.js +14 -34
  113. package/cjs/lib/utils/getAppIdAndApiKey.js +2 -3
  114. package/cjs/lib/utils/getContainerNode.js +0 -6
  115. package/cjs/lib/utils/getHighlightFromSiblings.js +0 -6
  116. package/cjs/lib/utils/getHighlightedParts.js +1 -4
  117. package/cjs/lib/utils/getObjectType.js +0 -1
  118. package/cjs/lib/utils/getPropertyByPath.js +0 -1
  119. package/cjs/lib/utils/getRefinements.js +13 -26
  120. package/cjs/lib/utils/getWidgetAttribute.js +0 -6
  121. package/cjs/lib/utils/hits-absolute-position.js +2 -6
  122. package/cjs/lib/utils/hits-query-id.js +2 -7
  123. package/cjs/lib/utils/index.js +0 -92
  124. package/cjs/lib/utils/isDomElement.js +0 -1
  125. package/cjs/lib/utils/isEqual.js +0 -8
  126. package/cjs/lib/utils/isFacetRefined.js +0 -1
  127. package/cjs/lib/utils/isFiniteNumber.js +0 -1
  128. package/cjs/lib/utils/isIndexWidget.js +0 -1
  129. package/cjs/lib/utils/isPlainObject.js +3 -11
  130. package/cjs/lib/utils/isSpecialClick.js +0 -1
  131. package/cjs/lib/utils/logger.js +3 -13
  132. package/cjs/lib/utils/mergeSearchParameters.js +16 -40
  133. package/cjs/lib/utils/noop.js +0 -1
  134. package/cjs/lib/utils/range.js +8 -14
  135. package/cjs/lib/utils/render-args.js +0 -2
  136. package/cjs/lib/utils/resolveSearchParameters.js +0 -3
  137. package/cjs/lib/utils/reverseHighlightedParts.js +2 -8
  138. package/cjs/lib/utils/safelyRunOnBrowser.js +7 -9
  139. package/cjs/lib/utils/serializer.js +1 -3
  140. package/cjs/lib/utils/setIndexHelperState.js +0 -5
  141. package/cjs/lib/utils/toArray.js +0 -1
  142. package/cjs/lib/utils/typedObject.js +0 -1
  143. package/cjs/lib/utils/uniq.js +0 -1
  144. package/cjs/lib/version.js +1 -1
  145. package/cjs/lib/voiceSearchHelper/index.js +8 -36
  146. package/cjs/middlewares/createInsightsMiddleware.js +15 -44
  147. package/cjs/middlewares/createMetadataMiddleware.js +4 -12
  148. package/cjs/middlewares/createRouterMiddleware.js +8 -19
  149. package/cjs/middlewares/index.js +0 -6
  150. package/cjs/types/algoliasearch.js +0 -2
  151. package/cjs/types/index.js +0 -28
  152. package/cjs/widgets/analytics/analytics.js +12 -47
  153. package/cjs/widgets/answers/answers.js +19 -39
  154. package/cjs/widgets/breadcrumb/breadcrumb.js +18 -38
  155. package/cjs/widgets/clear-refinements/clear-refinements.js +15 -35
  156. package/cjs/widgets/configure/configure.js +2 -10
  157. package/cjs/widgets/configure-related-items/configure-related-items.js +2 -10
  158. package/cjs/widgets/current-refinements/current-refinements.js +12 -30
  159. package/cjs/widgets/dynamic-widgets/dynamic-widgets.js +6 -25
  160. package/cjs/widgets/geo-search/GeoSearchRenderer.js +41 -68
  161. package/cjs/widgets/geo-search/createHTMLMarker.js +30 -60
  162. package/cjs/widgets/geo-search/defaultTemplates.js +0 -3
  163. package/cjs/widgets/geo-search/geo-search.js +27 -59
  164. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +4 -7
  165. package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +28 -47
  166. package/cjs/widgets/hits/hits.js +16 -37
  167. package/cjs/widgets/hits-per-page/hits-per-page.js +13 -31
  168. package/cjs/widgets/index/index.js +49 -95
  169. package/cjs/widgets/index.js +12 -50
  170. package/cjs/widgets/infinite-hits/infinite-hits.js +23 -44
  171. package/cjs/widgets/menu/defaultTemplates.js +3 -6
  172. package/cjs/widgets/menu/menu.js +23 -43
  173. package/cjs/widgets/menu-select/defaultTemplates.js +1 -3
  174. package/cjs/widgets/menu-select/menu-select.js +18 -38
  175. package/cjs/widgets/numeric-menu/defaultTemplates.js +3 -4
  176. package/cjs/widgets/numeric-menu/numeric-menu.js +17 -37
  177. package/cjs/widgets/pagination/pagination.js +32 -53
  178. package/cjs/widgets/panel/panel.js +20 -48
  179. package/cjs/widgets/places/places.js +16 -33
  180. package/cjs/widgets/powered-by/powered-by.js +10 -27
  181. package/cjs/widgets/query-rule-context/query-rule-context.js +2 -13
  182. package/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js +14 -32
  183. package/cjs/widgets/range-input/range-input.js +23 -50
  184. package/cjs/widgets/range-slider/range-slider.js +28 -53
  185. package/cjs/widgets/rating-menu/defaultTemplates.js +8 -14
  186. package/cjs/widgets/rating-menu/rating-menu.js +17 -38
  187. package/cjs/widgets/refinement-list/defaultTemplates.js +5 -8
  188. package/cjs/widgets/refinement-list/refinement-list.js +39 -60
  189. package/cjs/widgets/relevant-sort/relevant-sort.js +10 -29
  190. package/cjs/widgets/search-box/defaultTemplates.js +0 -5
  191. package/cjs/widgets/search-box/search-box.js +31 -49
  192. package/cjs/widgets/sort-by/sort-by.js +11 -29
  193. package/cjs/widgets/stats/defaultTemplates.js +0 -1
  194. package/cjs/widgets/stats/stats.js +27 -57
  195. package/cjs/widgets/toggle-refinement/toggle-refinement.js +16 -36
  196. package/cjs/widgets/voice-search/defaultTemplates.js +4 -14
  197. package/cjs/widgets/voice-search/voice-search.js +17 -36
  198. package/dist/instantsearch.development.d.ts +8 -6
  199. package/dist/instantsearch.development.js +1725 -3087
  200. package/dist/instantsearch.development.js.map +1 -1
  201. package/dist/instantsearch.production.d.ts +8 -6
  202. package/dist/instantsearch.production.min.d.ts +8 -6
  203. package/dist/instantsearch.production.min.js +2 -2
  204. package/dist/instantsearch.production.min.js.map +1 -1
  205. package/es/components/Answers/Answers.js +6 -11
  206. package/es/components/Breadcrumb/Breadcrumb.js +5 -7
  207. package/es/components/ClearRefinements/ClearRefinements.js +4 -6
  208. package/es/components/CurrentRefinements/CurrentRefinements.js +7 -10
  209. package/es/components/GeoSearchControls/GeoSearchButton.js +6 -6
  210. package/es/components/GeoSearchControls/GeoSearchControls.js +11 -13
  211. package/es/components/GeoSearchControls/GeoSearchToggle.js +6 -6
  212. package/es/components/Highlight/Highlight.js +3 -7
  213. package/es/components/Hits/Hits.js +8 -15
  214. package/es/components/InfiniteHits/InfiniteHits.js +13 -20
  215. package/es/components/MenuSelect/MenuSelect.js +9 -13
  216. package/es/components/Pagination/Pagination.js +12 -15
  217. package/es/components/Panel/Panel.js +7 -20
  218. package/es/components/PoweredBy/PoweredBy.js +6 -5
  219. package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +4 -4
  220. package/es/components/RangeInput/RangeInput.js +16 -43
  221. package/es/components/RefinementList/RefinementList.js +19 -64
  222. package/es/components/RefinementList/RefinementListItem.js +8 -10
  223. package/es/components/RelevantSort/RelevantSort.js +6 -6
  224. package/es/components/ReverseHighlight/ReverseHighlight.js +3 -7
  225. package/es/components/ReverseSnippet/ReverseSnippet.js +3 -7
  226. package/es/components/SearchBox/SearchBox.js +25 -63
  227. package/es/components/Selector/Selector.js +5 -5
  228. package/es/components/Slider/Pit.js +3 -7
  229. package/es/components/Slider/Rheostat.js +64 -129
  230. package/es/components/Slider/Slider.js +28 -58
  231. package/es/components/Snippet/Snippet.js +3 -7
  232. package/es/components/Stats/Stats.js +7 -15
  233. package/es/components/Template/Template.js +8 -32
  234. package/es/components/ToggleRefinement/ToggleRefinement.js +4 -6
  235. package/es/components/VoiceSearch/VoiceSearch.js +10 -13
  236. package/es/connectors/answers/connectAnswers.js +21 -35
  237. package/es/connectors/autocomplete/connectAutocomplete.js +8 -23
  238. package/es/connectors/breadcrumb/connectBreadcrumb.js +17 -46
  239. package/es/connectors/clear-refinements/connectClearRefinements.js +27 -43
  240. package/es/connectors/configure/connectConfigure.js +7 -16
  241. package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +11 -31
  242. package/es/connectors/current-refinements/connectCurrentRefinements.js +18 -55
  243. package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +17 -35
  244. package/es/connectors/geo-search/connectGeoSearch.js +17 -45
  245. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +38 -72
  246. package/es/connectors/hits/connectHits.js +10 -24
  247. package/es/connectors/hits-per-page/connectHitsPerPage.js +15 -36
  248. package/es/connectors/index.d.ts +2 -1
  249. package/es/connectors/index.js +6 -3
  250. package/es/connectors/infinite-hits/connectInfiniteHits.js +26 -60
  251. package/es/connectors/menu/connectMenu.js +28 -64
  252. package/es/connectors/numeric-menu/connectNumericMenu.js +24 -76
  253. package/es/connectors/pagination/Paginator.js +3 -19
  254. package/es/connectors/pagination/connectPagination.js +8 -21
  255. package/es/connectors/powered-by/connectPoweredBy.js +4 -11
  256. package/es/connectors/query-rules/connectQueryRules.js +32 -54
  257. package/es/connectors/range/connectRange.js +41 -99
  258. package/es/connectors/rating-menu/connectRatingMenu.js +23 -77
  259. package/es/connectors/refinement-list/connectRefinementList.js +37 -68
  260. package/es/connectors/relevant-sort/connectRelevantSort.js +4 -13
  261. package/es/connectors/search-box/connectSearchBox.js +7 -21
  262. package/es/connectors/sort-by/connectSortBy.js +11 -19
  263. package/es/connectors/stats/connectStats.js +4 -9
  264. package/es/connectors/toggle-refinement/connectToggleRefinement.js +29 -61
  265. package/es/connectors/voice-search/connectVoiceSearch.js +13 -31
  266. package/es/helpers/components/Highlight.js +4 -8
  267. package/es/helpers/components/ReverseHighlight.js +7 -15
  268. package/es/helpers/components/ReverseSnippet.js +7 -15
  269. package/es/helpers/components/Snippet.js +4 -8
  270. package/es/helpers/get-insights-anonymous-user-token.js +5 -7
  271. package/es/helpers/highlight.js +9 -11
  272. package/es/helpers/insights.js +3 -10
  273. package/es/helpers/reverseHighlight.js +9 -11
  274. package/es/helpers/reverseSnippet.js +9 -11
  275. package/es/helpers/snippet.js +9 -11
  276. package/es/index.js +0 -2
  277. package/es/lib/InstantSearch.js +79 -170
  278. package/es/lib/createHelpers.js +4 -8
  279. package/es/lib/infiniteHitsCache/sessionStorage.js +9 -16
  280. package/es/lib/insights/client.js +8 -32
  281. package/es/lib/insights/listener.js +6 -18
  282. package/es/lib/routers/history.js +63 -99
  283. package/es/lib/stateMappings/simple.js +6 -12
  284. package/es/lib/stateMappings/singleIndex.js +1 -6
  285. package/es/lib/suit.js +2 -3
  286. package/es/lib/templating/prepareTemplateProps.js +8 -18
  287. package/es/lib/templating/renderTemplate.js +9 -20
  288. package/es/lib/utils/checkIndexUiState.js +18 -40
  289. package/es/lib/utils/clearRefinements.js +2 -8
  290. package/es/lib/utils/concatHighlightedParts.js +1 -1
  291. package/es/lib/utils/createConcurrentSafePromise.js +0 -2
  292. package/es/lib/utils/createSendEventForFacet.js +7 -12
  293. package/es/lib/utils/createSendEventForHits.js +8 -30
  294. package/es/lib/utils/debounce.js +0 -2
  295. package/es/lib/utils/defer.js +0 -10
  296. package/es/lib/utils/documentation.js +2 -3
  297. package/es/lib/utils/escape-highlight.js +3 -16
  298. package/es/lib/utils/escape-html.js +9 -5
  299. package/es/lib/utils/escapeFacetValue.js +0 -2
  300. package/es/lib/utils/find.js +2 -4
  301. package/es/lib/utils/findIndex.js +0 -2
  302. package/es/lib/utils/geo-search.js +14 -32
  303. package/es/lib/utils/getAppIdAndApiKey.js +2 -2
  304. package/es/lib/utils/getContainerNode.js +1 -5
  305. package/es/lib/utils/getHighlightFromSiblings.js +0 -3
  306. package/es/lib/utils/getHighlightedParts.js +1 -2
  307. package/es/lib/utils/getRefinements.js +13 -24
  308. package/es/lib/utils/getWidgetAttribute.js +0 -5
  309. package/es/lib/utils/hits-absolute-position.js +2 -5
  310. package/es/lib/utils/hits-query-id.js +2 -6
  311. package/es/lib/utils/isEqual.js +0 -7
  312. package/es/lib/utils/isPlainObject.js +3 -10
  313. package/es/lib/utils/logger.js +2 -12
  314. package/es/lib/utils/mergeSearchParameters.js +16 -37
  315. package/es/lib/utils/range.js +8 -13
  316. package/es/lib/utils/resolveSearchParameters.js +0 -2
  317. package/es/lib/utils/reverseHighlightedParts.js +2 -6
  318. package/es/lib/utils/safelyRunOnBrowser.js +7 -8
  319. package/es/lib/utils/setIndexHelperState.js +0 -2
  320. package/es/lib/version.d.ts +1 -1
  321. package/es/lib/version.js +1 -1
  322. package/es/lib/voiceSearchHelper/index.js +8 -35
  323. package/es/middlewares/createInsightsMiddleware.js +15 -41
  324. package/es/middlewares/createMetadataMiddleware.js +3 -9
  325. package/es/middlewares/createRouterMiddleware.js +8 -13
  326. package/es/types/index.js +9 -5
  327. package/es/widgets/analytics/analytics.js +12 -45
  328. package/es/widgets/answers/answers.js +19 -28
  329. package/es/widgets/breadcrumb/breadcrumb.js +18 -27
  330. package/es/widgets/clear-refinements/clear-refinements.js +15 -24
  331. package/es/widgets/configure/configure.js +3 -6
  332. package/es/widgets/configure-related-items/configure-related-items.js +2 -7
  333. package/es/widgets/current-refinements/current-refinements.js +12 -21
  334. package/es/widgets/dynamic-widgets/dynamic-widgets.js +6 -20
  335. package/es/widgets/geo-search/GeoSearchRenderer.js +41 -63
  336. package/es/widgets/geo-search/createHTMLMarker.js +30 -59
  337. package/es/widgets/geo-search/defaultTemplates.js +2 -2
  338. package/es/widgets/geo-search/geo-search.js +27 -49
  339. package/es/widgets/hierarchical-menu/defaultTemplates.js +5 -4
  340. package/es/widgets/hierarchical-menu/hierarchical-menu.js +28 -36
  341. package/es/widgets/hits/hits.js +16 -25
  342. package/es/widgets/hits-per-page/hits-per-page.js +13 -22
  343. package/es/widgets/index/index.js +49 -91
  344. package/es/widgets/index.d.ts +2 -1
  345. package/es/widgets/index.js +4 -3
  346. package/es/widgets/infinite-hits/infinite-hits.js +23 -32
  347. package/es/widgets/menu/defaultTemplates.js +4 -3
  348. package/es/widgets/menu/menu.js +23 -32
  349. package/es/widgets/menu-select/defaultTemplates.js +1 -1
  350. package/es/widgets/menu-select/menu-select.js +18 -27
  351. package/es/widgets/numeric-menu/defaultTemplates.js +4 -3
  352. package/es/widgets/numeric-menu/numeric-menu.js +17 -26
  353. package/es/widgets/pagination/pagination.js +32 -44
  354. package/es/widgets/panel/panel.js +20 -40
  355. package/es/widgets/places/places.js +16 -32
  356. package/es/widgets/powered-by/powered-by.js +10 -18
  357. package/es/widgets/query-rule-context/query-rule-context.js +2 -9
  358. package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +13 -22
  359. package/es/widgets/range-input/range-input.js +23 -40
  360. package/es/widgets/range-slider/range-slider.js +28 -44
  361. package/es/widgets/rating-menu/defaultTemplates.js +9 -12
  362. package/es/widgets/rating-menu/rating-menu.js +17 -27
  363. package/es/widgets/refinement-list/defaultTemplates.js +6 -5
  364. package/es/widgets/refinement-list/refinement-list.js +39 -48
  365. package/es/widgets/relevant-sort/relevant-sort.js +10 -19
  366. package/es/widgets/search-box/defaultTemplates.js +1 -4
  367. package/es/widgets/search-box/search-box.js +31 -39
  368. package/es/widgets/sort-by/sort-by.js +11 -20
  369. package/es/widgets/stats/stats.js +26 -45
  370. package/es/widgets/toggle-refinement/toggle-refinement.js +16 -25
  371. package/es/widgets/voice-search/defaultTemplates.js +5 -13
  372. package/es/widgets/voice-search/voice-search.js +17 -26
  373. package/package.json +20 -119
  374. package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.input.js +0 -1
  375. package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.output.js +0 -1
  376. package/CHANGELOG.md +0 -3684
@@ -4,35 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createInsightsMiddleware = createInsightsMiddleware;
7
-
8
7
  var _index = require("../helpers/index.js");
9
-
10
8
  var _index2 = require("../lib/utils/index.js");
11
-
12
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
13
-
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
-
9
+ 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; }
10
+ 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; }
16
11
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
-
18
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
-
20
13
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21
-
22
14
  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); }
23
-
24
15
  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; }
25
-
26
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
27
-
16
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
28
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
-
30
18
  function createInsightsMiddleware(props) {
31
19
  var _ref = props || {},
32
- _insightsClient = _ref.insightsClient,
33
- insightsInitParams = _ref.insightsInitParams,
34
- onEvent = _ref.onEvent;
35
-
20
+ _insightsClient = _ref.insightsClient,
21
+ insightsInitParams = _ref.insightsInitParams,
22
+ onEvent = _ref.onEvent;
36
23
  if (_insightsClient !== null && !_insightsClient) {
37
24
  if (process.env.NODE_ENV === 'development') {
38
25
  throw new Error("The `insightsClient` option is required if you want userToken to be automatically set in search calls. If you don't want this behaviour, set it to `null`.");
@@ -40,25 +27,19 @@ function createInsightsMiddleware(props) {
40
27
  throw new Error('The `insightsClient` option is required. To disable, set it to `null`.');
41
28
  }
42
29
  }
43
-
44
30
  var hasInsightsClient = Boolean(_insightsClient);
45
31
  var insightsClient = _insightsClient === null ? _index2.noop : _insightsClient;
46
32
  return function (_ref2) {
47
33
  var instantSearchInstance = _ref2.instantSearchInstance;
48
-
49
34
  var _getAppIdAndApiKey = (0, _index2.getAppIdAndApiKey)(instantSearchInstance.client),
50
- _getAppIdAndApiKey2 = _slicedToArray(_getAppIdAndApiKey, 2),
51
- appId = _getAppIdAndApiKey2[0],
52
- apiKey = _getAppIdAndApiKey2[1]; // search-insights.js also throws an error so dev-only clarification is sufficient
53
-
54
-
35
+ _getAppIdAndApiKey2 = _slicedToArray(_getAppIdAndApiKey, 2),
36
+ appId = _getAppIdAndApiKey2[0],
37
+ apiKey = _getAppIdAndApiKey2[1]; // search-insights.js also throws an error so dev-only clarification is sufficient
55
38
  if (process.env.NODE_ENV === 'development' && !(appId && apiKey)) {
56
39
  throw new Error('[insights middleware]: could not extract Algolia credentials from searchClient');
57
40
  }
58
-
59
41
  var queuedUserToken = undefined;
60
42
  var userTokenBeforeInit = undefined;
61
-
62
43
  if (Array.isArray(insightsClient.queue)) {
63
44
  // Context: The umd build of search-insights is asynchronously loaded by the snippet.
64
45
  //
@@ -72,16 +53,12 @@ function createInsightsMiddleware(props) {
72
53
  // Otherwise, the first search call will be fired without the token.
73
54
  var _ref3 = (0, _index2.find)(insightsClient.queue.slice().reverse(), function (_ref5) {
74
55
  var _ref6 = _slicedToArray(_ref5, 1),
75
- method = _ref6[0];
76
-
56
+ method = _ref6[0];
77
57
  return method === 'setUserToken';
78
58
  }) || [];
79
-
80
59
  var _ref4 = _slicedToArray(_ref3, 2);
81
-
82
60
  queuedUserToken = _ref4[1];
83
61
  }
84
-
85
62
  insightsClient('getUserToken', null, function (_error, userToken) {
86
63
  // If user has called `aa('setUserToken', 'my-user-token')` before creating
87
64
  // the `insights` middleware, we store them temporarily and
@@ -110,41 +87,36 @@ function createInsightsMiddleware(props) {
110
87
  clickAnalytics: true
111
88
  }));
112
89
  instantSearchInstance.scheduleSearch();
113
-
114
90
  var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
115
91
  helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, helper.state), {}, {
116
92
  userToken: userToken
117
93
  }));
118
94
  instantSearchInstance.scheduleSearch();
119
95
  };
120
-
121
96
  var anonymousUserToken = (0, _index.getInsightsAnonymousUserTokenInternal)();
122
-
123
97
  if (hasInsightsClient && anonymousUserToken) {
124
98
  // When `aa('init', { ... })` is called, it creates an anonymous user token in cookie.
125
99
  // We can set it as userToken.
126
100
  setUserTokenToSearch(anonymousUserToken);
127
- } // We consider the `userToken` coming from a `init` call to have a higher
128
- // importance than the one coming from the queue.
129
-
101
+ }
130
102
 
103
+ // We consider the `userToken` coming from a `init` call to have a higher
104
+ // importance than the one coming from the queue.
131
105
  if (userTokenBeforeInit) {
132
106
  insightsClient('setUserToken', userTokenBeforeInit);
133
107
  } else if (queuedUserToken) {
134
108
  insightsClient('setUserToken', queuedUserToken);
135
- } // This updates userToken which is set explicitly by `aa('setUserToken', userToken)`
136
-
109
+ }
137
110
 
111
+ // This updates userToken which is set explicitly by `aa('setUserToken', userToken)`
138
112
  insightsClient('onUserTokenChange', setUserTokenToSearch, {
139
113
  immediate: true
140
114
  });
141
-
142
115
  instantSearchInstance.sendEventToInsights = function (event) {
143
116
  if (onEvent) {
144
117
  onEvent(event, _insightsClient);
145
118
  } else if (event.insightsMethod) {
146
119
  var hasUserToken = Boolean(helper.state.userToken);
147
-
148
120
  if (hasUserToken) {
149
121
  insightsClient(event.insightsMethod, event.payload);
150
122
  } else {
@@ -158,7 +130,6 @@ function createInsightsMiddleware(props) {
158
130
  unsubscribe: function unsubscribe() {
159
131
  insightsClient('onUserTokenChange', undefined);
160
132
  instantSearchInstance.sendEventToInsights = _index2.noop;
161
-
162
133
  if (helper && initialParameters) {
163
134
  helper.setState(_objectSpread(_objectSpread({}, helper.state), initialParameters));
164
135
  instantSearchInstance.scheduleSearch();
@@ -3,26 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isMetadataEnabled = isMetadataEnabled;
7
6
  exports.createMetadataMiddleware = createMetadataMiddleware;
8
-
7
+ exports.isMetadataEnabled = isMetadataEnabled;
9
8
  var _index = require("../lib/utils/index.js");
10
-
11
9
  function extractPayload(widgets, instantSearchInstance, payload) {
12
10
  var initOptions = (0, _index.createInitArgs)(instantSearchInstance, instantSearchInstance.mainIndex, instantSearchInstance._initialUiState);
13
11
  widgets.forEach(function (widget) {
14
12
  var widgetParams = {};
15
-
16
13
  if (widget.getWidgetRenderState) {
17
14
  var renderState = widget.getWidgetRenderState(initOptions);
18
-
19
15
  if (renderState && renderState.widgetParams) {
20
16
  // casting, as we just earlier checked widgetParams exists, and thus an object
21
17
  widgetParams = renderState.widgetParams;
22
18
  }
23
- } // since we destructure in all widgets, the parameters with defaults are set to "undefined"
24
-
19
+ }
25
20
 
21
+ // since we destructure in all widgets, the parameters with defaults are set to "undefined"
26
22
  var params = Object.keys(widgetParams).filter(function (key) {
27
23
  return widgetParams[key] !== undefined;
28
24
  });
@@ -31,17 +27,14 @@ function extractPayload(widgets, instantSearchInstance, payload) {
31
27
  widgetType: widget.$$widgetType,
32
28
  params: params
33
29
  });
34
-
35
30
  if (widget.$$type === 'ais.index') {
36
31
  extractPayload(widget.getWidgets(), instantSearchInstance, payload);
37
32
  }
38
33
  });
39
34
  }
40
-
41
35
  function isMetadataEnabled() {
42
36
  return (0, _index.safelyRunOnBrowser)(function (_ref) {
43
37
  var _window$navigator, _window$navigator$use;
44
-
45
38
  var window = _ref.window;
46
39
  return ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : (_window$navigator$use = _window$navigator.userAgent) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.indexOf('Algolia Crawler')) > -1;
47
40
  }, {
@@ -50,6 +43,7 @@ function isMetadataEnabled() {
50
43
  }
51
44
  });
52
45
  }
46
+
53
47
  /**
54
48
  * Exposes the metadata of mounted widgets in a custom
55
49
  * `<meta name="instantsearch:widgets" />` tag. The metadata per widget is:
@@ -57,8 +51,6 @@ function isMetadataEnabled() {
57
51
  * - widget name
58
52
  * - connector name
59
53
  */
60
-
61
-
62
54
  function createMetadataMiddleware() {
63
55
  return function (_ref2) {
64
56
  var instantSearchInstance = _ref2.instantSearchInstance;
@@ -4,40 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createRouterMiddleware = void 0;
7
-
8
7
  var _simple = _interopRequireDefault(require("../lib/stateMappings/simple.js"));
9
-
10
8
  var _history = _interopRequireDefault(require("../lib/routers/history.js"));
11
-
12
9
  var _index = require("../lib/utils/index.js");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
11
+ 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; }
12
+ 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; }
20
13
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
14
  var createRouterMiddleware = function createRouterMiddleware() {
23
15
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
16
  var _props$router = props.router,
25
- router = _props$router === void 0 ? (0, _history.default)() : _props$router,
26
- _props$stateMapping = props.stateMapping,
27
- stateMapping = _props$stateMapping === void 0 ? (0, _simple.default)() : _props$stateMapping;
17
+ router = _props$router === void 0 ? (0, _history.default)() : _props$router,
18
+ _props$stateMapping = props.stateMapping,
19
+ stateMapping = _props$stateMapping === void 0 ? (0, _simple.default)() : _props$stateMapping;
28
20
  return function (_ref) {
29
21
  var instantSearchInstance = _ref.instantSearchInstance;
30
-
31
22
  function topLevelCreateURL(nextState) {
32
23
  var uiState = Object.keys(nextState).reduce(function (acc, indexId) {
33
24
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, indexId, nextState[indexId]));
34
25
  }, instantSearchInstance.mainIndex.getWidgetUiState({}));
35
26
  var route = stateMapping.stateToRoute(uiState);
36
27
  return router.createURL(route);
37
- } // casting to UiState here to keep createURL unaware of custom UiState
38
- // (as long as it's an object, it's ok)
39
-
28
+ }
40
29
 
30
+ // casting to UiState here to keep createURL unaware of custom UiState
31
+ // (as long as it's an object, it's ok)
41
32
  instantSearchInstance._createURL = topLevelCreateURL;
42
33
  var lastRouteState = undefined;
43
34
  var initialUiState = instantSearchInstance._initialUiState;
@@ -45,7 +36,6 @@ var createRouterMiddleware = function createRouterMiddleware() {
45
36
  onStateChange: function onStateChange(_ref2) {
46
37
  var uiState = _ref2.uiState;
47
38
  var routeState = stateMapping.stateToRoute(uiState);
48
-
49
39
  if (lastRouteState === undefined || !(0, _index.isEqual)(lastRouteState, routeState)) {
50
40
  router.write(routeState);
51
41
  lastRouteState = routeState;
@@ -64,5 +54,4 @@ var createRouterMiddleware = function createRouterMiddleware() {
64
54
  };
65
55
  };
66
56
  };
67
-
68
57
  exports.createRouterMiddleware = createRouterMiddleware;
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _createInsightsMiddleware = require("./createInsightsMiddleware.js");
8
-
9
7
  Object.keys(_createInsightsMiddleware).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _createInsightsMiddleware[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_createInsightsMiddleware).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _createRouterMiddleware = require("./createRouterMiddleware.js");
21
-
22
18
  Object.keys(_createRouterMiddleware).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _createRouterMiddleware[key]) return;
@@ -29,9 +25,7 @@ Object.keys(_createRouterMiddleware).forEach(function (key) {
29
25
  }
30
26
  });
31
27
  });
32
-
33
28
  var _createMetadataMiddleware = require("./createMetadataMiddleware.js");
34
-
35
29
  Object.keys(_createMetadataMiddleware).forEach(function (key) {
36
30
  if (key === "default" || key === "__esModule") return;
37
31
  if (key in exports && exports[key] === _createMetadataMiddleware[key]) return;
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _algoliasearch = require("algoliasearch-helper/types/algoliasearch.js");
8
-
9
7
  Object.keys(_algoliasearch).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _algoliasearch[key]) return;
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _utils = require("./utils.js");
8
-
9
7
  Object.keys(_utils).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _utils[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_utils).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _algoliasearch = require("./algoliasearch.js");
21
-
22
18
  Object.keys(_algoliasearch).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _algoliasearch[key]) return;
@@ -29,9 +25,7 @@ Object.keys(_algoliasearch).forEach(function (key) {
29
25
  }
30
26
  });
31
27
  });
32
-
33
28
  var _results = require("./results.js");
34
-
35
29
  Object.keys(_results).forEach(function (key) {
36
30
  if (key === "default" || key === "__esModule") return;
37
31
  if (key in exports && exports[key] === _results[key]) return;
@@ -42,9 +36,7 @@ Object.keys(_results).forEach(function (key) {
42
36
  }
43
37
  });
44
38
  });
45
-
46
39
  var _component = require("./component.js");
47
-
48
40
  Object.keys(_component).forEach(function (key) {
49
41
  if (key === "default" || key === "__esModule") return;
50
42
  if (key in exports && exports[key] === _component[key]) return;
@@ -55,9 +47,7 @@ Object.keys(_component).forEach(function (key) {
55
47
  }
56
48
  });
57
49
  });
58
-
59
50
  var _instantsearch = require("./instantsearch.js");
60
-
61
51
  Object.keys(_instantsearch).forEach(function (key) {
62
52
  if (key === "default" || key === "__esModule") return;
63
53
  if (key in exports && exports[key] === _instantsearch[key]) return;
@@ -68,9 +58,7 @@ Object.keys(_instantsearch).forEach(function (key) {
68
58
  }
69
59
  });
70
60
  });
71
-
72
61
  var _middleware = require("./middleware.js");
73
-
74
62
  Object.keys(_middleware).forEach(function (key) {
75
63
  if (key === "default" || key === "__esModule") return;
76
64
  if (key in exports && exports[key] === _middleware[key]) return;
@@ -81,9 +69,7 @@ Object.keys(_middleware).forEach(function (key) {
81
69
  }
82
70
  });
83
71
  });
84
-
85
72
  var _router = require("./router.js");
86
-
87
73
  Object.keys(_router).forEach(function (key) {
88
74
  if (key === "default" || key === "__esModule") return;
89
75
  if (key in exports && exports[key] === _router[key]) return;
@@ -94,9 +80,7 @@ Object.keys(_router).forEach(function (key) {
94
80
  }
95
81
  });
96
82
  });
97
-
98
83
  var _insights = require("./insights.js");
99
-
100
84
  Object.keys(_insights).forEach(function (key) {
101
85
  if (key === "default" || key === "__esModule") return;
102
86
  if (key in exports && exports[key] === _insights[key]) return;
@@ -107,9 +91,7 @@ Object.keys(_insights).forEach(function (key) {
107
91
  }
108
92
  });
109
93
  });
110
-
111
94
  var _connector = require("./connector.js");
112
-
113
95
  Object.keys(_connector).forEach(function (key) {
114
96
  if (key === "default" || key === "__esModule") return;
115
97
  if (key in exports && exports[key] === _connector[key]) return;
@@ -120,9 +102,7 @@ Object.keys(_connector).forEach(function (key) {
120
102
  }
121
103
  });
122
104
  });
123
-
124
105
  var _widgetFactory = require("./widget-factory.js");
125
-
126
106
  Object.keys(_widgetFactory).forEach(function (key) {
127
107
  if (key === "default" || key === "__esModule") return;
128
108
  if (key in exports && exports[key] === _widgetFactory[key]) return;
@@ -133,9 +113,7 @@ Object.keys(_widgetFactory).forEach(function (key) {
133
113
  }
134
114
  });
135
115
  });
136
-
137
116
  var _widget = require("./widget.js");
138
-
139
117
  Object.keys(_widget).forEach(function (key) {
140
118
  if (key === "default" || key === "__esModule") return;
141
119
  if (key in exports && exports[key] === _widget[key]) return;
@@ -146,9 +124,7 @@ Object.keys(_widget).forEach(function (key) {
146
124
  }
147
125
  });
148
126
  });
149
-
150
127
  var _uiState = require("./ui-state.js");
151
-
152
128
  Object.keys(_uiState).forEach(function (key) {
153
129
  if (key === "default" || key === "__esModule") return;
154
130
  if (key in exports && exports[key] === _uiState[key]) return;
@@ -159,9 +135,7 @@ Object.keys(_uiState).forEach(function (key) {
159
135
  }
160
136
  });
161
137
  });
162
-
163
138
  var _renderState = require("./render-state.js");
164
-
165
139
  Object.keys(_renderState).forEach(function (key) {
166
140
  if (key === "default" || key === "__esModule") return;
167
141
  if (key in exports && exports[key] === _renderState[key]) return;
@@ -172,9 +146,7 @@ Object.keys(_renderState).forEach(function (key) {
172
146
  }
173
147
  });
174
148
  });
175
-
176
149
  var _templates = require("./templates.js");
177
-
178
150
  Object.keys(_templates).forEach(function (key) {
179
151
  if (key === "default" || key === "__esModule") return;
180
152
  if (key in exports && exports[key] === _templates[key]) return;
@@ -4,59 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _index = require("../../lib/utils/index.js");
9
-
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
11
-
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
-
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; }
14
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
16
11
  var withUsage = (0, _index.createDocumentationMessageGenerator)({
17
12
  name: 'analytics'
18
13
  });
19
-
20
14
  // @major this widget will be removed from the next major version.
21
15
  var analytics = function analytics(widgetParams) {
22
16
  var _ref = widgetParams || {},
23
- pushFunction = _ref.pushFunction,
24
- _ref$delay = _ref.delay,
25
- delay = _ref$delay === void 0 ? 3000 : _ref$delay,
26
- _ref$triggerOnUIInter = _ref.triggerOnUIInteraction,
27
- triggerOnUIInteraction = _ref$triggerOnUIInter === void 0 ? false : _ref$triggerOnUIInter,
28
- _ref$pushInitialSearc = _ref.pushInitialSearch,
29
- pushInitialSearch = _ref$pushInitialSearc === void 0 ? true : _ref$pushInitialSearc,
30
- _ref$pushPagination = _ref.pushPagination,
31
- pushPagination = _ref$pushPagination === void 0 ? false : _ref$pushPagination;
32
-
17
+ pushFunction = _ref.pushFunction,
18
+ _ref$delay = _ref.delay,
19
+ delay = _ref$delay === void 0 ? 3000 : _ref$delay,
20
+ _ref$triggerOnUIInter = _ref.triggerOnUIInteraction,
21
+ triggerOnUIInteraction = _ref$triggerOnUIInter === void 0 ? false : _ref$triggerOnUIInter,
22
+ _ref$pushInitialSearc = _ref.pushInitialSearch,
23
+ pushInitialSearch = _ref$pushInitialSearc === void 0 ? true : _ref$pushInitialSearc,
24
+ _ref$pushPagination = _ref.pushPagination,
25
+ pushPagination = _ref$pushPagination === void 0 ? false : _ref$pushPagination;
33
26
  if (!pushFunction) {
34
27
  throw new Error(withUsage('The `pushFunction` option is required.'));
35
28
  }
36
-
37
29
  process.env.NODE_ENV === 'development' ? (0, _index.warning)(false, "`analytics` widget has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor the migration, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#analytics-widget") : void 0;
38
30
  var cachedState = null;
39
-
40
31
  var serializeRefinements = function serializeRefinements(parameters) {
41
32
  var refinements = [];
42
-
43
33
  for (var parameter in parameters) {
44
34
  if (parameters.hasOwnProperty(parameter)) {
45
35
  var values = parameters[parameter].join('+');
46
36
  refinements.push("".concat(encodeURIComponent(parameter), "=").concat(encodeURIComponent(parameter), "_").concat(encodeURIComponent(values)));
47
37
  }
48
38
  }
49
-
50
39
  return refinements.join('&');
51
40
  };
52
-
53
41
  var serializeNumericRefinements = function serializeNumericRefinements(numericRefinements) {
54
42
  var refinements = [];
55
-
56
43
  for (var attribute in numericRefinements) {
57
44
  if (numericRefinements.hasOwnProperty(attribute)) {
58
45
  var filter = numericRefinements[attribute];
59
-
60
46
  if (filter.hasOwnProperty('>=') && filter.hasOwnProperty('<=')) {
61
47
  if (filter['>='] && filter['>='][0] === filter['<='] && filter['<='][0]) {
62
48
  refinements.push("".concat(attribute, "=").concat(attribute, "_").concat(filter['>=']));
@@ -69,7 +55,6 @@ var analytics = function analytics(widgetParams) {
69
55
  refinements.push("".concat(attribute, "=").concat(attribute, "_to").concat(filter['<=']));
70
56
  } else if (filter.hasOwnProperty('=')) {
71
57
  var equals = [];
72
-
73
58
  for (var equal in filter['=']) {
74
59
  // eslint-disable-next-line max-depth
75
60
  if (filter['='].hasOwnProperty(equal)) {
@@ -77,62 +62,47 @@ var analytics = function analytics(widgetParams) {
77
62
  equals.push(filter['='][equal]);
78
63
  }
79
64
  }
80
-
81
65
  refinements.push("".concat(attribute, "=").concat(attribute, "_").concat(equals.join('-')));
82
66
  }
83
67
  }
84
68
  }
85
-
86
69
  return refinements.join('&');
87
70
  };
88
-
89
71
  var lastSentData = '';
90
-
91
72
  var sendAnalytics = function sendAnalytics(analyticsState) {
92
73
  if (analyticsState === null) {
93
74
  return;
94
75
  }
95
-
96
76
  var serializedParams = [];
97
77
  var serializedRefinements = serializeRefinements(_objectSpread(_objectSpread(_objectSpread({}, analyticsState.state.disjunctiveFacetsRefinements), analyticsState.state.facetsRefinements), analyticsState.state.hierarchicalFacetsRefinements));
98
78
  var serializedNumericRefinements = serializeNumericRefinements(analyticsState.state.numericRefinements);
99
-
100
79
  if (serializedRefinements !== '') {
101
80
  serializedParams.push(serializedRefinements);
102
81
  }
103
-
104
82
  if (serializedNumericRefinements !== '') {
105
83
  serializedParams.push(serializedNumericRefinements);
106
84
  }
107
-
108
85
  var stringifiedParams = serializedParams.join('&');
109
86
  var dataToSend = "Query: ".concat(analyticsState.state.query || '', ", ").concat(stringifiedParams);
110
-
111
87
  if (pushPagination === true) {
112
88
  dataToSend += ", Page: ".concat(analyticsState.state.page || 0);
113
89
  }
114
-
115
90
  if (lastSentData !== dataToSend) {
116
91
  pushFunction(stringifiedParams, analyticsState.state, analyticsState.results);
117
92
  lastSentData = dataToSend;
118
93
  }
119
94
  };
120
-
121
95
  var pushTimeout;
122
96
  var isInitialSearch = true;
123
-
124
97
  if (pushInitialSearch === true) {
125
98
  isInitialSearch = false;
126
99
  }
127
-
128
100
  var onClick = function onClick() {
129
101
  sendAnalytics(cachedState);
130
102
  };
131
-
132
103
  var onUnload = function onUnload() {
133
104
  sendAnalytics(cachedState);
134
105
  };
135
-
136
106
  return {
137
107
  $$type: 'ais.analytics',
138
108
  $$widgetType: 'ais.analytics',
@@ -144,22 +114,18 @@ var analytics = function analytics(widgetParams) {
144
114
  },
145
115
  render: function render(_ref2) {
146
116
  var results = _ref2.results,
147
- state = _ref2.state;
148
-
117
+ state = _ref2.state;
149
118
  if (isInitialSearch === true) {
150
119
  isInitialSearch = false;
151
120
  return;
152
121
  }
153
-
154
122
  cachedState = {
155
123
  results: results,
156
124
  state: state
157
125
  };
158
-
159
126
  if (pushTimeout) {
160
127
  clearTimeout(pushTimeout);
161
128
  }
162
-
163
129
  pushTimeout = window.setTimeout(function () {
164
130
  return sendAnalytics(cachedState);
165
131
  }, delay);
@@ -182,6 +148,5 @@ var analytics = function analytics(widgetParams) {
182
148
  }
183
149
  };
184
150
  };
185
-
186
151
  var _default = analytics;
187
152
  exports.default = _default;