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
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createConnectorWithoutContext = createConnectorWithoutContext;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
10
|
-
var _context = require("./context");
|
|
11
|
-
var _utils = require("./utils");
|
|
12
|
-
var _excluded = ["contextValue"];
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
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); }
|
|
17
|
-
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); }
|
|
18
|
-
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; }
|
|
19
|
-
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; }
|
|
20
|
-
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; }
|
|
21
|
-
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; }
|
|
22
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
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); } }
|
|
24
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
-
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); }
|
|
26
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
27
|
-
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); }; }
|
|
28
|
-
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); }
|
|
29
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
|
-
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; } }
|
|
31
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
32
|
-
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; }
|
|
33
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
34
|
-
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); }
|
|
35
|
-
/**
|
|
36
|
-
* Connectors are the HOC used to transform React components
|
|
37
|
-
* into InstantSearch widgets.
|
|
38
|
-
* In order to simplify the construction of such connectors
|
|
39
|
-
* `createConnector` takes a description and transform it into
|
|
40
|
-
* a connector.
|
|
41
|
-
* @param {ConnectorDescription} connectorDesc the description of the connector
|
|
42
|
-
* @return {Connector} a function that wraps a component into
|
|
43
|
-
* an instantsearch connected one.
|
|
44
|
-
*/
|
|
45
|
-
function createConnectorWithoutContext(connectorDesc) {
|
|
46
|
-
if (!connectorDesc.displayName) {
|
|
47
|
-
throw new Error('`createConnector` requires you to provide a `displayName` property.');
|
|
48
|
-
}
|
|
49
|
-
var isWidget = typeof connectorDesc.getSearchParameters === 'function' || typeof connectorDesc.getMetadata === 'function' || typeof connectorDesc.transitionState === 'function';
|
|
50
|
-
return function (Composed) {
|
|
51
|
-
var additionalWidgetProperties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
52
|
-
var Connector = /*#__PURE__*/function (_Component) {
|
|
53
|
-
_inherits(Connector, _Component);
|
|
54
|
-
var _super = _createSuper(Connector);
|
|
55
|
-
function Connector(props) {
|
|
56
|
-
var _this;
|
|
57
|
-
_classCallCheck(this, Connector);
|
|
58
|
-
_this = _super.call(this, props);
|
|
59
|
-
_defineProperty(_assertThisInitialized(_this), "unsubscribe", void 0);
|
|
60
|
-
_defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
|
|
61
|
-
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
62
|
-
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
63
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
64
|
-
providedProps: _this.getProvidedProps(_this.props)
|
|
65
|
-
});
|
|
66
|
-
_defineProperty(_assertThisInitialized(_this), "refine", function () {
|
|
67
|
-
var _ref;
|
|
68
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
69
|
-
args[_key] = arguments[_key];
|
|
70
|
-
}
|
|
71
|
-
_this.props.contextValue.onInternalStateUpdate(
|
|
72
|
-
// refine will always be defined here because the prop is only given conditionally
|
|
73
|
-
(_ref = connectorDesc.refine).call.apply(_ref, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
|
|
74
|
-
});
|
|
75
|
-
_defineProperty(_assertThisInitialized(_this), "createURL", function () {
|
|
76
|
-
var _ref2;
|
|
77
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
78
|
-
args[_key2] = arguments[_key2];
|
|
79
|
-
}
|
|
80
|
-
return _this.props.contextValue.createHrefForState(
|
|
81
|
-
// refine will always be defined here because the prop is only given conditionally
|
|
82
|
-
(_ref2 = connectorDesc.refine).call.apply(_ref2, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
|
|
83
|
-
});
|
|
84
|
-
_defineProperty(_assertThisInitialized(_this), "searchForFacetValues", function () {
|
|
85
|
-
var _ref3;
|
|
86
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
87
|
-
args[_key3] = arguments[_key3];
|
|
88
|
-
}
|
|
89
|
-
_this.props.contextValue.onSearchForFacetValues(
|
|
90
|
-
// searchForFacetValues will always be defined here because the prop is only given conditionally
|
|
91
|
-
(_ref3 = connectorDesc.searchForFacetValues).call.apply(_ref3, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
|
|
92
|
-
});
|
|
93
|
-
if (connectorDesc.getSearchParameters) {
|
|
94
|
-
_this.props.contextValue.onSearchParameters(connectorDesc.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
95
|
-
ais: _this.props.contextValue,
|
|
96
|
-
multiIndexContext: _this.props.indexContextValue
|
|
97
|
-
}, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind(_assertThisInitialized(_this)), connectorDesc.displayName);
|
|
98
|
-
}
|
|
99
|
-
return _this;
|
|
100
|
-
}
|
|
101
|
-
_createClass(Connector, [{
|
|
102
|
-
key: "componentDidMount",
|
|
103
|
-
value: function componentDidMount() {
|
|
104
|
-
var _this2 = this;
|
|
105
|
-
if (this.cleanupTimerRef) {
|
|
106
|
-
clearTimeout(this.cleanupTimerRef);
|
|
107
|
-
this.cleanupTimerRef = null;
|
|
108
|
-
}
|
|
109
|
-
this.unsubscribe = this.props.contextValue.store.subscribe(function () {
|
|
110
|
-
if (!_this2.isUnmounting) {
|
|
111
|
-
_this2.setState({
|
|
112
|
-
providedProps: _this2.getProvidedProps(_this2.props)
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
if (isWidget) {
|
|
117
|
-
this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(this);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "shouldComponentUpdate",
|
|
122
|
-
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
123
|
-
if (typeof connectorDesc.shouldComponentUpdate === 'function') {
|
|
124
|
-
return connectorDesc.shouldComponentUpdate.call(this, this.props, nextProps, this.state, nextState);
|
|
125
|
-
}
|
|
126
|
-
var propsEqual = (0, _utils.shallowEqual)(this.props, nextProps);
|
|
127
|
-
if (this.state.providedProps === null || nextState.providedProps === null) {
|
|
128
|
-
if (this.state.providedProps === nextState.providedProps) {
|
|
129
|
-
return !propsEqual;
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
return !propsEqual || !(0, _utils.shallowEqual)(this.state.providedProps, nextState.providedProps);
|
|
134
|
-
}
|
|
135
|
-
}, {
|
|
136
|
-
key: "componentDidUpdate",
|
|
137
|
-
value: function componentDidUpdate(prevProps) {
|
|
138
|
-
if (!(0, _reactFastCompare.default)(prevProps, this.props)) {
|
|
139
|
-
this.setState({
|
|
140
|
-
providedProps: this.getProvidedProps(this.props)
|
|
141
|
-
});
|
|
142
|
-
if (isWidget) {
|
|
143
|
-
this.props.contextValue.widgetsManager.update();
|
|
144
|
-
if (typeof connectorDesc.transitionState === 'function') {
|
|
145
|
-
this.props.contextValue.onSearchStateChange(connectorDesc.transitionState.call(this, this.props, this.props.contextValue.store.getState().widgets, this.props.contextValue.store.getState().widgets));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
key: "componentWillUnmount",
|
|
152
|
-
value: function componentWillUnmount() {
|
|
153
|
-
var _this3 = this;
|
|
154
|
-
this.cleanupTimerRef = setTimeout(function () {
|
|
155
|
-
_this3.isUnmounting = true;
|
|
156
|
-
if (_this3.unsubscribe) {
|
|
157
|
-
_this3.unsubscribe();
|
|
158
|
-
}
|
|
159
|
-
if (_this3.unregisterWidget) {
|
|
160
|
-
_this3.unregisterWidget();
|
|
161
|
-
if (typeof connectorDesc.cleanUp === 'function') {
|
|
162
|
-
var nextState = connectorDesc.cleanUp.call(_this3, _this3.props, _this3.props.contextValue.store.getState().widgets);
|
|
163
|
-
_this3.props.contextValue.store.setState(_objectSpread(_objectSpread({}, _this3.props.contextValue.store.getState()), {}, {
|
|
164
|
-
widgets: nextState
|
|
165
|
-
}));
|
|
166
|
-
_this3.props.contextValue.onSearchStateChange((0, _utils.removeEmptyKey)(nextState));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
key: "getProvidedProps",
|
|
173
|
-
value: function getProvidedProps(props) {
|
|
174
|
-
var _this$props$contextVa = this.props.contextValue.store.getState(),
|
|
175
|
-
widgets = _this$props$contextVa.widgets,
|
|
176
|
-
results = _this$props$contextVa.results,
|
|
177
|
-
resultsFacetValues = _this$props$contextVa.resultsFacetValues,
|
|
178
|
-
searching = _this$props$contextVa.searching,
|
|
179
|
-
searchingForFacetValues = _this$props$contextVa.searchingForFacetValues,
|
|
180
|
-
isSearchStalled = _this$props$contextVa.isSearchStalled,
|
|
181
|
-
metadata = _this$props$contextVa.metadata,
|
|
182
|
-
error = _this$props$contextVa.error;
|
|
183
|
-
var searchResults = {
|
|
184
|
-
results: results,
|
|
185
|
-
searching: searching,
|
|
186
|
-
searchingForFacetValues: searchingForFacetValues,
|
|
187
|
-
isSearchStalled: isSearchStalled,
|
|
188
|
-
error: error
|
|
189
|
-
};
|
|
190
|
-
return connectorDesc.getProvidedProps.call(this, props, widgets, searchResults, metadata,
|
|
191
|
-
// @MAJOR: move this attribute on the `searchResults` it doesn't
|
|
192
|
-
// makes sense to have it into a separate argument. The search
|
|
193
|
-
// flags are on the object why not the results?
|
|
194
|
-
resultsFacetValues);
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "getSearchParameters",
|
|
198
|
-
value: function getSearchParameters(searchParameters) {
|
|
199
|
-
if (typeof connectorDesc.getSearchParameters === 'function') {
|
|
200
|
-
return connectorDesc.getSearchParameters.call(this, searchParameters, this.props, this.props.contextValue.store.getState().widgets);
|
|
201
|
-
}
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
}, {
|
|
205
|
-
key: "getMetadata",
|
|
206
|
-
value: function getMetadata(nextWidgetsState) {
|
|
207
|
-
if (typeof connectorDesc.getMetadata === 'function') {
|
|
208
|
-
return connectorDesc.getMetadata.call(this, this.props, nextWidgetsState);
|
|
209
|
-
}
|
|
210
|
-
return {};
|
|
211
|
-
}
|
|
212
|
-
}, {
|
|
213
|
-
key: "transitionState",
|
|
214
|
-
value: function transitionState(prevWidgetsState, nextWidgetsState) {
|
|
215
|
-
if (typeof connectorDesc.transitionState === 'function') {
|
|
216
|
-
return connectorDesc.transitionState.call(this, this.props, prevWidgetsState, nextWidgetsState);
|
|
217
|
-
}
|
|
218
|
-
return nextWidgetsState;
|
|
219
|
-
}
|
|
220
|
-
}, {
|
|
221
|
-
key: "render",
|
|
222
|
-
value: function render() {
|
|
223
|
-
var _this$props = this.props,
|
|
224
|
-
contextValue = _this$props.contextValue,
|
|
225
|
-
props = _objectWithoutProperties(_this$props, _excluded);
|
|
226
|
-
var providedProps = this.state.providedProps;
|
|
227
|
-
if (providedProps === null) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
var refineProps = typeof connectorDesc.refine === 'function' ? {
|
|
231
|
-
refine: this.refine,
|
|
232
|
-
createURL: this.createURL
|
|
233
|
-
} : {};
|
|
234
|
-
var searchForFacetValuesProps = typeof connectorDesc.searchForFacetValues === 'function' ? {
|
|
235
|
-
searchForItems: this.searchForFacetValues
|
|
236
|
-
} : {};
|
|
237
|
-
return /*#__PURE__*/_react.default.createElement(Composed, _extends({}, props, providedProps, refineProps, searchForFacetValuesProps));
|
|
238
|
-
}
|
|
239
|
-
}]);
|
|
240
|
-
return Connector;
|
|
241
|
-
}(_react.Component);
|
|
242
|
-
_defineProperty(Connector, "displayName", "".concat(connectorDesc.displayName, "(").concat((0, _utils.getDisplayName)(Composed), ")"));
|
|
243
|
-
_defineProperty(Connector, "$$type", connectorDesc.$$type);
|
|
244
|
-
_defineProperty(Connector, "$$widgetType", additionalWidgetProperties.$$widgetType);
|
|
245
|
-
_defineProperty(Connector, "propTypes", connectorDesc.propTypes);
|
|
246
|
-
_defineProperty(Connector, "defaultProps", connectorDesc.defaultProps);
|
|
247
|
-
_defineProperty(Connector, "_connectorDesc", connectorDesc);
|
|
248
|
-
return Connector;
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
var createConnectorWithContext = function createConnectorWithContext(connectorDesc) {
|
|
252
|
-
return function (Composed, additionalWidgetProperties) {
|
|
253
|
-
var Connector = createConnectorWithoutContext(connectorDesc)(Composed, additionalWidgetProperties);
|
|
254
|
-
var ConnectorWrapper = function ConnectorWrapper(props) {
|
|
255
|
-
return /*#__PURE__*/_react.default.createElement(_context.InstantSearchConsumer, null, function (contextValue) {
|
|
256
|
-
return /*#__PURE__*/_react.default.createElement(_context.IndexConsumer, null, function (indexContextValue) {
|
|
257
|
-
return /*#__PURE__*/_react.default.createElement(Connector, _extends({
|
|
258
|
-
contextValue: contextValue,
|
|
259
|
-
indexContextValue: indexContextValue
|
|
260
|
-
}, props));
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
return ConnectorWrapper;
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
var _default = createConnectorWithContext;
|
|
268
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|