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,11 +1,12 @@
|
|
|
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); }
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import createConnector from "../core/createConnector.js";
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
11
|
* connectCurrentRefinements connector provides the logic to build a widget that will
|
|
11
12
|
* give the user the ability to remove all or some of the filters that were
|
|
@@ -18,7 +19,6 @@ import createConnector from "../core/createConnector.js";
|
|
|
18
19
|
* @providedPropType {array.<{label: string, attribute: string, currentRefinement: string || object, items: array, value: function}>} items - all the filters, the `value` is to pass to the `refine` function for removing all currentrefinements, `label` is for the display. When existing several refinements for the same atribute name, then you get a nested `items` object that contains a `label` and a `value` function to use to remove a single filter. `attribute` and `currentRefinement` are metadata containing row values.
|
|
19
20
|
* @providedPropType {string} query - the search query
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
22
|
export default createConnector({
|
|
23
23
|
displayName: 'AlgoliaCurrentRefinements',
|
|
24
24
|
$$type: 'ais.currentRefinements',
|
|
@@ -34,7 +34,6 @@ export default createConnector({
|
|
|
34
34
|
if (props.clearsQuery && meta.id === 'query' && meta.items[0].currentRefinement === '') {
|
|
35
35
|
return res;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
return res.concat(meta.items.map(function (item) {
|
|
39
38
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
40
39
|
id: meta.id,
|
|
@@ -43,7 +42,6 @@ export default createConnector({
|
|
|
43
42
|
}));
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
|
|
47
45
|
return res;
|
|
48
46
|
}, []);
|
|
49
47
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import createConnector from "../core/createConnector.js";
|
|
3
|
+
// @ts-ignore
|
|
3
4
|
import { getResults } from "../core/indexUtils.js";
|
|
4
5
|
var MAX_WILDCARD_FACETS = 20;
|
|
5
6
|
export default createConnector({
|
|
@@ -21,32 +22,26 @@ export default createConnector({
|
|
|
21
22
|
ais: props.contextValue,
|
|
22
23
|
multiIndexContext: props.indexContextValue
|
|
23
24
|
});
|
|
24
|
-
|
|
25
25
|
if (props.facets && !(Array.isArray(props.facets) && props.facets.length <= 1 && (props.facets[0] === '*' || props.facets[0] === undefined))) {
|
|
26
26
|
throw new Error("The `facets` prop only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(props.facets)));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
if (!results) {
|
|
30
29
|
return {
|
|
31
30
|
attributesToRender: []
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
var facetOrder = results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.facets && results.renderingContent.facetOrdering.facets.order || [];
|
|
36
34
|
var attributesToRender = props.transformItems(facetOrder, {
|
|
37
35
|
results: results
|
|
38
36
|
});
|
|
39
|
-
|
|
40
37
|
if (attributesToRender.length > MAX_WILDCARD_FACETS && !props.facets) {
|
|
41
38
|
// eslint-disable-next-line no-console
|
|
42
39
|
console.warn("More than ".concat(MAX_WILDCARD_FACETS, " facets are requested to be displayed without explicitly setting which facets to retrieve. This could have a performance impact. Set \"facets\" to [] to do two smaller network requests, or explicitly to ['*'] to avoid this warning."));
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
if (props.maxValuesPerFacet < results._state.maxValuesPerFacet) {
|
|
46
42
|
// eslint-disable-next-line no-console
|
|
47
43
|
console.warn("The maxValuesPerFacet set by dynamic widgets (".concat(props.maxValuesPerFacet, ") is smaller than one of the limits set by a widget (").concat(results._state.maxValuesPerFacet, "). This causes a mismatch in query parameters and thus an extra network request when that widget is mounted."));
|
|
48
44
|
}
|
|
49
|
-
|
|
50
45
|
return {
|
|
51
46
|
attributesToRender: attributesToRender
|
|
52
47
|
};
|
|
@@ -1,9 +1,14 @@
|
|
|
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 = ["defaultRefinement"];
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
4
8
|
import { objectHasKeys } from "../core/utils.js";
|
|
5
9
|
import createConnector from "../core/createConnector.js";
|
|
6
10
|
import { getResults, getCurrentRefinementValue, getIndexId, refineValue, cleanUpValue } from "../core/indexUtils.js";
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* The GeoSearch connector provides the logic to build a widget that will display the results on a map.
|
|
9
14
|
* It also provides a way to search for results based on their position. The connector provides function to manage the search experience (search on map interaction).
|
|
@@ -20,25 +25,21 @@ import { getResults, getCurrentRefinementValue, getIndexId, refineValue, cleanUp
|
|
|
20
25
|
* @providedPropType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [currentRefinement] - the refinement currently applied
|
|
21
26
|
* @providedPropType {{ lat: number, lng: number }} [position] - the position of the search
|
|
22
27
|
*/
|
|
28
|
+
|
|
23
29
|
// To control the map with an external widget the other widget
|
|
24
30
|
// **must** write the value in the attribute `aroundLatLng`
|
|
25
|
-
|
|
26
31
|
var getBoundingBoxId = function getBoundingBoxId() {
|
|
27
32
|
return 'boundingBox';
|
|
28
33
|
};
|
|
29
|
-
|
|
30
34
|
var getAroundLatLngId = function getAroundLatLngId() {
|
|
31
35
|
return 'aroundLatLng';
|
|
32
36
|
};
|
|
33
|
-
|
|
34
37
|
var getConfigureAroundLatLngId = function getConfigureAroundLatLngId() {
|
|
35
38
|
return 'configure.aroundLatLng';
|
|
36
39
|
};
|
|
37
|
-
|
|
38
40
|
var currentRefinementToString = function currentRefinementToString(currentRefinement) {
|
|
39
41
|
return [currentRefinement.northEast.lat, currentRefinement.northEast.lng, currentRefinement.southWest.lat, currentRefinement.southWest.lng].join();
|
|
40
42
|
};
|
|
41
|
-
|
|
42
43
|
var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
|
|
43
44
|
var values = value.split(',');
|
|
44
45
|
return {
|
|
@@ -52,9 +53,7 @@ var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
|
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
|
-
|
|
56
56
|
var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
|
|
57
|
-
|
|
58
57
|
var stringToPosition = function stringToPosition(value) {
|
|
59
58
|
var pattern = value.match(latLngRegExp);
|
|
60
59
|
return {
|
|
@@ -62,15 +61,13 @@ var stringToPosition = function stringToPosition(value) {
|
|
|
62
61
|
lng: parseFloat(pattern[2])
|
|
63
62
|
};
|
|
64
63
|
};
|
|
65
|
-
|
|
66
64
|
var getCurrentRefinement = function getCurrentRefinement(props, searchState, context) {
|
|
67
65
|
var refinement = getCurrentRefinementValue(props, searchState, context, getBoundingBoxId(), {});
|
|
68
|
-
|
|
69
66
|
if (!objectHasKeys(refinement)) {
|
|
70
67
|
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
68
|
+
}
|
|
73
69
|
|
|
70
|
+
// eslint-disable-next-line consistent-return
|
|
74
71
|
return {
|
|
75
72
|
northEast: {
|
|
76
73
|
lat: parseFloat(refinement.northEast.lat),
|
|
@@ -82,30 +79,22 @@ var getCurrentRefinement = function getCurrentRefinement(props, searchState, con
|
|
|
82
79
|
}
|
|
83
80
|
};
|
|
84
81
|
};
|
|
85
|
-
|
|
86
82
|
var getCurrentPosition = function getCurrentPosition(props, searchState, context) {
|
|
87
83
|
var defaultRefinement = props.defaultRefinement,
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
propsWithoutDefaultRefinement = _objectWithoutProperties(props, _excluded);
|
|
90
85
|
var aroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getAroundLatLngId());
|
|
91
|
-
|
|
92
86
|
if (!aroundLatLng) {
|
|
93
87
|
// Fallback on `configure.aroundLatLng`
|
|
94
88
|
var configureAroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getConfigureAroundLatLngId());
|
|
95
89
|
return configureAroundLatLng && stringToPosition(configureAroundLatLng);
|
|
96
90
|
}
|
|
97
|
-
|
|
98
91
|
return aroundLatLng;
|
|
99
92
|
};
|
|
100
|
-
|
|
101
93
|
var _refine = function refine(searchState, nextValue, context) {
|
|
102
94
|
var resetPage = true;
|
|
103
|
-
|
|
104
95
|
var nextRefinement = _defineProperty({}, getBoundingBoxId(), nextValue);
|
|
105
|
-
|
|
106
96
|
return refineValue(searchState, nextRefinement, context, resetPage);
|
|
107
97
|
};
|
|
108
|
-
|
|
109
98
|
export default createConnector({
|
|
110
99
|
displayName: 'AlgoliaGeoSearch',
|
|
111
100
|
$$type: 'ais.geoSearch',
|
|
@@ -114,7 +103,9 @@ export default createConnector({
|
|
|
114
103
|
ais: props.contextValue,
|
|
115
104
|
multiIndexContext: props.indexContextValue
|
|
116
105
|
};
|
|
117
|
-
var results = getResults(searchResults, context);
|
|
106
|
+
var results = getResults(searchResults, context);
|
|
107
|
+
|
|
108
|
+
// We read it from both because the SearchParameters & the searchState are not always
|
|
118
109
|
// in sync. When we set the refinement the searchState is used but when we clear the refinement
|
|
119
110
|
// the SearchParameters is used. In the first case when we render, the results are not there
|
|
120
111
|
// so we can't find the value from the results. The most up to date value is the searchState.
|
|
@@ -149,11 +140,9 @@ export default createConnector({
|
|
|
149
140
|
ais: props.contextValue,
|
|
150
141
|
multiIndexContext: props.indexContextValue
|
|
151
142
|
});
|
|
152
|
-
|
|
153
143
|
if (!currentRefinement) {
|
|
154
144
|
return searchParameters;
|
|
155
145
|
}
|
|
156
|
-
|
|
157
146
|
return searchParameters.setQueryParameter('insideBoundingBox', currentRefinementToString(currentRefinement));
|
|
158
147
|
},
|
|
159
148
|
cleanUp: function cleanUp(props, searchState) {
|
|
@@ -172,7 +161,6 @@ export default createConnector({
|
|
|
172
161
|
var index = getIndexId(context);
|
|
173
162
|
var nextRefinement = {};
|
|
174
163
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
175
|
-
|
|
176
164
|
if (currentRefinement) {
|
|
177
165
|
items.push({
|
|
178
166
|
label: "".concat(id, ": ").concat(currentRefinementToString(currentRefinement)),
|
|
@@ -182,7 +170,6 @@ export default createConnector({
|
|
|
182
170
|
currentRefinement: currentRefinement
|
|
183
171
|
});
|
|
184
172
|
}
|
|
185
|
-
|
|
186
173
|
return {
|
|
187
174
|
id: id,
|
|
188
175
|
index: index,
|
|
@@ -1,9 +1,9 @@
|
|
|
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); }
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import algoliasearchHelper from 'algoliasearch-helper';
|
|
9
9
|
import createConnector from "../core/createConnector.js";
|
|
@@ -13,26 +13,21 @@ export var getId = function getId(props) {
|
|
|
13
13
|
return props.attributes[0];
|
|
14
14
|
};
|
|
15
15
|
var namespace = 'hierarchicalMenu';
|
|
16
|
-
|
|
17
16
|
function getCurrentRefinement(props, searchState, context) {
|
|
18
17
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), null);
|
|
19
|
-
|
|
20
18
|
if (currentRefinement === '') {
|
|
21
19
|
return null;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return currentRefinement;
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function getValue(value, props, searchState, context) {
|
|
28
24
|
var id = props.id,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
attributes = props.attributes,
|
|
26
|
+
separator = props.separator,
|
|
27
|
+
rootPath = props.rootPath,
|
|
28
|
+
showParentLevel = props.showParentLevel;
|
|
33
29
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
34
30
|
var nextRefinement;
|
|
35
|
-
|
|
36
31
|
if (currentRefinement === null) {
|
|
37
32
|
nextRefinement = value;
|
|
38
33
|
} else {
|
|
@@ -47,10 +42,8 @@ function getValue(value, props, searchState, context) {
|
|
|
47
42
|
});
|
|
48
43
|
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id, value).getHierarchicalRefinement(id)[0];
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
return nextRefinement;
|
|
52
46
|
}
|
|
53
|
-
|
|
54
47
|
function transformValue(value, props, searchState, context) {
|
|
55
48
|
return value.map(function (v) {
|
|
56
49
|
return {
|
|
@@ -62,7 +55,6 @@ function transformValue(value, props, searchState, context) {
|
|
|
62
55
|
};
|
|
63
56
|
});
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
var truncate = function truncate() {
|
|
67
59
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
68
60
|
var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
@@ -73,21 +65,17 @@ var truncate = function truncate() {
|
|
|
73
65
|
}) : item;
|
|
74
66
|
});
|
|
75
67
|
};
|
|
76
|
-
|
|
77
68
|
function _refine(props, searchState, nextRefinement, context) {
|
|
78
69
|
var id = getId(props);
|
|
79
|
-
|
|
80
70
|
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
81
|
-
|
|
82
71
|
var resetPage = true;
|
|
83
72
|
return refineValue(searchState, nextValue, context, resetPage, namespace);
|
|
84
73
|
}
|
|
85
|
-
|
|
86
74
|
function _cleanUp(props, searchState, context) {
|
|
87
75
|
return cleanUpValue(searchState, context, "".concat(namespace, ".").concat(getId(props)));
|
|
88
76
|
}
|
|
89
|
-
|
|
90
77
|
var sortBy = ['name:asc'];
|
|
78
|
+
|
|
91
79
|
/**
|
|
92
80
|
* connectHierarchicalMenu connector provides the logic to build a widget that will
|
|
93
81
|
* give the user the ability to explore a tree-like structure.
|
|
@@ -133,7 +121,6 @@ var sortBy = ['name:asc'];
|
|
|
133
121
|
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
134
122
|
* @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the HierarchicalMenu can display. items has the same shape as parent items.
|
|
135
123
|
*/
|
|
136
|
-
|
|
137
124
|
export default createConnector({
|
|
138
125
|
displayName: 'AlgoliaHierarchicalMenu',
|
|
139
126
|
$$type: 'ais.hierarchicalMenu',
|
|
@@ -142,11 +129,9 @@ export default createConnector({
|
|
|
142
129
|
var isNotString = function isNotString(val) {
|
|
143
130
|
return typeof val !== 'string';
|
|
144
131
|
};
|
|
145
|
-
|
|
146
132
|
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
147
133
|
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
148
134
|
}
|
|
149
|
-
|
|
150
135
|
return undefined;
|
|
151
136
|
},
|
|
152
137
|
separator: PropTypes.string,
|
|
@@ -170,16 +155,15 @@ export default createConnector({
|
|
|
170
155
|
},
|
|
171
156
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
172
157
|
var showMore = props.showMore,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
limit = props.limit,
|
|
159
|
+
showMoreLimit = props.showMoreLimit,
|
|
160
|
+
facetOrdering = props.facetOrdering;
|
|
176
161
|
var id = getId(props);
|
|
177
162
|
var results = getResults(searchResults, {
|
|
178
163
|
ais: props.contextValue,
|
|
179
164
|
multiIndexContext: props.indexContextValue
|
|
180
165
|
});
|
|
181
166
|
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
182
|
-
|
|
183
167
|
if (!isFacetPresent) {
|
|
184
168
|
return {
|
|
185
169
|
items: [],
|
|
@@ -190,7 +174,6 @@ export default createConnector({
|
|
|
190
174
|
canRefine: false
|
|
191
175
|
};
|
|
192
176
|
}
|
|
193
|
-
|
|
194
177
|
var itemsLimit = showMore ? showMoreLimit : limit;
|
|
195
178
|
var value = results.getFacetValues(id, {
|
|
196
179
|
sortBy: sortBy,
|
|
@@ -224,13 +207,13 @@ export default createConnector({
|
|
|
224
207
|
},
|
|
225
208
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
226
209
|
var attributes = props.attributes,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
210
|
+
separator = props.separator,
|
|
211
|
+
rootPath = props.rootPath,
|
|
212
|
+
showParentLevel = props.showParentLevel,
|
|
213
|
+
showMore = props.showMore,
|
|
214
|
+
limit = props.limit,
|
|
215
|
+
showMoreLimit = props.showMoreLimit,
|
|
216
|
+
contextValue = props.contextValue;
|
|
234
217
|
var id = getId(props);
|
|
235
218
|
var itemsLimit = showMore ? showMoreLimit : limit;
|
|
236
219
|
searchParameters = searchParameters.addHierarchicalFacet({
|
|
@@ -246,11 +229,9 @@ export default createConnector({
|
|
|
246
229
|
ais: contextValue,
|
|
247
230
|
multiIndexContext: props.indexContextValue
|
|
248
231
|
});
|
|
249
|
-
|
|
250
232
|
if (currentRefinement !== null) {
|
|
251
233
|
searchParameters = searchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement);
|
|
252
234
|
}
|
|
253
|
-
|
|
254
235
|
return searchParameters;
|
|
255
236
|
},
|
|
256
237
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import createConnector from "../core/createConnector.js";
|
|
2
2
|
import { HIGHLIGHT_TAGS, parseAlgoliaHit } from "../core/highlight.js";
|
|
3
|
-
|
|
4
3
|
var highlight = function highlight(_ref) {
|
|
5
4
|
var attribute = _ref.attribute,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
hit = _ref.hit,
|
|
6
|
+
highlightProperty = _ref.highlightProperty,
|
|
7
|
+
_ref$preTag = _ref.preTag,
|
|
8
|
+
preTag = _ref$preTag === void 0 ? HIGHLIGHT_TAGS.highlightPreTag : _ref$preTag,
|
|
9
|
+
_ref$postTag = _ref.postTag,
|
|
10
|
+
postTag = _ref$postTag === void 0 ? HIGHLIGHT_TAGS.highlightPostTag : _ref$postTag;
|
|
12
11
|
return parseAlgoliaHit({
|
|
13
12
|
attribute: attribute,
|
|
14
13
|
highlightProperty: highlightProperty,
|
|
@@ -17,6 +16,7 @@ var highlight = function highlight(_ref) {
|
|
|
17
16
|
postTag: postTag
|
|
18
17
|
});
|
|
19
18
|
};
|
|
19
|
+
|
|
20
20
|
/**
|
|
21
21
|
* connectHighlight connector provides the logic to create an highlighter
|
|
22
22
|
* component that will retrieve, parse and render an highlighted attribute
|
|
@@ -67,8 +67,6 @@ var highlight = function highlight(_ref) {
|
|
|
67
67
|
* </InstantSearch>
|
|
68
68
|
* );
|
|
69
69
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
70
|
export default createConnector({
|
|
73
71
|
displayName: 'AlgoliaHighlighter',
|
|
74
72
|
$$type: 'ais.highlighter',
|
|
@@ -1,24 +1,22 @@
|
|
|
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); }
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
7
|
import createConnector from "../core/createConnector.js";
|
|
8
|
+
// @ts-ignore
|
|
8
9
|
import { getResults } from "../core/indexUtils.js";
|
|
9
|
-
|
|
10
10
|
function inferPayload(_ref) {
|
|
11
11
|
var method = _ref.method,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
results = _ref.results,
|
|
13
|
+
currentHit = _ref.currentHit;
|
|
14
14
|
var index = results.index;
|
|
15
15
|
var queryID = currentHit.__queryID;
|
|
16
16
|
var objectIDs = [currentHit.objectID];
|
|
17
|
-
|
|
18
17
|
if (!queryID) {
|
|
19
18
|
throw new Error("Could not infer `queryID`. Ensure `clickAnalytics: true` was added with the Configure widget.\nSee: https://alg.li/VpPpLt");
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
switch (method) {
|
|
23
21
|
case 'clickedObjectIDsAfterSearch':
|
|
24
22
|
{
|
|
@@ -30,25 +28,21 @@ function inferPayload(_ref) {
|
|
|
30
28
|
positions: positions
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
case 'convertedObjectIDsAfterSearch':
|
|
35
32
|
return {
|
|
36
33
|
index: index,
|
|
37
34
|
queryID: queryID,
|
|
38
35
|
objectIDs: objectIDs
|
|
39
36
|
};
|
|
40
|
-
|
|
41
37
|
default:
|
|
42
38
|
throw new Error("Unsupported method \"".concat(method, "\" passed to the insights function. The supported methods are: \"clickedObjectIDsAfterSearch\", \"convertedObjectIDsAfterSearch\"."));
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
var wrapInsightsClient = function wrapInsightsClient(aa, results, currentHit) {
|
|
47
42
|
return function (method, payload) {
|
|
48
43
|
if (typeof aa !== 'function') {
|
|
49
44
|
throw new TypeError("Expected insightsClient to be a Function");
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
var inferredPayload = inferPayload({
|
|
53
47
|
method: method,
|
|
54
48
|
results: results,
|
|
@@ -57,7 +51,6 @@ var wrapInsightsClient = function wrapInsightsClient(aa, results, currentHit) {
|
|
|
57
51
|
aa(method, _objectSpread(_objectSpread({}, inferredPayload), payload));
|
|
58
52
|
};
|
|
59
53
|
};
|
|
60
|
-
|
|
61
54
|
export default (function (insightsClient) {
|
|
62
55
|
return createConnector({
|
|
63
56
|
displayName: 'AlgoliaInsights',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import createConnector from "../core/createConnector.js";
|
|
2
2
|
import { getResults } from "../core/indexUtils.js";
|
|
3
3
|
import { addAbsolutePositions, addQueryID } from "../core/utils.js";
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* connectHits connector provides the logic to create connected
|
|
6
7
|
* components that will render the results retrieved from
|
|
@@ -44,7 +45,6 @@ import { addAbsolutePositions, addQueryID } from "../core/utils.js";
|
|
|
44
45
|
* </InstantSearch>
|
|
45
46
|
* );
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
48
|
export default createConnector({
|
|
49
49
|
displayName: 'AlgoliaHits',
|
|
50
50
|
$$type: 'ais.hits',
|
|
@@ -53,21 +53,18 @@ export default createConnector({
|
|
|
53
53
|
ais: props.contextValue,
|
|
54
54
|
multiIndexContext: props.indexContextValue
|
|
55
55
|
});
|
|
56
|
-
|
|
57
56
|
if (!results) {
|
|
58
57
|
return {
|
|
59
58
|
hits: []
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
|
-
|
|
63
61
|
var hitsWithPositions = addAbsolutePositions(results.hits, results.hitsPerPage, results.page);
|
|
64
62
|
var hitsWithPositionsAndQueryID = addQueryID(hitsWithPositions, results.queryID);
|
|
65
63
|
return {
|
|
66
64
|
hits: hitsWithPositionsAndQueryID
|
|
67
65
|
};
|
|
68
66
|
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
67
|
+
/*
|
|
71
68
|
* Hits needs to be considered as a widget to trigger a search,
|
|
72
69
|
* even if no other widgets are used.
|
|
73
70
|
*
|
|
@@ -1,27 +1,24 @@
|
|
|
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); }
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import createConnector from "../core/createConnector.js";
|
|
9
9
|
import { cleanUpValue, refineValue, getCurrentRefinementValue } from "../core/indexUtils.js";
|
|
10
|
-
|
|
11
10
|
function getId() {
|
|
12
11
|
return 'hitsPerPage';
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
function getCurrentRefinement(props, searchState, context) {
|
|
16
14
|
var id = getId();
|
|
17
15
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, null);
|
|
18
|
-
|
|
19
16
|
if (typeof currentRefinement === 'string') {
|
|
20
17
|
return parseInt(currentRefinement, 10);
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
return currentRefinement;
|
|
24
20
|
}
|
|
21
|
+
|
|
25
22
|
/**
|
|
26
23
|
* connectHitsPerPage connector provides the logic to create connected
|
|
27
24
|
* components that will allow a user to choose to display more or less results from Algolia.
|
|
@@ -35,8 +32,6 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
35
32
|
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
36
33
|
* @providedPropType {array.<{isRefined: boolean, label?: string, value: number}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
|
|
37
34
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
35
|
export default createConnector({
|
|
41
36
|
displayName: 'AlgoliaHitsPerPage',
|
|
42
37
|
$$type: 'ais.hitsPerPage',
|
|
@@ -67,9 +62,7 @@ export default createConnector({
|
|
|
67
62
|
},
|
|
68
63
|
refine: function refine(props, searchState, nextRefinement) {
|
|
69
64
|
var id = getId();
|
|
70
|
-
|
|
71
65
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
72
|
-
|
|
73
66
|
var resetPage = true;
|
|
74
67
|
return refineValue(searchState, nextValue, {
|
|
75
68
|
ais: props.contextValue,
|