instantsearch.js 4.49.1 → 4.49.3

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 (396) hide show
  1. package/README.md +14 -8
  2. package/cjs/components/Answers/Answers.js +11 -18
  3. package/cjs/components/Breadcrumb/Breadcrumb.js +6 -13
  4. package/cjs/components/ClearRefinements/ClearRefinements.js +5 -12
  5. package/cjs/components/CurrentRefinements/CurrentRefinements.js +8 -16
  6. package/cjs/components/GeoSearchControls/GeoSearchButton.js +4 -7
  7. package/cjs/components/GeoSearchControls/GeoSearchControls.js +14 -23
  8. package/cjs/components/GeoSearchControls/GeoSearchToggle.js +4 -7
  9. package/cjs/components/Highlight/Highlight.js +5 -12
  10. package/cjs/components/Hits/Hits.js +13 -22
  11. package/cjs/components/InfiniteHits/InfiniteHits.js +18 -27
  12. package/cjs/components/InternalHighlight/InternalHighlight.js +0 -3
  13. package/cjs/components/MenuSelect/MenuSelect.js +12 -22
  14. package/cjs/components/Pagination/Pagination.js +12 -20
  15. package/cjs/components/Panel/Panel.js +9 -28
  16. package/cjs/components/PoweredBy/PoweredBy.js +4 -6
  17. package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +3 -8
  18. package/cjs/components/RangeInput/RangeInput.js +21 -51
  19. package/cjs/components/RefinementList/RefinementList.js +30 -81
  20. package/cjs/components/RefinementList/RefinementListItem.js +9 -15
  21. package/cjs/components/RelevantSort/RelevantSort.js +5 -10
  22. package/cjs/components/ReverseHighlight/ReverseHighlight.js +5 -12
  23. package/cjs/components/ReverseSnippet/ReverseSnippet.js +5 -12
  24. package/cjs/components/SearchBox/SearchBox.js +35 -77
  25. package/cjs/components/Selector/Selector.js +3 -7
  26. package/cjs/components/Slider/Pit.js +7 -11
  27. package/cjs/components/Slider/Rheostat.js +69 -133
  28. package/cjs/components/Slider/Slider.js +39 -72
  29. package/cjs/components/Snippet/Snippet.js +5 -12
  30. package/cjs/components/Stats/Stats.js +13 -22
  31. package/cjs/components/Template/Template.js +17 -44
  32. package/cjs/components/ToggleRefinement/ToggleRefinement.js +5 -11
  33. package/cjs/components/VoiceSearch/VoiceSearch.js +9 -17
  34. package/cjs/connectors/answers/connectAnswers.js +36 -46
  35. package/cjs/connectors/autocomplete/connectAutocomplete.js +21 -35
  36. package/cjs/connectors/breadcrumb/connectBreadcrumb.js +27 -55
  37. package/cjs/connectors/clear-refinements/connectClearRefinements.js +41 -56
  38. package/cjs/connectors/configure/connectConfigure.js +17 -28
  39. package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +21 -43
  40. package/cjs/connectors/current-refinements/connectCurrentRefinements.js +29 -65
  41. package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +27 -45
  42. package/cjs/connectors/geo-search/connectGeoSearch.js +32 -59
  43. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +50 -82
  44. package/cjs/connectors/hits/connectHits.js +25 -38
  45. package/cjs/connectors/hits/connectHitsWithInsights.js +3 -7
  46. package/cjs/connectors/hits-per-page/connectHitsPerPage.js +26 -46
  47. package/cjs/connectors/index.js +92 -126
  48. package/cjs/connectors/infinite-hits/connectInfiniteHits.js +43 -75
  49. package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +3 -7
  50. package/cjs/connectors/menu/connectMenu.js +39 -73
  51. package/cjs/connectors/numeric-menu/connectNumericMenu.js +37 -86
  52. package/cjs/connectors/pagination/Paginator.js +11 -25
  53. package/cjs/connectors/pagination/connectPagination.js +17 -31
  54. package/cjs/connectors/powered-by/connectPoweredBy.js +13 -19
  55. package/cjs/connectors/query-rules/connectQueryRules.js +44 -65
  56. package/cjs/connectors/range/connectRange.js +72 -129
  57. package/cjs/connectors/rating-menu/connectRatingMenu.js +34 -87
  58. package/cjs/connectors/refinement-list/connectRefinementList.js +51 -79
  59. package/cjs/connectors/relevant-sort/connectRelevantSort.js +11 -18
  60. package/cjs/connectors/search-box/connectSearchBox.js +15 -28
  61. package/cjs/connectors/sort-by/connectSortBy.js +21 -28
  62. package/cjs/connectors/stats/connectStats.js +12 -16
  63. package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +44 -75
  64. package/cjs/connectors/voice-search/connectVoiceSearch.js +22 -41
  65. package/cjs/helpers/components/Highlight.js +11 -18
  66. package/cjs/helpers/components/ReverseHighlight.js +19 -26
  67. package/cjs/helpers/components/ReverseSnippet.js +19 -26
  68. package/cjs/helpers/components/Snippet.js +11 -18
  69. package/cjs/helpers/components/index.js +4 -12
  70. package/cjs/helpers/get-insights-anonymous-user-token.js +6 -17
  71. package/cjs/helpers/highlight.js +15 -19
  72. package/cjs/helpers/index.js +23 -37
  73. package/cjs/helpers/insights.js +9 -21
  74. package/cjs/helpers/reverseHighlight.js +16 -20
  75. package/cjs/helpers/reverseSnippet.js +16 -20
  76. package/cjs/helpers/snippet.js +15 -19
  77. package/cjs/index.js +12 -27
  78. package/cjs/lib/InstantSearch.js +108 -207
  79. package/cjs/lib/createHelpers.js +15 -19
  80. package/cjs/lib/formatNumber.js +0 -1
  81. package/cjs/lib/infiniteHitsCache/index.js +1 -3
  82. package/cjs/lib/infiniteHitsCache/sessionStorage.js +14 -22
  83. package/cjs/lib/insights/client.js +17 -40
  84. package/cjs/lib/insights/index.js +9 -15
  85. package/cjs/lib/insights/listener.js +7 -24
  86. package/cjs/lib/routers/history.js +75 -117
  87. package/cjs/lib/routers/index.js +1 -3
  88. package/cjs/lib/stateMappings/index.js +2 -5
  89. package/cjs/lib/stateMappings/simple.js +11 -14
  90. package/cjs/lib/stateMappings/singleIndex.js +6 -8
  91. package/cjs/lib/suit.js +2 -5
  92. package/cjs/lib/templating/index.js +2 -6
  93. package/cjs/lib/templating/prepareTemplateProps.js +14 -22
  94. package/cjs/lib/templating/renderTemplate.js +17 -30
  95. package/cjs/lib/utils/capitalize.js +0 -1
  96. package/cjs/lib/utils/checkIndexUiState.js +19 -47
  97. package/cjs/lib/utils/checkRendering.js +1 -3
  98. package/cjs/lib/utils/clearRefinements.js +2 -9
  99. package/cjs/lib/utils/concatHighlightedParts.js +2 -4
  100. package/cjs/lib/utils/createConcurrentSafePromise.js +0 -3
  101. package/cjs/lib/utils/createSendEventForFacet.js +8 -15
  102. package/cjs/lib/utils/createSendEventForHits.js +10 -34
  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 +1 -3
  106. package/cjs/lib/utils/documentation.js +2 -5
  107. package/cjs/lib/utils/escape-highlight.js +13 -26
  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 +21 -37
  113. package/cjs/lib/utils/getAppIdAndApiKey.js +2 -3
  114. package/cjs/lib/utils/getContainerNode.js +1 -7
  115. package/cjs/lib/utils/getHighlightFromSiblings.js +1 -7
  116. package/cjs/lib/utils/getHighlightedParts.js +2 -5
  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 +30 -45
  120. package/cjs/lib/utils/getWidgetAttribute.js +0 -6
  121. package/cjs/lib/utils/hits-absolute-position.js +6 -7
  122. package/cjs/lib/utils/hits-query-id.js +6 -8
  123. package/cjs/lib/utils/index.js +46 -138
  124. package/cjs/lib/utils/isDomElement.js +0 -1
  125. package/cjs/lib/utils/isEqual.js +2 -7
  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 +6 -16
  132. package/cjs/lib/utils/mergeSearchParameters.js +23 -43
  133. package/cjs/lib/utils/noop.js +0 -1
  134. package/cjs/lib/utils/range.js +9 -15
  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 +7 -10
  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 +2 -7
  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 +12 -37
  146. package/cjs/middlewares/createInsightsMiddleware.js +30 -54
  147. package/cjs/middlewares/createMetadataMiddleware.js +7 -15
  148. package/cjs/middlewares/createRouterMiddleware.js +16 -24
  149. package/cjs/middlewares/index.js +3 -9
  150. package/cjs/types/algoliasearch.js +0 -2
  151. package/cjs/types/index.js +14 -42
  152. package/cjs/widgets/analytics/analytics.js +22 -48
  153. package/cjs/widgets/answers/answers.js +32 -49
  154. package/cjs/widgets/breadcrumb/breadcrumb.js +31 -48
  155. package/cjs/widgets/clear-refinements/clear-refinements.js +28 -45
  156. package/cjs/widgets/configure/configure.js +9 -14
  157. package/cjs/widgets/configure-related-items/configure-related-items.js +9 -14
  158. package/cjs/widgets/current-refinements/current-refinements.js +22 -37
  159. package/cjs/widgets/dynamic-widgets/dynamic-widgets.js +17 -32
  160. package/cjs/widgets/geo-search/GeoSearchRenderer.js +50 -72
  161. package/cjs/widgets/geo-search/createHTMLMarker.js +34 -62
  162. package/cjs/widgets/geo-search/defaultTemplates.js +0 -3
  163. package/cjs/widgets/geo-search/geo-search.js +44 -70
  164. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +5 -9
  165. package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +41 -57
  166. package/cjs/widgets/hits/hits.js +32 -50
  167. package/cjs/widgets/hits-per-page/hits-per-page.js +24 -39
  168. package/cjs/widgets/index/index.js +71 -113
  169. package/cjs/widgets/index.js +47 -85
  170. package/cjs/widgets/infinite-hits/infinite-hits.js +39 -57
  171. package/cjs/widgets/menu/defaultTemplates.js +4 -8
  172. package/cjs/widgets/menu/menu.js +36 -53
  173. package/cjs/widgets/menu-select/defaultTemplates.js +2 -4
  174. package/cjs/widgets/menu-select/menu-select.js +31 -48
  175. package/cjs/widgets/numeric-menu/defaultTemplates.js +3 -5
  176. package/cjs/widgets/numeric-menu/numeric-menu.js +30 -47
  177. package/cjs/widgets/pagination/pagination.js +43 -61
  178. package/cjs/widgets/panel/panel.js +31 -56
  179. package/cjs/widgets/places/places.js +22 -34
  180. package/cjs/widgets/powered-by/powered-by.js +20 -34
  181. package/cjs/widgets/query-rule-context/query-rule-context.js +10 -18
  182. package/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js +24 -39
  183. package/cjs/widgets/range-input/range-input.js +36 -60
  184. package/cjs/widgets/range-slider/range-slider.js +39 -61
  185. package/cjs/widgets/rating-menu/defaultTemplates.js +9 -16
  186. package/cjs/widgets/rating-menu/rating-menu.js +30 -48
  187. package/cjs/widgets/refinement-list/defaultTemplates.js +6 -10
  188. package/cjs/widgets/refinement-list/refinement-list.js +54 -72
  189. package/cjs/widgets/relevant-sort/relevant-sort.js +21 -37
  190. package/cjs/widgets/search-box/defaultTemplates.js +0 -5
  191. package/cjs/widgets/search-box/search-box.js +42 -57
  192. package/cjs/widgets/sort-by/sort-by.js +21 -36
  193. package/cjs/widgets/stats/defaultTemplates.js +1 -2
  194. package/cjs/widgets/stats/stats.js +40 -67
  195. package/cjs/widgets/toggle-refinement/toggle-refinement.js +29 -46
  196. package/cjs/widgets/voice-search/defaultTemplates.js +4 -14
  197. package/cjs/widgets/voice-search/voice-search.js +28 -44
  198. package/dist/instantsearch.development.d.ts +9 -6
  199. package/dist/instantsearch.development.js +1840 -3142
  200. package/dist/instantsearch.development.js.map +1 -1
  201. package/dist/instantsearch.production.d.ts +9 -6
  202. package/dist/instantsearch.production.min.d.ts +9 -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 +10 -13
  206. package/es/components/Breadcrumb/Breadcrumb.js +5 -8
  207. package/es/components/ClearRefinements/ClearRefinements.js +4 -7
  208. package/es/components/CurrentRefinements/CurrentRefinements.js +5 -10
  209. package/es/components/GeoSearchControls/GeoSearchButton.js +4 -6
  210. package/es/components/GeoSearchControls/GeoSearchControls.js +11 -14
  211. package/es/components/GeoSearchControls/GeoSearchToggle.js +4 -6
  212. package/es/components/Highlight/Highlight.js +4 -7
  213. package/es/components/Hits/Hits.js +12 -17
  214. package/es/components/InfiniteHits/InfiniteHits.js +17 -22
  215. package/es/components/MenuSelect/MenuSelect.js +9 -14
  216. package/es/components/Pagination/Pagination.js +10 -15
  217. package/es/components/Panel/Panel.js +8 -22
  218. package/es/components/PoweredBy/PoweredBy.js +4 -5
  219. package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +2 -4
  220. package/es/components/RangeInput/RangeInput.js +20 -46
  221. package/es/components/RefinementList/RefinementList.js +24 -67
  222. package/es/components/RefinementList/RefinementListItem.js +8 -11
  223. package/es/components/RelevantSort/RelevantSort.js +4 -6
  224. package/es/components/ReverseHighlight/ReverseHighlight.js +4 -7
  225. package/es/components/ReverseSnippet/ReverseSnippet.js +4 -7
  226. package/es/components/SearchBox/SearchBox.js +29 -66
  227. package/es/components/Selector/Selector.js +3 -5
  228. package/es/components/Slider/Pit.js +7 -9
  229. package/es/components/Slider/Rheostat.js +70 -133
  230. package/es/components/Slider/Slider.js +34 -61
  231. package/es/components/Snippet/Snippet.js +4 -7
  232. package/es/components/Stats/Stats.js +12 -17
  233. package/es/components/Template/Template.js +12 -35
  234. package/es/components/ToggleRefinement/ToggleRefinement.js +4 -7
  235. package/es/components/VoiceSearch/VoiceSearch.js +8 -13
  236. package/es/connectors/answers/connectAnswers.js +27 -36
  237. package/es/connectors/autocomplete/connectAutocomplete.js +12 -24
  238. package/es/connectors/breadcrumb/connectBreadcrumb.js +22 -48
  239. package/es/connectors/clear-refinements/connectClearRefinements.js +32 -45
  240. package/es/connectors/configure/connectConfigure.js +11 -17
  241. package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +16 -33
  242. package/es/connectors/current-refinements/connectCurrentRefinements.js +23 -57
  243. package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +20 -36
  244. package/es/connectors/geo-search/connectGeoSearch.js +21 -46
  245. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +44 -74
  246. package/es/connectors/hits/connectHits.js +14 -25
  247. package/es/connectors/hits-per-page/connectHitsPerPage.js +20 -38
  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 +32 -62
  251. package/es/connectors/menu/connectMenu.js +34 -66
  252. package/es/connectors/numeric-menu/connectNumericMenu.js +31 -78
  253. package/es/connectors/pagination/Paginator.js +8 -21
  254. package/es/connectors/pagination/connectPagination.js +12 -22
  255. package/es/connectors/powered-by/connectPoweredBy.js +8 -12
  256. package/es/connectors/query-rules/connectQueryRules.js +37 -56
  257. package/es/connectors/range/connectRange.js +46 -101
  258. package/es/connectors/rating-menu/connectRatingMenu.js +28 -79
  259. package/es/connectors/refinement-list/connectRefinementList.js +43 -69
  260. package/es/connectors/relevant-sort/connectRelevantSort.js +8 -14
  261. package/es/connectors/search-box/connectSearchBox.js +11 -22
  262. package/es/connectors/sort-by/connectSortBy.js +15 -20
  263. package/es/connectors/stats/connectStats.js +8 -10
  264. package/es/connectors/toggle-refinement/connectToggleRefinement.js +33 -62
  265. package/es/connectors/toggle-refinement/types.js +1 -0
  266. package/es/connectors/voice-search/connectVoiceSearch.js +17 -32
  267. package/es/helpers/components/Highlight.js +5 -8
  268. package/es/helpers/components/ReverseHighlight.js +13 -16
  269. package/es/helpers/components/ReverseSnippet.js +13 -16
  270. package/es/helpers/components/Snippet.js +5 -8
  271. package/es/helpers/get-insights-anonymous-user-token.js +2 -10
  272. package/es/helpers/highlight.js +10 -10
  273. package/es/helpers/insights.js +3 -10
  274. package/es/helpers/reverseHighlight.js +10 -10
  275. package/es/helpers/reverseSnippet.js +10 -10
  276. package/es/helpers/snippet.js +10 -10
  277. package/es/index.js +0 -2
  278. package/es/lib/InstantSearch.js +83 -172
  279. package/es/lib/createHelpers.js +8 -9
  280. package/es/lib/infiniteHitsCache/sessionStorage.js +10 -16
  281. package/es/lib/insights/client.js +12 -33
  282. package/es/lib/insights/listener.js +4 -18
  283. package/es/lib/routers/history.js +69 -108
  284. package/es/lib/stateMappings/simple.js +11 -13
  285. package/es/lib/stateMappings/singleIndex.js +6 -7
  286. package/es/lib/suit.js +2 -3
  287. package/es/lib/templating/prepareTemplateProps.js +13 -20
  288. package/es/lib/templating/renderTemplate.js +12 -21
  289. package/es/lib/utils/checkIndexUiState.js +19 -41
  290. package/es/lib/utils/clearRefinements.js +2 -8
  291. package/es/lib/utils/concatHighlightedParts.js +1 -1
  292. package/es/lib/utils/createConcurrentSafePromise.js +0 -2
  293. package/es/lib/utils/createSendEventForFacet.js +7 -12
  294. package/es/lib/utils/createSendEventForHits.js +8 -30
  295. package/es/lib/utils/debounce.js +0 -2
  296. package/es/lib/utils/defer.js +0 -10
  297. package/es/lib/utils/documentation.js +2 -3
  298. package/es/lib/utils/escape-highlight.js +9 -18
  299. package/es/lib/utils/escape-html.js +9 -5
  300. package/es/lib/utils/escapeFacetValue.js +0 -2
  301. package/es/lib/utils/find.js +2 -4
  302. package/es/lib/utils/findIndex.js +0 -2
  303. package/es/lib/utils/geo-search.js +21 -35
  304. package/es/lib/utils/getAppIdAndApiKey.js +2 -2
  305. package/es/lib/utils/getContainerNode.js +1 -5
  306. package/es/lib/utils/getHighlightFromSiblings.js +0 -3
  307. package/es/lib/utils/getHighlightedParts.js +1 -2
  308. package/es/lib/utils/getRefinements.js +28 -41
  309. package/es/lib/utils/getWidgetAttribute.js +0 -5
  310. package/es/lib/utils/hits-absolute-position.js +6 -6
  311. package/es/lib/utils/hits-query-id.js +6 -7
  312. package/es/lib/utils/isEqual.js +2 -6
  313. package/es/lib/utils/isPlainObject.js +3 -10
  314. package/es/lib/utils/logger.js +4 -14
  315. package/es/lib/utils/mergeSearchParameters.js +21 -38
  316. package/es/lib/utils/range.js +9 -14
  317. package/es/lib/utils/resolveSearchParameters.js +0 -2
  318. package/es/lib/utils/reverseHighlightedParts.js +6 -7
  319. package/es/lib/utils/safelyRunOnBrowser.js +7 -8
  320. package/es/lib/utils/setIndexHelperState.js +0 -2
  321. package/es/lib/version.d.ts +1 -1
  322. package/es/lib/version.js +1 -1
  323. package/es/lib/voiceSearchHelper/index.js +12 -36
  324. package/es/lib/voiceSearchHelper/types.js +1 -0
  325. package/es/middlewares/createInsightsMiddleware.js +21 -42
  326. package/es/middlewares/createMetadataMiddleware.js +3 -9
  327. package/es/middlewares/createRouterMiddleware.js +12 -14
  328. package/es/types/algoliasearch.js +1 -0
  329. package/es/types/component.js +1 -0
  330. package/es/types/connector.js +1 -0
  331. package/es/types/index.js +9 -5
  332. package/es/types/insights.js +1 -0
  333. package/es/types/instantsearch.js +1 -0
  334. package/es/types/middleware.js +1 -0
  335. package/es/types/render-state.js +1 -0
  336. package/es/types/results.js +1 -0
  337. package/es/types/router.js +1 -0
  338. package/es/types/templates.js +1 -0
  339. package/es/types/ui-state.js +1 -0
  340. package/es/types/utils.js +1 -0
  341. package/es/types/widget-factory.js +1 -0
  342. package/es/types/widget.js +1 -0
  343. package/es/widgets/analytics/analytics.js +19 -43
  344. package/es/widgets/answers/answers.js +23 -30
  345. package/es/widgets/breadcrumb/breadcrumb.js +22 -29
  346. package/es/widgets/clear-refinements/clear-refinements.js +19 -26
  347. package/es/widgets/configure/configure.js +7 -7
  348. package/es/widgets/configure-related-items/configure-related-items.js +6 -8
  349. package/es/widgets/current-refinements/current-refinements.js +16 -23
  350. package/es/widgets/dynamic-widgets/dynamic-widgets.js +11 -21
  351. package/es/widgets/geo-search/GeoSearchRenderer.d.js +1 -0
  352. package/es/widgets/geo-search/GeoSearchRenderer.js +47 -65
  353. package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -0
  354. package/es/widgets/geo-search/createHTMLMarker.js +34 -61
  355. package/es/widgets/geo-search/defaultTemplates.js +0 -2
  356. package/es/widgets/geo-search/geo-search.d.ts +1 -0
  357. package/es/widgets/geo-search/geo-search.js +34 -50
  358. package/es/widgets/hierarchical-menu/defaultTemplates.js +4 -4
  359. package/es/widgets/hierarchical-menu/hierarchical-menu.js +32 -38
  360. package/es/widgets/hits/hits.js +20 -27
  361. package/es/widgets/hits-per-page/hits-per-page.js +17 -24
  362. package/es/widgets/index/index.js +55 -93
  363. package/es/widgets/index.d.ts +2 -1
  364. package/es/widgets/index.js +4 -3
  365. package/es/widgets/infinite-hits/infinite-hits.js +27 -34
  366. package/es/widgets/menu/defaultTemplates.js +3 -3
  367. package/es/widgets/menu/menu.js +27 -34
  368. package/es/widgets/menu-select/defaultTemplates.js +1 -1
  369. package/es/widgets/menu-select/menu-select.js +22 -29
  370. package/es/widgets/numeric-menu/defaultTemplates.js +3 -3
  371. package/es/widgets/numeric-menu/numeric-menu.js +21 -28
  372. package/es/widgets/pagination/pagination.js +36 -46
  373. package/es/widgets/panel/panel.js +24 -42
  374. package/es/widgets/places/places.js +22 -33
  375. package/es/widgets/powered-by/powered-by.js +14 -20
  376. package/es/widgets/query-rule-context/query-rule-context.js +6 -10
  377. package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +17 -24
  378. package/es/widgets/range-input/range-input.js +28 -43
  379. package/es/widgets/range-slider/range-slider.js +33 -47
  380. package/es/widgets/rating-menu/defaultTemplates.js +8 -12
  381. package/es/widgets/rating-menu/rating-menu.js +21 -29
  382. package/es/widgets/refinement-list/defaultTemplates.js +5 -5
  383. package/es/widgets/refinement-list/refinement-list.js +43 -50
  384. package/es/widgets/relevant-sort/relevant-sort.js +14 -21
  385. package/es/widgets/search-box/defaultTemplates.js +0 -4
  386. package/es/widgets/search-box/search-box.js +35 -41
  387. package/es/widgets/sort-by/sort-by.js +15 -22
  388. package/es/widgets/stats/stats.js +30 -47
  389. package/es/widgets/toggle-refinement/toggle-refinement.js +20 -27
  390. package/es/widgets/voice-search/defaultTemplates.js +4 -13
  391. package/es/widgets/voice-search/voice-search.js +21 -28
  392. package/package.json +20 -119
  393. package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.input.js +0 -1
  394. package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.output.js +0 -1
  395. package/scripts/transforms/__tests__/addWidget-to-addWidgets.test.js +1 -0
  396. package/CHANGELOG.md +0 -3693
@@ -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,11 @@
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
-
7
- 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
-
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 _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
3
+ 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); }
4
+ 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; }
5
+ 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; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
9
  import { escape } from "./escape-html.js";
10
10
  import { isPlainObject } from "./isPlainObject.js";
11
11
  export var TAG_PLACEHOLDER = {
@@ -16,47 +16,38 @@ export var TAG_REPLACEMENT = {
16
16
  highlightPreTag: '<mark>',
17
17
  highlightPostTag: '</mark>'
18
18
  };
19
-
20
19
  function replaceTagsAndEscape(value) {
21
20
  return escape(value).replace(new RegExp(TAG_PLACEHOLDER.highlightPreTag, 'g'), TAG_REPLACEMENT.highlightPreTag).replace(new RegExp(TAG_PLACEHOLDER.highlightPostTag, 'g'), TAG_REPLACEMENT.highlightPostTag);
22
21
  }
23
-
24
22
  function recursiveEscape(input) {
25
23
  if (isPlainObject(input) && typeof input.value !== 'string') {
26
24
  return Object.keys(input).reduce(function (acc, key) {
27
25
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, recursiveEscape(input[key])));
28
26
  }, {});
29
27
  }
30
-
31
28
  if (Array.isArray(input)) {
32
29
  return input.map(recursiveEscape);
33
30
  }
34
-
35
31
  return _objectSpread(_objectSpread({}, input), {}, {
36
32
  value: replaceTagsAndEscape(input.value)
37
33
  });
38
34
  }
39
-
40
35
  export function escapeHits(hits) {
41
36
  if (hits.__escaped === undefined) {
42
37
  // We don't override the value on hit because it will mutate the raw results
43
38
  // instead we make a shallow copy and we assign the escaped values on it.
44
39
  hits = hits.map(function (_ref) {
45
- var hit = _extends({}, _ref);
46
-
40
+ var hit = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
47
41
  if (hit._highlightResult) {
48
42
  hit._highlightResult = recursiveEscape(hit._highlightResult);
49
43
  }
50
-
51
44
  if (hit._snippetResult) {
52
45
  hit._snippetResult = recursiveEscape(hit._snippetResult);
53
46
  }
54
-
55
47
  return hit;
56
48
  });
57
49
  hits.__escaped = true;
58
50
  }
59
-
60
51
  return hits;
61
52
  }
62
53
  export function escapeFacets(facetHits) {
@@ -2,6 +2,7 @@
2
2
  * This implementation is taken from Lodash implementation.
3
3
  * See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
4
4
  */
5
+
5
6
  // Used to map characters to HTML entities.
6
7
  var htmlEntities = {
7
8
  '&': '&amp;',
@@ -9,41 +10,44 @@ var htmlEntities = {
9
10
  '>': '&gt;',
10
11
  '"': '&quot;',
11
12
  "'": '&#39;'
12
- }; // Used to match HTML entities and HTML characters.
13
+ };
13
14
 
15
+ // Used to match HTML entities and HTML characters.
14
16
  var regexUnescapedHtml = /[&<>"']/g;
15
17
  var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
18
+
16
19
  /**
17
20
  * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
18
21
  * corresponding HTML entities.
19
22
  */
20
-
21
23
  export function escape(value) {
22
24
  return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
23
25
  return htmlEntities[character];
24
26
  }) : value;
25
27
  }
28
+
26
29
  /**
27
30
  * This implementation is taken from Lodash implementation.
28
31
  * See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
29
32
  */
30
- // Used to map HTML entities to characters.
31
33
 
34
+ // Used to map HTML entities to characters.
32
35
  var htmlCharacters = {
33
36
  '&amp;': '&',
34
37
  '&lt;': '<',
35
38
  '&gt;': '>',
36
39
  '&quot;': '"',
37
40
  '&#39;': "'"
38
- }; // Used to match HTML entities and HTML characters.
41
+ };
39
42
 
43
+ // Used to match HTML entities and HTML characters.
40
44
  var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
41
45
  var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
46
+
42
47
  /**
43
48
  * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
44
49
  * characters.
45
50
  */
46
-
47
51
  export function unescape(value) {
48
52
  return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
49
53
  return htmlCharacters[character];
@@ -2,13 +2,11 @@ export function unescapeFacetValue(value) {
2
2
  if (typeof value === 'string') {
3
3
  return value.replace(/^\\-/, '-');
4
4
  }
5
-
6
5
  return value;
7
6
  }
8
7
  export function escapeFacetValue(value) {
9
8
  if (typeof value === 'number' && value < 0 || typeof value === 'string') {
10
9
  return String(value).replace(/^-/, '\\-');
11
10
  }
12
-
13
11
  return value;
14
12
  }
@@ -6,14 +6,12 @@
6
6
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
7
7
  export function find(items, predicate) {
8
8
  var value;
9
-
10
9
  for (var i = 0; i < items.length; i++) {
11
- value = items[i]; // inlined for performance: if (Call(predicate, thisArg, [value, i, list])) {
12
-
10
+ value = items[i];
11
+ // inlined for performance: if (Call(predicate, thisArg, [value, i, list])) {
13
12
  if (predicate(value, i, items)) {
14
13
  return value;
15
14
  }
16
15
  }
17
-
18
16
  return undefined;
19
17
  }
@@ -8,12 +8,10 @@ export function findIndex(array, comparator) {
8
8
  if (!Array.isArray(array)) {
9
9
  return -1;
10
10
  }
11
-
12
11
  for (var i = 0; i < array.length; i++) {
13
12
  if (comparator(array[i])) {
14
13
  return i;
15
14
  }
16
15
  }
17
-
18
16
  return -1;
19
17
  }
@@ -1,48 +1,38 @@
1
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
2
  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."); }
4
-
5
3
  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); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- 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; }
10
-
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
11
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
7
  var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
14
8
  export function aroundLatLngToPosition(value) {
15
- var pattern = value.match(latLngRegExp); // Since the value provided is the one send with the request, the API should
16
- // throw an error due to the wrong format. So throw an error should be safe.
9
+ var pattern = value.match(latLngRegExp);
17
10
 
11
+ // Since the value provided is the one send with the request, the API should
12
+ // throw an error due to the wrong format. So throw an error should be safe.
18
13
  if (!pattern) {
19
14
  throw new Error("Invalid value for \"aroundLatLng\" parameter: \"".concat(value, "\""));
20
15
  }
21
-
22
16
  return {
23
17
  lat: parseFloat(pattern[1]),
24
18
  lng: parseFloat(pattern[2])
25
19
  };
26
20
  }
27
-
28
21
  function insideBoundingBoxArrayToBoundingBox(value) {
29
22
  var _value = _slicedToArray(value, 1),
30
- _value$ = _value[0];
31
-
32
- _value$ = _value$ === void 0 ? [undefined, undefined, undefined, undefined] : _value$;
33
-
34
- var _value$2 = _slicedToArray(_value$, 4),
35
- neLat = _value$2[0],
36
- neLng = _value$2[1],
37
- swLat = _value$2[2],
38
- swLng = _value$2[3]; // Since the value provided is the one send with the request, the API should
23
+ _value$ = _value[0],
24
+ _value$2 = _value$ === void 0 ? [undefined, undefined, undefined, undefined] : _value$,
25
+ _value$3 = _slicedToArray(_value$2, 4),
26
+ neLat = _value$3[0],
27
+ neLng = _value$3[1],
28
+ swLat = _value$3[2],
29
+ swLng = _value$3[3];
30
+
31
+ // Since the value provided is the one send with the request, the API should
39
32
  // throw an error due to the wrong format. So throw an error should be safe.
40
-
41
-
42
33
  if (!neLat || !neLng || !swLat || !swLng) {
43
34
  throw new Error("Invalid value for \"insideBoundingBox\" parameter: [".concat(value, "]"));
44
35
  }
45
-
46
36
  return {
47
37
  northEast: {
48
38
  lat: neLat,
@@ -54,21 +44,19 @@ function insideBoundingBoxArrayToBoundingBox(value) {
54
44
  }
55
45
  };
56
46
  }
57
-
58
47
  function insideBoundingBoxStringToBoundingBox(value) {
59
48
  var _value$split$map = value.split(',').map(parseFloat),
60
- _value$split$map2 = _slicedToArray(_value$split$map, 4),
61
- neLat = _value$split$map2[0],
62
- neLng = _value$split$map2[1],
63
- swLat = _value$split$map2[2],
64
- swLng = _value$split$map2[3]; // Since the value provided is the one send with the request, the API should
65
- // throw an error due to the wrong format. So throw an error should be safe.
66
-
49
+ _value$split$map2 = _slicedToArray(_value$split$map, 4),
50
+ neLat = _value$split$map2[0],
51
+ neLng = _value$split$map2[1],
52
+ swLat = _value$split$map2[2],
53
+ swLng = _value$split$map2[3];
67
54
 
55
+ // Since the value provided is the one send with the request, the API should
56
+ // throw an error due to the wrong format. So throw an error should be safe.
68
57
  if (!neLat || !neLng || !swLat || !swLng) {
69
58
  throw new Error("Invalid value for \"insideBoundingBox\" parameter: \"".concat(value, "\""));
70
59
  }
71
-
72
60
  return {
73
61
  northEast: {
74
62
  lat: neLat,
@@ -80,11 +68,9 @@ function insideBoundingBoxStringToBoundingBox(value) {
80
68
  }
81
69
  };
82
70
  }
83
-
84
71
  export function insideBoundingBoxToBoundingBox(value) {
85
72
  if (Array.isArray(value)) {
86
73
  return insideBoundingBoxArrayToBoundingBox(value);
87
74
  }
88
-
89
75
  return insideBoundingBoxStringToBoundingBox(value);
90
76
  }
@@ -3,8 +3,8 @@ export function getAppIdAndApiKey(searchClient) {
3
3
  if (searchClient.transporter) {
4
4
  // searchClient v4
5
5
  var _searchClient$transpo = searchClient.transporter,
6
- headers = _searchClient$transpo.headers,
7
- queryParameters = _searchClient$transpo.queryParameters;
6
+ headers = _searchClient$transpo.headers,
7
+ queryParameters = _searchClient$transpo.queryParameters;
8
8
  var APP_ID = 'x-algolia-application-id';
9
9
  var API_KEY = 'x-algolia-api-key';
10
10
  var appId = headers[APP_ID] || queryParameters[APP_ID];
@@ -1,4 +1,5 @@
1
1
  import { isDomElement } from "./isDomElement.js";
2
+
2
3
  /**
3
4
  * Return the container. If it's a string, it is considered a
4
5
  * css selector and retrieves the first matching element. Otherwise
@@ -8,20 +9,15 @@ import { isDomElement } from "./isDomElement.js";
8
9
  * @return {HTMLElement} Container node
9
10
  * @throws Error when the type is not correct
10
11
  */
11
-
12
12
  export function getContainerNode(selectorOrHTMLElement) {
13
13
  var isSelectorString = typeof selectorOrHTMLElement === 'string';
14
14
  var domElement = isSelectorString ? document.querySelector(selectorOrHTMLElement) : selectorOrHTMLElement;
15
-
16
15
  if (!isDomElement(domElement)) {
17
16
  var errorMessage = 'Container must be `string` or `HTMLElement`.';
18
-
19
17
  if (isSelectorString) {
20
18
  errorMessage += " Unable to find ".concat(selectorOrHTMLElement);
21
19
  }
22
-
23
20
  throw new Error(errorMessage);
24
21
  }
25
-
26
22
  return domElement;
27
23
  }
@@ -2,14 +2,11 @@ import { unescape } from "./escape-html.js";
2
2
  var hasAlphanumeric = new RegExp(/\w/i);
3
3
  export function getHighlightFromSiblings(parts, i) {
4
4
  var _parts, _parts2;
5
-
6
5
  var current = parts[i];
7
6
  var isNextHighlighted = ((_parts = parts[i + 1]) === null || _parts === void 0 ? void 0 : _parts.isHighlighted) || true;
8
7
  var isPreviousHighlighted = ((_parts2 = parts[i - 1]) === null || _parts2 === void 0 ? void 0 : _parts2.isHighlighted) || true;
9
-
10
8
  if (!hasAlphanumeric.test(unescape(current.value)) && isPreviousHighlighted === isNextHighlighted) {
11
9
  return isPreviousHighlighted;
12
10
  }
13
-
14
11
  return current.isHighlighted;
15
12
  }
@@ -1,7 +1,7 @@
1
1
  import { TAG_REPLACEMENT } from "./escape-highlight.js";
2
2
  export function getHighlightedParts(highlightedValue) {
3
3
  var highlightPostTag = TAG_REPLACEMENT.highlightPostTag,
4
- highlightPreTag = TAG_REPLACEMENT.highlightPreTag;
4
+ highlightPreTag = TAG_REPLACEMENT.highlightPreTag;
5
5
  var splitByPreTag = highlightedValue.split(highlightPreTag);
6
6
  var firstValue = splitByPreTag.shift();
7
7
  var elements = !firstValue ? [] : [{
@@ -14,7 +14,6 @@ export function getHighlightedParts(highlightedValue) {
14
14
  value: splitByPostTag[0],
15
15
  isHighlighted: true
16
16
  });
17
-
18
17
  if (splitByPostTag[1] !== '') {
19
18
  elements.push({
20
19
  value: splitByPostTag[1],
@@ -1,6 +1,5 @@
1
1
  import { find } from "./find.js";
2
2
  import { unescapeFacetValue, escapeFacetValue } from "./escapeFacetValue.js";
3
-
4
3
  function getRefinement(state, type, attribute, name) {
5
4
  var resultsFacets = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
6
5
  var res = {
@@ -13,60 +12,49 @@ function getRefinement(state, type, attribute, name) {
13
12
  return resultsFacet.name === attribute;
14
13
  });
15
14
  var count;
16
-
17
15
  if (type === 'hierarchical') {
18
- (function () {
19
- var facetDeclaration = state.getHierarchicalFacetByName(attribute);
20
- var nameParts = name.split(facetDeclaration.separator);
21
-
22
- var getFacetRefinement = function getFacetRefinement(facetData) {
23
- return function (refinementKey) {
24
- return facetData[refinementKey];
25
- };
16
+ var facetDeclaration = state.getHierarchicalFacetByName(attribute);
17
+ var nameParts = name.split(facetDeclaration.separator);
18
+ var getFacetRefinement = function getFacetRefinement(facetData) {
19
+ return function (refinementKey) {
20
+ return facetData[refinementKey];
26
21
  };
27
-
28
- var _loop = function _loop(i) {
29
- facet = facet && facet.data && find(Object.keys(facet.data).map(getFacetRefinement(facet.data)), function (refinement) {
30
- return refinement.name === nameParts[i];
31
- });
32
- };
33
-
34
- for (var i = 0; facet !== undefined && i < nameParts.length; ++i) {
35
- _loop(i);
36
- }
37
-
38
- count = facet && facet.count;
39
- })();
22
+ };
23
+ var _loop = function _loop(i) {
24
+ facet = facet && facet.data && find(Object.keys(facet.data).map(getFacetRefinement(facet.data)), function (refinement) {
25
+ return refinement.name === nameParts[i];
26
+ });
27
+ };
28
+ for (var i = 0; facet !== undefined && i < nameParts.length; ++i) {
29
+ _loop(i);
30
+ }
31
+ count = facet && facet.count;
40
32
  } else {
41
33
  count = facet && facet.data && facet.data[res.name];
42
34
  }
43
-
44
35
  if (count !== undefined) {
45
36
  res.count = count;
46
37
  }
47
-
48
38
  if (facet && facet.exhaustive !== undefined) {
49
39
  res.exhaustive = facet.exhaustive;
50
40
  }
51
-
52
41
  return res;
53
42
  }
54
-
55
43
  export function getRefinements(results, state) {
56
44
  var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
57
45
  var refinements = [];
58
46
  var _state$facetsRefineme = state.facetsRefinements,
59
- facetsRefinements = _state$facetsRefineme === void 0 ? {} : _state$facetsRefineme,
60
- _state$facetsExcludes = state.facetsExcludes,
61
- facetsExcludes = _state$facetsExcludes === void 0 ? {} : _state$facetsExcludes,
62
- _state$disjunctiveFac = state.disjunctiveFacetsRefinements,
63
- disjunctiveFacetsRefinements = _state$disjunctiveFac === void 0 ? {} : _state$disjunctiveFac,
64
- _state$hierarchicalFa = state.hierarchicalFacetsRefinements,
65
- hierarchicalFacetsRefinements = _state$hierarchicalFa === void 0 ? {} : _state$hierarchicalFa,
66
- _state$numericRefinem = state.numericRefinements,
67
- numericRefinements = _state$numericRefinem === void 0 ? {} : _state$numericRefinem,
68
- _state$tagRefinements = state.tagRefinements,
69
- tagRefinements = _state$tagRefinements === void 0 ? [] : _state$tagRefinements;
47
+ facetsRefinements = _state$facetsRefineme === void 0 ? {} : _state$facetsRefineme,
48
+ _state$facetsExcludes = state.facetsExcludes,
49
+ facetsExcludes = _state$facetsExcludes === void 0 ? {} : _state$facetsExcludes,
50
+ _state$disjunctiveFac = state.disjunctiveFacetsRefinements,
51
+ disjunctiveFacetsRefinements = _state$disjunctiveFac === void 0 ? {} : _state$disjunctiveFac,
52
+ _state$hierarchicalFa = state.hierarchicalFacetsRefinements,
53
+ hierarchicalFacetsRefinements = _state$hierarchicalFa === void 0 ? {} : _state$hierarchicalFa,
54
+ _state$numericRefinem = state.numericRefinements,
55
+ numericRefinements = _state$numericRefinem === void 0 ? {} : _state$numericRefinem,
56
+ _state$tagRefinements = state.tagRefinements,
57
+ tagRefinements = _state$tagRefinements === void 0 ? [] : _state$tagRefinements;
70
58
  Object.keys(facetsRefinements).forEach(function (attribute) {
71
59
  var refinementNames = facetsRefinements[attribute];
72
60
  refinementNames.forEach(function (refinementName) {
@@ -87,7 +75,8 @@ export function getRefinements(results, state) {
87
75
  Object.keys(disjunctiveFacetsRefinements).forEach(function (attribute) {
88
76
  var refinementNames = disjunctiveFacetsRefinements[attribute];
89
77
  refinementNames.forEach(function (refinementName) {
90
- refinements.push(getRefinement(state, 'disjunctive', attribute, // We unescape any disjunctive refined values with `unescapeFacetValue` because
78
+ refinements.push(getRefinement(state, 'disjunctive', attribute,
79
+ // We unescape any disjunctive refined values with `unescapeFacetValue` because
91
80
  // they can be escaped on negative numeric values with `escapeFacetValue`.
92
81
  unescapeFacetValue(refinementName), results.disjunctiveFacets));
93
82
  });
@@ -122,7 +111,6 @@ export function getRefinements(results, state) {
122
111
  name: refinementName
123
112
  });
124
113
  });
125
-
126
114
  if (includesQuery && state.query && state.query.trim()) {
127
115
  refinements.push({
128
116
  attribute: 'query',
@@ -131,6 +119,5 @@ export function getRefinements(results, state) {
131
119
  query: state.query
132
120
  });
133
121
  }
134
-
135
122
  return refinements;
136
123
  }
@@ -1,23 +1,18 @@
1
1
  export function getWidgetAttribute(widget, initOptions) {
2
2
  var _widget$getWidgetRend;
3
-
4
3
  var renderState = (_widget$getWidgetRend = widget.getWidgetRenderState) === null || _widget$getWidgetRend === void 0 ? void 0 : _widget$getWidgetRend.call(widget, initOptions);
5
4
  var attribute = null;
6
-
7
5
  if (renderState && renderState.widgetParams) {
8
6
  // casting as widgetParams is checked just before
9
7
  var widgetParams = renderState.widgetParams;
10
-
11
8
  if (widgetParams.attribute) {
12
9
  attribute = widgetParams.attribute;
13
10
  } else if (Array.isArray(widgetParams.attributes)) {
14
11
  attribute = widgetParams.attributes[0];
15
12
  }
16
13
  }
17
-
18
14
  if (typeof attribute !== 'string') {
19
15
  throw new Error("Could not find the attribute of the widget:\n\n".concat(JSON.stringify(widget), "\n\nPlease check whether the widget's getWidgetRenderState returns widgetParams.attribute correctly."));
20
16
  }
21
-
22
17
  return attribute;
23
18
  }
@@ -1,9 +1,9 @@
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
-
5
- 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
-
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  export function addAbsolutePosition(hits, page, hitsPerPage) {
8
8
  return hits.map(function (hit, idx) {
9
9
  return _objectSpread(_objectSpread({}, hit), {}, {
@@ -1,14 +1,13 @@
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
-
5
- 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
-
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  export function addQueryID(hits, queryID) {
8
8
  if (!queryID) {
9
9
  return hits;
10
10
  }
11
-
12
11
  return hits.map(function (hit) {
13
12
  return _objectSpread(_objectSpread({}, hit), {}, {
14
13
  __queryID: queryID
@@ -1,31 +1,27 @@
1
1
  function isPrimitive(obj) {
2
2
  return obj !== Object(obj);
3
3
  }
4
-
5
4
  export function isEqual(first, second) {
6
5
  if (first === second) {
7
6
  return true;
8
7
  }
9
-
10
8
  if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') {
11
9
  return first === second;
12
10
  }
13
-
14
11
  if (Object.keys(first).length !== Object.keys(second).length) {
15
12
  return false;
16
13
  }
17
14
 
15
+ // @TODO avoid for..of because of the large polyfill
16
+ // eslint-disable-next-line no-restricted-syntax
18
17
  for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) {
19
18
  var key = _Object$keys[_i];
20
-
21
19
  if (!(key in second)) {
22
20
  return false;
23
21
  }
24
-
25
22
  if (!isEqual(first[key], second[key])) {
26
23
  return false;
27
24
  }
28
25
  }
29
-
30
26
  return true;
31
27
  }