instantsearch.js 4.78.3 → 4.79.0
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/cjs/components/RefinementList/RefinementList.js +3 -0
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +1 -3
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +5 -1
- package/cjs/lib/InstantSearch.js +21 -8
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/refinement-list/refinement-list.js +7 -2
- package/dist/instantsearch.development.d.ts +7 -0
- package/dist/instantsearch.development.js +55 -18
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +7 -0
- package/dist/instantsearch.production.min.d.ts +7 -0
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/RefinementList/RefinementList.d.ts +1 -0
- package/es/components/RefinementList/RefinementList.js +3 -0
- package/es/connectors/breadcrumb/connectBreadcrumb.js +1 -3
- package/es/connectors/infinite-hits/connectInfiniteHits.js +5 -1
- package/es/lib/InstantSearch.d.ts +2 -0
- package/es/lib/InstantSearch.js +21 -8
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/widgets/refinement-list/refinement-list.d.ts +5 -0
- package/es/widgets/refinement-list/refinement-list.js +7 -2
- package/package.json +6 -6
|
@@ -181,6 +181,9 @@ var RefinementList = /*#__PURE__*/function (_Component) {
|
|
|
181
181
|
}, {
|
|
182
182
|
key: "refineFirstValue",
|
|
183
183
|
value: function refineFirstValue() {
|
|
184
|
+
if (this.props.searchableSelectOnSubmit === false) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
184
187
|
var firstValue = this.props.facetValues && this.props.facetValues[0];
|
|
185
188
|
if (firstValue) {
|
|
186
189
|
var actualValue = firstValue.value;
|
|
@@ -85,9 +85,7 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
|
|
|
85
85
|
if (!results || state.hierarchicalFacets.length === 0) {
|
|
86
86
|
return [];
|
|
87
87
|
}
|
|
88
|
-
var
|
|
89
|
-
facetName = _state$hierarchicalFa[0].name;
|
|
90
|
-
var facetValues = results.getFacetValues(facetName, {});
|
|
88
|
+
var facetValues = results.getFacetValues(hierarchicalFacetName, {});
|
|
91
89
|
var facetItems = facetValues && !Array.isArray(facetValues) && facetValues.data ? facetValues.data : [];
|
|
92
90
|
var items = transformItems(shiftItemsValues(prepareItems(facetItems)), {
|
|
93
91
|
results: results
|
|
@@ -157,9 +157,11 @@ var connectInfiniteHits = exports.default = function connectInfiniteHits(renderF
|
|
|
157
157
|
state: normalizeState(state)
|
|
158
158
|
}) || {};
|
|
159
159
|
var banner = results === null || results === void 0 ? void 0 : (_results$renderingCon = results.renderingContent) === null || _results$renderingCon === void 0 ? void 0 : (_results$renderingCon2 = _results$renderingCon.widgets) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.banners) === null || _results$renderingCon3 === void 0 ? void 0 : _results$renderingCon3[0];
|
|
160
|
-
if (!
|
|
160
|
+
if (!showPrevious) {
|
|
161
161
|
showPrevious = getShowPrevious(helper);
|
|
162
162
|
showMore = getShowMore(helper);
|
|
163
|
+
}
|
|
164
|
+
if (!sendEvent) {
|
|
163
165
|
sendEvent = (0, _utils.createSendEventForHits)({
|
|
164
166
|
instantSearchInstance: instantSearchInstance,
|
|
165
167
|
helper: helper,
|
|
@@ -170,6 +172,8 @@ var connectInfiniteHits = exports.default = function connectInfiniteHits(renderF
|
|
|
170
172
|
widgetType: this.$$type,
|
|
171
173
|
instantSearchInstance: instantSearchInstance
|
|
172
174
|
});
|
|
175
|
+
}
|
|
176
|
+
if (!results) {
|
|
173
177
|
isFirstPage = state.page === undefined || getFirstReceivedPage(state, cachedHits) === 0;
|
|
174
178
|
} else {
|
|
175
179
|
var _state$disjunctiveFac, _state$hierarchicalFa;
|
package/cjs/lib/InstantSearch.js
CHANGED
|
@@ -81,6 +81,8 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
81
81
|
_defineProperty(_assertThisInitialized(_this), "_searchStalledTimer", void 0);
|
|
82
82
|
_defineProperty(_assertThisInitialized(_this), "_initialUiState", void 0);
|
|
83
83
|
_defineProperty(_assertThisInitialized(_this), "_initialResults", void 0);
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "_manuallyResetScheduleSearch", false);
|
|
85
|
+
_defineProperty(_assertThisInitialized(_this), "_resetScheduleSearch", void 0);
|
|
84
86
|
_defineProperty(_assertThisInitialized(_this), "_createURL", void 0);
|
|
85
87
|
_defineProperty(_assertThisInitialized(_this), "_searchFunction", void 0);
|
|
86
88
|
_defineProperty(_assertThisInitialized(_this), "_mainHelperSearch", void 0);
|
|
@@ -489,14 +491,25 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
489
491
|
// because we already have the results to render. This skips the initial
|
|
490
492
|
// network request on the browser on `start`.
|
|
491
493
|
this.scheduleSearch = (0, _utils.defer)(_utils.noop);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
494
|
+
if (this._manuallyResetScheduleSearch) {
|
|
495
|
+
// If `_manuallyResetScheduleSearch` is passed, it means that we don't
|
|
496
|
+
// want to rely on a single `defer` to reset the `scheduleSearch`.
|
|
497
|
+
// Instead, the consumer will call `_resetScheduleSearch` to restore
|
|
498
|
+
// the original `scheduleSearch` function.
|
|
499
|
+
// This happens in the React flavour after rendering.
|
|
500
|
+
this._resetScheduleSearch = function () {
|
|
501
|
+
_this3.scheduleSearch = originalScheduleSearch;
|
|
502
|
+
};
|
|
503
|
+
} else {
|
|
504
|
+
// We also skip the initial network request when widgets are dynamically
|
|
505
|
+
// added in the first tick (that's the case in all the framework-based flavors).
|
|
506
|
+
// When we add a widget to `index`, it calls `scheduleSearch`. We can rely
|
|
507
|
+
// on our `defer` util to restore the original `scheduleSearch` value once
|
|
508
|
+
// widgets are added to hook back to the regular lifecycle.
|
|
509
|
+
(0, _utils.defer)(function () {
|
|
510
|
+
_this3.scheduleSearch = originalScheduleSearch;
|
|
511
|
+
})();
|
|
512
|
+
}
|
|
500
513
|
}
|
|
501
514
|
// We only schedule a search when widgets have been added before `start()`
|
|
502
515
|
// because there are listeners that can use these results.
|
package/cjs/lib/version.js
CHANGED
|
@@ -34,7 +34,8 @@ var renderer = function renderer(_ref) {
|
|
|
34
34
|
showMore = _ref.showMore,
|
|
35
35
|
searchable = _ref.searchable,
|
|
36
36
|
searchablePlaceholder = _ref.searchablePlaceholder,
|
|
37
|
-
searchableIsAlwaysActive = _ref.searchableIsAlwaysActive
|
|
37
|
+
searchableIsAlwaysActive = _ref.searchableIsAlwaysActive,
|
|
38
|
+
searchableSelectOnSubmit = _ref.searchableSelectOnSubmit;
|
|
38
39
|
return function (_ref2, isFirstRendering) {
|
|
39
40
|
var refine = _ref2.refine,
|
|
40
41
|
items = _ref2.items,
|
|
@@ -74,7 +75,8 @@ var renderer = function renderer(_ref) {
|
|
|
74
75
|
toggleShowMore: toggleShowMore,
|
|
75
76
|
isShowingMore: isShowingMore,
|
|
76
77
|
hasExhaustiveItems: hasExhaustiveItems,
|
|
77
|
-
canToggleShowMore: canToggleShowMore
|
|
78
|
+
canToggleShowMore: canToggleShowMore,
|
|
79
|
+
searchableSelectOnSubmit: searchableSelectOnSubmit
|
|
78
80
|
}), containerNode);
|
|
79
81
|
};
|
|
80
82
|
};
|
|
@@ -114,6 +116,8 @@ var refinementList = function refinementList(widgetParams) {
|
|
|
114
116
|
searchableEscapeFacetValues = _ref3$searchableEscap === void 0 ? true : _ref3$searchableEscap,
|
|
115
117
|
_ref3$searchableIsAlw = _ref3.searchableIsAlwaysActive,
|
|
116
118
|
searchableIsAlwaysActive = _ref3$searchableIsAlw === void 0 ? true : _ref3$searchableIsAlw,
|
|
119
|
+
_ref3$searchableSelec = _ref3.searchableSelectOnSubmit,
|
|
120
|
+
searchableSelectOnSubmit = _ref3$searchableSelec === void 0 ? true : _ref3$searchableSelec,
|
|
117
121
|
_ref3$cssClasses = _ref3.cssClasses,
|
|
118
122
|
userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses,
|
|
119
123
|
_ref3$templates = _ref3.templates,
|
|
@@ -205,6 +209,7 @@ var refinementList = function refinementList(widgetParams) {
|
|
|
205
209
|
searchable: searchable,
|
|
206
210
|
searchablePlaceholder: searchablePlaceholder,
|
|
207
211
|
searchableIsAlwaysActive: searchableIsAlwaysActive,
|
|
212
|
+
searchableSelectOnSubmit: searchableSelectOnSubmit,
|
|
208
213
|
showMore: showMore
|
|
209
214
|
});
|
|
210
215
|
var makeWidget = (0, _connectRefinementList.default)(specializedRenderer, function () {
|
|
@@ -5076,6 +5076,8 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
5076
5076
|
_searchStalledTimer: any;
|
|
5077
5077
|
_initialUiState: TUiState;
|
|
5078
5078
|
_initialResults: InitialResults | null;
|
|
5079
|
+
_manuallyResetScheduleSearch: boolean;
|
|
5080
|
+
_resetScheduleSearch?: () => void;
|
|
5079
5081
|
_createURL: CreateURL<TUiState>;
|
|
5080
5082
|
_searchFunction?: InstantSearchOptions['searchFunction'];
|
|
5081
5083
|
_mainHelperSearch?: AlgoliaSearchHelper['search'];
|
|
@@ -7148,6 +7150,11 @@ declare type RefinementListWidgetParams = {
|
|
|
7148
7150
|
* In this case, the surrounding tags will always be `<mark></mark>`.
|
|
7149
7151
|
*/
|
|
7150
7152
|
searchableEscapeFacetValues?: boolean;
|
|
7153
|
+
/**
|
|
7154
|
+
* When activated, submitting the search box will select the first item in the list.
|
|
7155
|
+
* @default true
|
|
7156
|
+
*/
|
|
7157
|
+
searchableSelectOnSubmit?: boolean;
|
|
7151
7158
|
/**
|
|
7152
7159
|
* Templates to use for the widget.
|
|
7153
7160
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.79.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -6598,7 +6598,7 @@
|
|
|
6598
6598
|
|
|
6599
6599
|
var sortAndMergeRecommendations_1 = sortAndMergeRecommendations;
|
|
6600
6600
|
|
|
6601
|
-
var version = '3.
|
|
6601
|
+
var version = '3.26.0';
|
|
6602
6602
|
|
|
6603
6603
|
var escapeFacetValue$4 = escapeFacetValue_1.escapeFacetValue;
|
|
6604
6604
|
|
|
@@ -7034,6 +7034,16 @@
|
|
|
7034
7034
|
query: query,
|
|
7035
7035
|
});
|
|
7036
7036
|
|
|
7037
|
+
var hide =
|
|
7038
|
+
(this.lastResults &&
|
|
7039
|
+
this.lastResults.index === state.index &&
|
|
7040
|
+
this.lastResults.renderingContent &&
|
|
7041
|
+
this.lastResults.renderingContent.facetOrdering &&
|
|
7042
|
+
this.lastResults.renderingContent.facetOrdering.values &&
|
|
7043
|
+
this.lastResults.renderingContent.facetOrdering.values[facet] &&
|
|
7044
|
+
this.lastResults.renderingContent.facetOrdering.values[facet].hide) ||
|
|
7045
|
+
[];
|
|
7046
|
+
|
|
7037
7047
|
return searchForFacetValuesPromise.then(
|
|
7038
7048
|
function addIsRefined(content) {
|
|
7039
7049
|
self._currentNbQueries--;
|
|
@@ -7041,7 +7051,11 @@
|
|
|
7041
7051
|
|
|
7042
7052
|
content = Array.isArray(content) ? content[0] : content;
|
|
7043
7053
|
|
|
7044
|
-
content.facetHits.forEach(function (f) {
|
|
7054
|
+
content.facetHits.forEach(function (f, i) {
|
|
7055
|
+
if (hide.indexOf(f.value) > -1) {
|
|
7056
|
+
content.facetHits.splice(i, 1);
|
|
7057
|
+
return;
|
|
7058
|
+
}
|
|
7045
7059
|
f.escapedValue = escapeFacetValue$4(f.value);
|
|
7046
7060
|
f.isRefined = isDisjunctive
|
|
7047
7061
|
? state.isDisjunctiveFacetRefined(facet, f.escapedValue)
|
|
@@ -10280,9 +10294,11 @@
|
|
|
10280
10294
|
state: normalizeState(state)
|
|
10281
10295
|
}) || {};
|
|
10282
10296
|
var banner = results === null || results === void 0 ? void 0 : (_results$renderingCon = results.renderingContent) === null || _results$renderingCon === void 0 ? void 0 : (_results$renderingCon2 = _results$renderingCon.widgets) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.banners) === null || _results$renderingCon3 === void 0 ? void 0 : _results$renderingCon3[0];
|
|
10283
|
-
if (!
|
|
10297
|
+
if (!showPrevious) {
|
|
10284
10298
|
showPrevious = getShowPrevious(helper);
|
|
10285
10299
|
showMore = getShowMore(helper);
|
|
10300
|
+
}
|
|
10301
|
+
if (!sendEvent) {
|
|
10286
10302
|
sendEvent = createSendEventForHits({
|
|
10287
10303
|
instantSearchInstance: instantSearchInstance,
|
|
10288
10304
|
helper: helper,
|
|
@@ -10293,6 +10309,8 @@
|
|
|
10293
10309
|
widgetType: this.$$type,
|
|
10294
10310
|
instantSearchInstance: instantSearchInstance
|
|
10295
10311
|
});
|
|
10312
|
+
}
|
|
10313
|
+
if (!results) {
|
|
10296
10314
|
isFirstPage = state.page === undefined || getFirstReceivedPage(state, cachedHits) === 0;
|
|
10297
10315
|
} else {
|
|
10298
10316
|
var _state$disjunctiveFac, _state$hierarchicalFa;
|
|
@@ -12674,9 +12692,7 @@
|
|
|
12674
12692
|
if (!results || state.hierarchicalFacets.length === 0) {
|
|
12675
12693
|
return [];
|
|
12676
12694
|
}
|
|
12677
|
-
var
|
|
12678
|
-
facetName = _state$hierarchicalFa[0].name;
|
|
12679
|
-
var facetValues = results.getFacetValues(facetName, {});
|
|
12695
|
+
var facetValues = results.getFacetValues(hierarchicalFacetName, {});
|
|
12680
12696
|
var facetItems = facetValues && !Array.isArray(facetValues) && facetValues.data ? facetValues.data : [];
|
|
12681
12697
|
var items = transformItems(shiftItemsValues(prepareItems(facetItems)), {
|
|
12682
12698
|
results: results
|
|
@@ -16418,7 +16434,7 @@
|
|
|
16418
16434
|
};
|
|
16419
16435
|
}
|
|
16420
16436
|
|
|
16421
|
-
var version$1 = '4.
|
|
16437
|
+
var version$1 = '4.79.0';
|
|
16422
16438
|
|
|
16423
16439
|
var withUsage$v = createDocumentationMessageGenerator({
|
|
16424
16440
|
name: 'instantsearch'
|
|
@@ -16471,6 +16487,8 @@
|
|
|
16471
16487
|
_defineProperty(_assertThisInitialized(_this), "_searchStalledTimer", void 0);
|
|
16472
16488
|
_defineProperty(_assertThisInitialized(_this), "_initialUiState", void 0);
|
|
16473
16489
|
_defineProperty(_assertThisInitialized(_this), "_initialResults", void 0);
|
|
16490
|
+
_defineProperty(_assertThisInitialized(_this), "_manuallyResetScheduleSearch", false);
|
|
16491
|
+
_defineProperty(_assertThisInitialized(_this), "_resetScheduleSearch", void 0);
|
|
16474
16492
|
_defineProperty(_assertThisInitialized(_this), "_createURL", void 0);
|
|
16475
16493
|
_defineProperty(_assertThisInitialized(_this), "_searchFunction", void 0);
|
|
16476
16494
|
_defineProperty(_assertThisInitialized(_this), "_mainHelperSearch", void 0);
|
|
@@ -16879,14 +16897,25 @@
|
|
|
16879
16897
|
// because we already have the results to render. This skips the initial
|
|
16880
16898
|
// network request on the browser on `start`.
|
|
16881
16899
|
this.scheduleSearch = defer(noop);
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16900
|
+
if (this._manuallyResetScheduleSearch) {
|
|
16901
|
+
// If `_manuallyResetScheduleSearch` is passed, it means that we don't
|
|
16902
|
+
// want to rely on a single `defer` to reset the `scheduleSearch`.
|
|
16903
|
+
// Instead, the consumer will call `_resetScheduleSearch` to restore
|
|
16904
|
+
// the original `scheduleSearch` function.
|
|
16905
|
+
// This happens in the React flavour after rendering.
|
|
16906
|
+
this._resetScheduleSearch = function () {
|
|
16907
|
+
_this3.scheduleSearch = originalScheduleSearch;
|
|
16908
|
+
};
|
|
16909
|
+
} else {
|
|
16910
|
+
// We also skip the initial network request when widgets are dynamically
|
|
16911
|
+
// added in the first tick (that's the case in all the framework-based flavors).
|
|
16912
|
+
// When we add a widget to `index`, it calls `scheduleSearch`. We can rely
|
|
16913
|
+
// on our `defer` util to restore the original `scheduleSearch` value once
|
|
16914
|
+
// widgets are added to hook back to the regular lifecycle.
|
|
16915
|
+
defer(function () {
|
|
16916
|
+
_this3.scheduleSearch = originalScheduleSearch;
|
|
16917
|
+
})();
|
|
16918
|
+
}
|
|
16890
16919
|
}
|
|
16891
16920
|
// We only schedule a search when widgets have been added before `start()`
|
|
16892
16921
|
// because there are listeners that can use these results.
|
|
@@ -20814,6 +20843,9 @@
|
|
|
20814
20843
|
}, {
|
|
20815
20844
|
key: "refineFirstValue",
|
|
20816
20845
|
value: function refineFirstValue() {
|
|
20846
|
+
if (this.props.searchableSelectOnSubmit === false) {
|
|
20847
|
+
return;
|
|
20848
|
+
}
|
|
20817
20849
|
var firstValue = this.props.facetValues && this.props.facetValues[0];
|
|
20818
20850
|
if (firstValue) {
|
|
20819
20851
|
var actualValue = firstValue.value;
|
|
@@ -24123,7 +24155,8 @@
|
|
|
24123
24155
|
showMore = _ref.showMore,
|
|
24124
24156
|
searchable = _ref.searchable,
|
|
24125
24157
|
searchablePlaceholder = _ref.searchablePlaceholder,
|
|
24126
|
-
searchableIsAlwaysActive = _ref.searchableIsAlwaysActive
|
|
24158
|
+
searchableIsAlwaysActive = _ref.searchableIsAlwaysActive,
|
|
24159
|
+
searchableSelectOnSubmit = _ref.searchableSelectOnSubmit;
|
|
24127
24160
|
return function (_ref2, isFirstRendering) {
|
|
24128
24161
|
var refine = _ref2.refine,
|
|
24129
24162
|
items = _ref2.items,
|
|
@@ -24163,7 +24196,8 @@
|
|
|
24163
24196
|
toggleShowMore: toggleShowMore,
|
|
24164
24197
|
isShowingMore: isShowingMore,
|
|
24165
24198
|
hasExhaustiveItems: hasExhaustiveItems,
|
|
24166
|
-
canToggleShowMore: canToggleShowMore
|
|
24199
|
+
canToggleShowMore: canToggleShowMore,
|
|
24200
|
+
searchableSelectOnSubmit: searchableSelectOnSubmit
|
|
24167
24201
|
}), containerNode);
|
|
24168
24202
|
};
|
|
24169
24203
|
};
|
|
@@ -24203,6 +24237,8 @@
|
|
|
24203
24237
|
searchableEscapeFacetValues = _ref3$searchableEscap === void 0 ? true : _ref3$searchableEscap,
|
|
24204
24238
|
_ref3$searchableIsAlw = _ref3.searchableIsAlwaysActive,
|
|
24205
24239
|
searchableIsAlwaysActive = _ref3$searchableIsAlw === void 0 ? true : _ref3$searchableIsAlw,
|
|
24240
|
+
_ref3$searchableSelec = _ref3.searchableSelectOnSubmit,
|
|
24241
|
+
searchableSelectOnSubmit = _ref3$searchableSelec === void 0 ? true : _ref3$searchableSelec,
|
|
24206
24242
|
_ref3$cssClasses = _ref3.cssClasses,
|
|
24207
24243
|
userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses,
|
|
24208
24244
|
_ref3$templates = _ref3.templates,
|
|
@@ -24294,6 +24330,7 @@
|
|
|
24294
24330
|
searchable: searchable,
|
|
24295
24331
|
searchablePlaceholder: searchablePlaceholder,
|
|
24296
24332
|
searchableIsAlwaysActive: searchableIsAlwaysActive,
|
|
24333
|
+
searchableSelectOnSubmit: searchableSelectOnSubmit,
|
|
24297
24334
|
showMore: showMore
|
|
24298
24335
|
});
|
|
24299
24336
|
var makeWidget = connectRefinementList(specializedRenderer, function () {
|