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
@@ -1,16 +1,11 @@
1
1
  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; }
2
-
3
2
  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; }
4
-
5
3
  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; }
6
-
7
4
  function getIndexStateWithoutConfigure(uiState) {
8
5
  var configure = uiState.configure,
9
- trackedUiState = _objectWithoutProperties(uiState, ["configure"]);
10
-
6
+ trackedUiState = _objectWithoutProperties(uiState, ["configure"]);
11
7
  return trackedUiState;
12
8
  }
13
-
14
9
  export default function singleIndexStateMapping(indexName) {
15
10
  return {
16
11
  stateToRoute: function stateToRoute(uiState) {
package/es/lib/suit.js CHANGED
@@ -2,9 +2,8 @@ var NAMESPACE = 'ais';
2
2
  export var component = function component(componentName) {
3
3
  return function () {
4
4
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
5
- descendantName = _ref.descendantName,
6
- modifierName = _ref.modifierName;
7
-
5
+ descendantName = _ref.descendantName,
6
+ modifierName = _ref.modifierName;
8
7
  var descendent = descendantName ? "-".concat(descendantName) : '';
9
8
  var modifier = modifierName ? "--".concat(modifierName) : '';
10
9
  return "".concat(NAMESPACE, "-").concat(componentName).concat(descendent).concat(modifier);
@@ -1,24 +1,15 @@
1
- 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; }
2
-
3
- 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; }
4
-
1
+ 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; }
2
+ 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; }
5
3
  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; }
6
-
7
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
-
9
5
  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."); }
10
-
11
6
  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); }
12
-
13
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
14
-
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
8
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
-
17
9
  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; }
18
-
19
10
  import { uniq } from "../utils/uniq.js";
20
-
21
- function prepareTemplates( // can not use = {} here, since the template could have different constraints
11
+ function prepareTemplates(
12
+ // can not use = {} here, since the template could have different constraints
22
13
  defaultTemplates) {
23
14
  var templates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24
15
  var allKeys = uniq([].concat(_toConsumableArray(Object.keys(defaultTemplates || {})), _toConsumableArray(Object.keys(templates))));
@@ -37,15 +28,14 @@ defaultTemplates) {
37
28
  useCustomCompileOptions: {}
38
29
  });
39
30
  }
31
+
40
32
  /**
41
33
  * Prepares an object to be passed to the Template widget
42
34
  */
43
-
44
-
45
35
  export function prepareTemplateProps(_ref) {
46
36
  var defaultTemplates = _ref.defaultTemplates,
47
- templates = _ref.templates,
48
- templatesConfig = _ref.templatesConfig;
37
+ templates = _ref.templates,
38
+ templatesConfig = _ref.templatesConfig;
49
39
  var preparedTemplates = prepareTemplates(defaultTemplates, templates);
50
40
  return _objectSpread({
51
41
  templatesConfig: templatesConfig
@@ -1,15 +1,10 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- 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; }
4
-
5
- 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; }
6
-
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; }
7
4
  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; }
8
-
9
5
  import hogan from 'hogan.js';
10
6
  import { html } from 'htm/preact';
11
7
  import { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from "../../helpers/components/index.js";
12
-
13
8
  // We add all our template helper methods to the template as lambdas. Note
14
9
  // that lambdas in Mustache are supposed to accept a second argument of
15
10
  // `render` to get the rendered value, not the literal `{{value}}`. But
@@ -21,32 +16,27 @@ function transformHelpersToHogan() {
21
16
  return Object.keys(helpers).reduce(function (acc, helperKey) {
22
17
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, helperKey, function () {
23
18
  var _this = this;
24
-
25
19
  return function (text) {
26
20
  var render = function render(value) {
27
21
  return hogan.compile(value, compileOptions).render(_this);
28
22
  };
29
-
30
23
  return helpers[helperKey].call(data, text, render);
31
24
  };
32
25
  }));
33
26
  }, {});
34
27
  }
35
-
36
28
  export function renderTemplate(_ref) {
37
29
  var templates = _ref.templates,
38
- templateKey = _ref.templateKey,
39
- compileOptions = _ref.compileOptions,
40
- helpers = _ref.helpers,
41
- data = _ref.data,
42
- bindEvent = _ref.bindEvent,
43
- sendEvent = _ref.sendEvent;
30
+ templateKey = _ref.templateKey,
31
+ compileOptions = _ref.compileOptions,
32
+ helpers = _ref.helpers,
33
+ data = _ref.data,
34
+ bindEvent = _ref.bindEvent,
35
+ sendEvent = _ref.sendEvent;
44
36
  var template = templates[templateKey];
45
-
46
37
  if (typeof template !== 'string' && typeof template !== 'function') {
47
38
  throw new Error("Template must be 'string' or 'function', was '".concat(_typeof(template), "' (key: ").concat(templateKey, ")"));
48
39
  }
49
-
50
40
  if (typeof template === 'function') {
51
41
  // @MAJOR no longer pass bindEvent when string templates are removed
52
42
  var params = bindEvent || {};
@@ -60,7 +50,6 @@ export function renderTemplate(_ref) {
60
50
  };
61
51
  return template(data, params);
62
52
  }
63
-
64
53
  var transformedHelpers = transformHelpersToHogan(helpers, compileOptions, data);
65
54
  return hogan.compile(template, compileOptions).render(_objectSpread(_objectSpread({}, data), {}, {
66
55
  helpers: transformedHelpers
@@ -1,41 +1,29 @@
1
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
2
  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
-
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
6
-
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
4
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
-
9
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
-
11
6
  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."); }
12
-
13
7
  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); }
14
-
15
8
  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; }
16
-
17
- 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; }
18
-
9
+ 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; }
19
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
-
21
11
  import { capitalize } from "./capitalize.js";
22
12
  import { warning } from "./logger.js";
23
- import { keys } from "./typedObject.js"; // Some connectors are responsible for multiple widgets so we need
24
- // to map them.
13
+ import { keys } from "./typedObject.js";
25
14
 
15
+ // Some connectors are responsible for multiple widgets so we need
16
+ // to map them.
26
17
  function getWidgetNames(connectorName) {
27
18
  switch (connectorName) {
28
19
  case 'range':
29
20
  return [];
30
-
31
21
  case 'menu':
32
22
  return ['menu', 'menuSelect'];
33
-
34
23
  default:
35
24
  return [connectorName];
36
25
  }
37
26
  }
38
-
39
27
  var stateToWidgetsMap = {
40
28
  query: {
41
29
  connectors: ['connectSearchBox'],
@@ -96,19 +84,16 @@ var stateToWidgetsMap = {
96
84
  };
97
85
  export function checkIndexUiState(_ref) {
98
86
  var index = _ref.index,
99
- indexUiState = _ref.indexUiState;
87
+ indexUiState = _ref.indexUiState;
100
88
  var mountedWidgets = index.getWidgets().map(function (widget) {
101
89
  return widget.$$type;
102
90
  }).filter(Boolean);
103
91
  var missingWidgets = keys(indexUiState).reduce(function (acc, parameter) {
104
92
  var widgetUiState = stateToWidgetsMap[parameter];
105
-
106
93
  if (!widgetUiState) {
107
94
  return acc;
108
95
  }
109
-
110
96
  var requiredWidgets = widgetUiState.widgets;
111
-
112
97
  if (requiredWidgets && !requiredWidgets.some(function (requiredWidget) {
113
98
  return mountedWidgets.includes(requiredWidget);
114
99
  })) {
@@ -119,16 +104,13 @@ export function checkIndexUiState(_ref) {
119
104
  })
120
105
  }]);
121
106
  }
122
-
123
107
  return acc;
124
108
  }, []);
125
109
  process.env.NODE_ENV === 'development' ? warning(missingWidgets.length === 0, "The UI state for the index \"".concat(index.getIndexId(), "\" is not consistent with the widgets mounted.\n\nThis can happen when the UI state is specified via `initialUiState`, `routing` or `setUiState` but that the widgets responsible for this state were not added. This results in those query parameters not being sent to the API.\n\nTo fully reflect the state, some widgets need to be added to the index \"").concat(index.getIndexId(), "\":\n\n").concat(missingWidgets.map(function (_ref2) {
126
110
  var _ref4;
127
-
128
111
  var _ref3 = _slicedToArray(_ref2, 2),
129
- stateParameter = _ref3[0],
130
- widgets = _ref3[1].widgets;
131
-
112
+ stateParameter = _ref3[0],
113
+ widgets = _ref3[1].widgets;
132
114
  return "- `".concat(stateParameter, "` needs one of these widgets: ").concat((_ref4 = []).concat.apply(_ref4, _toConsumableArray(widgets.map(function (name) {
133
115
  return getWidgetNames(name);
134
116
  }))).map(function (name) {
@@ -136,31 +118,27 @@ export function checkIndexUiState(_ref) {
136
118
  }).join(', '));
137
119
  }).join('\n'), "\n\nIf you do not wish to display widgets but still want to support their search parameters, you can mount \"virtual widgets\" that don't render anything:\n\n```\n").concat(missingWidgets.filter(function (_ref5) {
138
120
  var _ref6 = _slicedToArray(_ref5, 2),
139
- _stateParameter = _ref6[0],
140
- connectors = _ref6[1].connectors;
141
-
121
+ _stateParameter = _ref6[0],
122
+ connectors = _ref6[1].connectors;
142
123
  return connectors.length > 0;
143
124
  }).map(function (_ref7) {
144
125
  var _ref8 = _slicedToArray(_ref7, 2),
145
- _stateParameter = _ref8[0],
146
- _ref8$ = _ref8[1],
147
- connectors = _ref8$.connectors,
148
- widgets = _ref8$.widgets;
149
-
126
+ _stateParameter = _ref8[0],
127
+ _ref8$ = _ref8[1],
128
+ connectors = _ref8$.connectors,
129
+ widgets = _ref8$.widgets;
150
130
  var capitalizedWidget = capitalize(widgets[0]);
151
131
  var connectorName = connectors[0];
152
132
  return "const virtual".concat(capitalizedWidget, " = ").concat(connectorName, "(() => null);");
153
133
  }).join('\n'), "\n\nsearch.addWidgets([\n ").concat(missingWidgets.filter(function (_ref9) {
154
134
  var _ref10 = _slicedToArray(_ref9, 2),
155
- _stateParameter = _ref10[0],
156
- connectors = _ref10[1].connectors;
157
-
135
+ _stateParameter = _ref10[0],
136
+ connectors = _ref10[1].connectors;
158
137
  return connectors.length > 0;
159
138
  }).map(function (_ref11) {
160
139
  var _ref12 = _slicedToArray(_ref11, 2),
161
- _stateParameter = _ref12[0],
162
- widgets = _ref12[1].widgets;
163
-
140
+ _stateParameter = _ref12[0],
141
+ widgets = _ref12[1].widgets;
164
142
  var capitalizedWidget = capitalize(widgets[0]);
165
143
  return "virtual".concat(capitalizedWidget, "({ /* ... */ })");
166
144
  }).join(',\n '), "\n]);\n```\n\nIf you're using custom widgets that do set these query parameters, we recommend using connectors instead.\n\nSee https://www.algolia.com/doc/guides/building-search-ui/widgets/customize-an-existing-widget/js/#customize-the-complete-ui-of-the-widgets")) : void 0;
@@ -6,32 +6,26 @@
6
6
  */
7
7
  export function clearRefinements(_ref) {
8
8
  var helper = _ref.helper,
9
- _ref$attributesToClea = _ref.attributesToClear,
10
- attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea;
9
+ _ref$attributesToClea = _ref.attributesToClear,
10
+ attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea;
11
11
  var finalState = helper.state.setPage(0);
12
12
  finalState = attributesToClear.reduce(function (state, attribute) {
13
13
  if (finalState.isNumericRefined(attribute)) {
14
14
  return state.removeNumericRefinement(attribute);
15
15
  }
16
-
17
16
  if (finalState.isHierarchicalFacet(attribute)) {
18
17
  return state.removeHierarchicalFacetRefinement(attribute);
19
18
  }
20
-
21
19
  if (finalState.isDisjunctiveFacet(attribute)) {
22
20
  return state.removeDisjunctiveFacetRefinement(attribute);
23
21
  }
24
-
25
22
  if (finalState.isConjunctiveFacet(attribute)) {
26
23
  return state.removeFacetRefinement(attribute);
27
24
  }
28
-
29
25
  return state;
30
26
  }, finalState);
31
-
32
27
  if (attributesToClear.indexOf('query') !== -1) {
33
28
  finalState = finalState.setQuery('');
34
29
  }
35
-
36
30
  return finalState;
37
31
  }
@@ -1,7 +1,7 @@
1
1
  import { TAG_REPLACEMENT } from "./escape-highlight.js";
2
2
  export function concatHighlightedParts(parts) {
3
3
  var highlightPreTag = TAG_REPLACEMENT.highlightPreTag,
4
- highlightPostTag = TAG_REPLACEMENT.highlightPostTag;
4
+ highlightPostTag = TAG_REPLACEMENT.highlightPostTag;
5
5
  return parts.map(function (part) {
6
6
  return part.isHighlighted ? highlightPreTag + part.value + highlightPostTag : part.value;
7
7
  }).join('');
@@ -1,6 +1,5 @@
1
1
  // copied from
2
2
  // https://github.com/algolia/autocomplete.js/blob/307a7acc4283e10a19cb7d067f04f1bea79dc56f/packages/autocomplete-core/src/utils/createConcurrentSafePromise.ts#L1:L1
3
-
4
3
  /**
5
4
  * Creates a runner that executes promises in a concurrent-safe way.
6
5
  *
@@ -30,7 +29,6 @@ export function createConcurrentSafePromise() {
30
29
  if (latestResolvedValue && currentPromiseId < latestResolvedId) {
31
30
  return latestResolvedValue;
32
31
  }
33
-
34
32
  latestResolvedId = currentPromiseId;
35
33
  latestResolvedValue = x;
36
34
  return x;
@@ -1,23 +1,19 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
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); }
3
2
  import { isFacetRefined } from "./isFacetRefined.js";
4
3
  export function createSendEventForFacet(_ref) {
5
4
  var instantSearchInstance = _ref.instantSearchInstance,
6
- helper = _ref.helper,
7
- attr = _ref.attribute,
8
- widgetType = _ref.widgetType;
9
-
5
+ helper = _ref.helper,
6
+ attr = _ref.attribute,
7
+ widgetType = _ref.widgetType;
10
8
  var sendEventForFacet = function sendEventForFacet() {
11
9
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12
10
  args[_key] = arguments[_key];
13
11
  }
14
-
15
12
  var eventType = args[0],
16
- facetValue = args[1],
17
- _args$ = args[2],
18
- eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
13
+ facetValue = args[1],
14
+ _args$ = args[2],
15
+ eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
19
16
  var attribute = typeof attr === 'string' ? attr : attr(facetValue);
20
-
21
17
  if (args.length === 1 && _typeof(args[0]) === 'object') {
22
18
  instantSearchInstance.sendEventToInsights(args[0]);
23
19
  } else if (eventType === 'click' && (args.length === 2 || args.length === 3)) {
@@ -39,6 +35,5 @@ export function createSendEventForFacet(_ref) {
39
35
  throw new Error("You need to pass two arguments like:\n sendEvent('click', facetValue);\n\nIf you want to send a custom payload, you can pass one object: sendEvent(customPayload);\n");
40
36
  }
41
37
  };
42
-
43
38
  return sendEventForFacet;
44
39
  }
@@ -1,34 +1,26 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
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); }
3
2
  import { serializePayload } from "./serializer.js";
4
-
5
3
  function chunk(arr) {
6
4
  var chunkSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
7
5
  var chunks = [];
8
-
9
6
  for (var i = 0; i < Math.ceil(arr.length / chunkSize); i++) {
10
7
  chunks.push(arr.slice(i * chunkSize, (i + 1) * chunkSize));
11
8
  }
12
-
13
9
  return chunks;
14
10
  }
15
-
16
11
  var buildPayloads = function buildPayloads(_ref) {
17
12
  var index = _ref.index,
18
- widgetType = _ref.widgetType,
19
- methodName = _ref.methodName,
20
- args = _ref.args,
21
- isSearchStalled = _ref.isSearchStalled;
22
-
13
+ widgetType = _ref.widgetType,
14
+ methodName = _ref.methodName,
15
+ args = _ref.args,
16
+ isSearchStalled = _ref.isSearchStalled;
23
17
  // when there's only one argument, that means it's custom
24
18
  if (args.length === 1 && _typeof(args[0]) === 'object') {
25
19
  return [args[0]];
26
20
  }
27
-
28
21
  var eventType = args[0];
29
22
  var hits = args[1];
30
23
  var eventName = args[2];
31
-
32
24
  if (!hits) {
33
25
  if (process.env.NODE_ENV === 'development') {
34
26
  throw new Error("You need to pass hit or hits as the second argument like:\n ".concat(methodName, "(eventType, hit);\n "));
@@ -36,7 +28,6 @@ var buildPayloads = function buildPayloads(_ref) {
36
28
  return [];
37
29
  }
38
30
  }
39
-
40
31
  if ((eventType === 'click' || eventType === 'conversion') && !eventName) {
41
32
  if (process.env.NODE_ENV === 'development') {
42
33
  throw new Error("You need to pass eventName as the third argument for 'click' or 'conversion' events like:\n ".concat(methodName, "('click', hit, 'Product Purchased');\n\n To learn more about event naming: https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/in-depth/clicks-conversions-best-practices/\n "));
@@ -44,13 +35,10 @@ var buildPayloads = function buildPayloads(_ref) {
44
35
  return [];
45
36
  }
46
37
  }
47
-
48
38
  var hitsArray = Array.isArray(hits) ? removeEscapedFromHits(hits) : [hits];
49
-
50
39
  if (hitsArray.length === 0) {
51
40
  return [];
52
41
  }
53
-
54
42
  var queryID = hitsArray[0].__queryID;
55
43
  var hitsChunks = chunk(hitsArray);
56
44
  var objectIDsByChunk = hitsChunks.map(function (batch) {
@@ -63,12 +51,10 @@ var buildPayloads = function buildPayloads(_ref) {
63
51
  return hit.__position;
64
52
  });
65
53
  });
66
-
67
54
  if (eventType === 'view') {
68
55
  if (isSearchStalled) {
69
56
  return [];
70
57
  }
71
-
72
58
  return hitsChunks.map(function (batch, i) {
73
59
  return {
74
60
  insightsMethod: 'viewedObjectIDs',
@@ -119,22 +105,18 @@ var buildPayloads = function buildPayloads(_ref) {
119
105
  return [];
120
106
  }
121
107
  };
122
-
123
108
  function removeEscapedFromHits(hits) {
124
109
  // remove `hits.__escaped` without mutating
125
110
  return hits.slice();
126
111
  }
127
-
128
112
  export function createSendEventForHits(_ref2) {
129
113
  var instantSearchInstance = _ref2.instantSearchInstance,
130
- index = _ref2.index,
131
- widgetType = _ref2.widgetType;
132
-
114
+ index = _ref2.index,
115
+ widgetType = _ref2.widgetType;
133
116
  var sendEventForHits = function sendEventForHits() {
134
117
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
135
118
  args[_key] = arguments[_key];
136
119
  }
137
-
138
120
  var payloads = buildPayloads({
139
121
  widgetType: widgetType,
140
122
  index: index,
@@ -146,18 +128,15 @@ export function createSendEventForHits(_ref2) {
146
128
  return instantSearchInstance.sendEventToInsights(payload);
147
129
  });
148
130
  };
149
-
150
131
  return sendEventForHits;
151
132
  }
152
133
  export function createBindEventForHits(_ref3) {
153
134
  var index = _ref3.index,
154
- widgetType = _ref3.widgetType;
155
-
135
+ widgetType = _ref3.widgetType;
156
136
  var bindEventForHits = function bindEventForHits() {
157
137
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
158
138
  args[_key2] = arguments[_key2];
159
139
  }
160
-
161
140
  var payloads = buildPayloads({
162
141
  widgetType: widgetType,
163
142
  index: index,
@@ -167,6 +146,5 @@ export function createBindEventForHits(_ref3) {
167
146
  });
168
147
  return payloads.length ? "data-insights-event=".concat(serializePayload(payloads)) : '';
169
148
  };
170
-
171
149
  return bindEventForHits;
172
150
  }
@@ -6,12 +6,10 @@ export function debounce(func, wait) {
6
6
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7
7
  args[_key] = arguments[_key];
8
8
  }
9
-
10
9
  return new Promise(function (resolve, reject) {
11
10
  if (lastTimeout) {
12
11
  clearTimeout(lastTimeout);
13
12
  }
14
-
15
13
  lastTimeout = setTimeout(function () {
16
14
  lastTimeout = null;
17
15
  Promise.resolve(func.apply(void 0, args)).then(resolve).catch(reject);
@@ -2,43 +2,33 @@ var nextMicroTask = Promise.resolve();
2
2
  export function defer(callback) {
3
3
  var progress = null;
4
4
  var cancelled = false;
5
-
6
5
  var fn = function fn() {
7
6
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
7
  args[_key] = arguments[_key];
9
8
  }
10
-
11
9
  if (progress !== null) {
12
10
  return;
13
11
  }
14
-
15
12
  progress = nextMicroTask.then(function () {
16
13
  progress = null;
17
-
18
14
  if (cancelled) {
19
15
  cancelled = false;
20
16
  return;
21
17
  }
22
-
23
18
  callback.apply(void 0, args);
24
19
  });
25
20
  };
26
-
27
21
  fn.wait = function () {
28
22
  if (progress === null) {
29
23
  throw new Error('The deferred function should be called before calling `wait()`');
30
24
  }
31
-
32
25
  return progress;
33
26
  };
34
-
35
27
  fn.cancel = function () {
36
28
  if (progress === null) {
37
29
  return;
38
30
  }
39
-
40
31
  cancelled = true;
41
32
  };
42
-
43
33
  return fn;
44
34
  }
@@ -1,14 +1,13 @@
1
1
  export function createDocumentationLink(_ref) {
2
2
  var name = _ref.name,
3
- _ref$connector = _ref.connector,
4
- connector = _ref$connector === void 0 ? false : _ref$connector;
3
+ _ref$connector = _ref.connector,
4
+ connector = _ref$connector === void 0 ? false : _ref$connector;
5
5
  return ['https://www.algolia.com/doc/api-reference/widgets/', name, '/js/', connector ? '#connector' : ''].join('');
6
6
  }
7
7
  export function createDocumentationMessageGenerator() {
8
8
  for (var _len = arguments.length, widgets = new Array(_len), _key = 0; _key < _len; _key++) {
9
9
  widgets[_key] = arguments[_key];
10
10
  }
11
-
12
11
  var links = widgets.map(function (widget) {
13
12
  return createDocumentationLink(widget);
14
13
  }).join(', ');
@@ -1,11 +1,7 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- 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; }
4
-
5
- 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; }
6
-
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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; }
7
4
  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; }
8
-
9
5
  import { escape } from "./escape-html.js";
10
6
  import { isPlainObject } from "./isPlainObject.js";
11
7
  export var TAG_PLACEHOLDER = {
@@ -16,47 +12,38 @@ export var TAG_REPLACEMENT = {
16
12
  highlightPreTag: '<mark>',
17
13
  highlightPostTag: '</mark>'
18
14
  };
19
-
20
15
  function replaceTagsAndEscape(value) {
21
16
  return escape(value).replace(new RegExp(TAG_PLACEHOLDER.highlightPreTag, 'g'), TAG_REPLACEMENT.highlightPreTag).replace(new RegExp(TAG_PLACEHOLDER.highlightPostTag, 'g'), TAG_REPLACEMENT.highlightPostTag);
22
17
  }
23
-
24
18
  function recursiveEscape(input) {
25
19
  if (isPlainObject(input) && typeof input.value !== 'string') {
26
20
  return Object.keys(input).reduce(function (acc, key) {
27
21
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, recursiveEscape(input[key])));
28
22
  }, {});
29
23
  }
30
-
31
24
  if (Array.isArray(input)) {
32
25
  return input.map(recursiveEscape);
33
26
  }
34
-
35
27
  return _objectSpread(_objectSpread({}, input), {}, {
36
28
  value: replaceTagsAndEscape(input.value)
37
29
  });
38
30
  }
39
-
40
31
  export function escapeHits(hits) {
41
32
  if (hits.__escaped === undefined) {
42
33
  // We don't override the value on hit because it will mutate the raw results
43
34
  // instead we make a shallow copy and we assign the escaped values on it.
44
35
  hits = hits.map(function (_ref) {
45
36
  var hit = _extends({}, _ref);
46
-
47
37
  if (hit._highlightResult) {
48
38
  hit._highlightResult = recursiveEscape(hit._highlightResult);
49
39
  }
50
-
51
40
  if (hit._snippetResult) {
52
41
  hit._snippetResult = recursiveEscape(hit._snippetResult);
53
42
  }
54
-
55
43
  return hit;
56
44
  });
57
45
  hits.__escaped = true;
58
46
  }
59
-
60
47
  return hits;
61
48
  }
62
49
  export function escapeFacets(facetHits) {