instantsearch.js 4.37.1 → 4.38.1
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/CHANGELOG.md +41 -0
- package/cjs/components/Hits/Hits.js +0 -6
- package/cjs/components/Pagination/Pagination.js +60 -41
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +6 -1
- package/cjs/connectors/clear-refinements/connectClearRefinements.js +11 -6
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +6 -2
- package/cjs/connectors/geo-search/connectGeoSearch.js +3 -1
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +3 -1
- package/cjs/connectors/hits/connectHits.js +3 -1
- package/cjs/connectors/hits-per-page/connectHitsPerPage.js +3 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +3 -1
- package/cjs/connectors/menu/connectMenu.js +3 -1
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +5 -3
- package/cjs/connectors/query-rules/connectQueryRules.js +3 -1
- package/cjs/connectors/refinement-list/connectRefinementList.js +8 -3
- package/cjs/connectors/search-box/connectSearchBox.js +15 -25
- package/cjs/connectors/sort-by/connectSortBy.js +3 -1
- package/cjs/helpers/highlight.js +4 -1
- package/cjs/helpers/reverseHighlight.js +4 -1
- package/cjs/helpers/reverseSnippet.js +4 -1
- package/cjs/helpers/snippet.js +4 -1
- package/cjs/lib/routers/history.js +44 -29
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createMetadataMiddleware.js +3 -1
- package/dist/instantsearch.development.d.ts +56 -14
- package/dist/instantsearch.development.js +194 -171
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +56 -14
- package/dist/instantsearch.production.min.d.ts +56 -14
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Hits/Hits.d.ts +1 -9
- package/es/components/Hits/Hits.js +0 -6
- package/es/components/Pagination/Pagination.d.ts +3 -10
- package/es/components/Pagination/Pagination.js +55 -34
- package/es/connectors/breadcrumb/connectBreadcrumb.js +6 -1
- package/es/connectors/clear-refinements/connectClearRefinements.js +11 -6
- package/es/connectors/current-refinements/connectCurrentRefinements.js +6 -2
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +4 -5
- package/es/connectors/geo-search/connectGeoSearch.js +3 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +3 -1
- package/es/connectors/hits/connectHits.js +3 -1
- package/es/connectors/hits-per-page/connectHitsPerPage.js +3 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.js +3 -1
- package/es/connectors/menu/connectMenu.js +3 -1
- package/es/connectors/numeric-menu/connectNumericMenu.js +5 -3
- package/es/connectors/query-rules/connectQueryRules.d.ts +1 -2
- package/es/connectors/query-rules/connectQueryRules.js +3 -1
- package/es/connectors/refinement-list/connectRefinementList.js +8 -3
- package/es/connectors/search-box/connectSearchBox.js +15 -25
- package/es/connectors/sort-by/connectSortBy.js +3 -1
- package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +36 -7
- package/es/helpers/highlight.js +5 -2
- package/es/helpers/reverseHighlight.js +5 -2
- package/es/helpers/reverseSnippet.js +5 -2
- package/es/helpers/snippet.js +5 -2
- package/es/lib/routers/history.d.ts +11 -0
- package/es/lib/routers/history.js +44 -29
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createMetadataMiddleware.js +3 -1
- package/es/types/widget.d.ts +4 -1
- package/package.json +3 -3
- package/cjs/components/Pagination/PaginationLink.js +0 -60
- package/dist/instantsearch.development.min.d.ts +0 -5217
- package/es/components/Pagination/PaginationLink.d.ts +0 -16
- package/es/components/Pagination/PaginationLink.js +0 -49
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
## [4.38.1](https://github.com/algolia/instantsearch.js/compare/v4.38.0...v4.38.1) (2022-02-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **routing:** fix history router based on history length ([#5004](https://github.com/algolia/instantsearch.js/issues/5004)) ([40541af](https://github.com/algolia/instantsearch.js/commit/40541af5c8face0e32a1ec3a4665a8387d89c626))
|
|
7
|
+
* **metadata:** ensure safe user agent detection ([#5009](https://github.com/algolia/instantsearch.js/pull/5009) [15a6a9d](https://github.com/algolia/instantsearch.js/commit/15a6a9d10ee512fab6884696bc59bedea13bd1b3))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# [4.38.0](https://github.com/algolia/instantsearch.js/compare/v4.37.3...v4.38.0) (2022-01-28)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **typescript:** remove non-existing UMD type definition ([#5001](https://github.com/algolia/instantsearch.js/issues/5001)) ([c234374](https://github.com/algolia/instantsearch.js/commit/c234374a1f5333f6625980c45fa0833a8c130257))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **connectors:** expose search results to `transformItems` when available ([#5000](https://github.com/algolia/instantsearch.js/issues/5000)) ([58c2651](https://github.com/algolia/instantsearch.js/commit/58c26517aad916ce49b474458e3411ff7ef5497a))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [4.37.3](https://github.com/algolia/instantsearch.js/compare/v4.37.2...v4.37.3) (2022-01-25)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* **helpers:** display warning if attribute cannot be highlighted/snippeted ([#4996](https://github.com/algolia/instantsearch.js/issues/4996)) ([e81bf59](https://github.com/algolia/instantsearch.js/commit/e81bf59f0f28eb7b9f54f7d4424c60546b9a4d8c))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [4.37.2](https://github.com/algolia/instantsearch.js/compare/v4.37.1...v4.37.2) (2022-01-10)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **searchbox:** make sure setting query to the initial doesn't cause a stale state ([#4990](https://github.com/algolia/instantsearch.js/issues/4990)) ([3faca01](https://github.com/algolia/instantsearch.js/commit/3faca014aad08145c3b4cc66a5e841da3a0f64b8))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
1
42
|
## [4.37.1](https://github.com/algolia/instantsearch.js/compare/v4.37.0...v4.37.1) (2022-01-05)
|
|
2
43
|
|
|
3
44
|
|
|
@@ -9,91 +9,110 @@ var _preact = require("preact");
|
|
|
9
9
|
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
|
|
12
|
-
var _PaginationLink = _interopRequireDefault(require("./PaginationLink.js"));
|
|
13
|
-
|
|
14
12
|
var _index = require("../../lib/utils/index.js");
|
|
15
13
|
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
17
|
|
|
20
|
-
var defaultProps = {
|
|
21
|
-
currentPage: 0,
|
|
22
|
-
nbPages: 0,
|
|
23
|
-
pages: []
|
|
24
|
-
};
|
|
25
|
-
|
|
26
18
|
function Pagination(props) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
function createClickHandler(pageNumber) {
|
|
20
|
+
return function (event) {
|
|
21
|
+
if ((0, _index.isSpecialClick)(event)) {
|
|
22
|
+
// do not alter the default browser behavior
|
|
23
|
+
// if one special key is down
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
props.setCurrentPage(pageNumber);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
37
31
|
|
|
38
32
|
return (0, _preact.h)("div", {
|
|
39
33
|
className: (0, _classnames.default)(props.cssClasses.root, _defineProperty({}, props.cssClasses.noRefinementRoot, props.nbPages <= 1))
|
|
40
34
|
}, (0, _preact.h)("ul", {
|
|
41
35
|
className: props.cssClasses.list
|
|
42
|
-
}, props.showFirst && (0, _preact.h)(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
additionalClassName: props.cssClasses.firstPageItem,
|
|
36
|
+
}, props.showFirst && (0, _preact.h)(PaginationLink, {
|
|
37
|
+
ariaLabel: "First",
|
|
38
|
+
className: props.cssClasses.firstPageItem,
|
|
46
39
|
isDisabled: props.isFirstPage,
|
|
47
40
|
label: props.templates.first,
|
|
48
41
|
pageNumber: 0,
|
|
49
42
|
createURL: props.createURL,
|
|
50
43
|
cssClasses: props.cssClasses,
|
|
51
|
-
|
|
52
|
-
}), props.showPrevious && (0, _preact.h)(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
additionalClassName: props.cssClasses.previousPageItem,
|
|
44
|
+
createClickHandler: createClickHandler
|
|
45
|
+
}), props.showPrevious && (0, _preact.h)(PaginationLink, {
|
|
46
|
+
ariaLabel: "Previous",
|
|
47
|
+
className: props.cssClasses.previousPageItem,
|
|
56
48
|
isDisabled: props.isFirstPage,
|
|
57
49
|
label: props.templates.previous,
|
|
58
50
|
pageNumber: props.currentPage - 1,
|
|
59
51
|
createURL: props.createURL,
|
|
60
52
|
cssClasses: props.cssClasses,
|
|
61
|
-
|
|
53
|
+
createClickHandler: createClickHandler
|
|
62
54
|
}), props.pages.map(function (pageNumber) {
|
|
63
|
-
return (0, _preact.h)(
|
|
55
|
+
return (0, _preact.h)(PaginationLink, {
|
|
64
56
|
key: pageNumber,
|
|
65
57
|
ariaLabel: "".concat(pageNumber + 1),
|
|
66
|
-
|
|
58
|
+
className: props.cssClasses.pageItem,
|
|
67
59
|
isSelected: pageNumber === props.currentPage,
|
|
68
60
|
label: "".concat(pageNumber + 1),
|
|
69
61
|
pageNumber: pageNumber,
|
|
70
62
|
createURL: props.createURL,
|
|
71
63
|
cssClasses: props.cssClasses,
|
|
72
|
-
|
|
64
|
+
createClickHandler: createClickHandler
|
|
73
65
|
});
|
|
74
|
-
}), props.showNext && (0, _preact.h)(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
additionalClassName: props.cssClasses.nextPageItem,
|
|
66
|
+
}), props.showNext && (0, _preact.h)(PaginationLink, {
|
|
67
|
+
ariaLabel: "Next",
|
|
68
|
+
className: props.cssClasses.nextPageItem,
|
|
78
69
|
isDisabled: props.isLastPage,
|
|
79
70
|
label: props.templates.next,
|
|
80
71
|
pageNumber: props.currentPage + 1,
|
|
81
72
|
createURL: props.createURL,
|
|
82
73
|
cssClasses: props.cssClasses,
|
|
83
|
-
|
|
84
|
-
}), props.showLast && (0, _preact.h)(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
additionalClassName: props.cssClasses.lastPageItem,
|
|
74
|
+
createClickHandler: createClickHandler
|
|
75
|
+
}), props.showLast && (0, _preact.h)(PaginationLink, {
|
|
76
|
+
ariaLabel: "Last",
|
|
77
|
+
className: props.cssClasses.lastPageItem,
|
|
88
78
|
isDisabled: props.isLastPage,
|
|
89
79
|
label: props.templates.last,
|
|
90
80
|
pageNumber: props.nbPages - 1,
|
|
91
81
|
createURL: props.createURL,
|
|
92
82
|
cssClasses: props.cssClasses,
|
|
93
|
-
|
|
83
|
+
createClickHandler: createClickHandler
|
|
94
84
|
})));
|
|
95
85
|
}
|
|
96
86
|
|
|
97
|
-
|
|
87
|
+
function PaginationLink(_ref) {
|
|
88
|
+
var label = _ref.label,
|
|
89
|
+
ariaLabel = _ref.ariaLabel,
|
|
90
|
+
pageNumber = _ref.pageNumber,
|
|
91
|
+
className = _ref.className,
|
|
92
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
93
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
94
|
+
_ref$isSelected = _ref.isSelected,
|
|
95
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
96
|
+
cssClasses = _ref.cssClasses,
|
|
97
|
+
createURL = _ref.createURL,
|
|
98
|
+
createClickHandler = _ref.createClickHandler;
|
|
99
|
+
return (0, _preact.h)("li", {
|
|
100
|
+
className: (0, _classnames.default)(cssClasses.item, className, isDisabled && cssClasses.disabledItem, isSelected && cssClasses.selectedItem)
|
|
101
|
+
}, isDisabled ? (0, _preact.h)("span", {
|
|
102
|
+
className: cssClasses.link,
|
|
103
|
+
dangerouslySetInnerHTML: {
|
|
104
|
+
__html: label
|
|
105
|
+
}
|
|
106
|
+
}) : (0, _preact.h)("a", {
|
|
107
|
+
className: cssClasses.link,
|
|
108
|
+
"aria-label": ariaLabel,
|
|
109
|
+
href: createURL(pageNumber),
|
|
110
|
+
onClick: createClickHandler(pageNumber),
|
|
111
|
+
dangerouslySetInnerHTML: {
|
|
112
|
+
__html: label
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
|
|
98
117
|
var _default = Pagination;
|
|
99
118
|
exports.default = _default;
|
|
@@ -94,6 +94,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
|
|
|
94
94
|
state = _ref2.state;
|
|
95
95
|
|
|
96
96
|
function getItems() {
|
|
97
|
+
// The hierarchicalFacets condition is required for flavors
|
|
98
|
+
// that render immediately with empty results, without relying
|
|
99
|
+
// on init() (like React InstantSearch Hooks).
|
|
97
100
|
if (!results || state.hierarchicalFacets.length === 0) {
|
|
98
101
|
return [];
|
|
99
102
|
}
|
|
@@ -103,7 +106,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
|
|
|
103
106
|
|
|
104
107
|
var facetValues = results.getFacetValues(facetName, {});
|
|
105
108
|
var data = Array.isArray(facetValues.data) ? facetValues.data : [];
|
|
106
|
-
var items = transformItems(shiftItemsValues(prepareItems(data))
|
|
109
|
+
var items = transformItems(shiftItemsValues(prepareItems(data)), {
|
|
110
|
+
results: results
|
|
111
|
+
});
|
|
107
112
|
return items;
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -88,13 +88,15 @@ var connectClearRefinements = function connectClearRefinements(renderFn) {
|
|
|
88
88
|
},
|
|
89
89
|
getWidgetRenderState: function getWidgetRenderState(_ref2) {
|
|
90
90
|
var createURL = _ref2.createURL,
|
|
91
|
-
scopedResults = _ref2.scopedResults
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
scopedResults = _ref2.scopedResults,
|
|
92
|
+
results = _ref2.results;
|
|
93
|
+
connectorState.attributesToClear = scopedResults.reduce(function (attributesToClear, scopedResult) {
|
|
94
|
+
return attributesToClear.concat(getAttributesToClear({
|
|
94
95
|
scopedResult: scopedResult,
|
|
95
96
|
includedAttributes: includedAttributes,
|
|
96
97
|
excludedAttributes: excludedAttributes,
|
|
97
|
-
transformItems: transformItems
|
|
98
|
+
transformItems: transformItems,
|
|
99
|
+
results: results
|
|
98
100
|
}));
|
|
99
101
|
}, []);
|
|
100
102
|
|
|
@@ -139,7 +141,8 @@ function getAttributesToClear(_ref5) {
|
|
|
139
141
|
var scopedResult = _ref5.scopedResult,
|
|
140
142
|
includedAttributes = _ref5.includedAttributes,
|
|
141
143
|
excludedAttributes = _ref5.excludedAttributes,
|
|
142
|
-
transformItems = _ref5.transformItems
|
|
144
|
+
transformItems = _ref5.transformItems,
|
|
145
|
+
results = _ref5.results;
|
|
143
146
|
var includesQuery = includedAttributes.indexOf('query') !== -1 || excludedAttributes.indexOf('query') === -1;
|
|
144
147
|
return {
|
|
145
148
|
helper: scopedResult.helper,
|
|
@@ -155,7 +158,9 @@ function getAttributesToClear(_ref5) {
|
|
|
155
158
|
attribute === 'query' && includesQuery || // Otherwise, ignore the excluded attributes
|
|
156
159
|
excludedAttributes.indexOf(attribute) === -1
|
|
157
160
|
);
|
|
158
|
-
}))
|
|
161
|
+
})), {
|
|
162
|
+
results: results
|
|
163
|
+
})
|
|
159
164
|
};
|
|
160
165
|
}
|
|
161
166
|
|
|
@@ -82,7 +82,9 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
|
|
|
82
82
|
helper: helper,
|
|
83
83
|
includedAttributes: includedAttributes,
|
|
84
84
|
excludedAttributes: excludedAttributes
|
|
85
|
-
})
|
|
85
|
+
}), {
|
|
86
|
+
results: results
|
|
87
|
+
});
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
return scopedResults.reduce(function (accResults, scopedResult) {
|
|
@@ -91,7 +93,9 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
|
|
|
91
93
|
helper: scopedResult.helper,
|
|
92
94
|
includedAttributes: includedAttributes,
|
|
93
95
|
excludedAttributes: excludedAttributes
|
|
94
|
-
})
|
|
96
|
+
}), {
|
|
97
|
+
results: results
|
|
98
|
+
}));
|
|
95
99
|
}, []);
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -169,7 +169,9 @@ var connectGeoSearch = function connectGeoSearch(renderFn) {
|
|
|
169
169
|
var state = helper.state;
|
|
170
170
|
var items = results ? transformItems(results.hits.filter(function (hit) {
|
|
171
171
|
return hit._geoloc;
|
|
172
|
-
})
|
|
172
|
+
}), {
|
|
173
|
+
results: results
|
|
174
|
+
}) : [];
|
|
173
175
|
|
|
174
176
|
if (!sendEvent) {
|
|
175
177
|
sendEvent = (0, _index.createSendEventForHits)({
|
|
@@ -200,7 +200,9 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
|
|
|
200
200
|
|
|
201
201
|
var hasExhaustiveItems = (state.maxValuesPerFacet || 0) > getLimit() ? facetItems.length <= getLimit() : facetItems.length < getLimit();
|
|
202
202
|
canToggleShowMore = showMore && (isShowingMore || !hasExhaustiveItems);
|
|
203
|
-
items = transformItems(_prepareFacetValues(facetItems)
|
|
203
|
+
items = transformItems(_prepareFacetValues(facetItems), {
|
|
204
|
+
results: results
|
|
205
|
+
});
|
|
204
206
|
}
|
|
205
207
|
|
|
206
208
|
return {
|
|
@@ -87,7 +87,9 @@ var connectHits = function connectHits(renderFn) {
|
|
|
87
87
|
|
|
88
88
|
var hitsWithAbsolutePosition = (0, _index.addAbsolutePosition)(results.hits, results.page, results.hitsPerPage);
|
|
89
89
|
var hitsWithAbsolutePositionAndQueryID = (0, _index.addQueryID)(hitsWithAbsolutePosition, results.queryID);
|
|
90
|
-
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID
|
|
90
|
+
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
91
|
+
results: results
|
|
92
|
+
});
|
|
91
93
|
return {
|
|
92
94
|
hits: transformedHits,
|
|
93
95
|
results: results,
|
|
@@ -128,7 +128,9 @@ var connectHitsPerPage = function connectHitsPerPage(renderFn) {
|
|
|
128
128
|
createURL = _ref5.createURL,
|
|
129
129
|
helper = _ref5.helper;
|
|
130
130
|
return {
|
|
131
|
-
items: transformItems(normalizeItems(state)
|
|
131
|
+
items: transformItems(normalizeItems(state), {
|
|
132
|
+
results: results
|
|
133
|
+
}),
|
|
132
134
|
refine: connectorState.getRefine(helper),
|
|
133
135
|
createURL: connectorState.createURLFactory({
|
|
134
136
|
state: state,
|
|
@@ -184,7 +184,9 @@ var connectInfiniteHits = function connectInfiniteHits(renderFn) {
|
|
|
184
184
|
|
|
185
185
|
var hitsWithAbsolutePosition = (0, _index.addAbsolutePosition)(results.hits, results.page, results.hitsPerPage);
|
|
186
186
|
var hitsWithAbsolutePositionAndQueryID = (0, _index.addQueryID)(hitsWithAbsolutePosition, results.queryID);
|
|
187
|
-
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID
|
|
187
|
+
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
188
|
+
results: results
|
|
189
|
+
});
|
|
188
190
|
|
|
189
191
|
if (cachedHits[_page] === undefined) {
|
|
190
192
|
cachedHits[_page] = transformedHits;
|
|
@@ -86,8 +86,8 @@ var connectNumericMenu = function connectNumericMenu(renderFn) {
|
|
|
86
86
|
_ref2$items = _ref2.items,
|
|
87
87
|
items = _ref2$items === void 0 ? [] : _ref2$items,
|
|
88
88
|
_ref2$transformItems = _ref2.transformItems,
|
|
89
|
-
transformItems = _ref2$transformItems === void 0 ? function (
|
|
90
|
-
return
|
|
89
|
+
transformItems = _ref2$transformItems === void 0 ? function (item) {
|
|
90
|
+
return item;
|
|
91
91
|
} : _ref2$transformItems;
|
|
92
92
|
|
|
93
93
|
if (attribute === '') {
|
|
@@ -224,7 +224,9 @@ var connectNumericMenu = function connectNumericMenu(renderFn) {
|
|
|
224
224
|
|
|
225
225
|
return {
|
|
226
226
|
createURL: connectorState.createURL(state),
|
|
227
|
-
items: transformItems(prepareItems(state)
|
|
227
|
+
items: transformItems(prepareItems(state), {
|
|
228
|
+
results: results
|
|
229
|
+
}),
|
|
228
230
|
hasNoResults: results ? results.nbHits === 0 : true,
|
|
229
231
|
refine: connectorState.refine,
|
|
230
232
|
sendEvent: connectorState.sendEvent,
|
|
@@ -160,7 +160,9 @@ var connectQueryRules = function connectQueryRules(_render) {
|
|
|
160
160
|
_ref4$userData = _ref4.userData,
|
|
161
161
|
userData = _ref4$userData === void 0 ? [] : _ref4$userData;
|
|
162
162
|
|
|
163
|
-
var items = transformItems(userData
|
|
163
|
+
var items = transformItems(userData, {
|
|
164
|
+
results: results
|
|
165
|
+
});
|
|
164
166
|
return {
|
|
165
167
|
items: items,
|
|
166
168
|
widgetParams: widgetParams
|
|
@@ -113,7 +113,8 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
113
113
|
var createSearchForFacetValues = function createSearchForFacetValues(helper, widget) {
|
|
114
114
|
return function (renderOptions) {
|
|
115
115
|
return function (query) {
|
|
116
|
-
var instantSearchInstance = renderOptions.instantSearchInstance
|
|
116
|
+
var instantSearchInstance = renderOptions.instantSearchInstance,
|
|
117
|
+
searchResults = renderOptions.results;
|
|
117
118
|
|
|
118
119
|
if (query === '' && lastItemsFromMainSearch) {
|
|
119
120
|
// render with previous data from the helper.
|
|
@@ -140,7 +141,9 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
140
141
|
value: value,
|
|
141
142
|
label: value
|
|
142
143
|
});
|
|
143
|
-
})
|
|
144
|
+
}), {
|
|
145
|
+
results: searchResults
|
|
146
|
+
});
|
|
144
147
|
renderFn(_objectSpread(_objectSpread({}, widget.getWidgetRenderState(_objectSpread(_objectSpread({}, renderOptions), {}, {
|
|
145
148
|
results: lastResultsFromMainSearch
|
|
146
149
|
}))), {}, {
|
|
@@ -204,7 +207,9 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
204
207
|
facetOrdering: sortBy === DEFAULT_SORT
|
|
205
208
|
});
|
|
206
209
|
facetValues = values && Array.isArray(values) ? values : [];
|
|
207
|
-
items = transformItems(facetValues.slice(0, getLimit()).map(formatItems)
|
|
210
|
+
items = transformItems(facetValues.slice(0, getLimit()).map(formatItems), {
|
|
211
|
+
results: results
|
|
212
|
+
});
|
|
208
213
|
var maxValuesPerFacetConfig = state.maxValuesPerFacet;
|
|
209
214
|
var currentLimit = getLimit(); // If the limit is the max number of facet retrieved it is impossible to know
|
|
210
215
|
// if the facets are exhaustive. The only moment we are sure it is exhaustive
|
|
@@ -18,32 +18,28 @@ var withUsage = (0, _index.createDocumentationMessageGenerator)({
|
|
|
18
18
|
connector: true
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
var defaultQueryHook = function defaultQueryHook(query, hook) {
|
|
22
|
+
return hook(query);
|
|
23
|
+
};
|
|
21
24
|
/**
|
|
22
25
|
* **SearchBox** connector provides the logic to build a widget that will let the user search for a query.
|
|
23
26
|
*
|
|
24
27
|
* The connector provides to the rendering: `refine()` to set the query. The behaviour of this function
|
|
25
28
|
* may be impacted by the `queryHook` widget parameter.
|
|
26
29
|
*/
|
|
30
|
+
|
|
31
|
+
|
|
27
32
|
var connectSearchBox = function connectSearchBox(renderFn) {
|
|
28
33
|
var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _index.noop;
|
|
29
34
|
(0, _index.checkRendering)(renderFn, withUsage());
|
|
30
35
|
return function (widgetParams) {
|
|
31
36
|
var _ref = widgetParams || {},
|
|
32
|
-
queryHook = _ref.queryHook
|
|
33
|
-
|
|
34
|
-
function clear(helper) {
|
|
35
|
-
return function () {
|
|
36
|
-
helper.setQuery('').search();
|
|
37
|
-
};
|
|
38
|
-
}
|
|
37
|
+
_ref$queryHook = _ref.queryHook,
|
|
38
|
+
queryHook = _ref$queryHook === void 0 ? defaultQueryHook : _ref$queryHook;
|
|
39
39
|
|
|
40
40
|
var _refine;
|
|
41
41
|
|
|
42
|
-
var _clear
|
|
43
|
-
|
|
44
|
-
function _cachedClear() {
|
|
45
|
-
_clear();
|
|
46
|
-
}
|
|
42
|
+
var _clear;
|
|
47
43
|
|
|
48
44
|
return {
|
|
49
45
|
$$type: 'ais.searchBox',
|
|
@@ -75,27 +71,21 @@ var connectSearchBox = function connectSearchBox(renderFn) {
|
|
|
75
71
|
state = _ref3.state;
|
|
76
72
|
|
|
77
73
|
if (!_refine) {
|
|
78
|
-
var setQueryAndSearch = function setQueryAndSearch(query) {
|
|
79
|
-
if (query !== state.query) {
|
|
80
|
-
helper.setQuery(query).search();
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
74
|
_refine = function _refine(query) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
queryHook(query, function (q) {
|
|
76
|
+
return helper.setQuery(q).search();
|
|
77
|
+
});
|
|
78
|
+
};
|
|
89
79
|
|
|
90
|
-
|
|
80
|
+
_clear = function _clear() {
|
|
81
|
+
helper.setQuery('').search();
|
|
91
82
|
};
|
|
92
83
|
}
|
|
93
84
|
|
|
94
|
-
_clear = clear(helper);
|
|
95
85
|
return {
|
|
96
86
|
query: state.query || '',
|
|
97
87
|
refine: _refine,
|
|
98
|
-
clear:
|
|
88
|
+
clear: _clear,
|
|
99
89
|
widgetParams: widgetParams,
|
|
100
90
|
isSearchStalled: searchMetadata.isSearchStalled
|
|
101
91
|
};
|
|
@@ -87,7 +87,9 @@ var connectSortBy = function connectSortBy(renderFn) {
|
|
|
87
87
|
|
|
88
88
|
return {
|
|
89
89
|
currentRefinement: state.index,
|
|
90
|
-
options: transformItems(items
|
|
90
|
+
options: transformItems(items, {
|
|
91
|
+
results: results
|
|
92
|
+
}),
|
|
91
93
|
refine: connectorState.setIndex,
|
|
92
94
|
hasNoResults: results ? results.nbHits === 0 : true,
|
|
93
95
|
widgetParams: widgetParams
|
package/cjs/helpers/highlight.js
CHANGED
|
@@ -18,8 +18,11 @@ function highlight(_ref) {
|
|
|
18
18
|
hit = _ref.hit,
|
|
19
19
|
_ref$cssClasses = _ref.cssClasses,
|
|
20
20
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
21
|
+
var highlightAttributeResult = (0, _index.getPropertyByPath)(hit._highlightResult, attribute); // @MAJOR fallback to attribute value if highlight is not found
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
process.env.NODE_ENV === 'development' ? (0, _index.warning)(highlightAttributeResult, "Could not enable highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
24
|
+
|
|
25
|
+
var _ref2 = highlightAttributeResult || {},
|
|
23
26
|
_ref2$value = _ref2.value,
|
|
24
27
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
|
|
25
28
|
|
|
@@ -18,8 +18,11 @@ function reverseHighlight(_ref) {
|
|
|
18
18
|
hit = _ref.hit,
|
|
19
19
|
_ref$cssClasses = _ref.cssClasses,
|
|
20
20
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
21
|
+
var highlightAttributeResult = (0, _index.getPropertyByPath)(hit._highlightResult, attribute); // @MAJOR fallback to attribute value if highlight is not found
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
process.env.NODE_ENV === 'development' ? (0, _index.warning)(highlightAttributeResult, "Could not enable reverse highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
24
|
+
|
|
25
|
+
var _ref2 = highlightAttributeResult || {},
|
|
23
26
|
_ref2$value = _ref2.value,
|
|
24
27
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
|
|
25
28
|
|
|
@@ -18,8 +18,11 @@ function reverseSnippet(_ref) {
|
|
|
18
18
|
hit = _ref.hit,
|
|
19
19
|
_ref$cssClasses = _ref.cssClasses,
|
|
20
20
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
21
|
+
var snippetAttributeResult = (0, _index.getPropertyByPath)(hit._snippetResult, attribute); // @MAJOR fallback to attribute value if snippet is not found
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
process.env.NODE_ENV === 'development' ? (0, _index.warning)(snippetAttributeResult, "Could not enable reverse snippet for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
24
|
+
|
|
25
|
+
var _ref2 = snippetAttributeResult || {},
|
|
23
26
|
_ref2$value = _ref2.value,
|
|
24
27
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
|
|
25
28
|
|
package/cjs/helpers/snippet.js
CHANGED
|
@@ -18,8 +18,11 @@ function snippet(_ref) {
|
|
|
18
18
|
hit = _ref.hit,
|
|
19
19
|
_ref$cssClasses = _ref.cssClasses,
|
|
20
20
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
21
|
+
var snippetAttributeResult = (0, _index.getPropertyByPath)(hit._snippetResult, attribute); // @MAJOR fallback to attribute value if snippet is not found
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
process.env.NODE_ENV === 'development' ? (0, _index.warning)(snippetAttributeResult, "Could not enable snippet for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
24
|
+
|
|
25
|
+
var _ref2 = snippetAttributeResult || {},
|
|
23
26
|
_ref2$value = _ref2.value,
|
|
24
27
|
attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular
|
|
25
28
|
|