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.
- package/README.md +70 -2
- package/dist/cjs/components/Configure.js +13 -0
- package/dist/cjs/components/DynamicWidgets.js +63 -0
- package/dist/cjs/components/Index.js +24 -0
- package/dist/cjs/components/InstantSearch.js +27 -0
- package/dist/cjs/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +27 -63
- package/dist/cjs/components/InstantSearchServerContext.js +12 -0
- package/dist/cjs/connectors/useBreadcrumb.js +12 -0
- package/dist/cjs/connectors/useClearRefinements.js +12 -0
- package/dist/cjs/connectors/useConfigure.js +14 -0
- package/dist/cjs/connectors/useCurrentRefinements.js +12 -0
- package/dist/cjs/connectors/useDynamicWidgets.js +22 -0
- package/dist/cjs/connectors/useGeoSearch.js +12 -0
- package/dist/cjs/connectors/useHierarchicalMenu.js +12 -0
- package/dist/cjs/connectors/useHits.js +12 -0
- package/dist/cjs/connectors/useHitsPerPage.js +12 -0
- package/dist/cjs/connectors/useInfiniteHits.js +12 -0
- package/dist/cjs/connectors/useMenu.js +12 -0
- package/dist/cjs/connectors/useNumericMenu.js +12 -0
- package/dist/cjs/connectors/usePagination.js +12 -0
- package/dist/cjs/connectors/usePoweredBy.js +21 -0
- package/dist/cjs/connectors/useQueryRules.js +12 -0
- package/dist/cjs/connectors/useRange.js +12 -0
- package/dist/cjs/connectors/useRefinementList.js +12 -0
- package/dist/cjs/connectors/useSearchBox.js +12 -0
- package/dist/cjs/connectors/useSortBy.js +12 -0
- package/dist/cjs/connectors/useStats.js +12 -0
- package/dist/cjs/connectors/useToggleRefinement.js +12 -0
- package/dist/cjs/hooks/useConnector.js +136 -0
- package/dist/cjs/hooks/useInstantSearch.js +58 -0
- package/dist/cjs/index.js +328 -320
- package/dist/cjs/lib/IndexContext.js +12 -0
- package/dist/cjs/lib/InstantSearchContext.js +12 -0
- package/dist/cjs/lib/InstantSearchSSRContext.js +12 -0
- package/dist/cjs/lib/createSearchResults.js +27 -0
- package/dist/cjs/lib/dequal.js +53 -0
- package/dist/cjs/lib/getIndexSearchResults.js +32 -0
- package/dist/cjs/lib/invariant.js +25 -0
- package/dist/cjs/lib/noop.js +8 -0
- package/dist/cjs/lib/useForceUpdate.js +25 -0
- package/dist/cjs/lib/useIndex.js +38 -0
- package/dist/cjs/lib/useIndexContext.js +14 -0
- package/dist/cjs/lib/useInstantSearchApi.js +191 -0
- package/dist/cjs/lib/useInstantSearchContext.js +14 -0
- package/dist/cjs/lib/useInstantSearchSSRContext.js +11 -0
- package/dist/cjs/lib/useInstantSearchServerContext.js +11 -0
- package/dist/cjs/lib/useIsomorphicLayoutEffect.js +14 -0
- package/dist/cjs/lib/useSearchResults.js +46 -0
- package/dist/cjs/lib/useSearchState.js +48 -0
- package/dist/cjs/lib/useStableValue.js +26 -0
- package/dist/cjs/lib/useWidget.js +78 -0
- package/dist/cjs/lib/warn.js +41 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/server/getServerState.js +93 -0
- package/dist/cjs/{types → server}/index.js +4 -4
- package/dist/cjs/{core/version.js → version.js} +1 -1
- package/dist/es/components/Configure.d.ts +3 -0
- package/dist/es/components/Configure.js +7 -0
- package/dist/es/components/DynamicWidgets.d.ts +13 -0
- package/dist/es/components/DynamicWidgets.js +55 -0
- package/dist/es/components/Index.d.ts +6 -0
- package/dist/es/components/Index.js +17 -0
- package/dist/es/components/InstantSearch.d.ts +7 -0
- package/dist/es/components/InstantSearch.js +20 -0
- package/dist/es/components/InstantSearchSSRProvider.d.ts +13 -0
- package/dist/es/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +26 -61
- package/dist/es/components/InstantSearchServerContext.d.ts +12 -0
- package/dist/es/components/InstantSearchServerContext.js +5 -0
- package/dist/es/connectors/useBreadcrumb.d.ts +4 -0
- package/dist/es/connectors/useBreadcrumb.js +5 -0
- package/dist/es/connectors/useClearRefinements.d.ts +4 -0
- package/dist/es/connectors/useClearRefinements.js +5 -0
- package/dist/es/connectors/useConfigure.d.ts +4 -0
- package/dist/es/connectors/useConfigure.js +7 -0
- package/dist/es/connectors/useCurrentRefinements.d.ts +4 -0
- package/dist/es/connectors/useCurrentRefinements.js +5 -0
- package/dist/es/connectors/useDynamicWidgets.d.ts +4 -0
- package/dist/es/connectors/useDynamicWidgets.js +15 -0
- package/dist/es/connectors/useGeoSearch.d.ts +6 -0
- package/dist/es/connectors/useGeoSearch.js +5 -0
- package/dist/es/connectors/useHierarchicalMenu.d.ts +4 -0
- package/dist/es/connectors/useHierarchicalMenu.js +5 -0
- package/dist/es/connectors/useHits.d.ts +5 -0
- package/dist/es/connectors/useHits.js +5 -0
- package/dist/es/connectors/useHitsPerPage.d.ts +4 -0
- package/dist/es/connectors/useHitsPerPage.js +5 -0
- package/dist/es/connectors/useInfiniteHits.d.ts +5 -0
- package/dist/es/connectors/useInfiniteHits.js +5 -0
- package/dist/es/connectors/useMenu.d.ts +4 -0
- package/dist/es/connectors/useMenu.js +5 -0
- package/dist/es/connectors/useNumericMenu.d.ts +4 -0
- package/dist/es/connectors/useNumericMenu.js +5 -0
- package/dist/es/connectors/usePagination.d.ts +4 -0
- package/dist/es/connectors/usePagination.js +5 -0
- package/dist/es/connectors/usePoweredBy.d.ts +2 -0
- package/dist/es/connectors/usePoweredBy.js +15 -0
- package/dist/es/connectors/useQueryRules.d.ts +4 -0
- package/dist/es/connectors/useQueryRules.js +5 -0
- package/dist/es/connectors/useRange.d.ts +4 -0
- package/dist/es/connectors/useRange.js +5 -0
- package/dist/es/connectors/useRefinementList.d.ts +4 -0
- package/dist/es/connectors/useRefinementList.js +5 -0
- package/dist/es/connectors/useSearchBox.d.ts +4 -0
- package/dist/es/connectors/useSearchBox.js +5 -0
- package/dist/es/connectors/useSortBy.d.ts +4 -0
- package/dist/es/connectors/useSortBy.js +5 -0
- package/dist/es/connectors/useStats.d.ts +4 -0
- package/dist/es/connectors/useStats.js +5 -0
- package/dist/es/connectors/useToggleRefinement.d.ts +4 -0
- package/dist/es/connectors/useToggleRefinement.js +5 -0
- package/dist/es/hooks/useConnector.d.ts +3 -0
- package/dist/es/hooks/useConnector.js +130 -0
- package/dist/es/hooks/useInstantSearch.d.ts +32 -0
- package/dist/es/hooks/useInstantSearch.js +52 -0
- package/dist/es/index.d.ts +31 -0
- package/dist/es/index.js +31 -87
- package/dist/es/lib/IndexContext.d.ts +3 -0
- package/dist/es/lib/IndexContext.js +5 -0
- package/dist/es/lib/InstantSearchContext.d.ts +3 -0
- package/dist/es/lib/InstantSearchContext.js +5 -0
- package/dist/es/lib/InstantSearchSSRContext.d.ts +8 -0
- package/dist/es/lib/InstantSearchSSRContext.js +5 -0
- package/dist/es/lib/createSearchResults.d.ts +3 -0
- package/dist/es/lib/createSearchResults.js +20 -0
- package/dist/es/lib/dequal.d.ts +1 -0
- package/dist/es/lib/dequal.js +47 -0
- package/dist/es/lib/getIndexSearchResults.d.ts +9 -0
- package/dist/es/lib/getIndexSearchResults.js +26 -0
- package/dist/es/lib/invariant.d.ts +9 -0
- package/dist/es/lib/invariant.js +19 -0
- package/dist/es/lib/noop.d.ts +1 -0
- package/dist/es/lib/noop.js +1 -0
- package/dist/es/lib/useForceUpdate.d.ts +6 -0
- package/dist/es/lib/useForceUpdate.js +20 -0
- package/dist/es/lib/useIndex.d.ts +3 -0
- package/dist/es/lib/useIndex.js +31 -0
- package/dist/es/lib/useIndexContext.d.ts +2 -0
- package/dist/es/lib/useIndexContext.js +8 -0
- package/dist/es/lib/useInstantSearchApi.d.ts +21 -0
- package/dist/es/lib/useInstantSearchApi.js +184 -0
- package/dist/es/lib/useInstantSearchContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchContext.js +8 -0
- package/dist/es/lib/useInstantSearchSSRContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchSSRContext.js +5 -0
- package/dist/es/lib/useInstantSearchServerContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchServerContext.js +5 -0
- package/dist/es/lib/useIsomorphicLayoutEffect.d.ts +7 -0
- package/dist/es/lib/useIsomorphicLayoutEffect.js +8 -0
- package/dist/es/lib/useSearchResults.d.ts +7 -0
- package/dist/es/lib/useSearchResults.js +40 -0
- package/dist/es/lib/useSearchState.d.ts +8 -0
- package/dist/es/lib/useSearchState.js +42 -0
- package/dist/es/lib/useStableValue.d.ts +1 -0
- package/dist/es/lib/useStableValue.js +20 -0
- package/dist/es/lib/useWidget.d.ts +8 -0
- package/dist/es/lib/useWidget.js +72 -0
- package/dist/es/lib/warn.d.ts +10 -0
- package/dist/es/lib/warn.js +33 -0
- package/dist/es/server/getServerState.d.ts +10 -0
- package/dist/es/server/getServerState.js +86 -0
- package/dist/es/server/index.d.ts +1 -0
- package/dist/es/server/index.js +1 -0
- package/dist/es/version.d.ts +2 -0
- package/dist/es/version.js +1 -0
- package/dist/umd/ReactInstantSearchCore.js +14071 -7955
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +23 -8
- package/dist/cjs/connectors/connectAutoComplete.js +0 -104
- package/dist/cjs/connectors/connectBreadcrumb.js +0 -123
- package/dist/cjs/connectors/connectConfigureRelatedItems.js +0 -127
- package/dist/cjs/connectors/connectCurrentRefinements.js +0 -69
- package/dist/cjs/connectors/connectDynamicWidgets.js +0 -65
- package/dist/cjs/connectors/connectGeoSearch.js +0 -189
- package/dist/cjs/connectors/connectHierarchicalMenu.js +0 -273
- package/dist/cjs/connectors/connectHighlight.js +0 -87
- package/dist/cjs/connectors/connectHitInsights.js +0 -76
- package/dist/cjs/connectors/connectHits.js +0 -88
- package/dist/cjs/connectors/connectHitsPerPage.js +0 -97
- package/dist/cjs/connectors/connectInfiniteHits.js +0 -154
- package/dist/cjs/connectors/connectMenu.js +0 -221
- package/dist/cjs/connectors/connectNumericMenu.js +0 -215
- package/dist/cjs/connectors/connectPagination.js +0 -94
- package/dist/cjs/connectors/connectPoweredBy.js +0 -27
- package/dist/cjs/connectors/connectQueryRules.js +0 -129
- package/dist/cjs/connectors/connectRange.js +0 -287
- package/dist/cjs/connectors/connectRefinementList.js +0 -243
- package/dist/cjs/connectors/connectRelevantSort.js +0 -56
- package/dist/cjs/connectors/connectScrollTo.js +0 -70
- package/dist/cjs/connectors/connectSearchBox.js +0 -104
- package/dist/cjs/connectors/connectSortBy.js +0 -100
- package/dist/cjs/connectors/connectStateResults.js +0 -79
- package/dist/cjs/connectors/connectStats.js +0 -39
- package/dist/cjs/connectors/connectToggleRefinement.js +0 -163
- package/dist/cjs/connectors/connectVoiceSearch.js +0 -124
- package/dist/cjs/core/context.js +0 -37
- package/dist/cjs/core/createConnector.js +0 -268
- package/dist/cjs/core/createInstantSearchManager.d.js +0 -1
- package/dist/cjs/core/createInstantSearchManager.js +0 -541
- package/dist/cjs/core/createStore.js +0 -27
- package/dist/cjs/core/createWidgetsManager.js +0 -39
- package/dist/cjs/core/highlight.js +0 -102
- package/dist/cjs/core/indexUtils.js +0 -214
- package/dist/cjs/core/metadata.js +0 -46
- package/dist/cjs/core/translatable.js +0 -82
- package/dist/cjs/core/utils.js +0 -161
- package/dist/cjs/types/algoliasearch.js +0 -1
- package/dist/cjs/types/translatable.js +0 -1
- package/dist/cjs/widgets/Configure.js +0 -48
- package/dist/cjs/widgets/ConfigureRelatedItems.js +0 -21
- package/dist/cjs/widgets/DynamicWidgets.js +0 -61
- package/dist/cjs/widgets/Index.js +0 -149
- package/dist/cjs/widgets/InstantSearch.js +0 -251
- package/dist/cjs/widgets/QueryRuleContext.js +0 -14
- package/dist/es/connectors/connectAutoComplete.js +0 -96
- package/dist/es/connectors/connectBreadcrumb.js +0 -115
- package/dist/es/connectors/connectConfigureRelatedItems.js +0 -121
- package/dist/es/connectors/connectCurrentRefinements.js +0 -62
- package/dist/es/connectors/connectDynamicWidgets.js +0 -56
- package/dist/es/connectors/connectGeoSearch.js +0 -182
- package/dist/es/connectors/connectHierarchicalMenu.js +0 -264
- package/dist/es/connectors/connectHighlight.js +0 -79
- package/dist/es/connectors/connectHitInsights.js +0 -69
- package/dist/es/connectors/connectHits.js +0 -81
- package/dist/es/connectors/connectHitsPerPage.js +0 -89
- package/dist/es/connectors/connectInfiniteHits.js +0 -146
- package/dist/es/connectors/connectMenu.js +0 -213
- package/dist/es/connectors/connectNumericMenu.js +0 -207
- package/dist/es/connectors/connectPagination.js +0 -86
- package/dist/es/connectors/connectPoweredBy.js +0 -20
- package/dist/es/connectors/connectQueryRules.js +0 -122
- package/dist/es/connectors/connectRange.js +0 -280
- package/dist/es/connectors/connectRefinementList.js +0 -235
- package/dist/es/connectors/connectRelevantSort.js +0 -50
- package/dist/es/connectors/connectScrollTo.js +0 -63
- package/dist/es/connectors/connectSearchBox.js +0 -96
- package/dist/es/connectors/connectSortBy.js +0 -92
- package/dist/es/connectors/connectStateResults.js +0 -72
- package/dist/es/connectors/connectStats.js +0 -32
- package/dist/es/connectors/connectToggleRefinement.js +0 -155
- package/dist/es/connectors/connectVoiceSearch.js +0 -116
- package/dist/es/core/context.js +0 -28
- package/dist/es/core/createConnector.js +0 -257
- package/dist/es/core/createInstantSearchManager.d.js +0 -0
- package/dist/es/core/createInstantSearchManager.js +0 -534
- package/dist/es/core/createStore.js +0 -21
- package/dist/es/core/createWidgetsManager.js +0 -33
- package/dist/es/core/highlight.js +0 -94
- package/dist/es/core/indexUtils.js +0 -203
- package/dist/es/core/metadata.js +0 -38
- package/dist/es/core/translatable.js +0 -74
- package/dist/es/core/utils.js +0 -139
- package/dist/es/core/version.js +0 -1
- package/dist/es/types/algoliasearch.js +0 -1
- package/dist/es/types/index.js +0 -1
- package/dist/es/types/translatable.js +0 -1
- package/dist/es/widgets/Configure.js +0 -42
- package/dist/es/widgets/ConfigureRelatedItems.js +0 -13
- package/dist/es/widgets/DynamicWidgets.js +0 -51
- package/dist/es/widgets/Index.js +0 -138
- package/dist/es/widgets/InstantSearch.js +0 -241
- package/dist/es/widgets/QueryRuleContext.js +0 -6
package/dist/es/widgets/Index.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
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 _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
7
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
10
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
13
|
-
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; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
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); }
|
|
16
|
-
import PropTypes from 'prop-types';
|
|
17
|
-
import React, { Component, Children } from 'react';
|
|
18
|
-
import { InstantSearchConsumer, IndexProvider } from "../core/context.js";
|
|
19
|
-
function getIndexContext(props) {
|
|
20
|
-
return {
|
|
21
|
-
targetedIndex: props.indexId
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* The component that allows you to apply widgets to a dedicated index. It's
|
|
26
|
-
* useful if you want to build an interface that targets multiple indices.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* import React from 'react';
|
|
30
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
31
|
-
* import { InstantSearch, Index, SearchBox, Hits, Configure } from 'react-instantsearch-dom';
|
|
32
|
-
*
|
|
33
|
-
* const searchClient = algoliasearch(
|
|
34
|
-
* 'latency',
|
|
35
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
36
|
-
* );
|
|
37
|
-
*
|
|
38
|
-
* const App = () => (
|
|
39
|
-
* <InstantSearch
|
|
40
|
-
* searchClient={searchClient}
|
|
41
|
-
* indexName="instant_search"
|
|
42
|
-
* >
|
|
43
|
-
* <Configure hitsPerPage={5} />
|
|
44
|
-
* <SearchBox />
|
|
45
|
-
* <Index indexName="instant_search">
|
|
46
|
-
* <Hits />
|
|
47
|
-
* </Index>
|
|
48
|
-
* <Index indexName="bestbuy">
|
|
49
|
-
* <Hits />
|
|
50
|
-
* </Index>
|
|
51
|
-
* </InstantSearch>
|
|
52
|
-
* );
|
|
53
|
-
*/
|
|
54
|
-
var Index = /*#__PURE__*/function (_Component) {
|
|
55
|
-
_inherits(Index, _Component);
|
|
56
|
-
var _super = _createSuper(Index);
|
|
57
|
-
function Index(props) {
|
|
58
|
-
var _this;
|
|
59
|
-
_classCallCheck(this, Index);
|
|
60
|
-
_this = _super.call(this, props);
|
|
61
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
62
|
-
indexContext: getIndexContext(_this.props)
|
|
63
|
-
});
|
|
64
|
-
_defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
|
|
65
|
-
_this.props.contextValue.onSearchParameters(_this.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
66
|
-
ais: _this.props.contextValue,
|
|
67
|
-
multiIndexContext: _this.state.indexContext
|
|
68
|
-
}, _this.props, undefined, Index.displayName);
|
|
69
|
-
return _this;
|
|
70
|
-
}
|
|
71
|
-
_createClass(Index, [{
|
|
72
|
-
key: "componentDidMount",
|
|
73
|
-
value: function componentDidMount() {
|
|
74
|
-
this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(this);
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "componentDidUpdate",
|
|
78
|
-
value: function componentDidUpdate(prevProps) {
|
|
79
|
-
if (this.props.indexName !== prevProps.indexName) {
|
|
80
|
-
this.props.contextValue.widgetsManager.update();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "componentWillUnmount",
|
|
85
|
-
value: function componentWillUnmount() {
|
|
86
|
-
if (typeof this.unregisterWidget === 'function') {
|
|
87
|
-
this.unregisterWidget();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "getSearchParameters",
|
|
92
|
-
value: function getSearchParameters(searchParameters, props) {
|
|
93
|
-
return searchParameters.setIndex(this.props ? this.props.indexName : props.indexName);
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "render",
|
|
97
|
-
value: function render() {
|
|
98
|
-
var childrenCount = Children.count(this.props.children);
|
|
99
|
-
if (childrenCount === 0) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
return /*#__PURE__*/React.createElement(IndexProvider, {
|
|
103
|
-
value: this.state.indexContext
|
|
104
|
-
}, this.props.children);
|
|
105
|
-
}
|
|
106
|
-
}], [{
|
|
107
|
-
key: "getDerivedStateFromProps",
|
|
108
|
-
value: function getDerivedStateFromProps(props) {
|
|
109
|
-
return {
|
|
110
|
-
indexContext: getIndexContext(props)
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
114
|
-
return Index;
|
|
115
|
-
}(Component);
|
|
116
|
-
_defineProperty(Index, "propTypes", {
|
|
117
|
-
indexName: PropTypes.string.isRequired,
|
|
118
|
-
indexId: PropTypes.string.isRequired,
|
|
119
|
-
children: PropTypes.node
|
|
120
|
-
});
|
|
121
|
-
_defineProperty(Index, "displayName", 'AlgoliaIndex');
|
|
122
|
-
_defineProperty(Index, "$$type", 'ais.index');
|
|
123
|
-
_defineProperty(Index, "$$widgetType", 'ais.index');
|
|
124
|
-
var IndexWrapper = function IndexWrapper(props) {
|
|
125
|
-
var inferredIndexId = props.indexName;
|
|
126
|
-
return /*#__PURE__*/React.createElement(InstantSearchConsumer, null, function (contextValue) {
|
|
127
|
-
return /*#__PURE__*/React.createElement(Index, _extends({
|
|
128
|
-
contextValue: contextValue,
|
|
129
|
-
indexId: inferredIndexId
|
|
130
|
-
}, props));
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
IndexWrapper.propTypes = {
|
|
134
|
-
indexName: PropTypes.string.isRequired,
|
|
135
|
-
indexId: PropTypes.string
|
|
136
|
-
};
|
|
137
|
-
export var IndexComponentWithoutContext = Index;
|
|
138
|
-
export default IndexWrapper;
|
|
@@ -1,241 +0,0 @@
|
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
11
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
14
|
-
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; }
|
|
15
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
-
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); }
|
|
17
|
-
import PropTypes from 'prop-types';
|
|
18
|
-
import React, { Component, Children } from 'react';
|
|
19
|
-
import isEqual from 'react-fast-compare';
|
|
20
|
-
import { InstantSearchProvider } from "../core/context.js";
|
|
21
|
-
import createInstantSearchManager from "../core/createInstantSearchManager.js";
|
|
22
|
-
import { isMetadataEnabled, injectMetadata } from "../core/metadata.js";
|
|
23
|
-
function isControlled(props) {
|
|
24
|
-
return Boolean(props.searchState);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @description
|
|
29
|
-
* `<InstantSearch>` is the root component of all React InstantSearch implementations.
|
|
30
|
-
* It provides all the connected components (aka widgets) a means to interact
|
|
31
|
-
* with the searchState.
|
|
32
|
-
* @kind widget
|
|
33
|
-
* @name <InstantSearch>
|
|
34
|
-
* @requirements You will need to have an Algolia account to be able to use this widget.
|
|
35
|
-
* [Create one now](https://www.algolia.com/users/sign_up).
|
|
36
|
-
* @propType {string} indexName - Main index in which to search.
|
|
37
|
-
* @propType {boolean} [refresh=false] - Flag to activate when the cache needs to be cleared so that the front-end is updated when a change occurs in the index.
|
|
38
|
-
* @propType {object} [searchClient] - Provide a custom search client.
|
|
39
|
-
* @propType {func} [onSearchStateChange] - Function to be called everytime a new search is done. Useful for [URL Routing](guide/Routing.html).
|
|
40
|
-
* @propType {object} [searchState] - Object to inject some search state. Switches the InstantSearch component in controlled mode. Useful for [URL Routing](guide/Routing.html).
|
|
41
|
-
* @propType {func} [createURL] - Function to call when creating links, useful for [URL Routing](guide/Routing.html).
|
|
42
|
-
* @propType {SearchResults|SearchResults[]} [resultsState] - Use this to inject the results that will be used at first rendering. Those results are found by using the `findResultsState` function. Useful for [Server Side Rendering](guide/Server-side_rendering.html).
|
|
43
|
-
* @propType {number} [stalledSearchDelay=200] - The amount of time before considering that the search takes too much time. The time is expressed in milliseconds.
|
|
44
|
-
* @propType {{ Root: string|function, props: object }} [root] - Use this to customize the root element. Default value: `{ Root: 'div' }`
|
|
45
|
-
* @example
|
|
46
|
-
* import React from 'react';
|
|
47
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
48
|
-
* import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
|
|
49
|
-
*
|
|
50
|
-
* const searchClient = algoliasearch(
|
|
51
|
-
* 'latency',
|
|
52
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
53
|
-
* );
|
|
54
|
-
*
|
|
55
|
-
* const App = () => (
|
|
56
|
-
* <InstantSearch
|
|
57
|
-
* searchClient={searchClient}
|
|
58
|
-
* indexName="instant_search"
|
|
59
|
-
* >
|
|
60
|
-
* <SearchBox />
|
|
61
|
-
* <Hits />
|
|
62
|
-
* </InstantSearch>
|
|
63
|
-
* );
|
|
64
|
-
*/
|
|
65
|
-
var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
66
|
-
_inherits(InstantSearch, _Component);
|
|
67
|
-
var _super = _createSuper(InstantSearch);
|
|
68
|
-
function InstantSearch(props) {
|
|
69
|
-
var _this;
|
|
70
|
-
_classCallCheck(this, InstantSearch);
|
|
71
|
-
_this = _super.call(this, props);
|
|
72
|
-
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
74
|
-
var instantSearchManager = createInstantSearchManager({
|
|
75
|
-
indexName: _this.props.indexName,
|
|
76
|
-
searchClient: _this.props.searchClient,
|
|
77
|
-
initialState: _this.props.searchState || {},
|
|
78
|
-
resultsState: _this.props.resultsState,
|
|
79
|
-
stalledSearchDelay: _this.props.stalledSearchDelay
|
|
80
|
-
});
|
|
81
|
-
var contextValue = {
|
|
82
|
-
store: instantSearchManager.store,
|
|
83
|
-
widgetsManager: instantSearchManager.widgetsManager,
|
|
84
|
-
mainTargetedIndex: _this.props.indexName,
|
|
85
|
-
onInternalStateUpdate: _this.onWidgetsInternalStateUpdate.bind(_assertThisInitialized(_this)),
|
|
86
|
-
createHrefForState: _this.createHrefForState.bind(_assertThisInitialized(_this)),
|
|
87
|
-
onSearchForFacetValues: _this.onSearchForFacetValues.bind(_assertThisInitialized(_this)),
|
|
88
|
-
onSearchStateChange: _this.onSearchStateChange.bind(_assertThisInitialized(_this)),
|
|
89
|
-
onSearchParameters: _this.onSearchParameters.bind(_assertThisInitialized(_this))
|
|
90
|
-
};
|
|
91
|
-
_this.state = {
|
|
92
|
-
isControlled: isControlled(_this.props),
|
|
93
|
-
instantSearchManager: instantSearchManager,
|
|
94
|
-
contextValue: contextValue
|
|
95
|
-
};
|
|
96
|
-
return _this;
|
|
97
|
-
}
|
|
98
|
-
_createClass(InstantSearch, [{
|
|
99
|
-
key: "componentDidUpdate",
|
|
100
|
-
value: function componentDidUpdate(prevProps) {
|
|
101
|
-
var prevIsControlled = isControlled(prevProps);
|
|
102
|
-
if (prevIsControlled && !this.state.isControlled) {
|
|
103
|
-
throw new Error("You can't switch <InstantSearch> from being controlled to uncontrolled");
|
|
104
|
-
}
|
|
105
|
-
if (!prevIsControlled && this.state.isControlled) {
|
|
106
|
-
throw new Error("You can't switch <InstantSearch> from being uncontrolled to controlled");
|
|
107
|
-
}
|
|
108
|
-
if (this.props.refresh !== prevProps.refresh && this.props.refresh) {
|
|
109
|
-
this.state.instantSearchManager.clearCache();
|
|
110
|
-
}
|
|
111
|
-
if (prevProps.indexName !== this.props.indexName) {
|
|
112
|
-
this.state.instantSearchManager.updateIndex(this.props.indexName);
|
|
113
|
-
}
|
|
114
|
-
if (prevProps.searchClient !== this.props.searchClient) {
|
|
115
|
-
this.state.instantSearchManager.updateClient(this.props.searchClient);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "componentDidMount",
|
|
120
|
-
value: function componentDidMount() {
|
|
121
|
-
if (this.cleanupTimerRef) {
|
|
122
|
-
clearTimeout(this.cleanupTimerRef);
|
|
123
|
-
this.cleanupTimerRef = null;
|
|
124
|
-
}
|
|
125
|
-
if (isMetadataEnabled()) {
|
|
126
|
-
injectMetadata(this.state.instantSearchManager.widgetsManager.getWidgets(), this.props.searchClient);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "componentWillUnmount",
|
|
131
|
-
value: function componentWillUnmount() {
|
|
132
|
-
var _this2 = this;
|
|
133
|
-
this.cleanupTimerRef = setTimeout(function () {
|
|
134
|
-
_this2.isUnmounting = true;
|
|
135
|
-
_this2.state.instantSearchManager.skipSearch();
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "createHrefForState",
|
|
140
|
-
value: function createHrefForState(searchState) {
|
|
141
|
-
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
142
|
-
return this.state.isControlled && this.props.createURL ? this.props.createURL(searchState, this.getKnownKeys()) : '#';
|
|
143
|
-
}
|
|
144
|
-
}, {
|
|
145
|
-
key: "onWidgetsInternalStateUpdate",
|
|
146
|
-
value: function onWidgetsInternalStateUpdate(searchState) {
|
|
147
|
-
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
148
|
-
this.onSearchStateChange(searchState);
|
|
149
|
-
if (!this.state.isControlled) {
|
|
150
|
-
this.state.instantSearchManager.onExternalStateUpdate(searchState);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "onSearchStateChange",
|
|
155
|
-
value: function onSearchStateChange(searchState) {
|
|
156
|
-
if (this.props.onSearchStateChange && !this.isUnmounting) {
|
|
157
|
-
this.props.onSearchStateChange(searchState);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "onSearchParameters",
|
|
162
|
-
value: function onSearchParameters(getSearchParameters, context, props, getMetadata, displayName) {
|
|
163
|
-
if (this.props.onSearchParameters) {
|
|
164
|
-
var _searchState = this.props.searchState ? this.props.searchState : {};
|
|
165
|
-
this.props.onSearchParameters(getSearchParameters, context, props, _searchState);
|
|
166
|
-
}
|
|
167
|
-
if (this.props.widgetsCollector) {
|
|
168
|
-
var _searchState2 = this.props.searchState ? this.props.searchState : {};
|
|
169
|
-
this.props.widgetsCollector({
|
|
170
|
-
getSearchParameters: getSearchParameters,
|
|
171
|
-
getMetadata: getMetadata,
|
|
172
|
-
context: context,
|
|
173
|
-
props: props,
|
|
174
|
-
searchState: _searchState2,
|
|
175
|
-
displayName: displayName
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
key: "onSearchForFacetValues",
|
|
181
|
-
value: function onSearchForFacetValues(searchState) {
|
|
182
|
-
this.state.instantSearchManager.onSearchForFacetValues(searchState);
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "getKnownKeys",
|
|
186
|
-
value: function getKnownKeys() {
|
|
187
|
-
return this.state.instantSearchManager.getWidgetsIds();
|
|
188
|
-
}
|
|
189
|
-
}, {
|
|
190
|
-
key: "render",
|
|
191
|
-
value: function render() {
|
|
192
|
-
if (Children.count(this.props.children) === 0) {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
return /*#__PURE__*/React.createElement(InstantSearchProvider, {
|
|
196
|
-
value: this.state.contextValue
|
|
197
|
-
}, this.props.children);
|
|
198
|
-
}
|
|
199
|
-
}], [{
|
|
200
|
-
key: "getDerivedStateFromProps",
|
|
201
|
-
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
202
|
-
var nextIsControlled = isControlled(nextProps);
|
|
203
|
-
var previousSearchState = prevState.instantSearchManager.store.getState().widgets;
|
|
204
|
-
var nextSearchState = nextProps.searchState;
|
|
205
|
-
if (nextIsControlled && !isEqual(previousSearchState, nextSearchState)) {
|
|
206
|
-
prevState.instantSearchManager.onExternalStateUpdate(nextProps.searchState);
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
isControlled: nextIsControlled,
|
|
210
|
-
contextValue: _objectSpread(_objectSpread({}, prevState.contextValue), {}, {
|
|
211
|
-
mainTargetedIndex: nextProps.indexName
|
|
212
|
-
})
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}]);
|
|
216
|
-
return InstantSearch;
|
|
217
|
-
}(Component);
|
|
218
|
-
_defineProperty(InstantSearch, "defaultProps", {
|
|
219
|
-
stalledSearchDelay: 200,
|
|
220
|
-
refresh: false
|
|
221
|
-
});
|
|
222
|
-
_defineProperty(InstantSearch, "propTypes", {
|
|
223
|
-
// @TODO: These props are currently constant.
|
|
224
|
-
indexName: PropTypes.string.isRequired,
|
|
225
|
-
searchClient: PropTypes.shape({
|
|
226
|
-
search: PropTypes.func.isRequired,
|
|
227
|
-
searchForFacetValues: PropTypes.func,
|
|
228
|
-
addAlgoliaAgent: PropTypes.func,
|
|
229
|
-
clearCache: PropTypes.func
|
|
230
|
-
}).isRequired,
|
|
231
|
-
createURL: PropTypes.func,
|
|
232
|
-
refresh: PropTypes.bool,
|
|
233
|
-
searchState: PropTypes.object,
|
|
234
|
-
onSearchStateChange: PropTypes.func,
|
|
235
|
-
onSearchParameters: PropTypes.func,
|
|
236
|
-
widgetsCollector: PropTypes.func,
|
|
237
|
-
resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
238
|
-
children: PropTypes.node,
|
|
239
|
-
stalledSearchDelay: PropTypes.number
|
|
240
|
-
});
|
|
241
|
-
export default InstantSearch;
|