react-instantsearch-core 6.38.1 → 6.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -1
- package/dist/cjs/connectors/connectAutoComplete.js +14 -33
- package/dist/cjs/connectors/connectBreadcrumb.js +9 -22
- package/dist/cjs/connectors/connectConfigure.js +17 -26
- package/dist/cjs/connectors/connectConfigureRelatedItems.js +20 -33
- package/dist/cjs/connectors/connectCurrentRefinements.js +6 -13
- package/dist/cjs/connectors/connectDynamicWidgets.js +2 -13
- package/dist/cjs/connectors/connectGeoSearch.js +15 -34
- package/dist/cjs/connectors/connectHierarchicalMenu.js +22 -48
- package/dist/cjs/connectors/connectHighlight.js +8 -14
- package/dist/cjs/connectors/connectHitInsights.js +8 -20
- package/dist/cjs/connectors/connectHits.js +2 -11
- package/dist/cjs/connectors/connectHitsPerPage.js +8 -18
- package/dist/cjs/connectors/connectInfiniteHits.js +25 -43
- package/dist/cjs/connectors/connectMenu.js +14 -33
- package/dist/cjs/connectors/connectNumericMenu.js +24 -49
- package/dist/cjs/connectors/connectPagination.js +7 -17
- package/dist/cjs/connectors/connectPoweredBy.js +1 -5
- package/dist/cjs/connectors/connectQueryRules.js +11 -29
- package/dist/cjs/connectors/connectRange.js +33 -75
- package/dist/cjs/connectors/connectRefinementList.js +16 -34
- package/dist/cjs/connectors/connectRelevantSort.js +6 -13
- package/dist/cjs/connectors/connectScrollTo.js +6 -14
- package/dist/cjs/connectors/connectSearchBox.js +7 -17
- package/dist/cjs/connectors/connectSortBy.js +8 -18
- package/dist/cjs/connectors/connectStateResults.js +1 -6
- package/dist/cjs/connectors/connectStats.js +2 -8
- package/dist/cjs/connectors/connectToggleRefinement.js +14 -29
- package/dist/cjs/connectors/connectVoiceSearch.js +7 -24
- package/dist/cjs/core/context.js +3 -7
- package/dist/cjs/core/createConnector.js +60 -114
- package/dist/cjs/core/createInstantSearchManager.d.js +1 -0
- package/dist/cjs/core/createInstantSearchManager.js +67 -116
- package/dist/cjs/core/createStore.js +0 -1
- package/dist/cjs/core/createWidgetsManager.js +4 -7
- package/dist/cjs/core/highlight.js +11 -20
- package/dist/cjs/core/indexUtils.js +34 -77
- package/dist/cjs/core/metadata.js +7 -15
- package/dist/cjs/core/translatable.js +19 -46
- package/dist/cjs/core/utils.js +14 -52
- package/dist/cjs/core/version.js +1 -1
- package/dist/cjs/index.js +9 -44
- package/dist/cjs/types/index.js +0 -2
- package/dist/cjs/widgets/Configure.js +1 -5
- package/dist/cjs/widgets/ConfigureRelatedItems.js +1 -8
- package/dist/cjs/widgets/DynamicWidgets.js +12 -33
- package/dist/cjs/widgets/Index.js +26 -52
- package/dist/cjs/widgets/InstantSearch.js +28 -67
- package/dist/cjs/widgets/QueryRuleContext.js +1 -5
- package/dist/es/connectors/connectAutoComplete.js +11 -25
- package/dist/es/connectors/connectBreadcrumb.js +7 -13
- package/dist/es/connectors/connectConfigure.js +13 -22
- package/dist/es/connectors/connectConfigureRelatedItems.js +17 -25
- package/dist/es/connectors/connectCurrentRefinements.js +5 -7
- package/dist/es/connectors/connectDynamicWidgets.js +1 -6
- package/dist/es/connectors/connectGeoSearch.js +14 -27
- package/dist/es/connectors/connectHierarchicalMenu.js +19 -38
- package/dist/es/connectors/connectHighlight.js +7 -9
- package/dist/es/connectors/connectHitInsights.js +7 -14
- package/dist/es/connectors/connectHits.js +2 -5
- package/dist/es/connectors/connectHitsPerPage.js +5 -12
- package/dist/es/connectors/connectInfiniteHits.js +21 -31
- package/dist/es/connectors/connectMenu.js +12 -25
- package/dist/es/connectors/connectNumericMenu.js +22 -40
- package/dist/es/connectors/connectPagination.js +5 -12
- package/dist/es/connectors/connectPoweredBy.js +1 -1
- package/dist/es/connectors/connectQueryRules.js +9 -20
- package/dist/es/connectors/connectRange.js +31 -68
- package/dist/es/connectors/connectRefinementList.js +14 -24
- package/dist/es/connectors/connectRelevantSort.js +7 -8
- package/dist/es/connectors/connectScrollTo.js +6 -7
- package/dist/es/connectors/connectSearchBox.js +5 -11
- package/dist/es/connectors/connectSortBy.js +5 -12
- package/dist/es/connectors/connectStateResults.js +1 -1
- package/dist/es/connectors/connectStats.js +2 -3
- package/dist/es/connectors/connectToggleRefinement.js +12 -22
- package/dist/es/connectors/connectVoiceSearch.js +4 -16
- package/dist/es/core/context.js +3 -5
- package/dist/es/core/createConnector.js +33 -86
- package/dist/es/core/createInstantSearchManager.d.js +0 -0
- package/dist/es/core/createInstantSearchManager.js +59 -100
- package/dist/es/core/createWidgetsManager.js +4 -5
- package/dist/es/core/highlight.js +11 -17
- package/dist/es/core/indexUtils.js +27 -62
- package/dist/es/core/metadata.js +6 -8
- package/dist/es/core/translatable.js +13 -29
- package/dist/es/core/utils.js +12 -29
- package/dist/es/core/version.js +1 -1
- package/dist/es/index.js +39 -6
- package/dist/es/widgets/Configure.js +1 -0
- package/dist/es/widgets/ConfigureRelatedItems.js +0 -2
- package/dist/es/widgets/DynamicWidgets.js +9 -18
- package/dist/es/widgets/Index.js +13 -31
- package/dist/es/widgets/InstantSearch.js +13 -42
- package/dist/umd/ReactInstantSearchCore.js +507 -1078
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +2 -2
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +7 -5
|
@@ -1,55 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports.createConnectorWithoutContext = createConnectorWithoutContext;
|
|
11
7
|
exports.default = void 0;
|
|
12
|
-
|
|
13
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
-
|
|
15
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
16
|
-
|
|
17
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
-
|
|
19
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
20
|
-
|
|
21
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
22
|
-
|
|
23
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
24
|
-
|
|
25
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
26
|
-
|
|
27
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
28
|
-
|
|
29
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
30
|
-
|
|
31
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
32
|
-
|
|
33
9
|
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
34
|
-
|
|
35
10
|
var _utils = require("./utils");
|
|
36
|
-
|
|
37
11
|
var _context = require("./context");
|
|
38
|
-
|
|
39
12
|
var _excluded = ["contextValue"];
|
|
40
|
-
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
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); }
|
|
42
|
-
|
|
43
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; }
|
|
44
|
-
|
|
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; }
|
|
45
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; }
|
|
46
|
-
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
function
|
|
50
|
-
|
|
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; }
|
|
51
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; } }
|
|
52
|
-
|
|
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); }
|
|
53
35
|
/**
|
|
54
36
|
* Connectors are the HOC used to transform React components
|
|
55
37
|
* into InstantSearch widgets.
|
|
@@ -64,79 +46,66 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
64
46
|
if (!connectorDesc.displayName) {
|
|
65
47
|
throw new Error('`createConnector` requires you to provide a `displayName` property.');
|
|
66
48
|
}
|
|
67
|
-
|
|
68
49
|
var isWidget = typeof connectorDesc.getSearchParameters === 'function' || typeof connectorDesc.getMetadata === 'function' || typeof connectorDesc.transitionState === 'function';
|
|
69
50
|
return function (Composed) {
|
|
70
51
|
var additionalWidgetProperties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
-
|
|
72
52
|
var Connector = /*#__PURE__*/function (_Component) {
|
|
73
|
-
(
|
|
74
|
-
|
|
53
|
+
_inherits(Connector, _Component);
|
|
75
54
|
var _super = _createSuper(Connector);
|
|
76
|
-
|
|
77
55
|
function Connector(props) {
|
|
78
56
|
var _this;
|
|
79
|
-
|
|
80
|
-
(0, _classCallCheck2.default)(this, Connector);
|
|
57
|
+
_classCallCheck(this, Connector);
|
|
81
58
|
_this = _super.call(this, props);
|
|
82
|
-
(
|
|
83
|
-
(
|
|
84
|
-
(
|
|
85
|
-
(
|
|
86
|
-
(
|
|
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", {
|
|
87
64
|
providedProps: _this.getProvidedProps(_this.props)
|
|
88
65
|
});
|
|
89
|
-
(
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "refine", function () {
|
|
90
67
|
var _ref;
|
|
91
|
-
|
|
92
68
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
93
69
|
args[_key] = arguments[_key];
|
|
94
70
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
(_ref = connectorDesc.refine).call.apply(_ref, [(
|
|
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)));
|
|
98
74
|
});
|
|
99
|
-
(
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "createURL", function () {
|
|
100
76
|
var _ref2;
|
|
101
|
-
|
|
102
77
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
103
78
|
args[_key2] = arguments[_key2];
|
|
104
79
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
(_ref2 = connectorDesc.refine).call.apply(_ref2, [(
|
|
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)));
|
|
108
83
|
});
|
|
109
|
-
(
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "searchForFacetValues", function () {
|
|
110
85
|
var _ref3;
|
|
111
|
-
|
|
112
86
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
113
87
|
args[_key3] = arguments[_key3];
|
|
114
88
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
(_ref3 = connectorDesc.searchForFacetValues).call.apply(_ref3, [(
|
|
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)));
|
|
118
92
|
});
|
|
119
|
-
|
|
120
93
|
if (connectorDesc.getSearchParameters) {
|
|
121
|
-
_this.props.contextValue.onSearchParameters(connectorDesc.getSearchParameters.bind((
|
|
94
|
+
_this.props.contextValue.onSearchParameters(connectorDesc.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
122
95
|
ais: _this.props.contextValue,
|
|
123
96
|
multiIndexContext: _this.props.indexContextValue
|
|
124
|
-
}, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind((
|
|
97
|
+
}, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind(_assertThisInitialized(_this)), connectorDesc.displayName);
|
|
125
98
|
}
|
|
126
|
-
|
|
127
99
|
return _this;
|
|
128
100
|
}
|
|
129
|
-
|
|
130
|
-
(0, _createClass2.default)(Connector, [{
|
|
101
|
+
_createClass(Connector, [{
|
|
131
102
|
key: "componentDidMount",
|
|
132
103
|
value: function componentDidMount() {
|
|
133
104
|
var _this2 = this;
|
|
134
|
-
|
|
135
105
|
if (this.cleanupTimerRef) {
|
|
136
106
|
clearTimeout(this.cleanupTimerRef);
|
|
137
107
|
this.cleanupTimerRef = null;
|
|
138
108
|
}
|
|
139
|
-
|
|
140
109
|
this.unsubscribe = this.props.contextValue.store.subscribe(function () {
|
|
141
110
|
if (!_this2.isUnmounting) {
|
|
142
111
|
_this2.setState({
|
|
@@ -144,7 +113,6 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
144
113
|
});
|
|
145
114
|
}
|
|
146
115
|
});
|
|
147
|
-
|
|
148
116
|
if (isWidget) {
|
|
149
117
|
this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(this);
|
|
150
118
|
}
|
|
@@ -155,17 +123,13 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
155
123
|
if (typeof connectorDesc.shouldComponentUpdate === 'function') {
|
|
156
124
|
return connectorDesc.shouldComponentUpdate.call(this, this.props, nextProps, this.state, nextState);
|
|
157
125
|
}
|
|
158
|
-
|
|
159
126
|
var propsEqual = (0, _utils.shallowEqual)(this.props, nextProps);
|
|
160
|
-
|
|
161
127
|
if (this.state.providedProps === null || nextState.providedProps === null) {
|
|
162
128
|
if (this.state.providedProps === nextState.providedProps) {
|
|
163
129
|
return !propsEqual;
|
|
164
130
|
}
|
|
165
|
-
|
|
166
131
|
return true;
|
|
167
132
|
}
|
|
168
|
-
|
|
169
133
|
return !propsEqual || !(0, _utils.shallowEqual)(this.state.providedProps, nextState.providedProps);
|
|
170
134
|
}
|
|
171
135
|
}, {
|
|
@@ -175,10 +139,8 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
175
139
|
this.setState({
|
|
176
140
|
providedProps: this.getProvidedProps(this.props)
|
|
177
141
|
});
|
|
178
|
-
|
|
179
142
|
if (isWidget) {
|
|
180
143
|
this.props.contextValue.widgetsManager.update();
|
|
181
|
-
|
|
182
144
|
if (typeof connectorDesc.transitionState === 'function') {
|
|
183
145
|
this.props.contextValue.onSearchStateChange(connectorDesc.transitionState.call(this, this.props, this.props.contextValue.store.getState().widgets, this.props.contextValue.store.getState().widgets));
|
|
184
146
|
}
|
|
@@ -189,24 +151,18 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
189
151
|
key: "componentWillUnmount",
|
|
190
152
|
value: function componentWillUnmount() {
|
|
191
153
|
var _this3 = this;
|
|
192
|
-
|
|
193
154
|
this.cleanupTimerRef = setTimeout(function () {
|
|
194
155
|
_this3.isUnmounting = true;
|
|
195
|
-
|
|
196
156
|
if (_this3.unsubscribe) {
|
|
197
157
|
_this3.unsubscribe();
|
|
198
158
|
}
|
|
199
|
-
|
|
200
159
|
if (_this3.unregisterWidget) {
|
|
201
160
|
_this3.unregisterWidget();
|
|
202
|
-
|
|
203
161
|
if (typeof connectorDesc.cleanUp === 'function') {
|
|
204
162
|
var nextState = connectorDesc.cleanUp.call(_this3, _this3.props, _this3.props.contextValue.store.getState().widgets);
|
|
205
|
-
|
|
206
163
|
_this3.props.contextValue.store.setState(_objectSpread(_objectSpread({}, _this3.props.contextValue.store.getState()), {}, {
|
|
207
164
|
widgets: nextState
|
|
208
165
|
}));
|
|
209
|
-
|
|
210
166
|
_this3.props.contextValue.onSearchStateChange((0, _utils.removeEmptyKey)(nextState));
|
|
211
167
|
}
|
|
212
168
|
}
|
|
@@ -216,15 +172,14 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
216
172
|
key: "getProvidedProps",
|
|
217
173
|
value: function getProvidedProps(props) {
|
|
218
174
|
var _this$props$contextVa = this.props.contextValue.store.getState(),
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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;
|
|
228
183
|
var searchResults = {
|
|
229
184
|
results: results,
|
|
230
185
|
searching: searching,
|
|
@@ -232,7 +187,8 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
232
187
|
isSearchStalled: isSearchStalled,
|
|
233
188
|
error: error
|
|
234
189
|
};
|
|
235
|
-
return connectorDesc.getProvidedProps.call(this, props, widgets, searchResults, metadata,
|
|
190
|
+
return connectorDesc.getProvidedProps.call(this, props, widgets, searchResults, metadata,
|
|
191
|
+
// @MAJOR: move this attribute on the `searchResults` it doesn't
|
|
236
192
|
// makes sense to have it into a separate argument. The search
|
|
237
193
|
// flags are on the object why not the results?
|
|
238
194
|
resultsFacetValues);
|
|
@@ -243,7 +199,6 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
243
199
|
if (typeof connectorDesc.getSearchParameters === 'function') {
|
|
244
200
|
return connectorDesc.getSearchParameters.call(this, searchParameters, this.props, this.props.contextValue.store.getState().widgets);
|
|
245
201
|
}
|
|
246
|
-
|
|
247
202
|
return null;
|
|
248
203
|
}
|
|
249
204
|
}, {
|
|
@@ -252,7 +207,6 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
252
207
|
if (typeof connectorDesc.getMetadata === 'function') {
|
|
253
208
|
return connectorDesc.getMetadata.call(this, this.props, nextWidgetsState);
|
|
254
209
|
}
|
|
255
|
-
|
|
256
210
|
return {};
|
|
257
211
|
}
|
|
258
212
|
}, {
|
|
@@ -261,21 +215,18 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
261
215
|
if (typeof connectorDesc.transitionState === 'function') {
|
|
262
216
|
return connectorDesc.transitionState.call(this, this.props, prevWidgetsState, nextWidgetsState);
|
|
263
217
|
}
|
|
264
|
-
|
|
265
218
|
return nextWidgetsState;
|
|
266
219
|
}
|
|
267
220
|
}, {
|
|
268
221
|
key: "render",
|
|
269
222
|
value: function render() {
|
|
270
223
|
var _this$props = this.props,
|
|
271
|
-
|
|
272
|
-
|
|
224
|
+
contextValue = _this$props.contextValue,
|
|
225
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
273
226
|
var providedProps = this.state.providedProps;
|
|
274
|
-
|
|
275
227
|
if (providedProps === null) {
|
|
276
228
|
return null;
|
|
277
229
|
}
|
|
278
|
-
|
|
279
230
|
var refineProps = typeof connectorDesc.refine === 'function' ? {
|
|
280
231
|
refine: this.refine,
|
|
281
232
|
createURL: this.createURL
|
|
@@ -283,40 +234,35 @@ function createConnectorWithoutContext(connectorDesc) {
|
|
|
283
234
|
var searchForFacetValuesProps = typeof connectorDesc.searchForFacetValues === 'function' ? {
|
|
284
235
|
searchForItems: this.searchForFacetValues
|
|
285
236
|
} : {};
|
|
286
|
-
return /*#__PURE__*/_react.default.createElement(Composed, (
|
|
237
|
+
return /*#__PURE__*/_react.default.createElement(Composed, _extends({}, props, providedProps, refineProps, searchForFacetValuesProps));
|
|
287
238
|
}
|
|
288
239
|
}]);
|
|
289
240
|
return Connector;
|
|
290
241
|
}(_react.Component);
|
|
291
|
-
|
|
292
|
-
(
|
|
293
|
-
(
|
|
294
|
-
(
|
|
295
|
-
(
|
|
296
|
-
(
|
|
297
|
-
(0, _defineProperty2.default)(Connector, "_connectorDesc", connectorDesc);
|
|
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);
|
|
298
248
|
return Connector;
|
|
299
249
|
};
|
|
300
250
|
}
|
|
301
|
-
|
|
302
251
|
var createConnectorWithContext = function createConnectorWithContext(connectorDesc) {
|
|
303
252
|
return function (Composed, additionalWidgetProperties) {
|
|
304
253
|
var Connector = createConnectorWithoutContext(connectorDesc)(Composed, additionalWidgetProperties);
|
|
305
|
-
|
|
306
254
|
var ConnectorWrapper = function ConnectorWrapper(props) {
|
|
307
255
|
return /*#__PURE__*/_react.default.createElement(_context.InstantSearchConsumer, null, function (contextValue) {
|
|
308
256
|
return /*#__PURE__*/_react.default.createElement(_context.IndexConsumer, null, function (indexContextValue) {
|
|
309
|
-
return /*#__PURE__*/_react.default.createElement(Connector, (
|
|
257
|
+
return /*#__PURE__*/_react.default.createElement(Connector, _extends({
|
|
310
258
|
contextValue: contextValue,
|
|
311
259
|
indexContextValue: indexContextValue
|
|
312
260
|
}, props));
|
|
313
261
|
});
|
|
314
262
|
});
|
|
315
263
|
};
|
|
316
|
-
|
|
317
264
|
return ConnectorWrapper;
|
|
318
265
|
};
|
|
319
266
|
};
|
|
320
|
-
|
|
321
267
|
var _default = createConnectorWithContext;
|
|
322
268
|
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|