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,38 @@
|
|
|
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.default = void 0;
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
-
|
|
28
8
|
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
29
|
-
|
|
30
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
10
|
var _createInstantSearchManager = _interopRequireDefault(require("../core/createInstantSearchManager"));
|
|
33
|
-
|
|
34
11
|
var _context = require("../core/context");
|
|
35
|
-
|
|
36
12
|
var _metadata = require("../core/metadata");
|
|
37
|
-
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
38
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); }
|
|
39
|
-
|
|
40
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; }
|
|
41
|
-
|
|
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); }
|
|
42
17
|
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; }
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
|
|
18
|
+
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; }
|
|
19
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
+
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); } }
|
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
|
+
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); }
|
|
23
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
|
+
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); }; }
|
|
25
|
+
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); }
|
|
26
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
48
27
|
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; } }
|
|
49
|
-
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
+
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; }
|
|
30
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
31
|
+
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); }
|
|
50
32
|
function isControlled(props) {
|
|
51
33
|
return Boolean(props.searchState);
|
|
52
34
|
}
|
|
35
|
+
|
|
53
36
|
/**
|
|
54
37
|
* @description
|
|
55
38
|
* `<InstantSearch>` is the root component of all React InstantSearch implementations.
|
|
@@ -88,20 +71,15 @@ function isControlled(props) {
|
|
|
88
71
|
* </InstantSearch>
|
|
89
72
|
* );
|
|
90
73
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
74
|
var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
94
|
-
(
|
|
95
|
-
|
|
75
|
+
_inherits(InstantSearch, _Component);
|
|
96
76
|
var _super = _createSuper(InstantSearch);
|
|
97
|
-
|
|
98
77
|
function InstantSearch(props) {
|
|
99
78
|
var _this;
|
|
100
|
-
|
|
101
|
-
(0, _classCallCheck2.default)(this, InstantSearch);
|
|
79
|
+
_classCallCheck(this, InstantSearch);
|
|
102
80
|
_this = _super.call(this, props);
|
|
103
|
-
(
|
|
104
|
-
(
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
105
83
|
var instantSearchManager = (0, _createInstantSearchManager.default)({
|
|
106
84
|
indexName: _this.props.indexName,
|
|
107
85
|
searchClient: _this.props.searchClient,
|
|
@@ -113,11 +91,11 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
113
91
|
store: instantSearchManager.store,
|
|
114
92
|
widgetsManager: instantSearchManager.widgetsManager,
|
|
115
93
|
mainTargetedIndex: _this.props.indexName,
|
|
116
|
-
onInternalStateUpdate: _this.onWidgetsInternalStateUpdate.bind((
|
|
117
|
-
createHrefForState: _this.createHrefForState.bind((
|
|
118
|
-
onSearchForFacetValues: _this.onSearchForFacetValues.bind((
|
|
119
|
-
onSearchStateChange: _this.onSearchStateChange.bind((
|
|
120
|
-
onSearchParameters: _this.onSearchParameters.bind((
|
|
94
|
+
onInternalStateUpdate: _this.onWidgetsInternalStateUpdate.bind(_assertThisInitialized(_this)),
|
|
95
|
+
createHrefForState: _this.createHrefForState.bind(_assertThisInitialized(_this)),
|
|
96
|
+
onSearchForFacetValues: _this.onSearchForFacetValues.bind(_assertThisInitialized(_this)),
|
|
97
|
+
onSearchStateChange: _this.onSearchStateChange.bind(_assertThisInitialized(_this)),
|
|
98
|
+
onSearchParameters: _this.onSearchParameters.bind(_assertThisInitialized(_this))
|
|
121
99
|
};
|
|
122
100
|
_this.state = {
|
|
123
101
|
isControlled: isControlled(_this.props),
|
|
@@ -126,28 +104,22 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
126
104
|
};
|
|
127
105
|
return _this;
|
|
128
106
|
}
|
|
129
|
-
|
|
130
|
-
(0, _createClass2.default)(InstantSearch, [{
|
|
107
|
+
_createClass(InstantSearch, [{
|
|
131
108
|
key: "componentDidUpdate",
|
|
132
109
|
value: function componentDidUpdate(prevProps) {
|
|
133
110
|
var prevIsControlled = isControlled(prevProps);
|
|
134
|
-
|
|
135
111
|
if (prevIsControlled && !this.state.isControlled) {
|
|
136
112
|
throw new Error("You can't switch <InstantSearch> from being controlled to uncontrolled");
|
|
137
113
|
}
|
|
138
|
-
|
|
139
114
|
if (!prevIsControlled && this.state.isControlled) {
|
|
140
115
|
throw new Error("You can't switch <InstantSearch> from being uncontrolled to controlled");
|
|
141
116
|
}
|
|
142
|
-
|
|
143
117
|
if (this.props.refresh !== prevProps.refresh && this.props.refresh) {
|
|
144
118
|
this.state.instantSearchManager.clearCache();
|
|
145
119
|
}
|
|
146
|
-
|
|
147
120
|
if (prevProps.indexName !== this.props.indexName) {
|
|
148
121
|
this.state.instantSearchManager.updateIndex(this.props.indexName);
|
|
149
122
|
}
|
|
150
|
-
|
|
151
123
|
if (prevProps.searchClient !== this.props.searchClient) {
|
|
152
124
|
this.state.instantSearchManager.updateClient(this.props.searchClient);
|
|
153
125
|
}
|
|
@@ -159,7 +131,6 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
159
131
|
clearTimeout(this.cleanupTimerRef);
|
|
160
132
|
this.cleanupTimerRef = null;
|
|
161
133
|
}
|
|
162
|
-
|
|
163
134
|
if ((0, _metadata.isMetadataEnabled)()) {
|
|
164
135
|
(0, _metadata.injectMetadata)(this.state.instantSearchManager.widgetsManager.getWidgets(), this.props.searchClient);
|
|
165
136
|
}
|
|
@@ -168,10 +139,8 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
168
139
|
key: "componentWillUnmount",
|
|
169
140
|
value: function componentWillUnmount() {
|
|
170
141
|
var _this2 = this;
|
|
171
|
-
|
|
172
142
|
this.cleanupTimerRef = setTimeout(function () {
|
|
173
143
|
_this2.isUnmounting = true;
|
|
174
|
-
|
|
175
144
|
_this2.state.instantSearchManager.skipSearch();
|
|
176
145
|
});
|
|
177
146
|
}
|
|
@@ -186,7 +155,6 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
186
155
|
value: function onWidgetsInternalStateUpdate(searchState) {
|
|
187
156
|
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
188
157
|
this.onSearchStateChange(searchState);
|
|
189
|
-
|
|
190
158
|
if (!this.state.isControlled) {
|
|
191
159
|
this.state.instantSearchManager.onExternalStateUpdate(searchState);
|
|
192
160
|
}
|
|
@@ -203,13 +171,10 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
203
171
|
value: function onSearchParameters(getSearchParameters, context, props, getMetadata, displayName) {
|
|
204
172
|
if (this.props.onSearchParameters) {
|
|
205
173
|
var _searchState = this.props.searchState ? this.props.searchState : {};
|
|
206
|
-
|
|
207
174
|
this.props.onSearchParameters(getSearchParameters, context, props, _searchState);
|
|
208
175
|
}
|
|
209
|
-
|
|
210
176
|
if (this.props.widgetsCollector) {
|
|
211
177
|
var _searchState2 = this.props.searchState ? this.props.searchState : {};
|
|
212
|
-
|
|
213
178
|
this.props.widgetsCollector({
|
|
214
179
|
getSearchParameters: getSearchParameters,
|
|
215
180
|
getMetadata: getMetadata,
|
|
@@ -236,7 +201,6 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
236
201
|
if (_react.Children.count(this.props.children) === 0) {
|
|
237
202
|
return null;
|
|
238
203
|
}
|
|
239
|
-
|
|
240
204
|
return /*#__PURE__*/_react.default.createElement(_context.InstantSearchProvider, {
|
|
241
205
|
value: this.state.contextValue
|
|
242
206
|
}, this.props.children);
|
|
@@ -247,11 +211,9 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
247
211
|
var nextIsControlled = isControlled(nextProps);
|
|
248
212
|
var previousSearchState = prevState.instantSearchManager.store.getState().widgets;
|
|
249
213
|
var nextSearchState = nextProps.searchState;
|
|
250
|
-
|
|
251
214
|
if (nextIsControlled && !(0, _reactFastCompare.default)(previousSearchState, nextSearchState)) {
|
|
252
215
|
prevState.instantSearchManager.onExternalStateUpdate(nextProps.searchState);
|
|
253
216
|
}
|
|
254
|
-
|
|
255
217
|
return {
|
|
256
218
|
isControlled: nextIsControlled,
|
|
257
219
|
contextValue: _objectSpread(_objectSpread({}, prevState.contextValue), {}, {
|
|
@@ -262,12 +224,11 @@ var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
|
262
224
|
}]);
|
|
263
225
|
return InstantSearch;
|
|
264
226
|
}(_react.Component);
|
|
265
|
-
|
|
266
|
-
(0, _defineProperty2.default)(InstantSearch, "defaultProps", {
|
|
227
|
+
_defineProperty(InstantSearch, "defaultProps", {
|
|
267
228
|
stalledSearchDelay: 200,
|
|
268
229
|
refresh: false
|
|
269
230
|
});
|
|
270
|
-
(
|
|
231
|
+
_defineProperty(InstantSearch, "propTypes", {
|
|
271
232
|
// @TODO: These props are currently constant.
|
|
272
233
|
indexName: _propTypes.default.string.isRequired,
|
|
273
234
|
searchClient: _propTypes.default.shape({
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
|
-
|
|
10
7
|
var _connectQueryRules = _interopRequireDefault(require("../connectors/connectQueryRules"));
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
9
|
var _default = (0, _connectQueryRules.default)(function QueryRuleContext() {
|
|
13
10
|
return null;
|
|
14
11
|
}, {
|
|
15
12
|
$$widgetType: 'ais.queryRuleContext'
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
exports.default = _default;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
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); }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
3
11
|
import createConnector from "../core/createConnector.js";
|
|
4
12
|
import { cleanUpValue, refineValue, getCurrentRefinementValue } from "../core/indexUtils.js";
|
|
5
13
|
import { addQueryID, addAbsolutePositions } from "../core/utils.js";
|
|
6
|
-
|
|
7
14
|
var getId = function getId() {
|
|
8
15
|
return 'query';
|
|
9
16
|
};
|
|
10
|
-
|
|
11
17
|
function getCurrentRefinement(props, searchState, context) {
|
|
12
18
|
var id = getId();
|
|
13
19
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
14
|
-
|
|
15
20
|
if (currentRefinement) {
|
|
16
21
|
return currentRefinement;
|
|
17
22
|
}
|
|
18
|
-
|
|
19
23
|
return '';
|
|
20
24
|
}
|
|
21
|
-
|
|
22
25
|
function getHits(searchResults) {
|
|
23
26
|
if (searchResults.results) {
|
|
24
27
|
if (searchResults.results.hits && Array.isArray(searchResults.results.hits)) {
|
|
@@ -35,19 +38,16 @@ function getHits(searchResults) {
|
|
|
35
38
|
return [];
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
|
|
39
41
|
function _refine(props, searchState, nextRefinement, context) {
|
|
40
42
|
var id = getId();
|
|
41
|
-
|
|
42
43
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
43
|
-
|
|
44
44
|
var resetPage = true;
|
|
45
45
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
46
46
|
}
|
|
47
|
-
|
|
48
47
|
function _cleanUp(props, searchState, context) {
|
|
49
48
|
return cleanUpValue(searchState, context, getId());
|
|
50
49
|
}
|
|
50
|
+
|
|
51
51
|
/**
|
|
52
52
|
* connectAutoComplete connector provides the logic to create connected
|
|
53
53
|
* components that will render the results retrieved from
|
|
@@ -63,8 +63,6 @@ function _cleanUp(props, searchState, context) {
|
|
|
63
63
|
* @providedPropType {function} refine - a function to change the query
|
|
64
64
|
* @providedPropType {string} currentRefinement - the query to search for
|
|
65
65
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
66
|
export default createConnector({
|
|
69
67
|
displayName: 'AlgoliaAutoComplete',
|
|
70
68
|
$$type: 'ais.autoComplete',
|
|
@@ -89,18 +87,6 @@ export default createConnector({
|
|
|
89
87
|
multiIndexContext: props.indexContextValue
|
|
90
88
|
});
|
|
91
89
|
},
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* AutoComplete needs to be considered as a widget to trigger a search,
|
|
95
|
-
* even if no other widgets are used.
|
|
96
|
-
*
|
|
97
|
-
* To be considered as a widget you need either:
|
|
98
|
-
* - getSearchParameters
|
|
99
|
-
* - getMetadata
|
|
100
|
-
* - transitionState
|
|
101
|
-
*
|
|
102
|
-
* See: createConnector.tsx
|
|
103
|
-
*/
|
|
104
90
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
105
91
|
return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
|
|
106
92
|
ais: props.contextValue,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
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); }
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import createConnector from "../core/createConnector.js";
|
|
4
7
|
import { refineValue, getResults } from "../core/indexUtils.js";
|
|
@@ -6,16 +9,12 @@ export var getId = function getId(props) {
|
|
|
6
9
|
return props.attributes[0];
|
|
7
10
|
};
|
|
8
11
|
var namespace = 'hierarchicalMenu';
|
|
9
|
-
|
|
10
12
|
function _refine(props, searchState, nextRefinement, context) {
|
|
11
13
|
var id = getId(props);
|
|
12
|
-
|
|
13
14
|
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
14
|
-
|
|
15
15
|
var resetPage = true;
|
|
16
16
|
return refineValue(searchState, nextValue, context, resetPage, namespace);
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
function transformValue(values) {
|
|
20
19
|
return values.reduce(function (acc, item) {
|
|
21
20
|
if (item.isRefined) {
|
|
@@ -24,16 +23,16 @@ function transformValue(values) {
|
|
|
24
23
|
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
|
|
25
24
|
// If dealing with the first level, "value" is equal to the current value
|
|
26
25
|
value: item.escapedValue
|
|
27
|
-
});
|
|
28
|
-
|
|
26
|
+
});
|
|
27
|
+
// Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
|
|
29
28
|
if (item.data) {
|
|
30
29
|
acc = acc.concat(transformValue(item.data, acc));
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
|
|
34
32
|
return acc;
|
|
35
33
|
}, []);
|
|
36
34
|
}
|
|
35
|
+
|
|
37
36
|
/**
|
|
38
37
|
* The breadcrumb component is s a type of secondary navigation scheme that
|
|
39
38
|
* reveals the user’s location in a website or web application.
|
|
@@ -71,7 +70,6 @@ function transformValue(values) {
|
|
|
71
70
|
* @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.
|
|
72
71
|
*/
|
|
73
72
|
|
|
74
|
-
|
|
75
73
|
export default createConnector({
|
|
76
74
|
displayName: 'AlgoliaBreadcrumb',
|
|
77
75
|
$$type: 'ais.breadcrumb',
|
|
@@ -80,11 +78,9 @@ export default createConnector({
|
|
|
80
78
|
var isNotString = function isNotString(val) {
|
|
81
79
|
return typeof val !== 'string';
|
|
82
80
|
};
|
|
83
|
-
|
|
84
81
|
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
85
82
|
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
86
83
|
}
|
|
87
|
-
|
|
88
84
|
return undefined;
|
|
89
85
|
},
|
|
90
86
|
transformItems: PropTypes.func
|
|
@@ -96,14 +92,12 @@ export default createConnector({
|
|
|
96
92
|
multiIndexContext: props.indexContextValue
|
|
97
93
|
});
|
|
98
94
|
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
99
|
-
|
|
100
95
|
if (!isFacetPresent) {
|
|
101
96
|
return {
|
|
102
97
|
items: [],
|
|
103
98
|
canRefine: false
|
|
104
99
|
};
|
|
105
100
|
}
|
|
106
|
-
|
|
107
101
|
var values = results.getFacetValues(id);
|
|
108
102
|
var items = values.data ? transformValue(values.data) : [];
|
|
109
103
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
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); }
|
|
3
2
|
var _excluded = ["children", "contextValue", "indexContextValue"],
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
_excluded2 = ["children", "contextValue", "indexContextValue"];
|
|
6
4
|
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; }
|
|
7
|
-
|
|
8
5
|
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; }
|
|
9
|
-
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
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; }
|
|
10
11
|
import { omit } from "../core/utils.js";
|
|
11
12
|
import createConnector from "../core/createConnector.js";
|
|
12
13
|
import { refineValue, getIndexId, hasMultipleIndices } from "../core/indexUtils.js";
|
|
13
|
-
|
|
14
14
|
function getId() {
|
|
15
15
|
return 'configure';
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
export default createConnector({
|
|
19
18
|
displayName: 'AlgoliaConfigure',
|
|
20
19
|
$$type: 'ais.configure',
|
|
@@ -23,28 +22,23 @@ export default createConnector({
|
|
|
23
22
|
},
|
|
24
23
|
getSearchParameters: function getSearchParameters(searchParameters, props) {
|
|
25
24
|
var children = props.children,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
contextValue = props.contextValue,
|
|
26
|
+
indexContextValue = props.indexContextValue,
|
|
27
|
+
items = _objectWithoutProperties(props, _excluded);
|
|
30
28
|
return searchParameters.setQueryParameters(items);
|
|
31
29
|
},
|
|
32
30
|
transitionState: function transitionState(props, prevSearchState, nextSearchState) {
|
|
33
31
|
var id = getId();
|
|
34
|
-
|
|
35
32
|
var children = props.children,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
contextValue = props.contextValue,
|
|
34
|
+
indexContextValue = props.indexContextValue,
|
|
35
|
+
items = _objectWithoutProperties(props, _excluded2);
|
|
40
36
|
var propKeys = Object.keys(props);
|
|
41
37
|
var nonPresentKeys = this._props ? Object.keys(this._props).filter(function (prop) {
|
|
42
38
|
return propKeys.indexOf(prop) === -1;
|
|
43
39
|
}) : [];
|
|
44
40
|
this._props = props;
|
|
45
|
-
|
|
46
41
|
var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, omit(nextSearchState[id], nonPresentKeys)), items));
|
|
47
|
-
|
|
48
42
|
return refineValue(nextSearchState, nextValue, {
|
|
49
43
|
ais: props.contextValue,
|
|
50
44
|
multiIndexContext: props.indexContextValue
|
|
@@ -65,12 +59,9 @@ export default createConnector({
|
|
|
65
59
|
if (!props[item]) {
|
|
66
60
|
acc[item] = subState[id][item];
|
|
67
61
|
}
|
|
68
|
-
|
|
69
62
|
return acc;
|
|
70
63
|
}, {});
|
|
71
|
-
|
|
72
64
|
var nextValue = _defineProperty({}, id, configureState);
|
|
73
|
-
|
|
74
65
|
return refineValue(searchState, nextValue, {
|
|
75
66
|
ais: props.contextValue,
|
|
76
67
|
multiIndexContext: props.indexContextValue
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
9
|
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; }
|
|
7
|
-
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
8
13
|
import algoliasearchHelper from 'algoliasearch-helper';
|
|
9
14
|
import createConnector from "../core/createConnector.js";
|
|
10
15
|
import { omit, getObjectType, getPropertyByPath, removeEmptyKey, removeEmptyArraysFromObject } from "../core/utils.js";
|
|
11
|
-
import { refineValue, getIndexId, hasMultipleIndices
|
|
12
|
-
|
|
16
|
+
import { refineValue, getIndexId, hasMultipleIndices
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
} from "../core/indexUtils.js";
|
|
13
19
|
function createOptionalFilter(_ref) {
|
|
14
20
|
var attributeName = _ref.attributeName,
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
attributeValue = _ref.attributeValue,
|
|
22
|
+
attributeScore = _ref.attributeScore;
|
|
17
23
|
return "".concat(attributeName, ":").concat(attributeValue, "<score=").concat(attributeScore || 1, ">");
|
|
18
24
|
}
|
|
19
|
-
|
|
20
25
|
var defaultProps = {
|
|
21
26
|
transformSearchParameters: function transformSearchParameters(x) {
|
|
22
27
|
return _objectSpread({}, x);
|
|
23
28
|
}
|
|
24
29
|
};
|
|
25
|
-
|
|
26
30
|
function getId() {
|
|
27
31
|
// We store the search state of this widget in `configure`.
|
|
28
32
|
return 'configure';
|
|
29
33
|
}
|
|
30
|
-
|
|
31
34
|
function getSearchParametersFromProps(props) {
|
|
32
35
|
var optionalFilters = Object.keys(props.matchingPatterns).reduce(function (acc, attributeName) {
|
|
33
36
|
var attributePattern = props.matchingPatterns[attributeName];
|
|
34
37
|
var attributeValue = getPropertyByPath(props.hit, attributeName);
|
|
35
38
|
var attributeScore = attributePattern.score;
|
|
36
|
-
|
|
37
39
|
if (Array.isArray(attributeValue)) {
|
|
38
40
|
return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) {
|
|
39
41
|
return createOptionalFilter({
|
|
@@ -43,7 +45,6 @@ function getSearchParametersFromProps(props) {
|
|
|
43
45
|
});
|
|
44
46
|
})]);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
48
|
if (typeof attributeValue === 'string') {
|
|
48
49
|
return [].concat(_toConsumableArray(acc), [createOptionalFilter({
|
|
49
50
|
attributeName: attributeName,
|
|
@@ -51,12 +52,10 @@ function getSearchParametersFromProps(props) {
|
|
|
51
52
|
attributeScore: attributeScore
|
|
52
53
|
})]);
|
|
53
54
|
}
|
|
54
|
-
|
|
55
55
|
if (process.env.NODE_ENV === 'development') {
|
|
56
56
|
// eslint-disable-next-line no-console
|
|
57
57
|
console.warn("The `matchingPatterns` option returned a value of type ".concat(getObjectType(attributeValue), " for the \"").concat(attributeName, "\" key. This value was not sent to Algolia because `optionalFilters` only supports strings and array of strings.\n\nYou can remove the \"").concat(attributeName, "\" key from the `matchingPatterns` option.\n\nSee https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/"));
|
|
58
58
|
}
|
|
59
|
-
|
|
60
59
|
return acc;
|
|
61
60
|
}, []);
|
|
62
61
|
return props.transformSearchParameters(new algoliasearchHelper.SearchParameters({
|
|
@@ -68,7 +67,6 @@ function getSearchParametersFromProps(props) {
|
|
|
68
67
|
optionalFilters: optionalFilters
|
|
69
68
|
}));
|
|
70
69
|
}
|
|
71
|
-
|
|
72
70
|
export default createConnector({
|
|
73
71
|
displayName: 'AlgoliaConfigureRelatedItems',
|
|
74
72
|
$$type: 'ais.configureRelatedItems',
|
|
@@ -80,19 +78,17 @@ export default createConnector({
|
|
|
80
78
|
return searchParameters.setQueryParameters(getSearchParametersFromProps(props));
|
|
81
79
|
},
|
|
82
80
|
transitionState: function transitionState(props, _prevSearchState, nextSearchState) {
|
|
83
|
-
var id = getId();
|
|
81
|
+
var id = getId();
|
|
82
|
+
// We need to transform the exhaustive search parameters back to clean
|
|
84
83
|
// search parameters without the empty default keys so we don't pollute the
|
|
85
84
|
// `configure` search state.
|
|
86
|
-
|
|
87
85
|
var searchParameters = removeEmptyArraysFromObject(removeEmptyKey(getSearchParametersFromProps(props)));
|
|
88
86
|
var searchParametersKeys = Object.keys(searchParameters);
|
|
89
87
|
var nonPresentKeys = this._searchParameters ? Object.keys(this._searchParameters).filter(function (prop) {
|
|
90
88
|
return searchParametersKeys.indexOf(prop) === -1;
|
|
91
89
|
}) : [];
|
|
92
90
|
this._searchParameters = searchParameters;
|
|
93
|
-
|
|
94
91
|
var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, omit(nextSearchState[id], nonPresentKeys)), searchParameters));
|
|
95
|
-
|
|
96
92
|
return refineValue(nextSearchState, nextValue, {
|
|
97
93
|
ais: props.contextValue,
|
|
98
94
|
multiIndexContext: props.indexContextValue
|
|
@@ -100,7 +96,6 @@ export default createConnector({
|
|
|
100
96
|
},
|
|
101
97
|
cleanUp: function cleanUp(props, searchState) {
|
|
102
98
|
var _this = this;
|
|
103
|
-
|
|
104
99
|
var id = getId();
|
|
105
100
|
var indexId = getIndexId({
|
|
106
101
|
ais: props.contextValue,
|
|
@@ -115,12 +110,9 @@ export default createConnector({
|
|
|
115
110
|
if (!_this._searchParameters[item]) {
|
|
116
111
|
acc[item] = subState[id][item];
|
|
117
112
|
}
|
|
118
|
-
|
|
119
113
|
return acc;
|
|
120
114
|
}, {});
|
|
121
|
-
|
|
122
115
|
var nextValue = _defineProperty({}, id, configureState);
|
|
123
|
-
|
|
124
116
|
return refineValue(searchState, nextValue, {
|
|
125
117
|
ais: props.contextValue,
|
|
126
118
|
multiIndexContext: props.indexContextValue
|