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,20 +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 _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
8
|
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
13
|
-
|
|
14
9
|
var _indexUtils = require("../core/indexUtils");
|
|
15
|
-
|
|
16
10
|
var _utils = require("../core/utils");
|
|
17
|
-
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
12
|
/**
|
|
19
13
|
* connectScrollTo connector provides the logic to build a widget that will
|
|
20
14
|
* let the page scroll to a certain point.
|
|
@@ -39,12 +33,11 @@ var _default = (0, _createConnector.default)({
|
|
|
39
33
|
ais: props.contextValue,
|
|
40
34
|
multiIndexContext: props.indexContextValue
|
|
41
35
|
}, id, null);
|
|
42
|
-
|
|
43
36
|
if (!this._prevSearchState) {
|
|
44
37
|
this._prevSearchState = {};
|
|
45
|
-
}
|
|
46
|
-
|
|
38
|
+
}
|
|
47
39
|
|
|
40
|
+
// Get the subpart of the state that interest us
|
|
48
41
|
if ((0, _indexUtils.hasMultipleIndices)({
|
|
49
42
|
ais: props.contextValue,
|
|
50
43
|
multiIndexContext: props.indexContextValue
|
|
@@ -53,7 +46,9 @@ var _default = (0, _createConnector.default)({
|
|
|
53
46
|
ais: props.contextValue,
|
|
54
47
|
multiIndexContext: props.indexContextValue
|
|
55
48
|
})] : {};
|
|
56
|
-
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// if there is a change in the app that has been triggered by another element
|
|
57
52
|
// than "props.scrollOn (id) or the Configure widget, we need to keep track of
|
|
58
53
|
// the search state to know if there's a change in the app that was not triggered
|
|
59
54
|
// by the props.scrollOn (id) or the Configure widget. This is useful when
|
|
@@ -63,8 +58,6 @@ var _default = (0, _createConnector.default)({
|
|
|
63
58
|
// do this comparison because for now configure values are not present in the
|
|
64
59
|
// search state before a first refinement has been made and will false the results.
|
|
65
60
|
// See: https://github.com/algolia/react-instantsearch/issues/164
|
|
66
|
-
|
|
67
|
-
|
|
68
61
|
var cleanedSearchState = (0, _utils.omit)(searchState, ['configure', id]);
|
|
69
62
|
var hasNotChanged = (0, _utils.shallowEqual)(this._prevSearchState, cleanedSearchState);
|
|
70
63
|
this._prevSearchState = cleanedSearchState;
|
|
@@ -74,5 +67,4 @@ var _default = (0, _createConnector.default)({
|
|
|
74
67
|
};
|
|
75
68
|
}
|
|
76
69
|
});
|
|
77
|
-
|
|
78
70
|
exports.default = _default;
|
|
@@ -1,45 +1,38 @@
|
|
|
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
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
8
|
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
15
|
-
|
|
16
9
|
var _indexUtils = require("../core/indexUtils");
|
|
17
|
-
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
18
15
|
function getId() {
|
|
19
16
|
return 'query';
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
function getCurrentRefinement(props, searchState, context) {
|
|
23
19
|
var id = getId(props);
|
|
24
20
|
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
25
|
-
|
|
26
21
|
if (currentRefinement) {
|
|
27
22
|
return currentRefinement;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
return '';
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
function _refine(props, searchState, nextRefinement, context) {
|
|
34
27
|
var id = getId();
|
|
35
|
-
var nextValue = (
|
|
28
|
+
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
36
29
|
var resetPage = true;
|
|
37
30
|
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
function _cleanUp(props, searchState, context) {
|
|
41
33
|
return (0, _indexUtils.cleanUpValue)(searchState, context, getId());
|
|
42
34
|
}
|
|
35
|
+
|
|
43
36
|
/**
|
|
44
37
|
* connectSearchBox connector provides the logic to build a widget that will
|
|
45
38
|
* let the user search for a query
|
|
@@ -50,8 +43,6 @@ function _cleanUp(props, searchState, context) {
|
|
|
50
43
|
* @providedPropType {string} currentRefinement - the current query used
|
|
51
44
|
* @providedPropType {boolean} isSearchStalled - a flag that indicates if InstantSearch has detected that searches are stalled
|
|
52
45
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
46
|
var _default = (0, _createConnector.default)({
|
|
56
47
|
displayName: 'AlgoliaSearchBox',
|
|
57
48
|
$$type: 'ais.searchBox',
|
|
@@ -110,5 +101,4 @@ var _default = (0, _createConnector.default)({
|
|
|
110
101
|
};
|
|
111
102
|
}
|
|
112
103
|
});
|
|
113
|
-
|
|
114
104
|
exports.default = _default;
|
|
@@ -1,38 +1,31 @@
|
|
|
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
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
8
|
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
15
|
-
|
|
16
9
|
var _indexUtils = require("../core/indexUtils");
|
|
17
|
-
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
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; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
17
|
function getId() {
|
|
23
18
|
return 'sortBy';
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
function getCurrentRefinement(props, searchState, context) {
|
|
27
21
|
var id = getId(props);
|
|
28
22
|
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, null);
|
|
29
|
-
|
|
30
23
|
if (currentRefinement) {
|
|
31
24
|
return currentRefinement;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
return null;
|
|
35
27
|
}
|
|
28
|
+
|
|
36
29
|
/**
|
|
37
30
|
* The connectSortBy connector provides the logic to build a widget that will
|
|
38
31
|
* display a list of indices. This allows a user to change how the hits are being sorted.
|
|
@@ -48,8 +41,6 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
48
41
|
* @providedPropType {string[]} currentRefinement - the refinement currently applied
|
|
49
42
|
* @providedPropType {array.<{isRefined: boolean, label?: string, value: string}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
|
|
50
43
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
44
|
var _default = (0, _createConnector.default)({
|
|
54
45
|
displayName: 'AlgoliaSortBy',
|
|
55
46
|
$$type: 'ais.sortBy',
|
|
@@ -80,7 +71,7 @@ var _default = (0, _createConnector.default)({
|
|
|
80
71
|
},
|
|
81
72
|
refine: function refine(props, searchState, nextRefinement) {
|
|
82
73
|
var id = getId();
|
|
83
|
-
var nextValue = (
|
|
74
|
+
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
84
75
|
var resetPage = true;
|
|
85
76
|
return (0, _indexUtils.refineValue)(searchState, nextValue, {
|
|
86
77
|
ais: props.contextValue,
|
|
@@ -106,5 +97,4 @@ var _default = (0, _createConnector.default)({
|
|
|
106
97
|
};
|
|
107
98
|
}
|
|
108
99
|
});
|
|
109
|
-
|
|
110
100
|
exports.default = _default;
|
|
@@ -1,16 +1,12 @@
|
|
|
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 _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
11
|
-
|
|
12
8
|
var _indexUtils = require("../core/indexUtils");
|
|
13
|
-
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
10
|
/**
|
|
15
11
|
* The `connectStateResults` connector provides a way to access the `searchState` and the `searchResults`
|
|
16
12
|
* of InstantSearch.
|
|
@@ -80,5 +76,4 @@ var _default = (0, _createConnector.default)({
|
|
|
80
76
|
};
|
|
81
77
|
}
|
|
82
78
|
});
|
|
83
|
-
|
|
84
79
|
exports.default = _default;
|
|
@@ -1,16 +1,13 @@
|
|
|
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 _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
11
|
-
|
|
12
8
|
var _indexUtils = require("../core/indexUtils");
|
|
13
|
-
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
// @ts-ignore
|
|
14
11
|
/**
|
|
15
12
|
* connectStats connector provides the logic to build a widget that will
|
|
16
13
|
* displays algolia search statistics (hits number and processing time).
|
|
@@ -28,11 +25,9 @@ var _default = (0, _createConnector.default)({
|
|
|
28
25
|
ais: props.contextValue,
|
|
29
26
|
multiIndexContext: props.indexContextValue
|
|
30
27
|
});
|
|
31
|
-
|
|
32
28
|
if (!results) {
|
|
33
29
|
return null;
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
return {
|
|
37
32
|
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits,
|
|
38
33
|
nbHits: results.nbHits,
|
|
@@ -41,5 +36,4 @@ var _default = (0, _createConnector.default)({
|
|
|
41
36
|
};
|
|
42
37
|
}
|
|
43
38
|
});
|
|
44
|
-
|
|
45
39
|
exports.default = _default;
|
|
@@ -1,49 +1,40 @@
|
|
|
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
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
8
|
var _utils = require("../core/utils");
|
|
15
|
-
|
|
16
9
|
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
17
|
-
|
|
18
10
|
var _indexUtils = require("../core/indexUtils");
|
|
19
|
-
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
16
|
function getId(props) {
|
|
21
17
|
return props.attribute;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
var namespace = 'toggle';
|
|
25
20
|
var falsyStrings = ['0', 'false', 'null', 'undefined'];
|
|
26
|
-
|
|
27
21
|
function getCurrentRefinement(props, searchState, context) {
|
|
28
22
|
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), false);
|
|
29
|
-
|
|
30
23
|
if (falsyStrings.indexOf(currentRefinement) !== -1) {
|
|
31
24
|
return false;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
return Boolean(currentRefinement);
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
function _refine(props, searchState, nextRefinement, context) {
|
|
38
29
|
var id = getId(props);
|
|
39
|
-
var nextValue = (
|
|
30
|
+
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : false);
|
|
40
31
|
var resetPage = true;
|
|
41
32
|
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
function _cleanUp(props, searchState, context) {
|
|
45
35
|
return (0, _indexUtils.cleanUpValue)(searchState, context, "".concat(namespace, ".").concat(getId(props)));
|
|
46
36
|
}
|
|
37
|
+
|
|
47
38
|
/**
|
|
48
39
|
* connectToggleRefinement connector provides the logic to build a widget that will
|
|
49
40
|
* provides an on/off filtering feature based on an attribute value.
|
|
@@ -63,8 +54,6 @@ function _cleanUp(props, searchState, context) {
|
|
|
63
54
|
* @providedPropType {function} refine - a function to toggle a refinement
|
|
64
55
|
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
65
56
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
57
|
var _default = (0, _createConnector.default)({
|
|
69
58
|
displayName: 'AlgoliaToggle',
|
|
70
59
|
$$type: 'ais.toggle',
|
|
@@ -77,7 +66,7 @@ var _default = (0, _createConnector.default)({
|
|
|
77
66
|
},
|
|
78
67
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
79
68
|
var attribute = props.attribute,
|
|
80
|
-
|
|
69
|
+
value = props.value;
|
|
81
70
|
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
82
71
|
ais: props.contextValue,
|
|
83
72
|
multiIndexContext: props.indexContextValue
|
|
@@ -87,13 +76,15 @@ var _default = (0, _createConnector.default)({
|
|
|
87
76
|
multiIndexContext: props.indexContextValue
|
|
88
77
|
});
|
|
89
78
|
var allFacetValues = results && results.getFacetByName(attribute) ? results.getFacetValues(attribute) : null;
|
|
90
|
-
var facetValue =
|
|
79
|
+
var facetValue =
|
|
80
|
+
// Use null to always be consistent with type of the value
|
|
91
81
|
// count: number | null
|
|
92
82
|
allFacetValues && allFacetValues.length ? (0, _utils.find)(allFacetValues, function (item) {
|
|
93
83
|
return item.name === value.toString();
|
|
94
84
|
}) : null;
|
|
95
85
|
var facetValueCount = facetValue && facetValue.count;
|
|
96
|
-
var allFacetValuesCount =
|
|
86
|
+
var allFacetValuesCount =
|
|
87
|
+
// Use null to always be consistent with type of the value
|
|
97
88
|
// count: number | null
|
|
98
89
|
allFacetValues && allFacetValues.length ? allFacetValues.reduce(function (acc, item) {
|
|
99
90
|
return acc + item.count;
|
|
@@ -123,22 +114,19 @@ var _default = (0, _createConnector.default)({
|
|
|
123
114
|
},
|
|
124
115
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
125
116
|
var attribute = props.attribute,
|
|
126
|
-
|
|
127
|
-
|
|
117
|
+
value = props.value,
|
|
118
|
+
filter = props.filter;
|
|
128
119
|
var checked = getCurrentRefinement(props, searchState, {
|
|
129
120
|
ais: props.contextValue,
|
|
130
121
|
multiIndexContext: props.indexContextValue
|
|
131
122
|
});
|
|
132
123
|
var nextSearchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
133
|
-
|
|
134
124
|
if (checked) {
|
|
135
125
|
nextSearchParameters = nextSearchParameters.addDisjunctiveFacetRefinement(attribute, value);
|
|
136
|
-
|
|
137
126
|
if (filter) {
|
|
138
127
|
nextSearchParameters = filter(nextSearchParameters);
|
|
139
128
|
}
|
|
140
129
|
}
|
|
141
|
-
|
|
142
130
|
return nextSearchParameters;
|
|
143
131
|
},
|
|
144
132
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -152,7 +140,6 @@ var _default = (0, _createConnector.default)({
|
|
|
152
140
|
ais: props.contextValue,
|
|
153
141
|
multiIndexContext: props.indexContextValue
|
|
154
142
|
});
|
|
155
|
-
|
|
156
143
|
if (checked) {
|
|
157
144
|
items.push({
|
|
158
145
|
label: props.label,
|
|
@@ -166,7 +153,6 @@ var _default = (0, _createConnector.default)({
|
|
|
166
153
|
}
|
|
167
154
|
});
|
|
168
155
|
}
|
|
169
|
-
|
|
170
156
|
return {
|
|
171
157
|
id: id,
|
|
172
158
|
index: index,
|
|
@@ -174,5 +160,4 @@ var _default = (0, _createConnector.default)({
|
|
|
174
160
|
};
|
|
175
161
|
}
|
|
176
162
|
});
|
|
177
|
-
|
|
178
163
|
exports.default = _default;
|
|
@@ -1,57 +1,43 @@
|
|
|
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
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
8
|
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
15
|
-
|
|
16
9
|
var _indexUtils = require("../core/indexUtils");
|
|
17
|
-
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
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; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
17
|
function getId() {
|
|
23
18
|
return 'query';
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
function getAdditionalId() {
|
|
27
21
|
return 'additionalVoiceParameters';
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
function getCurrentRefinementQuery(props, searchState, context) {
|
|
31
24
|
var id = getId();
|
|
32
25
|
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
33
|
-
|
|
34
26
|
if (currentRefinement) {
|
|
35
27
|
return currentRefinement;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
return '';
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
function getCurrentRefinementAdditional(props, searchState, context) {
|
|
42
32
|
var id = getAdditionalId();
|
|
43
33
|
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
44
|
-
|
|
45
34
|
if (currentRefinement) {
|
|
46
35
|
return currentRefinement;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
37
|
return {};
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
function _refine(props, searchState, nextRefinement, context) {
|
|
53
40
|
var _nextValue;
|
|
54
|
-
|
|
55
41
|
var id = getId();
|
|
56
42
|
var voiceParams = getAdditionalId();
|
|
57
43
|
var queryLanguages = props.language ? {
|
|
@@ -64,16 +50,14 @@ function _refine(props, searchState, nextRefinement, context) {
|
|
|
64
50
|
}, props.additionalQueryParameters({
|
|
65
51
|
query: nextRefinement
|
|
66
52
|
})) : {};
|
|
67
|
-
var nextValue = (_nextValue = {}, (
|
|
53
|
+
var nextValue = (_nextValue = {}, _defineProperty(_nextValue, id, nextRefinement), _defineProperty(_nextValue, voiceParams, _objectSpread(_objectSpread({}, queryLanguages), additionalQueryParameters)), _nextValue);
|
|
68
54
|
var resetPage = true;
|
|
69
55
|
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
function _cleanUp(props, searchState, context) {
|
|
73
58
|
var interimState = (0, _indexUtils.cleanUpValue)(searchState, context, getId());
|
|
74
59
|
return (0, _indexUtils.cleanUpValue)(interimState, context, getAdditionalId());
|
|
75
60
|
}
|
|
76
|
-
|
|
77
61
|
var _default = (0, _createConnector.default)({
|
|
78
62
|
displayName: 'AlgoliaVoiceSearch',
|
|
79
63
|
$$type: 'ais.voiceSearch',
|
|
@@ -137,5 +121,4 @@ var _default = (0, _createConnector.default)({
|
|
|
137
121
|
};
|
|
138
122
|
}
|
|
139
123
|
});
|
|
140
|
-
|
|
141
124
|
exports.default = _default;
|
package/dist/cjs/core/context.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.instantSearchContext = exports.InstantSearchProvider = exports.InstantSearchConsumer = exports.IndexProvider = exports.IndexConsumer = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var instantSearchContext = /*#__PURE__*/(0, _react.createContext)({
|
|
11
9
|
onInternalStateUpdate: function onInternalStateUpdate() {
|
|
12
10
|
return undefined;
|
|
@@ -29,13 +27,11 @@ var instantSearchContext = /*#__PURE__*/(0, _react.createContext)({
|
|
|
29
27
|
});
|
|
30
28
|
exports.instantSearchContext = instantSearchContext;
|
|
31
29
|
var InstantSearchConsumer = instantSearchContext.Consumer,
|
|
32
|
-
|
|
30
|
+
InstantSearchProvider = instantSearchContext.Provider;
|
|
33
31
|
exports.InstantSearchProvider = InstantSearchProvider;
|
|
34
32
|
exports.InstantSearchConsumer = InstantSearchConsumer;
|
|
35
|
-
|
|
36
33
|
var _createContext = /*#__PURE__*/(0, _react.createContext)(undefined),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
IndexConsumer = _createContext.Consumer,
|
|
35
|
+
IndexProvider = _createContext.Provider;
|
|
40
36
|
exports.IndexProvider = IndexProvider;
|
|
41
37
|
exports.IndexConsumer = IndexConsumer;
|