instantsearch.js 4.46.0 → 4.46.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 (320) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/cjs/components/CurrentRefinements/CurrentRefinements.js +0 -1
  3. package/cjs/components/GeoSearchControls/GeoSearchButton.js +0 -1
  4. package/cjs/components/GeoSearchControls/GeoSearchToggle.js +0 -1
  5. package/cjs/components/PoweredBy/PoweredBy.js +0 -1
  6. package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +0 -1
  7. package/cjs/components/RelevantSort/RelevantSort.js +0 -1
  8. package/cjs/components/Selector/Selector.js +0 -1
  9. package/cjs/components/Template/Template.js +3 -1
  10. package/cjs/components/VoiceSearch/VoiceSearch.js +0 -1
  11. package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
  12. package/cjs/helpers/components/Highlight.js +5 -13
  13. package/cjs/helpers/components/ReverseHighlight.js +5 -13
  14. package/cjs/helpers/components/ReverseSnippet.js +5 -13
  15. package/cjs/helpers/components/Snippet.js +5 -13
  16. package/cjs/lib/InstantSearch.js +33 -24
  17. package/cjs/lib/insights/listener.js +0 -1
  18. package/cjs/lib/templating/index.js +31 -0
  19. package/cjs/lib/{utils → templating}/prepareTemplateProps.js +4 -9
  20. package/cjs/lib/{utils → templating}/renderTemplate.js +4 -7
  21. package/cjs/lib/utils/capitalize.js +2 -5
  22. package/cjs/lib/utils/checkIndexUiState.js +3 -5
  23. package/cjs/lib/utils/checkRendering.js +4 -9
  24. package/cjs/lib/utils/clearRefinements.js +3 -9
  25. package/cjs/lib/utils/concatHighlightedParts.js +1 -1
  26. package/cjs/lib/utils/createSendEventForFacet.js +2 -4
  27. package/cjs/lib/utils/defer.js +3 -6
  28. package/cjs/lib/utils/detect-insights-client.js +1 -1
  29. package/cjs/lib/utils/documentation.js +6 -9
  30. package/cjs/lib/utils/escape-highlight.js +4 -6
  31. package/cjs/lib/utils/escape-html.js +60 -0
  32. package/cjs/lib/utils/find.js +2 -5
  33. package/cjs/lib/utils/findIndex.js +2 -5
  34. package/cjs/lib/utils/getContainerNode.js +4 -9
  35. package/cjs/lib/utils/getHighlightFromSiblings.js +3 -5
  36. package/cjs/lib/utils/getHighlightedParts.js +1 -1
  37. package/cjs/lib/utils/getObjectType.js +2 -5
  38. package/cjs/lib/utils/getPropertyByPath.js +2 -5
  39. package/cjs/lib/utils/getRefinements.js +4 -6
  40. package/cjs/lib/utils/index.js +536 -440
  41. package/cjs/lib/utils/isDomElement.js +2 -5
  42. package/cjs/lib/utils/isEqual.js +2 -5
  43. package/cjs/lib/utils/isFacetRefined.js +1 -1
  44. package/cjs/lib/utils/isFiniteNumber.js +3 -5
  45. package/cjs/lib/utils/isIndexWidget.js +10 -0
  46. package/cjs/lib/utils/isPlainObject.js +2 -5
  47. package/cjs/lib/utils/isSpecialClick.js +2 -5
  48. package/cjs/lib/utils/logger.js +3 -5
  49. package/cjs/lib/utils/mergeSearchParameters.js +7 -10
  50. package/cjs/lib/utils/noop.js +2 -5
  51. package/cjs/lib/utils/range.js +2 -5
  52. package/cjs/lib/utils/resolveSearchParameters.js +3 -6
  53. package/cjs/lib/utils/reverseHighlightedParts.js +3 -5
  54. package/cjs/lib/utils/setIndexHelperState.js +28 -0
  55. package/cjs/lib/utils/toArray.js +2 -5
  56. package/cjs/lib/utils/uniq.js +2 -5
  57. package/cjs/lib/version.js +1 -1
  58. package/cjs/middlewares/createInsightsMiddleware.js +23 -30
  59. package/cjs/middlewares/createMetadataMiddleware.js +1 -0
  60. package/cjs/middlewares/createRouterMiddleware.js +1 -0
  61. package/cjs/widgets/answers/answers.js +3 -1
  62. package/cjs/widgets/breadcrumb/breadcrumb.js +3 -1
  63. package/cjs/widgets/clear-refinements/clear-refinements.js +3 -1
  64. package/cjs/widgets/geo-search/GeoSearchRenderer.js +1 -1
  65. package/cjs/widgets/geo-search/defaultTemplates.js +0 -1
  66. package/cjs/widgets/geo-search/geo-search.js +3 -1
  67. package/cjs/widgets/hierarchical-menu/defaultTemplates.js +0 -1
  68. package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +3 -1
  69. package/cjs/widgets/hits/hits.js +6 -4
  70. package/cjs/widgets/index/index.js +8 -12
  71. package/cjs/widgets/infinite-hits/infinite-hits.js +6 -4
  72. package/cjs/widgets/menu/defaultTemplates.js +0 -1
  73. package/cjs/widgets/menu/menu.js +3 -1
  74. package/cjs/widgets/menu-select/menu-select.js +3 -1
  75. package/cjs/widgets/numeric-menu/defaultTemplates.js +0 -1
  76. package/cjs/widgets/numeric-menu/numeric-menu.js +3 -1
  77. package/cjs/widgets/range-input/range-input.js +3 -1
  78. package/cjs/widgets/rating-menu/defaultTemplates.js +0 -1
  79. package/cjs/widgets/rating-menu/rating-menu.js +3 -1
  80. package/cjs/widgets/refinement-list/defaultTemplates.js +0 -1
  81. package/cjs/widgets/refinement-list/refinement-list.js +4 -2
  82. package/cjs/widgets/search-box/defaultTemplates.js +0 -1
  83. package/cjs/widgets/stats/stats.js +3 -1
  84. package/cjs/widgets/toggle-refinement/toggle-refinement.js +3 -1
  85. package/cjs/widgets/voice-search/defaultTemplates.js +0 -1
  86. package/dist/instantsearch.development.d.ts +11 -3
  87. package/dist/instantsearch.development.js +8513 -8482
  88. package/dist/instantsearch.development.js.map +1 -1
  89. package/dist/instantsearch.production.d.ts +11 -3
  90. package/dist/instantsearch.production.min.d.ts +11 -3
  91. package/dist/instantsearch.production.min.js +2 -2
  92. package/dist/instantsearch.production.min.js.map +1 -1
  93. package/es/components/Answers/Answers.d.ts +1 -1
  94. package/es/components/Answers/Answers.js +0 -1
  95. package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -2
  96. package/es/components/Breadcrumb/Breadcrumb.js +0 -1
  97. package/es/components/ClearRefinements/ClearRefinements.d.ts +2 -2
  98. package/es/components/ClearRefinements/ClearRefinements.js +0 -1
  99. package/es/components/CurrentRefinements/CurrentRefinements.d.ts +1 -1
  100. package/es/components/CurrentRefinements/CurrentRefinements.js +0 -1
  101. package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
  102. package/es/components/GeoSearchControls/GeoSearchButton.js +0 -1
  103. package/es/components/GeoSearchControls/GeoSearchControls.d.ts +2 -2
  104. package/es/components/GeoSearchControls/GeoSearchControls.js +0 -1
  105. package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
  106. package/es/components/GeoSearchControls/GeoSearchToggle.js +0 -1
  107. package/es/components/Highlight/Highlight.js +0 -1
  108. package/es/components/Hits/Hits.d.ts +2 -2
  109. package/es/components/Hits/Hits.js +0 -1
  110. package/es/components/InfiniteHits/InfiniteHits.d.ts +1 -1
  111. package/es/components/InfiniteHits/InfiniteHits.js +0 -1
  112. package/es/components/MenuSelect/MenuSelect.d.ts +1 -1
  113. package/es/components/MenuSelect/MenuSelect.js +0 -1
  114. package/es/components/Pagination/Pagination.d.ts +1 -1
  115. package/es/components/Pagination/Pagination.js +0 -1
  116. package/es/components/Panel/Panel.d.ts +1 -1
  117. package/es/components/Panel/Panel.js +0 -1
  118. package/es/components/PoweredBy/PoweredBy.d.ts +1 -1
  119. package/es/components/PoweredBy/PoweredBy.js +0 -1
  120. package/es/components/QueryRuleCustomData/QueryRuleCustomData.d.ts +1 -1
  121. package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +0 -1
  122. package/es/components/RangeInput/RangeInput.d.ts +1 -1
  123. package/es/components/RangeInput/RangeInput.js +0 -1
  124. package/es/components/RefinementList/RefinementList.d.ts +2 -2
  125. package/es/components/RefinementList/RefinementList.js +0 -1
  126. package/es/components/RefinementList/RefinementListItem.d.ts +1 -1
  127. package/es/components/RefinementList/RefinementListItem.js +0 -1
  128. package/es/components/RelevantSort/RelevantSort.d.ts +1 -1
  129. package/es/components/RelevantSort/RelevantSort.js +0 -1
  130. package/es/components/ReverseHighlight/ReverseHighlight.js +0 -1
  131. package/es/components/ReverseSnippet/ReverseSnippet.js +0 -1
  132. package/es/components/SearchBox/SearchBox.d.ts +1 -1
  133. package/es/components/SearchBox/SearchBox.js +0 -1
  134. package/es/components/Selector/Selector.d.ts +1 -1
  135. package/es/components/Selector/Selector.js +0 -1
  136. package/es/components/Slider/Pit.d.ts +1 -1
  137. package/es/components/Slider/Pit.js +0 -1
  138. package/es/components/Slider/Rheostat.d.ts +1 -1
  139. package/es/components/Slider/Rheostat.js +0 -2
  140. package/es/components/Slider/Slider.d.ts +1 -1
  141. package/es/components/Slider/Slider.js +0 -1
  142. package/es/components/Snippet/Snippet.js +0 -1
  143. package/es/components/Stats/Stats.d.ts +1 -1
  144. package/es/components/Stats/Stats.js +0 -1
  145. package/es/components/Template/Template.d.ts +2 -2
  146. package/es/components/Template/Template.js +2 -2
  147. package/es/components/ToggleRefinement/ToggleRefinement.d.ts +2 -5
  148. package/es/components/ToggleRefinement/ToggleRefinement.js +0 -5
  149. package/es/components/VoiceSearch/VoiceSearch.d.ts +1 -1
  150. package/es/components/VoiceSearch/VoiceSearch.js +0 -1
  151. package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +3 -2
  152. package/es/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
  153. package/es/helpers/components/Highlight.d.ts +1 -1
  154. package/es/helpers/components/Highlight.js +2 -6
  155. package/es/helpers/components/ReverseHighlight.d.ts +1 -1
  156. package/es/helpers/components/ReverseHighlight.js +2 -6
  157. package/es/helpers/components/ReverseSnippet.d.ts +1 -1
  158. package/es/helpers/components/ReverseSnippet.js +2 -6
  159. package/es/helpers/components/Snippet.d.ts +1 -1
  160. package/es/helpers/components/Snippet.js +2 -6
  161. package/es/lib/InstantSearch.d.ts +6 -1
  162. package/es/lib/InstantSearch.js +34 -21
  163. package/es/lib/insights/listener.d.ts +1 -1
  164. package/es/lib/insights/listener.js +0 -1
  165. package/es/lib/templating/index.d.ts +2 -0
  166. package/es/lib/templating/index.js +2 -0
  167. package/es/lib/{utils → templating}/prepareTemplateProps.d.ts +2 -2
  168. package/es/lib/{utils → templating}/prepareTemplateProps.js +3 -5
  169. package/es/lib/{utils → templating}/renderTemplate.d.ts +2 -3
  170. package/es/lib/{utils → templating}/renderTemplate.js +3 -5
  171. package/es/lib/utils/capitalize.d.ts +1 -2
  172. package/es/lib/utils/capitalize.js +2 -4
  173. package/es/lib/utils/checkIndexUiState.js +1 -1
  174. package/es/lib/utils/checkRendering.d.ts +1 -2
  175. package/es/lib/utils/checkRendering.js +3 -6
  176. package/es/lib/utils/clearRefinements.d.ts +4 -8
  177. package/es/lib/utils/clearRefinements.js +3 -8
  178. package/es/lib/utils/concatHighlightedParts.d.ts +1 -1
  179. package/es/lib/utils/concatHighlightedParts.js +1 -1
  180. package/es/lib/utils/createSendEventForFacet.js +1 -1
  181. package/es/lib/utils/createSendEventForHits.d.ts +0 -3
  182. package/es/lib/utils/createSendEventForHits.js +0 -3
  183. package/es/lib/utils/defer.d.ts +2 -2
  184. package/es/lib/utils/defer.js +2 -5
  185. package/es/lib/utils/detect-insights-client.d.ts +1 -1
  186. package/es/lib/utils/detect-insights-client.js +1 -1
  187. package/es/lib/utils/documentation.d.ts +2 -2
  188. package/es/lib/utils/documentation.js +4 -4
  189. package/es/lib/utils/escape-highlight.js +2 -2
  190. package/es/lib/utils/{escape.d.ts → escape-html.d.ts} +6 -2
  191. package/es/lib/utils/escape-html.js +51 -0
  192. package/es/lib/utils/escapeFacetValue.d.ts +1 -1
  193. package/es/lib/utils/find.d.ts +1 -2
  194. package/es/lib/utils/find.js +2 -4
  195. package/es/lib/utils/findIndex.d.ts +1 -2
  196. package/es/lib/utils/findIndex.js +2 -4
  197. package/es/lib/utils/getContainerNode.d.ts +1 -2
  198. package/es/lib/utils/getContainerNode.js +3 -5
  199. package/es/lib/utils/getHighlightFromSiblings.d.ts +1 -1
  200. package/es/lib/utils/getHighlightFromSiblings.js +2 -2
  201. package/es/lib/utils/getHighlightedParts.d.ts +1 -1
  202. package/es/lib/utils/getHighlightedParts.js +1 -1
  203. package/es/lib/utils/getObjectType.d.ts +1 -2
  204. package/es/lib/utils/getObjectType.js +2 -4
  205. package/es/lib/utils/getPropertyByPath.d.ts +1 -2
  206. package/es/lib/utils/getPropertyByPath.js +2 -4
  207. package/es/lib/utils/getRefinements.d.ts +1 -1
  208. package/es/lib/utils/getRefinements.js +2 -2
  209. package/es/lib/utils/index.d.ts +44 -46
  210. package/es/lib/utils/index.js +44 -46
  211. package/es/lib/utils/isDomElement.d.ts +1 -2
  212. package/es/lib/utils/isDomElement.js +2 -4
  213. package/es/lib/utils/isEqual.d.ts +1 -2
  214. package/es/lib/utils/isEqual.js +2 -4
  215. package/es/lib/utils/isFacetRefined.d.ts +1 -1
  216. package/es/lib/utils/isFacetRefined.js +1 -1
  217. package/es/lib/utils/isFiniteNumber.d.ts +1 -2
  218. package/es/lib/utils/isFiniteNumber.js +3 -4
  219. package/es/lib/utils/isIndexWidget.d.ts +3 -0
  220. package/es/lib/utils/isIndexWidget.js +3 -0
  221. package/es/lib/utils/isPlainObject.d.ts +1 -2
  222. package/es/lib/utils/isPlainObject.js +2 -4
  223. package/es/lib/utils/isSpecialClick.d.ts +1 -2
  224. package/es/lib/utils/isSpecialClick.js +2 -4
  225. package/es/lib/utils/logger.js +1 -1
  226. package/es/lib/utils/mergeSearchParameters.d.ts +1 -2
  227. package/es/lib/utils/mergeSearchParameters.js +4 -6
  228. package/es/lib/utils/noop.d.ts +1 -2
  229. package/es/lib/utils/noop.js +1 -3
  230. package/es/lib/utils/range.d.ts +2 -2
  231. package/es/lib/utils/range.js +2 -4
  232. package/es/lib/utils/resolveSearchParameters.d.ts +1 -2
  233. package/es/lib/utils/resolveSearchParameters.js +2 -4
  234. package/es/lib/utils/reverseHighlightedParts.d.ts +1 -1
  235. package/es/lib/utils/reverseHighlightedParts.js +2 -2
  236. package/es/lib/utils/setIndexHelperState.d.ts +3 -0
  237. package/es/lib/utils/setIndexHelperState.js +19 -0
  238. package/es/lib/utils/toArray.d.ts +3 -2
  239. package/es/lib/utils/toArray.js +2 -4
  240. package/es/lib/utils/uniq.d.ts +1 -2
  241. package/es/lib/utils/uniq.js +2 -4
  242. package/es/lib/version.d.ts +1 -1
  243. package/es/lib/version.js +1 -1
  244. package/es/middlewares/createInsightsMiddleware.js +23 -27
  245. package/es/middlewares/createMetadataMiddleware.js +1 -0
  246. package/es/middlewares/createRouterMiddleware.js +1 -0
  247. package/es/types/middleware.d.ts +1 -0
  248. package/es/widgets/answers/answers.d.ts +1 -1
  249. package/es/widgets/answers/answers.js +2 -2
  250. package/es/widgets/breadcrumb/breadcrumb.d.ts +1 -1
  251. package/es/widgets/breadcrumb/breadcrumb.js +2 -2
  252. package/es/widgets/clear-refinements/clear-refinements.d.ts +1 -1
  253. package/es/widgets/clear-refinements/clear-refinements.js +2 -2
  254. package/es/widgets/current-refinements/current-refinements.d.ts +1 -1
  255. package/es/widgets/current-refinements/current-refinements.js +0 -1
  256. package/es/widgets/geo-search/GeoSearchRenderer.js +1 -2
  257. package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
  258. package/es/widgets/geo-search/defaultTemplates.d.ts +1 -1
  259. package/es/widgets/geo-search/defaultTemplates.js +0 -1
  260. package/es/widgets/geo-search/geo-search.js +2 -1
  261. package/es/widgets/hierarchical-menu/defaultTemplates.js +0 -1
  262. package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +1 -1
  263. package/es/widgets/hierarchical-menu/hierarchical-menu.js +2 -2
  264. package/es/widgets/hits/hits.d.ts +1 -1
  265. package/es/widgets/hits/hits.js +2 -2
  266. package/es/widgets/hits-per-page/hits-per-page.d.ts +1 -1
  267. package/es/widgets/hits-per-page/hits-per-page.js +0 -1
  268. package/es/widgets/index/index.d.ts +0 -1
  269. package/es/widgets/index/index.js +5 -6
  270. package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -1
  271. package/es/widgets/infinite-hits/infinite-hits.js +2 -2
  272. package/es/widgets/menu/defaultTemplates.js +0 -1
  273. package/es/widgets/menu/menu.d.ts +1 -1
  274. package/es/widgets/menu/menu.js +2 -2
  275. package/es/widgets/menu-select/menu-select.d.ts +1 -1
  276. package/es/widgets/menu-select/menu-select.js +2 -2
  277. package/es/widgets/numeric-menu/defaultTemplates.js +0 -1
  278. package/es/widgets/numeric-menu/numeric-menu.d.ts +1 -1
  279. package/es/widgets/numeric-menu/numeric-menu.js +2 -2
  280. package/es/widgets/pagination/pagination.d.ts +1 -1
  281. package/es/widgets/pagination/pagination.js +0 -1
  282. package/es/widgets/panel/panel.d.ts +1 -1
  283. package/es/widgets/panel/panel.js +0 -1
  284. package/es/widgets/powered-by/powered-by.d.ts +1 -1
  285. package/es/widgets/powered-by/powered-by.js +0 -1
  286. package/es/widgets/query-rule-custom-data/query-rule-custom-data.d.ts +1 -1
  287. package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +0 -1
  288. package/es/widgets/range-input/range-input.d.ts +1 -1
  289. package/es/widgets/range-input/range-input.js +2 -2
  290. package/es/widgets/range-slider/range-slider.d.ts +1 -1
  291. package/es/widgets/range-slider/range-slider.js +0 -1
  292. package/es/widgets/rating-menu/defaultTemplates.js +0 -1
  293. package/es/widgets/rating-menu/rating-menu.d.ts +1 -1
  294. package/es/widgets/rating-menu/rating-menu.js +2 -2
  295. package/es/widgets/refinement-list/defaultTemplates.js +0 -1
  296. package/es/widgets/refinement-list/refinement-list.d.ts +1 -1
  297. package/es/widgets/refinement-list/refinement-list.js +2 -2
  298. package/es/widgets/relevant-sort/relevant-sort.d.ts +1 -1
  299. package/es/widgets/relevant-sort/relevant-sort.js +0 -1
  300. package/es/widgets/search-box/defaultTemplates.js +0 -1
  301. package/es/widgets/search-box/search-box.d.ts +1 -1
  302. package/es/widgets/search-box/search-box.js +0 -1
  303. package/es/widgets/sort-by/sort-by.d.ts +1 -1
  304. package/es/widgets/sort-by/sort-by.js +0 -1
  305. package/es/widgets/stats/stats.d.ts +1 -1
  306. package/es/widgets/stats/stats.js +2 -2
  307. package/es/widgets/toggle-refinement/toggle-refinement.d.ts +1 -1
  308. package/es/widgets/toggle-refinement/toggle-refinement.js +2 -2
  309. package/es/widgets/voice-search/defaultTemplates.js +0 -1
  310. package/es/widgets/voice-search/voice-search.d.ts +1 -1
  311. package/es/widgets/voice-search/voice-search.js +0 -1
  312. package/package.json +6 -6
  313. package/cjs/lib/utils/convertNumericRefinementsToFilters.js +0 -31
  314. package/cjs/lib/utils/escape.js +0 -35
  315. package/cjs/lib/utils/unescape.js +0 -32
  316. package/es/lib/utils/convertNumericRefinementsToFilters.d.ts +0 -2
  317. package/es/lib/utils/convertNumericRefinementsToFilters.js +0 -24
  318. package/es/lib/utils/escape.js +0 -27
  319. package/es/lib/utils/unescape.d.ts +0 -9
  320. package/es/lib/utils/unescape.js +0 -25
@@ -10,13 +10,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
10
 
11
11
  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; }
12
12
 
13
- /** @jsx h */
14
13
  import { h } from 'preact';
15
14
  import { ReverseSnippet as ReverseSnippetUiComponent } from "../../components/ReverseSnippet/ReverseSnippet.js";
16
- import getHighlightedParts from "../../lib/utils/getHighlightedParts.js";
17
- import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
18
- import unescape from "../../lib/utils/unescape.js";
19
- import { warning } from "../../lib/utils/logger.js";
15
+ import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
20
16
  export function ReverseSnippet(_ref) {
21
17
  var hit = _ref.hit,
22
18
  attribute = _ref.attribute,
@@ -24,7 +20,7 @@ export function ReverseSnippet(_ref) {
24
20
  props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
25
21
 
26
22
  var property = getPropertyByPath(hit._snippetResult, attribute) || [];
27
- var properties = Array.isArray(property) ? property : [property];
23
+ var properties = toArray(property);
28
24
  process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
29
25
  var parts = properties.map(function (_ref2) {
30
26
  var value = _ref2.value;
@@ -1,4 +1,4 @@
1
- /** @jsx h */
1
+
2
2
  import { h } from 'preact';
3
3
  import type { BaseHit, Hit, PartialKeys } from '../../types';
4
4
  import type { SnippetProps as SnippetUiComponentProps } from '../../components/Snippet/Snippet';
@@ -4,13 +4,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
4
4
 
5
5
  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
6
 
7
- /** @jsx h */
8
7
  import { h } from 'preact';
9
8
  import { Snippet as SnippetUiComponent } from "../../components/Snippet/Snippet.js";
10
- import getHighlightedParts from "../../lib/utils/getHighlightedParts.js";
11
- import getPropertyByPath from "../../lib/utils/getPropertyByPath.js";
12
- import unescape from "../../lib/utils/unescape.js";
13
- import { warning } from "../../lib/utils/logger.js";
9
+ import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
14
10
  export function Snippet(_ref) {
15
11
  var hit = _ref.hit,
16
12
  attribute = _ref.attribute,
@@ -18,7 +14,7 @@ export function Snippet(_ref) {
18
14
  props = _objectWithoutProperties(_ref, ["hit", "attribute", "cssClasses"]);
19
15
 
20
16
  var property = getPropertyByPath(hit._snippetResult, attribute) || [];
21
- var properties = Array.isArray(property) ? property : [property];
17
+ var properties = toArray(property);
22
18
  process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
23
19
  var parts = properties.map(function (_ref2) {
24
20
  var value = _ref2.value;
@@ -177,7 +177,12 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
177
177
  cancel(): void;
178
178
  };
179
179
  scheduleStalledRender(): void;
180
- setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState)): void;
180
+ /**
181
+ * Set the UI state and trigger a search.
182
+ * @param uiState The next UI state or a function computing it from the current state
183
+ * @param callOnStateChange private parameter used to know if the method is called from a state change
184
+ */
185
+ setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
181
186
  getUiState(): TUiState;
182
187
  onInternalStateChange: ((...args: any[]) => void) & {
183
188
  wait(): Promise<void>;
@@ -28,10 +28,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
28
28
 
29
29
  import algoliasearchHelper from 'algoliasearch-helper';
30
30
  import EventEmitter from '@algolia/events';
31
- import index, { isIndexWidget } from "../widgets/index/index.js";
31
+ import index from "../widgets/index/index.js";
32
32
  import version from "./version.js";
33
33
  import createHelpers from "./createHelpers.js";
34
- import { createDocumentationMessageGenerator, createDocumentationLink, defer, noop, warning, checkIndexUiState } from "./utils/index.js";
34
+ import { createDocumentationMessageGenerator, createDocumentationLink, defer, noop, warning, setIndexHelperState } from "./utils/index.js";
35
35
  import { createRouterMiddleware } from "../middlewares/createRouterMiddleware.js";
36
36
  import { createMetadataMiddleware, isMetadataEnabled } from "../middlewares/createMetadataMiddleware.js";
37
37
  var withUsage = createDocumentationMessageGenerator({
@@ -233,6 +233,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
233
233
  var newMiddlewareList = middleware.map(function (fn) {
234
234
  var newMiddleware = _objectSpread({
235
235
  subscribe: noop,
236
+ started: noop,
236
237
  unsubscribe: noop,
237
238
  onStateChange: noop
238
239
  }, fn({
@@ -251,6 +252,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
251
252
  if (this.started) {
252
253
  newMiddlewareList.forEach(function (m) {
253
254
  m.subscribe();
255
+ m.started();
254
256
  });
255
257
  }
256
258
 
@@ -487,6 +489,10 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
487
489
  // to init them directly after add
488
490
 
489
491
  this.started = true;
492
+ this.middleware.forEach(function (_ref6) {
493
+ var instance = _ref6.instance;
494
+ instance.started();
495
+ });
490
496
  }
491
497
  /**
492
498
  * Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature,
@@ -513,8 +519,8 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
513
519
  this.mainHelper.removeAllListeners();
514
520
  this.mainHelper = null;
515
521
  this.helper = null;
516
- this.middleware.forEach(function (_ref6) {
517
- var instance = _ref6.instance;
522
+ this.middleware.forEach(function (_ref7) {
523
+ var instance = _ref7.instance;
518
524
  instance.unsubscribe();
519
525
  });
520
526
  }
@@ -531,9 +537,19 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
531
537
  }, this._stalledSearchDelay);
532
538
  }
533
539
  }
540
+ /**
541
+ * Set the UI state and trigger a search.
542
+ * @param uiState The next UI state or a function computing it from the current state
543
+ * @param callOnStateChange private parameter used to know if the method is called from a state change
544
+ */
545
+
534
546
  }, {
535
547
  key: "setUiState",
536
548
  value: function setUiState(uiState) {
549
+ var _this5 = this;
550
+
551
+ var callOnStateChange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
552
+
537
553
  if (!this.mainHelper) {
538
554
  throw new Error(withUsage('The `start` method needs to be called before `setUiState`.'));
539
555
  } // We refresh the index UI state to update the local UI state that the
@@ -543,25 +559,22 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
543
559
  this.mainIndex.refreshUiState();
544
560
  var nextUiState = typeof uiState === 'function' ? uiState(this.mainIndex.getWidgetUiState({})) : uiState;
545
561
 
546
- var setIndexHelperState = function setIndexHelperState(indexWidget) {
547
- var nextIndexUiState = nextUiState[indexWidget.getIndexId()] || {};
548
-
549
- if (process.env.NODE_ENV === 'development') {
550
- checkIndexUiState({
551
- index: indexWidget,
552
- indexUiState: nextIndexUiState
553
- });
554
- }
562
+ if (this.onStateChange && callOnStateChange) {
563
+ this.onStateChange({
564
+ uiState: nextUiState,
565
+ setUiState: function setUiState(finalUiState) {
566
+ setIndexHelperState(typeof finalUiState === 'function' ? finalUiState(nextUiState) : finalUiState, _this5.mainIndex);
555
567
 
556
- indexWidget.getHelper().setState(indexWidget.getWidgetSearchParameters(indexWidget.getHelper().state, {
557
- uiState: nextIndexUiState
558
- }));
559
- indexWidget.getWidgets().filter(isIndexWidget).forEach(setIndexHelperState);
560
- };
568
+ _this5.scheduleSearch();
561
569
 
562
- setIndexHelperState(this.mainIndex);
563
- this.scheduleSearch();
564
- this.onInternalStateChange();
570
+ _this5.onInternalStateChange();
571
+ }
572
+ });
573
+ } else {
574
+ setIndexHelperState(nextUiState, this.mainIndex);
575
+ this.scheduleSearch();
576
+ this.onInternalStateChange();
577
+ }
565
578
  }
566
579
  }, {
567
580
  key: "getUiState",
@@ -1,4 +1,4 @@
1
- /** @jsx h */
1
+
2
2
  import { h } from 'preact';
3
3
  import type { InsightsClient } from '../../types';
4
4
  import type { InsightsEvent } from '../../middlewares/createInsightsMiddleware';
@@ -1,4 +1,3 @@
1
- /** @jsx h */
2
1
  import { h } from 'preact';
3
2
  import { deserializePayload } from "../utils/index.js";
4
3
  import { readDataAttributes, hasDataAttributes } from "../../helpers/insights.js";
@@ -0,0 +1,2 @@
1
+ export * from './prepareTemplateProps';
2
+ export * from './renderTemplate';
@@ -0,0 +1,2 @@
1
+ export * from "./prepareTemplateProps.js";
2
+ export * from "./renderTemplate.js";
@@ -14,9 +14,9 @@ export declare type PreparedTemplateProps<TTemplates extends Templates> = {
14
14
  /**
15
15
  * Prepares an object to be passed to the Template widget
16
16
  */
17
- declare function prepareTemplateProps<TTemplates extends Templates>({ defaultTemplates, templates, templatesConfig, }: {
17
+ export declare function prepareTemplateProps<TTemplates extends Templates>({ defaultTemplates, templates, templatesConfig, }: {
18
18
  defaultTemplates: TTemplates;
19
19
  templates?: Partial<TTemplates>;
20
20
  templatesConfig: TemplatesConfig;
21
21
  }): PreparedTemplateProps<TTemplates>;
22
- export default prepareTemplateProps;
22
+ export {};
@@ -16,7 +16,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
16
16
 
17
17
  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
18
 
19
- import uniq from "./uniq.js";
19
+ import { uniq } from "../utils/uniq.js";
20
20
 
21
21
  function prepareTemplates( // can not use = {} here, since the template could have different constraints
22
22
  defaultTemplates) {
@@ -42,7 +42,7 @@ defaultTemplates) {
42
42
  */
43
43
 
44
44
 
45
- function prepareTemplateProps(_ref) {
45
+ export function prepareTemplateProps(_ref) {
46
46
  var defaultTemplates = _ref.defaultTemplates,
47
47
  templates = _ref.templates,
48
48
  templatesConfig = _ref.templatesConfig;
@@ -50,6 +50,4 @@ function prepareTemplateProps(_ref) {
50
50
  return _objectSpread({
51
51
  templatesConfig: templatesConfig
52
52
  }, preparedTemplates);
53
- }
54
-
55
- export default prepareTemplateProps;
53
+ }
@@ -1,7 +1,7 @@
1
1
  import type { HoganOptions } from 'hogan.js';
2
2
  import type { Templates, HoganHelpers } from '../../types';
3
- import type { BindEventForHits, SendEventForHits } from './createSendEventForHits';
4
- declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
3
+ import type { BindEventForHits, SendEventForHits } from '../utils/createSendEventForHits';
4
+ export declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
5
5
  templates: Templates;
6
6
  templateKey: string;
7
7
  compileOptions?: HoganOptions;
@@ -10,4 +10,3 @@ declare function renderTemplate({ templates, templateKey, compileOptions, helper
10
10
  bindEvent?: BindEventForHits;
11
11
  sendEvent?: SendEventForHits;
12
12
  }): string | import("preact").VNode<{}> | import("preact").VNode<{}>[];
13
- export default renderTemplate;
@@ -7,8 +7,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
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
8
 
9
9
  import hogan from 'hogan.js';
10
- import { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from "../../helpers/components/index.js";
11
10
  import { html } from 'htm/preact';
11
+ import { Highlight, ReverseHighlight, ReverseSnippet, Snippet } from "../../helpers/components/index.js";
12
12
 
13
13
  // We add all our template helper methods to the template as lambdas. Note
14
14
  // that lambdas in Mustache are supposed to accept a second argument of
@@ -33,7 +33,7 @@ function transformHelpersToHogan() {
33
33
  }, {});
34
34
  }
35
35
 
36
- function renderTemplate(_ref) {
36
+ export function renderTemplate(_ref) {
37
37
  var templates = _ref.templates,
38
38
  templateKey = _ref.templateKey,
39
39
  compileOptions = _ref.compileOptions,
@@ -67,6 +67,4 @@ function renderTemplate(_ref) {
67
67
  })).replace(/[ \n\r\t\f\xA0]+/g, function (spaces) {
68
68
  return spaces.replace(/(^|\xA0+)[^\xA0]+/g, '$1 ');
69
69
  }).trim();
70
- }
71
-
72
- export default renderTemplate;
70
+ }
@@ -1,2 +1 @@
1
- declare function capitalize(text: string): string;
2
- export default capitalize;
1
+ export declare function capitalize(text: string): string;
@@ -1,5 +1,3 @@
1
- function capitalize(text) {
1
+ export function capitalize(text) {
2
2
  return text.toString().charAt(0).toUpperCase() + text.toString().slice(1);
3
- }
4
-
5
- export default capitalize;
3
+ }
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
18
18
 
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
 
21
- import capitalize from "./capitalize.js";
21
+ import { capitalize } from "./capitalize.js";
22
22
  import { warning } from "./logger.js";
23
23
  import { keys } from "./typedObject.js"; // Some connectors are responsible for multiple widgets so we need
24
24
  // to map them.
@@ -1,3 +1,2 @@
1
1
  import type { Renderer } from '../../types/connector';
2
- declare function checkRendering<TRenderOptions, TWidgetParams>(rendering: Renderer<TRenderOptions, TWidgetParams>, usage: string): void;
3
- export default checkRendering;
2
+ export declare function checkRendering<TRenderOptions, TWidgetParams>(rendering: Renderer<TRenderOptions, TWidgetParams>, usage: string): void;
@@ -1,9 +1,6 @@
1
- import getObjectType from "./getObjectType.js";
2
-
3
- function checkRendering(rendering, usage) {
1
+ import { getObjectType } from "./getObjectType.js";
2
+ export function checkRendering(rendering, usage) {
4
3
  if (rendering === undefined || typeof rendering !== 'function') {
5
4
  throw new Error("The render function is not valid (received type ".concat(getObjectType(rendering), ").\n\n").concat(usage));
6
5
  }
7
- }
8
-
9
- export default checkRendering;
6
+ }
@@ -1,15 +1,11 @@
1
- import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
1
+ import type { AlgoliaSearchHelper, SearchParameters } from 'algoliasearch-helper';
2
2
  /**
3
3
  * Clears the refinements of a SearchParameters object based on rules provided.
4
4
  * The included attributes list is applied before the excluded attributes list. If the list
5
5
  * is not provided, this list of all the currently refined attributes is used as included attributes.
6
- * @param {object} $0 parameters
7
- * @param {Helper} $0.helper instance of the Helper
8
- * @param {string[]} [$0.attributesToClear = []] list of parameters to clear
9
- * @returns {SearchParameters} search parameters with refinements cleared
6
+ * @returns search parameters with refinements cleared
10
7
  */
11
- declare function clearRefinements({ helper, attributesToClear, }: {
8
+ export declare function clearRefinements({ helper, attributesToClear, }: {
12
9
  helper: AlgoliaSearchHelper;
13
10
  attributesToClear?: string[];
14
- }): import("algoliasearch-helper").SearchParameters;
15
- export default clearRefinements;
11
+ }): SearchParameters;
@@ -2,12 +2,9 @@
2
2
  * Clears the refinements of a SearchParameters object based on rules provided.
3
3
  * The included attributes list is applied before the excluded attributes list. If the list
4
4
  * is not provided, this list of all the currently refined attributes is used as included attributes.
5
- * @param {object} $0 parameters
6
- * @param {Helper} $0.helper instance of the Helper
7
- * @param {string[]} [$0.attributesToClear = []] list of parameters to clear
8
- * @returns {SearchParameters} search parameters with refinements cleared
5
+ * @returns search parameters with refinements cleared
9
6
  */
10
- function clearRefinements(_ref) {
7
+ export function clearRefinements(_ref) {
11
8
  var helper = _ref.helper,
12
9
  _ref$attributesToClea = _ref.attributesToClear,
13
10
  attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea;
@@ -37,6 +34,4 @@ function clearRefinements(_ref) {
37
34
  }
38
35
 
39
36
  return finalState;
40
- }
41
-
42
- export default clearRefinements;
37
+ }
@@ -1,2 +1,2 @@
1
1
  import type { HighlightedParts } from '../../types';
2
- export default function concatHighlightedParts(parts: HighlightedParts[]): string;
2
+ export declare function concatHighlightedParts(parts: HighlightedParts[]): string;
@@ -1,5 +1,5 @@
1
1
  import { TAG_REPLACEMENT } from "./escape-highlight.js";
2
- export default function concatHighlightedParts(parts) {
2
+ export function concatHighlightedParts(parts) {
3
3
  var highlightPreTag = TAG_REPLACEMENT.highlightPreTag,
4
4
  highlightPostTag = TAG_REPLACEMENT.highlightPostTag;
5
5
  return parts.map(function (part) {
@@ -1,6 +1,6 @@
1
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
2
 
3
- import isFacetRefined from "./isFacetRefined.js";
3
+ import { isFacetRefined } from "./isFacetRefined.js";
4
4
  export function createSendEventForFacet(_ref) {
5
5
  var instantSearchInstance = _ref.instantSearchInstance,
6
6
  helper = _ref.helper,
@@ -1,6 +1,3 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
1
  import type { InstantSearch, Hit } from '../../types';
5
2
  declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hit[], eventName?: string) => void;
6
3
  declare type CustomSendEventForHits = (customPayload: any) => void;
@@ -1,8 +1,5 @@
1
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
2
 
3
- /**
4
- * @jest-environment jsdom
5
- */
6
3
  import { serializePayload } from "./serializer.js";
7
4
 
8
5
  function chunk(arr) {
@@ -3,5 +3,5 @@ declare type Defer = Callback & {
3
3
  wait(): Promise<void>;
4
4
  cancel(): void;
5
5
  };
6
- declare const defer: (callback: Callback) => Defer;
7
- export default defer;
6
+ export declare function defer(callback: Callback): Defer;
7
+ export {};
@@ -1,6 +1,5 @@
1
1
  var nextMicroTask = Promise.resolve();
2
-
3
- var defer = function defer(callback) {
2
+ export function defer(callback) {
4
3
  var progress = null;
5
4
  var cancelled = false;
6
5
 
@@ -42,6 +41,4 @@ var defer = function defer(callback) {
42
41
  };
43
42
 
44
43
  return fn;
45
- };
46
-
47
- export default defer;
44
+ }
@@ -1 +1 @@
1
- export default function hasDetectedInsightsClient(): boolean;
1
+ export declare function hasDetectedInsightsClient(): boolean;
@@ -1,5 +1,5 @@
1
1
  import { safelyRunOnBrowser } from "./safelyRunOnBrowser.js";
2
- export default function hasDetectedInsightsClient() {
2
+ export function hasDetectedInsightsClient() {
3
3
  return safelyRunOnBrowser(function (_ref) {
4
4
  var window = _ref.window;
5
5
  return Boolean(window.AlgoliaAnalyticsObject);
@@ -2,7 +2,7 @@ declare type WidgetParam = {
2
2
  name: string;
3
3
  connector?: boolean;
4
4
  };
5
- export declare const createDocumentationLink: ({ name, connector, }: WidgetParam) => string;
5
+ export declare function createDocumentationLink({ name, connector, }: WidgetParam): string;
6
6
  declare type DocumentationMessageGenerator = (message?: string) => string;
7
- export declare const createDocumentationMessageGenerator: (...widgets: WidgetParam[]) => DocumentationMessageGenerator;
7
+ export declare function createDocumentationMessageGenerator(...widgets: WidgetParam[]): DocumentationMessageGenerator;
8
8
  export {};
@@ -1,10 +1,10 @@
1
- export var createDocumentationLink = function createDocumentationLink(_ref) {
1
+ export function createDocumentationLink(_ref) {
2
2
  var name = _ref.name,
3
3
  _ref$connector = _ref.connector,
4
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
- };
7
- export var createDocumentationMessageGenerator = function createDocumentationMessageGenerator() {
6
+ }
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
  }
@@ -15,4 +15,4 @@ export var createDocumentationMessageGenerator = function createDocumentationMes
15
15
  return function (message) {
16
16
  return [message, "See documentation: ".concat(links)].filter(Boolean).join('\n\n');
17
17
  };
18
- };
18
+ }
@@ -6,8 +6,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
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
8
 
9
- import escape from "./escape.js";
10
- import isPlainObject from "./isPlainObject.js";
9
+ import { escape } from "./escape-html.js";
10
+ import { isPlainObject } from "./isPlainObject.js";
11
11
  export var TAG_PLACEHOLDER = {
12
12
  highlightPreTag: '__ais-highlight__',
13
13
  highlightPostTag: '__/ais-highlight__'
@@ -6,5 +6,9 @@
6
6
  * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
7
7
  * corresponding HTML entities.
8
8
  */
9
- declare function escape(value: string): string;
10
- export default escape;
9
+ export declare function escape(value: string): string;
10
+ /**
11
+ * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
12
+ * characters.
13
+ */
14
+ export declare function unescape(value: string): string;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * This implementation is taken from Lodash implementation.
3
+ * See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
4
+ */
5
+ // Used to map characters to HTML entities.
6
+ var htmlEntities = {
7
+ '&': '&amp;',
8
+ '<': '&lt;',
9
+ '>': '&gt;',
10
+ '"': '&quot;',
11
+ "'": '&#39;'
12
+ }; // Used to match HTML entities and HTML characters.
13
+
14
+ var regexUnescapedHtml = /[&<>"']/g;
15
+ var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
16
+ /**
17
+ * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
18
+ * corresponding HTML entities.
19
+ */
20
+
21
+ export function escape(value) {
22
+ return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
23
+ return htmlEntities[character];
24
+ }) : value;
25
+ }
26
+ /**
27
+ * This implementation is taken from Lodash implementation.
28
+ * See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
29
+ */
30
+ // Used to map HTML entities to characters.
31
+
32
+ var htmlCharacters = {
33
+ '&amp;': '&',
34
+ '&lt;': '<',
35
+ '&gt;': '>',
36
+ '&quot;': '"',
37
+ '&#39;': "'"
38
+ }; // Used to match HTML entities and HTML characters.
39
+
40
+ var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
41
+ var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
42
+ /**
43
+ * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
44
+ * characters.
45
+ */
46
+
47
+ export function unescape(value) {
48
+ return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
49
+ return htmlCharacters[character];
50
+ }) : value;
51
+ }
@@ -1,4 +1,4 @@
1
- declare type FacetValue = string | number | undefined;
1
+ declare type FacetValue = string | number | boolean | undefined;
2
2
  export declare function unescapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
3
3
  export declare function escapeFacetValue<TFacetValue extends FacetValue>(value: TFacetValue): TFacetValue;
4
4
  export {};
@@ -1,2 +1 @@
1
- declare function find<TItem>(items: TItem[], predicate: (value: TItem, index: number, obj: TItem[]) => boolean): TItem | undefined;
2
- export default find;
1
+ export declare function find<TItem>(items: TItem[], predicate: (value: TItem, index: number, obj: TItem[]) => boolean): TItem | undefined;
@@ -4,7 +4,7 @@
4
4
  // was decided as too risky.
5
5
  // @MAJOR Replace with the native `Array.prototype.find` method
6
6
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
7
- function find(items, predicate) {
7
+ export function find(items, predicate) {
8
8
  var value;
9
9
 
10
10
  for (var i = 0; i < items.length; i++) {
@@ -16,6 +16,4 @@ function find(items, predicate) {
16
16
  }
17
17
 
18
18
  return undefined;
19
- }
20
-
21
- export default find;
19
+ }
@@ -1,2 +1 @@
1
- declare function findIndex<TItem>(array: TItem[], comparator: (value: TItem) => boolean): number;
2
- export default findIndex;
1
+ export declare function findIndex<TItem>(array: TItem[], comparator: (value: TItem) => boolean): number;
@@ -4,7 +4,7 @@
4
4
  // was decided as too risky.
5
5
  // @MAJOR Replace with the native `Array.prototype.findIndex` method
6
6
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
7
- function findIndex(array, comparator) {
7
+ export function findIndex(array, comparator) {
8
8
  if (!Array.isArray(array)) {
9
9
  return -1;
10
10
  }
@@ -16,6 +16,4 @@ function findIndex(array, comparator) {
16
16
  }
17
17
 
18
18
  return -1;
19
- }
20
-
21
- export default findIndex;
19
+ }
@@ -7,5 +7,4 @@
7
7
  * @return {HTMLElement} Container node
8
8
  * @throws Error when the type is not correct
9
9
  */
10
- declare function getContainerNode(selectorOrHTMLElement: string | HTMLElement): HTMLElement;
11
- export default getContainerNode;
10
+ export declare function getContainerNode(selectorOrHTMLElement: string | HTMLElement): HTMLElement;