react-instantsearch-core
Advanced tools
Comparing version 6.7.0 to 6.8.0
@@ -45,3 +45,3 @@ "use strict"; | ||
var attributePattern = props.matchingPatterns[attributeName]; | ||
var attributeValue = props.hit[attributeName]; | ||
var attributeValue = (0, _utils.getPropertyByPath)(props.hit, attributeName); | ||
var attributeScore = attributePattern.score; | ||
@@ -48,0 +48,0 @@ |
@@ -109,3 +109,3 @@ "use strict"; | ||
multiIndexContext: _this.props.indexContextValue | ||
}, _this.props); | ||
}, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind((0, _assertThisInitialized2.default)(_this))); | ||
} | ||
@@ -112,0 +112,0 @@ |
@@ -126,3 +126,3 @@ "use strict"; | ||
widgets: initialState, | ||
metadata: [], | ||
metadata: hydrateMetadata(resultsState), | ||
results: hydrateResultsState(resultsState), | ||
@@ -358,4 +358,4 @@ error: null, | ||
if (Array.isArray(results)) { | ||
hydrateSearchClientWithMultiIndexRequest(client, results); | ||
if (Array.isArray(results.results)) { | ||
hydrateSearchClientWithMultiIndexRequest(client, results.results); | ||
return; | ||
@@ -454,4 +454,4 @@ } | ||
if (Array.isArray(results)) { | ||
return results.reduce(function (acc, result) { | ||
if (Array.isArray(results.results)) { | ||
return results.results.reduce(function (acc, result) { | ||
return (0, _objectSpread8.default)({}, acc, (0, _defineProperty2.default)({}, result._internalIndexId, new _algoliasearchHelper.default.SearchResults(new _algoliasearchHelper.default.SearchParameters(result.state), result.rawResults))); | ||
@@ -553,2 +553,15 @@ }, {}); | ||
}; | ||
} | ||
function hydrateMetadata(resultsState) { | ||
if (!resultsState) { | ||
return []; | ||
} | ||
return resultsState.metadata.map(function (datum) { | ||
return (0, _objectSpread8.default)({}, datum, { | ||
// add a value noop, which gets replaced once the widgets are mounted | ||
value: function value() {} | ||
}); | ||
}); | ||
} |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _default = '6.7.0'; | ||
var _default = '6.8.0'; | ||
exports.default = _default; |
@@ -96,3 +96,3 @@ "use strict"; | ||
multiIndexContext: _this.state.indexContext | ||
}, _this.props); | ||
}, _this.props, undefined); | ||
@@ -99,0 +99,0 @@ return _this; |
@@ -192,3 +192,3 @@ "use strict"; | ||
key: "onSearchParameters", | ||
value: function onSearchParameters(getSearchParameters, context, props) { | ||
value: function onSearchParameters(getSearchParameters, context, props, getMetadata) { | ||
if (this.props.onSearchParameters) { | ||
@@ -199,2 +199,14 @@ var _searchState = this.props.searchState ? this.props.searchState : {}; | ||
} | ||
if (this.props.widgetsCollector) { | ||
var _searchState2 = this.props.searchState ? this.props.searchState : {}; | ||
this.props.widgetsCollector({ | ||
getSearchParameters: getSearchParameters, | ||
getMetadata: getMetadata, | ||
context: context, | ||
props: props, | ||
searchState: _searchState2 | ||
}); | ||
} | ||
} | ||
@@ -244,2 +256,3 @@ }, { | ||
onSearchParameters: _propTypes.default.func, | ||
widgetsCollector: _propTypes.default.func, | ||
resultsState: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]), | ||
@@ -246,0 +259,0 @@ children: _propTypes.default.node, |
@@ -6,3 +6,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import createConnector from '../core/createConnector'; | ||
import { omit, getObjectType, removeEmptyKey, removeEmptyArraysFromObject } from '../core/utils'; | ||
import { omit, getObjectType, getPropertyByPath, removeEmptyKey, removeEmptyArraysFromObject } from '../core/utils'; | ||
import { refineValue, getIndexId, hasMultipleIndices } from '../core/indexUtils'; | ||
@@ -31,3 +31,3 @@ | ||
var attributePattern = props.matchingPatterns[attributeName]; | ||
var attributeValue = props.hit[attributeName]; | ||
var attributeValue = getPropertyByPath(props.hit, attributeName); | ||
var attributeScore = attributePattern.score; | ||
@@ -34,0 +34,0 @@ |
@@ -92,3 +92,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
multiIndexContext: _this.props.indexContextValue | ||
}, _this.props); | ||
}, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind(_assertThisInitialized(_this))); | ||
} | ||
@@ -95,0 +95,0 @@ |
@@ -108,3 +108,3 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
widgets: initialState, | ||
metadata: [], | ||
metadata: hydrateMetadata(resultsState), | ||
results: hydrateResultsState(resultsState), | ||
@@ -342,4 +342,4 @@ error: null, | ||
if (Array.isArray(results)) { | ||
hydrateSearchClientWithMultiIndexRequest(client, results); | ||
if (Array.isArray(results.results)) { | ||
hydrateSearchClientWithMultiIndexRequest(client, results.results); | ||
return; | ||
@@ -438,4 +438,4 @@ } | ||
if (Array.isArray(results)) { | ||
return results.reduce(function (acc, result) { | ||
if (Array.isArray(results.results)) { | ||
return results.results.reduce(function (acc, result) { | ||
return _objectSpread({}, acc, _defineProperty({}, result._internalIndexId, new algoliasearchHelper.SearchResults(new algoliasearchHelper.SearchParameters(result.state), result.rawResults))); | ||
@@ -537,2 +537,15 @@ }, {}); | ||
}; | ||
} | ||
function hydrateMetadata(resultsState) { | ||
if (!resultsState) { | ||
return []; | ||
} | ||
return resultsState.metadata.map(function (datum) { | ||
return _objectSpread({}, datum, { | ||
// add a value noop, which gets replaced once the widgets are mounted | ||
value: function value() {} | ||
}); | ||
}); | ||
} |
@@ -1,1 +0,1 @@ | ||
export default '6.7.0'; | ||
export default '6.8.0'; |
@@ -79,3 +79,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
multiIndexContext: _this.state.indexContext | ||
}, _this.props); | ||
}, _this.props, undefined); | ||
@@ -82,0 +82,0 @@ return _this; |
@@ -173,3 +173,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread"; | ||
key: "onSearchParameters", | ||
value: function onSearchParameters(getSearchParameters, context, props) { | ||
value: function onSearchParameters(getSearchParameters, context, props, getMetadata) { | ||
if (this.props.onSearchParameters) { | ||
@@ -180,2 +180,14 @@ var _searchState = this.props.searchState ? this.props.searchState : {}; | ||
} | ||
if (this.props.widgetsCollector) { | ||
var _searchState2 = this.props.searchState ? this.props.searchState : {}; | ||
this.props.widgetsCollector({ | ||
getSearchParameters: getSearchParameters, | ||
getMetadata: getMetadata, | ||
context: context, | ||
props: props, | ||
searchState: _searchState2 | ||
}); | ||
} | ||
} | ||
@@ -227,2 +239,3 @@ }, { | ||
onSearchParameters: PropTypes.func, | ||
widgetsCollector: PropTypes.func, | ||
resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), | ||
@@ -229,0 +242,0 @@ children: PropTypes.node, |
{ | ||
"name": "react-instantsearch-core", | ||
"version": "6.7.0", | ||
"version": "6.8.0", | ||
"description": "⚡ Lightning-fast search for React, by Algolia", | ||
@@ -47,4 +47,5 @@ "main": "dist/cjs/index.js", | ||
"peerDependencies": { | ||
"algoliasearch": ">= 3.1 < 5", | ||
"react": ">= 16.3.0 < 17" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2067155
19868
6