react-instantsearch-core 6.40.4 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/README.md +70 -2
  2. package/dist/cjs/components/Configure.js +13 -0
  3. package/dist/cjs/components/DynamicWidgets.js +63 -0
  4. package/dist/cjs/components/Index.js +24 -0
  5. package/dist/cjs/components/InstantSearch.js +27 -0
  6. package/dist/cjs/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +27 -63
  7. package/dist/cjs/components/InstantSearchServerContext.js +12 -0
  8. package/dist/cjs/connectors/useBreadcrumb.js +12 -0
  9. package/dist/cjs/connectors/useClearRefinements.js +12 -0
  10. package/dist/cjs/connectors/useConfigure.js +14 -0
  11. package/dist/cjs/connectors/useCurrentRefinements.js +12 -0
  12. package/dist/cjs/connectors/useDynamicWidgets.js +22 -0
  13. package/dist/cjs/connectors/useGeoSearch.js +12 -0
  14. package/dist/cjs/connectors/useHierarchicalMenu.js +12 -0
  15. package/dist/cjs/connectors/useHits.js +12 -0
  16. package/dist/cjs/connectors/useHitsPerPage.js +12 -0
  17. package/dist/cjs/connectors/useInfiniteHits.js +12 -0
  18. package/dist/cjs/connectors/useMenu.js +12 -0
  19. package/dist/cjs/connectors/useNumericMenu.js +12 -0
  20. package/dist/cjs/connectors/usePagination.js +12 -0
  21. package/dist/cjs/connectors/usePoweredBy.js +21 -0
  22. package/dist/cjs/connectors/useQueryRules.js +12 -0
  23. package/dist/cjs/connectors/useRange.js +12 -0
  24. package/dist/cjs/connectors/useRefinementList.js +12 -0
  25. package/dist/cjs/connectors/useSearchBox.js +12 -0
  26. package/dist/cjs/connectors/useSortBy.js +12 -0
  27. package/dist/cjs/connectors/useStats.js +12 -0
  28. package/dist/cjs/connectors/useToggleRefinement.js +12 -0
  29. package/dist/cjs/hooks/useConnector.js +136 -0
  30. package/dist/cjs/hooks/useInstantSearch.js +58 -0
  31. package/dist/cjs/index.js +328 -320
  32. package/dist/cjs/lib/IndexContext.js +12 -0
  33. package/dist/cjs/lib/InstantSearchContext.js +12 -0
  34. package/dist/cjs/lib/InstantSearchSSRContext.js +12 -0
  35. package/dist/cjs/lib/createSearchResults.js +27 -0
  36. package/dist/cjs/lib/dequal.js +53 -0
  37. package/dist/cjs/lib/getIndexSearchResults.js +32 -0
  38. package/dist/cjs/lib/invariant.js +25 -0
  39. package/dist/cjs/lib/noop.js +8 -0
  40. package/dist/cjs/lib/useForceUpdate.js +25 -0
  41. package/dist/cjs/lib/useIndex.js +38 -0
  42. package/dist/cjs/lib/useIndexContext.js +14 -0
  43. package/dist/cjs/lib/useInstantSearchApi.js +191 -0
  44. package/dist/cjs/lib/useInstantSearchContext.js +14 -0
  45. package/dist/cjs/lib/useInstantSearchSSRContext.js +11 -0
  46. package/dist/cjs/lib/useInstantSearchServerContext.js +11 -0
  47. package/dist/cjs/lib/useIsomorphicLayoutEffect.js +14 -0
  48. package/dist/cjs/lib/useSearchResults.js +46 -0
  49. package/dist/cjs/lib/useSearchState.js +48 -0
  50. package/dist/cjs/lib/useStableValue.js +26 -0
  51. package/dist/cjs/lib/useWidget.js +78 -0
  52. package/dist/cjs/lib/warn.js +41 -0
  53. package/dist/cjs/package.json +1 -0
  54. package/dist/cjs/server/getServerState.js +93 -0
  55. package/dist/cjs/{types → server}/index.js +4 -4
  56. package/dist/cjs/{core/version.js → version.js} +1 -1
  57. package/dist/es/components/Configure.d.ts +3 -0
  58. package/dist/es/components/Configure.js +7 -0
  59. package/dist/es/components/DynamicWidgets.d.ts +13 -0
  60. package/dist/es/components/DynamicWidgets.js +55 -0
  61. package/dist/es/components/Index.d.ts +6 -0
  62. package/dist/es/components/Index.js +17 -0
  63. package/dist/es/components/InstantSearch.d.ts +7 -0
  64. package/dist/es/components/InstantSearch.js +20 -0
  65. package/dist/es/components/InstantSearchSSRProvider.d.ts +13 -0
  66. package/dist/es/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +26 -61
  67. package/dist/es/components/InstantSearchServerContext.d.ts +12 -0
  68. package/dist/es/components/InstantSearchServerContext.js +5 -0
  69. package/dist/es/connectors/useBreadcrumb.d.ts +4 -0
  70. package/dist/es/connectors/useBreadcrumb.js +5 -0
  71. package/dist/es/connectors/useClearRefinements.d.ts +4 -0
  72. package/dist/es/connectors/useClearRefinements.js +5 -0
  73. package/dist/es/connectors/useConfigure.d.ts +4 -0
  74. package/dist/es/connectors/useConfigure.js +7 -0
  75. package/dist/es/connectors/useCurrentRefinements.d.ts +4 -0
  76. package/dist/es/connectors/useCurrentRefinements.js +5 -0
  77. package/dist/es/connectors/useDynamicWidgets.d.ts +4 -0
  78. package/dist/es/connectors/useDynamicWidgets.js +15 -0
  79. package/dist/es/connectors/useGeoSearch.d.ts +6 -0
  80. package/dist/es/connectors/useGeoSearch.js +5 -0
  81. package/dist/es/connectors/useHierarchicalMenu.d.ts +4 -0
  82. package/dist/es/connectors/useHierarchicalMenu.js +5 -0
  83. package/dist/es/connectors/useHits.d.ts +5 -0
  84. package/dist/es/connectors/useHits.js +5 -0
  85. package/dist/es/connectors/useHitsPerPage.d.ts +4 -0
  86. package/dist/es/connectors/useHitsPerPage.js +5 -0
  87. package/dist/es/connectors/useInfiniteHits.d.ts +5 -0
  88. package/dist/es/connectors/useInfiniteHits.js +5 -0
  89. package/dist/es/connectors/useMenu.d.ts +4 -0
  90. package/dist/es/connectors/useMenu.js +5 -0
  91. package/dist/es/connectors/useNumericMenu.d.ts +4 -0
  92. package/dist/es/connectors/useNumericMenu.js +5 -0
  93. package/dist/es/connectors/usePagination.d.ts +4 -0
  94. package/dist/es/connectors/usePagination.js +5 -0
  95. package/dist/es/connectors/usePoweredBy.d.ts +2 -0
  96. package/dist/es/connectors/usePoweredBy.js +15 -0
  97. package/dist/es/connectors/useQueryRules.d.ts +4 -0
  98. package/dist/es/connectors/useQueryRules.js +5 -0
  99. package/dist/es/connectors/useRange.d.ts +4 -0
  100. package/dist/es/connectors/useRange.js +5 -0
  101. package/dist/es/connectors/useRefinementList.d.ts +4 -0
  102. package/dist/es/connectors/useRefinementList.js +5 -0
  103. package/dist/es/connectors/useSearchBox.d.ts +4 -0
  104. package/dist/es/connectors/useSearchBox.js +5 -0
  105. package/dist/es/connectors/useSortBy.d.ts +4 -0
  106. package/dist/es/connectors/useSortBy.js +5 -0
  107. package/dist/es/connectors/useStats.d.ts +4 -0
  108. package/dist/es/connectors/useStats.js +5 -0
  109. package/dist/es/connectors/useToggleRefinement.d.ts +4 -0
  110. package/dist/es/connectors/useToggleRefinement.js +5 -0
  111. package/dist/es/hooks/useConnector.d.ts +3 -0
  112. package/dist/es/hooks/useConnector.js +130 -0
  113. package/dist/es/hooks/useInstantSearch.d.ts +32 -0
  114. package/dist/es/hooks/useInstantSearch.js +52 -0
  115. package/dist/es/index.d.ts +31 -0
  116. package/dist/es/index.js +31 -87
  117. package/dist/es/lib/IndexContext.d.ts +3 -0
  118. package/dist/es/lib/IndexContext.js +5 -0
  119. package/dist/es/lib/InstantSearchContext.d.ts +3 -0
  120. package/dist/es/lib/InstantSearchContext.js +5 -0
  121. package/dist/es/lib/InstantSearchSSRContext.d.ts +8 -0
  122. package/dist/es/lib/InstantSearchSSRContext.js +5 -0
  123. package/dist/es/lib/createSearchResults.d.ts +3 -0
  124. package/dist/es/lib/createSearchResults.js +20 -0
  125. package/dist/es/lib/dequal.d.ts +1 -0
  126. package/dist/es/lib/dequal.js +47 -0
  127. package/dist/es/lib/getIndexSearchResults.d.ts +9 -0
  128. package/dist/es/lib/getIndexSearchResults.js +26 -0
  129. package/dist/es/lib/invariant.d.ts +9 -0
  130. package/dist/es/lib/invariant.js +19 -0
  131. package/dist/es/lib/noop.d.ts +1 -0
  132. package/dist/es/lib/noop.js +1 -0
  133. package/dist/es/lib/useForceUpdate.d.ts +6 -0
  134. package/dist/es/lib/useForceUpdate.js +20 -0
  135. package/dist/es/lib/useIndex.d.ts +3 -0
  136. package/dist/es/lib/useIndex.js +31 -0
  137. package/dist/es/lib/useIndexContext.d.ts +2 -0
  138. package/dist/es/lib/useIndexContext.js +8 -0
  139. package/dist/es/lib/useInstantSearchApi.d.ts +21 -0
  140. package/dist/es/lib/useInstantSearchApi.js +184 -0
  141. package/dist/es/lib/useInstantSearchContext.d.ts +3 -0
  142. package/dist/es/lib/useInstantSearchContext.js +8 -0
  143. package/dist/es/lib/useInstantSearchSSRContext.d.ts +3 -0
  144. package/dist/es/lib/useInstantSearchSSRContext.js +5 -0
  145. package/dist/es/lib/useInstantSearchServerContext.d.ts +3 -0
  146. package/dist/es/lib/useInstantSearchServerContext.js +5 -0
  147. package/dist/es/lib/useIsomorphicLayoutEffect.d.ts +7 -0
  148. package/dist/es/lib/useIsomorphicLayoutEffect.js +8 -0
  149. package/dist/es/lib/useSearchResults.d.ts +7 -0
  150. package/dist/es/lib/useSearchResults.js +40 -0
  151. package/dist/es/lib/useSearchState.d.ts +8 -0
  152. package/dist/es/lib/useSearchState.js +42 -0
  153. package/dist/es/lib/useStableValue.d.ts +1 -0
  154. package/dist/es/lib/useStableValue.js +20 -0
  155. package/dist/es/lib/useWidget.d.ts +8 -0
  156. package/dist/es/lib/useWidget.js +72 -0
  157. package/dist/es/lib/warn.d.ts +10 -0
  158. package/dist/es/lib/warn.js +33 -0
  159. package/dist/es/server/getServerState.d.ts +10 -0
  160. package/dist/es/server/getServerState.js +86 -0
  161. package/dist/es/server/index.d.ts +1 -0
  162. package/dist/es/server/index.js +1 -0
  163. package/dist/es/version.d.ts +2 -0
  164. package/dist/es/version.js +1 -0
  165. package/dist/umd/ReactInstantSearchCore.js +14071 -7955
  166. package/dist/umd/ReactInstantSearchCore.js.map +1 -1
  167. package/dist/umd/ReactInstantSearchCore.min.js +1 -1
  168. package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
  169. package/package.json +23 -8
  170. package/dist/cjs/connectors/connectAutoComplete.js +0 -104
  171. package/dist/cjs/connectors/connectBreadcrumb.js +0 -123
  172. package/dist/cjs/connectors/connectConfigureRelatedItems.js +0 -127
  173. package/dist/cjs/connectors/connectCurrentRefinements.js +0 -69
  174. package/dist/cjs/connectors/connectDynamicWidgets.js +0 -65
  175. package/dist/cjs/connectors/connectGeoSearch.js +0 -189
  176. package/dist/cjs/connectors/connectHierarchicalMenu.js +0 -273
  177. package/dist/cjs/connectors/connectHighlight.js +0 -87
  178. package/dist/cjs/connectors/connectHitInsights.js +0 -76
  179. package/dist/cjs/connectors/connectHits.js +0 -88
  180. package/dist/cjs/connectors/connectHitsPerPage.js +0 -97
  181. package/dist/cjs/connectors/connectInfiniteHits.js +0 -154
  182. package/dist/cjs/connectors/connectMenu.js +0 -221
  183. package/dist/cjs/connectors/connectNumericMenu.js +0 -215
  184. package/dist/cjs/connectors/connectPagination.js +0 -94
  185. package/dist/cjs/connectors/connectPoweredBy.js +0 -27
  186. package/dist/cjs/connectors/connectQueryRules.js +0 -129
  187. package/dist/cjs/connectors/connectRange.js +0 -287
  188. package/dist/cjs/connectors/connectRefinementList.js +0 -243
  189. package/dist/cjs/connectors/connectRelevantSort.js +0 -56
  190. package/dist/cjs/connectors/connectScrollTo.js +0 -70
  191. package/dist/cjs/connectors/connectSearchBox.js +0 -104
  192. package/dist/cjs/connectors/connectSortBy.js +0 -100
  193. package/dist/cjs/connectors/connectStateResults.js +0 -79
  194. package/dist/cjs/connectors/connectStats.js +0 -39
  195. package/dist/cjs/connectors/connectToggleRefinement.js +0 -163
  196. package/dist/cjs/connectors/connectVoiceSearch.js +0 -124
  197. package/dist/cjs/core/context.js +0 -37
  198. package/dist/cjs/core/createConnector.js +0 -268
  199. package/dist/cjs/core/createInstantSearchManager.d.js +0 -1
  200. package/dist/cjs/core/createInstantSearchManager.js +0 -541
  201. package/dist/cjs/core/createStore.js +0 -27
  202. package/dist/cjs/core/createWidgetsManager.js +0 -39
  203. package/dist/cjs/core/highlight.js +0 -102
  204. package/dist/cjs/core/indexUtils.js +0 -214
  205. package/dist/cjs/core/metadata.js +0 -46
  206. package/dist/cjs/core/translatable.js +0 -82
  207. package/dist/cjs/core/utils.js +0 -161
  208. package/dist/cjs/types/algoliasearch.js +0 -1
  209. package/dist/cjs/types/translatable.js +0 -1
  210. package/dist/cjs/widgets/Configure.js +0 -48
  211. package/dist/cjs/widgets/ConfigureRelatedItems.js +0 -21
  212. package/dist/cjs/widgets/DynamicWidgets.js +0 -61
  213. package/dist/cjs/widgets/Index.js +0 -149
  214. package/dist/cjs/widgets/InstantSearch.js +0 -251
  215. package/dist/cjs/widgets/QueryRuleContext.js +0 -14
  216. package/dist/es/connectors/connectAutoComplete.js +0 -96
  217. package/dist/es/connectors/connectBreadcrumb.js +0 -115
  218. package/dist/es/connectors/connectConfigureRelatedItems.js +0 -121
  219. package/dist/es/connectors/connectCurrentRefinements.js +0 -62
  220. package/dist/es/connectors/connectDynamicWidgets.js +0 -56
  221. package/dist/es/connectors/connectGeoSearch.js +0 -182
  222. package/dist/es/connectors/connectHierarchicalMenu.js +0 -264
  223. package/dist/es/connectors/connectHighlight.js +0 -79
  224. package/dist/es/connectors/connectHitInsights.js +0 -69
  225. package/dist/es/connectors/connectHits.js +0 -81
  226. package/dist/es/connectors/connectHitsPerPage.js +0 -89
  227. package/dist/es/connectors/connectInfiniteHits.js +0 -146
  228. package/dist/es/connectors/connectMenu.js +0 -213
  229. package/dist/es/connectors/connectNumericMenu.js +0 -207
  230. package/dist/es/connectors/connectPagination.js +0 -86
  231. package/dist/es/connectors/connectPoweredBy.js +0 -20
  232. package/dist/es/connectors/connectQueryRules.js +0 -122
  233. package/dist/es/connectors/connectRange.js +0 -280
  234. package/dist/es/connectors/connectRefinementList.js +0 -235
  235. package/dist/es/connectors/connectRelevantSort.js +0 -50
  236. package/dist/es/connectors/connectScrollTo.js +0 -63
  237. package/dist/es/connectors/connectSearchBox.js +0 -96
  238. package/dist/es/connectors/connectSortBy.js +0 -92
  239. package/dist/es/connectors/connectStateResults.js +0 -72
  240. package/dist/es/connectors/connectStats.js +0 -32
  241. package/dist/es/connectors/connectToggleRefinement.js +0 -155
  242. package/dist/es/connectors/connectVoiceSearch.js +0 -116
  243. package/dist/es/core/context.js +0 -28
  244. package/dist/es/core/createConnector.js +0 -257
  245. package/dist/es/core/createInstantSearchManager.d.js +0 -0
  246. package/dist/es/core/createInstantSearchManager.js +0 -534
  247. package/dist/es/core/createStore.js +0 -21
  248. package/dist/es/core/createWidgetsManager.js +0 -33
  249. package/dist/es/core/highlight.js +0 -94
  250. package/dist/es/core/indexUtils.js +0 -203
  251. package/dist/es/core/metadata.js +0 -38
  252. package/dist/es/core/translatable.js +0 -74
  253. package/dist/es/core/utils.js +0 -139
  254. package/dist/es/core/version.js +0 -1
  255. package/dist/es/types/algoliasearch.js +0 -1
  256. package/dist/es/types/index.js +0 -1
  257. package/dist/es/types/translatable.js +0 -1
  258. package/dist/es/widgets/Configure.js +0 -42
  259. package/dist/es/widgets/ConfigureRelatedItems.js +0 -13
  260. package/dist/es/widgets/DynamicWidgets.js +0 -51
  261. package/dist/es/widgets/Index.js +0 -138
  262. package/dist/es/widgets/InstantSearch.js +0 -241
  263. package/dist/es/widgets/QueryRuleContext.js +0 -6
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useWidget = useWidget;
7
+ var _react = require("react");
8
+ var _dequal = require("./dequal");
9
+ var _useInstantSearchContext = require("./useInstantSearchContext");
10
+ var _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect");
11
+ function useWidget(_ref) {
12
+ var widget = _ref.widget,
13
+ parentIndex = _ref.parentIndex,
14
+ props = _ref.props,
15
+ shouldSsr = _ref.shouldSsr;
16
+ var prevPropsRef = (0, _react.useRef)(props);
17
+ (0, _react.useEffect)(function () {
18
+ prevPropsRef.current = props;
19
+ }, [props]);
20
+ var prevWidgetRef = (0, _react.useRef)(widget);
21
+ (0, _react.useEffect)(function () {
22
+ prevWidgetRef.current = widget;
23
+ }, [widget]);
24
+ var cleanupTimerRef = (0, _react.useRef)(null);
25
+ var shouldAddWidgetEarly = shouldSsr && !parentIndex.getWidgets().includes(widget);
26
+ var search = (0, _useInstantSearchContext.useInstantSearchContext)();
27
+
28
+ // This effect is responsible for adding, removing, and updating the widget.
29
+ // We need to support scenarios where the widget is remounted quickly, like in
30
+ // Strict Mode, so that we don't lose its state, and therefore that we don't
31
+ // break routing.
32
+ (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () {
33
+ var previousWidget = prevWidgetRef.current;
34
+
35
+ // Scenario 1: the widget is added for the first time.
36
+ if (!cleanupTimerRef.current) {
37
+ if (!shouldAddWidgetEarly) {
38
+ parentIndex.addWidgets([widget]);
39
+ }
40
+ }
41
+ // Scenario 2: the widget is rerendered or updated.
42
+ else {
43
+ // We cancel the original effect cleanup because it may not be necessary if
44
+ // props haven't changed. (We manually call it if it is below.)
45
+ clearTimeout(cleanupTimerRef.current);
46
+
47
+ // Warning: if an unstable function prop is provided, `dequal` is not able
48
+ // to keep its reference and therefore will consider that props did change.
49
+ // This could unsollicitely remove/add the widget, therefore forget its state,
50
+ // and could be a source of confusion.
51
+ // If users face this issue, we should advise them to provide stable function
52
+ // references.
53
+ var arePropsEqual = (0, _dequal.dequal)(props, prevPropsRef.current);
54
+
55
+ // If props did change, then we execute the cleanup function instantly
56
+ // and then add the widget back. This lets us add the widget without
57
+ // waiting for the scheduled cleanup function to finish (that we canceled
58
+ // above).
59
+ if (!arePropsEqual) {
60
+ parentIndex.removeWidgets([previousWidget]);
61
+ parentIndex.addWidgets([widget]);
62
+ }
63
+ }
64
+ return function () {
65
+ // We don't remove the widget right away, but rather schedule it so that
66
+ // we're able to cancel it in the next effect.
67
+ cleanupTimerRef.current = setTimeout(function () {
68
+ search._schedule(function () {
69
+ if (search._preventWidgetCleanup) return;
70
+ parentIndex.removeWidgets([previousWidget]);
71
+ });
72
+ });
73
+ };
74
+ }, [parentIndex, widget, shouldAddWidgetEarly, search, props]);
75
+ if (shouldAddWidgetEarly) {
76
+ parentIndex.addWidgets([widget]);
77
+ }
78
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.warn = warn;
7
+ exports.warnCache = void 0;
8
+ /* eslint-disable no-console, no-empty */
9
+
10
+ var warnCache = {
11
+ current: {}
12
+ };
13
+
14
+ /**
15
+ * Logs a warning if the condition is not met.
16
+ * This is used to log issues in development environment only.
17
+ */
18
+ exports.warnCache = warnCache;
19
+ function warn(condition, message) {
20
+ if (!(process.env.NODE_ENV === 'development')) {
21
+ return;
22
+ }
23
+ if (condition) {
24
+ return;
25
+ }
26
+ var sanitizedMessage = message.trim();
27
+ var hasAlreadyPrinted = warnCache.current[sanitizedMessage];
28
+ if (!hasAlreadyPrinted) {
29
+ warnCache.current[sanitizedMessage] = true;
30
+ var warning = "[InstantSearch] ".concat(sanitizedMessage);
31
+ console.warn(warning);
32
+ try {
33
+ // Welcome to debugging InstantSearch.
34
+ //
35
+ // This error was thrown as a convenience so that you can find the source
36
+ // of the warning that appears in the console by enabling "Pause on exceptions"
37
+ // in your debugger.
38
+ throw new Error(warning);
39
+ } catch (error) {}
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ { "type": "commonjs", "sideEffects": false }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getServerState = getServerState;
7
+ var _server = require("instantsearch.js/cjs/lib/server");
8
+ var _utils = require("instantsearch.js/cjs/lib/utils");
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _ = require("..");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ * Returns the InstantSearch server state from a component.
14
+ */
15
+ function getServerState(children, _ref) {
16
+ var renderToString = _ref.renderToString;
17
+ var searchRef = {
18
+ current: undefined
19
+ };
20
+ var createNotifyServer = function createNotifyServer() {
21
+ var hasBeenNotified = false;
22
+ var notifyServer = function notifyServer(_ref2) {
23
+ var search = _ref2.search;
24
+ if (hasBeenNotified) {
25
+ throw new Error('getServerState should be called with a single InstantSearchSSRProvider and a single InstantSearch component.');
26
+ }
27
+ hasBeenNotified = true;
28
+ searchRef.current = search;
29
+ };
30
+ return notifyServer;
31
+ };
32
+ return execute({
33
+ children: children,
34
+ renderToString: renderToString,
35
+ searchRef: searchRef,
36
+ notifyServer: createNotifyServer()
37
+ }).then(function (serverState) {
38
+ var shouldRefetch = false;
39
+
40
+ // <DynamicWidgets> requires another query to retrieve the dynamic widgets
41
+ // to render.
42
+ (0, _utils.walkIndex)(searchRef.current.mainIndex, function (index) {
43
+ shouldRefetch = shouldRefetch || index.getWidgets().some(function (widget) {
44
+ return widget.$$type === 'ais.dynamicWidgets';
45
+ });
46
+ });
47
+ if (shouldRefetch) {
48
+ return execute({
49
+ children: /*#__PURE__*/_react.default.createElement(_.InstantSearchSSRProvider, serverState, children),
50
+ renderToString: renderToString,
51
+ searchRef: searchRef,
52
+ notifyServer: createNotifyServer()
53
+ });
54
+ }
55
+ return serverState;
56
+ });
57
+ }
58
+ function execute(_ref3) {
59
+ var children = _ref3.children,
60
+ renderToString = _ref3.renderToString,
61
+ notifyServer = _ref3.notifyServer,
62
+ searchRef = _ref3.searchRef;
63
+ return Promise.resolve().then(function () {
64
+ renderToString( /*#__PURE__*/_react.default.createElement(_.InstantSearchServerContext.Provider, {
65
+ value: {
66
+ notifyServer: notifyServer
67
+ }
68
+ }, children));
69
+ }).then(function () {
70
+ return (
71
+ // We wait for the component to mount so that `notifyServer()` is called.
72
+ new Promise(function (resolve) {
73
+ return setTimeout(resolve, 0);
74
+ })
75
+ );
76
+ }).then(function () {
77
+ // If `notifyServer()` is not called by then, it means that <InstantSearch>
78
+ // wasn't within the `children`.
79
+ // We decide to go with a strict behavior in that case; throwing. If users have
80
+ // some routes that don't mount the <InstantSearch> component, they would need
81
+ // to try/catch the `getServerState()` call.
82
+ // If this behavior turns out to be too strict for many users, we can decide
83
+ // to warn instead of throwing.
84
+ if (!searchRef.current) {
85
+ throw new Error("Unable to retrieve InstantSearch's server state in `getServerState()`. Did you mount the <InstantSearch> component?");
86
+ }
87
+ return (0, _server.waitForResults)(searchRef.current);
88
+ }).then(function () {
89
+ return {
90
+ initialResults: (0, _server.getInitialResults)(searchRef.current.mainIndex)
91
+ };
92
+ });
93
+ }
@@ -3,14 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _translatable = require("./translatable");
7
- Object.keys(_translatable).forEach(function (key) {
6
+ var _getServerState = require("./getServerState");
7
+ Object.keys(_getServerState).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _translatable[key]) return;
9
+ if (key in exports && exports[key] === _getServerState[key]) return;
10
10
  Object.defineProperty(exports, key, {
11
11
  enumerable: true,
12
12
  get: function get() {
13
- return _translatable[key];
13
+ return _getServerState[key];
14
14
  }
15
15
  });
16
16
  });
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '6.40.4';
7
+ var _default = '7.0.1';
8
8
  exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { UseConfigureProps } from '../connectors/useConfigure';
2
+ export type ConfigureProps = UseConfigureProps;
3
+ export declare function Configure(props: ConfigureProps): null;
@@ -0,0 +1,7 @@
1
+ import { useConfigure } from "../connectors/useConfigure.js";
2
+ export function Configure(props) {
3
+ useConfigure(props, {
4
+ $$widgetType: 'ais.configure'
5
+ });
6
+ return null;
7
+ }
@@ -0,0 +1,13 @@
1
+ import type { DynamicWidgetsConnectorParams } from 'instantsearch.js/es/connectors/dynamic-widgets/connectDynamicWidgets';
2
+ import type { ComponentType, ReactNode } from 'react';
3
+ type AtLeastOne<TTarget, TMapped = {
4
+ [Key in keyof TTarget]: Pick<TTarget, Key>;
5
+ }> = Partial<TTarget> & TMapped[keyof TMapped];
6
+ export type DynamicWidgetsProps = Omit<DynamicWidgetsConnectorParams, 'widgets' | 'fallbackWidget'> & AtLeastOne<{
7
+ children: ReactNode;
8
+ fallbackComponent: ComponentType<{
9
+ attribute: string;
10
+ }>;
11
+ }>;
12
+ export declare function DynamicWidgets({ children, fallbackComponent: Fallback, ...props }: DynamicWidgetsProps): JSX.Element;
13
+ export {};
@@ -0,0 +1,55 @@
1
+ var _excluded = ["children", "fallbackComponent"];
2
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ 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; }
5
+ import React, { Fragment } from 'react';
6
+ import { useDynamicWidgets } from "../connectors/useDynamicWidgets.js";
7
+ import { invariant } from "../lib/invariant.js";
8
+ import { warn } from "../lib/warn.js";
9
+ function DefaultFallbackComponent() {
10
+ return null;
11
+ }
12
+ export function DynamicWidgets(_ref) {
13
+ var children = _ref.children,
14
+ _ref$fallbackComponen = _ref.fallbackComponent,
15
+ Fallback = _ref$fallbackComponen === void 0 ? DefaultFallbackComponent : _ref$fallbackComponen,
16
+ props = _objectWithoutProperties(_ref, _excluded);
17
+ var FallbackComponent = React.useRef(Fallback);
18
+ process.env.NODE_ENV === 'development' ? warn(Fallback === FallbackComponent.current, 'The `fallbackComponent` prop of `DynamicWidgets` changed between renders. Please provide a stable reference, as described in https://www.algolia.com/doc/api-reference/widgets/dynamic-facets/react/#widget-param-fallbackcomponent') : void 0;
19
+ var _useDynamicWidgets = useDynamicWidgets(props, {
20
+ $$widgetType: 'ais.dynamicWidgets'
21
+ }),
22
+ attributesToRender = _useDynamicWidgets.attributesToRender;
23
+ var widgets = new Map();
24
+ React.Children.forEach(children, function (child) {
25
+ var attribute = getWidgetAttribute(child);
26
+ invariant(attribute !== undefined, "<DynamicWidgets> only supports InstantSearch widgets with an `attribute` or `attributes` prop.");
27
+ widgets.set(attribute, child);
28
+ });
29
+ return /*#__PURE__*/React.createElement(React.Fragment, null, attributesToRender.map(function (attribute) {
30
+ return /*#__PURE__*/React.createElement(Fragment, {
31
+ key: attribute
32
+ }, widgets.get(attribute) || /*#__PURE__*/React.createElement(FallbackComponent.current, {
33
+ attribute: attribute
34
+ }));
35
+ }));
36
+ }
37
+ function isReactElement(element) {
38
+ return _typeof(element) === 'object' && element.props;
39
+ }
40
+ function getWidgetAttribute(element) {
41
+ if (!isReactElement(element)) {
42
+ return undefined;
43
+ }
44
+ if (element.props.attribute) {
45
+ return element.props.attribute;
46
+ }
47
+ if (Array.isArray(element.props.attributes)) {
48
+ return element.props.attributes[0];
49
+ }
50
+ if (element.props.children) {
51
+ invariant(React.Children.count(element.props.children) === 1, "<DynamicWidgets> only supports a single component in nested components. Make sure to not render multiple children in a parent component.\n\nExample of an unsupported scenario:\n\n```\n<DynamicWidgets>\n <MyComponent>\n <RefinementList attribute=\"brand\" />\n <Menu attribute=\"categories\" />\n </MyComponent>\n</DynamicWidgets>\n```\n");
52
+ return getWidgetAttribute(React.Children.only(element.props.children));
53
+ }
54
+ return undefined;
55
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { UseIndexProps } from '../lib/useIndex';
3
+ export type IndexProps = UseIndexProps & {
4
+ children?: React.ReactNode;
5
+ };
6
+ export declare function Index({ children, ...props }: IndexProps): JSX.Element | null;
@@ -0,0 +1,17 @@
1
+ var _excluded = ["children"];
2
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
+ import React from 'react';
5
+ import { IndexContext } from "../lib/IndexContext.js";
6
+ import { useIndex } from "../lib/useIndex.js";
7
+ export function Index(_ref) {
8
+ var children = _ref.children,
9
+ props = _objectWithoutProperties(_ref, _excluded);
10
+ var index = useIndex(props);
11
+ if (index.getHelper() === null) {
12
+ return null;
13
+ }
14
+ return /*#__PURE__*/React.createElement(IndexContext.Provider, {
15
+ value: index
16
+ }, children);
17
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { UseInstantSearchApiProps } from '../lib/useInstantSearchApi';
3
+ import type { UiState } from 'instantsearch.js';
4
+ export type InstantSearchProps<TUiState extends UiState = UiState, TRouteState = TUiState> = UseInstantSearchApiProps<TUiState, TRouteState> & {
5
+ children?: React.ReactNode;
6
+ };
7
+ export declare function InstantSearch<TUiState extends UiState = UiState, TRouteState = TUiState>({ children, ...props }: InstantSearchProps<TUiState, TRouteState>): JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ var _excluded = ["children"];
2
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
3
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
+ import React from 'react';
5
+ import { IndexContext } from "../lib/IndexContext.js";
6
+ import { InstantSearchContext } from "../lib/InstantSearchContext.js";
7
+ import { useInstantSearchApi } from "../lib/useInstantSearchApi.js";
8
+ export function InstantSearch(_ref) {
9
+ var children = _ref.children,
10
+ props = _objectWithoutProperties(_ref, _excluded);
11
+ var search = useInstantSearchApi(props);
12
+ if (!search.started) {
13
+ return null;
14
+ }
15
+ return /*#__PURE__*/React.createElement(InstantSearchContext.Provider, {
16
+ value: search
17
+ }, /*#__PURE__*/React.createElement(IndexContext.Provider, {
18
+ value: search.mainIndex
19
+ }, children));
20
+ }
@@ -0,0 +1,13 @@
1
+ import type { InitialResults, UiState } from 'instantsearch.js';
2
+ import type { ReactNode } from 'react';
3
+ export type InstantSearchServerState = {
4
+ initialResults: InitialResults;
5
+ };
6
+ export type InstantSearchSSRProviderProps = Partial<InstantSearchServerState> & {
7
+ children?: ReactNode;
8
+ };
9
+ /**
10
+ * Provider to pass the server state retrieved from `getServerState()` to
11
+ * <InstantSearch>.
12
+ */
13
+ export declare function InstantSearchSSRProvider<TUiState extends UiState, TRouteState = TUiState>({ children, ...props }: InstantSearchSSRProviderProps): JSX.Element;
@@ -1,6 +1,5 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["children", "contextValue", "indexContextValue"],
3
- _excluded2 = ["children", "contextValue", "indexContextValue"];
2
+ var _excluded = ["children"];
4
3
  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
4
  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
5
  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; }
@@ -8,63 +7,29 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
8
7
  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
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
9
  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; }
11
- import createConnector from "../core/createConnector.js";
12
- import { refineValue, getIndexId, hasMultipleIndices } from "../core/indexUtils.js";
13
- import { omit } from "../core/utils.js";
14
- function getId() {
15
- return 'configure';
16
- }
17
- export default createConnector({
18
- displayName: 'AlgoliaConfigure',
19
- $$type: 'ais.configure',
20
- getProvidedProps: function getProvidedProps() {
21
- return {};
22
- },
23
- getSearchParameters: function getSearchParameters(searchParameters, props) {
24
- var children = props.children,
25
- contextValue = props.contextValue,
26
- indexContextValue = props.indexContextValue,
27
- items = _objectWithoutProperties(props, _excluded);
28
- return searchParameters.setQueryParameters(items);
29
- },
30
- transitionState: function transitionState(props, prevSearchState, nextSearchState) {
31
- var id = getId();
32
- var children = props.children,
33
- contextValue = props.contextValue,
34
- indexContextValue = props.indexContextValue,
35
- items = _objectWithoutProperties(props, _excluded2);
36
- var propKeys = Object.keys(props);
37
- var nonPresentKeys = this._props ? Object.keys(this._props).filter(function (prop) {
38
- return propKeys.indexOf(prop) === -1;
39
- }) : [];
40
- this._props = props;
41
- var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, omit(nextSearchState[id], nonPresentKeys)), items));
42
- return refineValue(nextSearchState, nextValue, {
43
- ais: props.contextValue,
44
- multiIndexContext: props.indexContextValue
45
- });
46
- },
47
- cleanUp: function cleanUp(props, searchState) {
48
- var id = getId();
49
- var indexId = getIndexId({
50
- ais: props.contextValue,
51
- multiIndexContext: props.indexContextValue
52
- });
53
- var subState = hasMultipleIndices({
54
- ais: props.contextValue,
55
- multiIndexContext: props.indexContextValue
56
- }) && searchState.indices ? searchState.indices[indexId] : searchState;
57
- var configureKeys = subState && subState[id] ? Object.keys(subState[id]) : [];
58
- var configureState = configureKeys.reduce(function (acc, item) {
59
- if (!props[item]) {
60
- acc[item] = subState[id][item];
61
- }
62
- return acc;
63
- }, {});
64
- var nextValue = _defineProperty({}, id, configureState);
65
- return refineValue(searchState, nextValue, {
66
- ais: props.contextValue,
67
- multiIndexContext: props.indexContextValue
68
- });
10
+ import React from 'react';
11
+ import { InstantSearchSSRContext } from "../lib/InstantSearchSSRContext.js";
12
+ /**
13
+ * Provider to pass the server state retrieved from `getServerState()` to
14
+ * <InstantSearch>.
15
+ */
16
+ export function InstantSearchSSRProvider(_ref) {
17
+ var children = _ref.children,
18
+ props = _objectWithoutProperties(_ref, _excluded);
19
+ // This is used in `useInstantSearchApi()` to avoid creating and starting multiple instances of
20
+ // `InstantSearch` on mount.
21
+ var ssrSearchRef = React.useRef(null);
22
+
23
+ // When <DynamicWidgets> is mounted, a second provider is used above the user-land
24
+ // <InstantSearchSSRProvider> in `getServerState()`.
25
+ // To avoid the user's provider overriding the context value with an empty object,
26
+ // we skip this provider.
27
+ if (Object.keys(props).length === 0) {
28
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
69
29
  }
70
- });
30
+ return /*#__PURE__*/React.createElement(InstantSearchSSRContext.Provider, {
31
+ value: _objectSpread(_objectSpread({}, props), {}, {
32
+ ssrSearchRef: ssrSearchRef
33
+ })
34
+ }, children);
35
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { InstantSearch, UiState } from 'instantsearch.js';
3
+ export type InstantSearchServerContextApi<TUiState extends UiState, TRouteState = TUiState> = {
4
+ /**
5
+ * Fowards search internals to the server execution context to access them
6
+ * in `getServerState()`.
7
+ */
8
+ notifyServer: (params: {
9
+ search: InstantSearch<TUiState, TRouteState>;
10
+ }) => void;
11
+ };
12
+ export declare const InstantSearchServerContext: import("react").Context<InstantSearchServerContextApi<UiState, UiState> | null>;
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ export var InstantSearchServerContext = /*#__PURE__*/createContext(null);
3
+ if (process.env.NODE_ENV === 'development') {
4
+ InstantSearchServerContext.displayName = 'InstantSearchServer';
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { BreadcrumbConnectorParams } from 'instantsearch.js/es/connectors/breadcrumb/connectBreadcrumb';
3
+ export type UseBreadcrumbProps = BreadcrumbConnectorParams;
4
+ export declare function useBreadcrumb(props: UseBreadcrumbProps, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/breadcrumb/connectBreadcrumb").BreadcrumbRenderState;
@@ -0,0 +1,5 @@
1
+ import connectBreadcrumb from "instantsearch.js/es/connectors/breadcrumb/connectBreadcrumb.js";
2
+ import { useConnector } from "../hooks/useConnector.js";
3
+ export function useBreadcrumb(props, additionalWidgetProperties) {
4
+ return useConnector(connectBreadcrumb, props, additionalWidgetProperties);
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { ClearRefinementsConnectorParams } from 'instantsearch.js/es/connectors/clear-refinements/connectClearRefinements';
3
+ export type UseClearRefinementsProps = ClearRefinementsConnectorParams;
4
+ export declare function useClearRefinements(props?: UseClearRefinementsProps, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/clear-refinements/connectClearRefinements").ClearRefinementsRenderState;
@@ -0,0 +1,5 @@
1
+ import connectClearRefinements from "instantsearch.js/es/connectors/clear-refinements/connectClearRefinements.js";
2
+ import { useConnector } from "../hooks/useConnector.js";
3
+ export function useClearRefinements(props, additionalWidgetProperties) {
4
+ return useConnector(connectClearRefinements, props, additionalWidgetProperties);
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { ConfigureConnectorParams } from 'instantsearch.js/es/connectors/configure/connectConfigure';
3
+ export type UseConfigureProps = ConfigureConnectorParams['searchParameters'];
4
+ export declare function useConfigure(props: UseConfigureProps, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/configure/connectConfigure").ConfigureRenderState;
@@ -0,0 +1,7 @@
1
+ import connectConfigure from "instantsearch.js/es/connectors/configure/connectConfigure.js";
2
+ import { useConnector } from "../hooks/useConnector.js";
3
+ export function useConfigure(props, additionalWidgetProperties) {
4
+ return useConnector(connectConfigure, {
5
+ searchParameters: props
6
+ }, additionalWidgetProperties);
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { CurrentRefinementsConnectorParams } from 'instantsearch.js/es/connectors/current-refinements/connectCurrentRefinements';
3
+ export type UseCurrentRefinementsProps = CurrentRefinementsConnectorParams;
4
+ export declare function useCurrentRefinements(props?: UseCurrentRefinementsProps, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/current-refinements/connectCurrentRefinements").CurrentRefinementsRenderState;
@@ -0,0 +1,5 @@
1
+ import connectCurrentRefinements from "instantsearch.js/es/connectors/current-refinements/connectCurrentRefinements.js";
2
+ import { useConnector } from "../hooks/useConnector.js";
3
+ export function useCurrentRefinements(props, additionalWidgetProperties) {
4
+ return useConnector(connectCurrentRefinements, props, additionalWidgetProperties);
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { DynamicWidgetsConnectorParams } from 'instantsearch.js/es/connectors/dynamic-widgets/connectDynamicWidgets';
3
+ export type UseDynamicWidgetsProps = Omit<DynamicWidgetsConnectorParams, 'widgets' | 'fallbackWidget'>;
4
+ export declare function useDynamicWidgets(props?: UseDynamicWidgetsProps, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/dynamic-widgets/connectDynamicWidgets").DynamicWidgetsRenderState;
@@ -0,0 +1,15 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import connectDynamicWidgets from "instantsearch.js/es/connectors/dynamic-widgets/connectDynamicWidgets.js";
8
+ import { useConnector } from "../hooks/useConnector.js";
9
+ export function useDynamicWidgets(props, additionalWidgetProperties) {
10
+ return useConnector(connectDynamicWidgets, _objectSpread(_objectSpread({}, props), {}, {
11
+ // We don't rely on InstantSearch.js for rendering widgets because React
12
+ // directly manipulates the children.
13
+ widgets: []
14
+ }), additionalWidgetProperties);
15
+ }
@@ -0,0 +1,6 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { BaseHit } from 'instantsearch.js';
3
+ import type { GeoSearchConnectorParams } from 'instantsearch.js/es/connectors/geo-search/connectGeoSearch';
4
+ export type { GeoHit } from 'instantsearch.js/es/connectors/geo-search/connectGeoSearch';
5
+ export type UseGeoSearchProps<THit extends BaseHit = BaseHit> = GeoSearchConnectorParams<THit>;
6
+ export declare function useGeoSearch<THit extends BaseHit>(props?: UseGeoSearchProps<THit>, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/geo-search/connectGeoSearch").GeoSearchRenderState<THit>;
@@ -0,0 +1,5 @@
1
+ import connectGeoSearch from "instantsearch.js/es/connectors/geo-search/connectGeoSearch.js";
2
+ import { useConnector } from "../hooks/useConnector.js";
3
+ export function useGeoSearch(props, additionalWidgetProperties) {
4
+ return useConnector(connectGeoSearch, props, additionalWidgetProperties);
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { AdditionalWidgetProperties } from '../hooks/useConnector';
2
+ import type { HierarchicalMenuConnectorParams } from 'instantsearch.js/es/connectors/hierarchical-menu/connectHierarchicalMenu';
3
+ export type UseHierarchicalMenuProps = HierarchicalMenuConnectorParams;
4
+ export declare function useHierarchicalMenu(props: UseHierarchicalMenuProps, additionalWidgetProperties?: AdditionalWidgetProperties): import("instantsearch.js/es/connectors/hierarchical-menu/connectHierarchicalMenu").HierarchicalMenuRenderState;
@@ -0,0 +1,5 @@
1
+ import connectHierarchicalMenu from "instantsearch.js/es/connectors/hierarchical-menu/connectHierarchicalMenu.js";
2
+ import { useConnector } from "../hooks/useConnector.js";
3
+ export function useHierarchicalMenu(props, additionalWidgetProperties) {
4
+ return useConnector(connectHierarchicalMenu, props, additionalWidgetProperties);
5
+ }