instantsearch.js 4.78.2 → 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.
@@ -42,6 +42,7 @@ export type RefinementListProps<TTemplates extends Templates> = {
42
42
  searchFacetValues?: (query: string) => void;
43
43
  searchPlaceholder?: string;
44
44
  searchBoxTemplateProps?: PreparedTemplateProps<SearchBoxComponentTemplates>;
45
+ searchableSelectOnSubmit?: boolean;
45
46
  };
46
47
  declare const defaultProps: {
47
48
  cssClasses: {};
@@ -175,6 +175,9 @@ var RefinementList = /*#__PURE__*/function (_Component) {
175
175
  }, {
176
176
  key: "refineFirstValue",
177
177
  value: function refineFirstValue() {
178
+ if (this.props.searchableSelectOnSubmit === false) {
179
+ return;
180
+ }
178
181
  var firstValue = this.props.facetValues && this.props.facetValues[0];
179
182
  if (firstValue) {
180
183
  var actualValue = firstValue.value;
@@ -79,9 +79,7 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
79
79
  if (!results || state.hierarchicalFacets.length === 0) {
80
80
  return [];
81
81
  }
82
- var _state$hierarchicalFa = _slicedToArray(state.hierarchicalFacets, 1),
83
- facetName = _state$hierarchicalFa[0].name;
84
- var facetValues = results.getFacetValues(facetName, {});
82
+ var facetValues = results.getFacetValues(hierarchicalFacetName, {});
85
83
  var facetItems = facetValues && !Array.isArray(facetValues) && facetValues.data ? facetValues.data : [];
86
84
  var items = transformItems(shiftItemsValues(prepareItems(facetItems)), {
87
85
  results: results
@@ -151,9 +151,11 @@ export default (function connectInfiniteHits(renderFn) {
151
151
  state: normalizeState(state)
152
152
  }) || {};
153
153
  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];
154
- if (!results) {
154
+ if (!showPrevious) {
155
155
  showPrevious = getShowPrevious(helper);
156
156
  showMore = getShowMore(helper);
157
+ }
158
+ if (!sendEvent) {
157
159
  sendEvent = createSendEventForHits({
158
160
  instantSearchInstance: instantSearchInstance,
159
161
  helper: helper,
@@ -164,6 +166,8 @@ export default (function connectInfiniteHits(renderFn) {
164
166
  widgetType: this.$$type,
165
167
  instantSearchInstance: instantSearchInstance
166
168
  });
169
+ }
170
+ if (!results) {
167
171
  isFirstPage = state.page === undefined || getFirstReceivedPage(state, cachedHits) === 0;
168
172
  } else {
169
173
  var _state$disjunctiveFac, _state$hierarchicalFa;
@@ -148,6 +148,8 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
148
148
  _searchStalledTimer: any;
149
149
  _initialUiState: TUiState;
150
150
  _initialResults: InitialResults | null;
151
+ _manuallyResetScheduleSearch: boolean;
152
+ _resetScheduleSearch?: () => void;
151
153
  _createURL: CreateURL<TUiState>;
152
154
  _searchFunction?: InstantSearchOptions['searchFunction'];
153
155
  _mainHelperSearch?: AlgoliaSearchHelper['search'];
@@ -74,6 +74,8 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
74
74
  _defineProperty(_assertThisInitialized(_this), "_searchStalledTimer", void 0);
75
75
  _defineProperty(_assertThisInitialized(_this), "_initialUiState", void 0);
76
76
  _defineProperty(_assertThisInitialized(_this), "_initialResults", void 0);
77
+ _defineProperty(_assertThisInitialized(_this), "_manuallyResetScheduleSearch", false);
78
+ _defineProperty(_assertThisInitialized(_this), "_resetScheduleSearch", void 0);
77
79
  _defineProperty(_assertThisInitialized(_this), "_createURL", void 0);
78
80
  _defineProperty(_assertThisInitialized(_this), "_searchFunction", void 0);
79
81
  _defineProperty(_assertThisInitialized(_this), "_mainHelperSearch", void 0);
@@ -482,14 +484,25 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
482
484
  // because we already have the results to render. This skips the initial
483
485
  // network request on the browser on `start`.
484
486
  this.scheduleSearch = defer(noop);
485
- // We also skip the initial network request when widgets are dynamically
486
- // added in the first tick (that's the case in all the framework-based flavors).
487
- // When we add a widget to `index`, it calls `scheduleSearch`. We can rely
488
- // on our `defer` util to restore the original `scheduleSearch` value once
489
- // widgets are added to hook back to the regular lifecycle.
490
- defer(function () {
491
- _this3.scheduleSearch = originalScheduleSearch;
492
- })();
487
+ if (this._manuallyResetScheduleSearch) {
488
+ // If `_manuallyResetScheduleSearch` is passed, it means that we don't
489
+ // want to rely on a single `defer` to reset the `scheduleSearch`.
490
+ // Instead, the consumer will call `_resetScheduleSearch` to restore
491
+ // the original `scheduleSearch` function.
492
+ // This happens in the React flavour after rendering.
493
+ this._resetScheduleSearch = function () {
494
+ _this3.scheduleSearch = originalScheduleSearch;
495
+ };
496
+ } else {
497
+ // We also skip the initial network request when widgets are dynamically
498
+ // added in the first tick (that's the case in all the framework-based flavors).
499
+ // When we add a widget to `index`, it calls `scheduleSearch`. We can rely
500
+ // on our `defer` util to restore the original `scheduleSearch` value once
501
+ // widgets are added to hook back to the regular lifecycle.
502
+ defer(function () {
503
+ _this3.scheduleSearch = originalScheduleSearch;
504
+ })();
505
+ }
493
506
  }
494
507
  // We only schedule a search when widgets have been added before `start()`
495
508
  // because there are listeners that can use these results.
@@ -1,2 +1,2 @@
1
- declare const _default: "4.78.2";
1
+ declare const _default: "4.79.0";
2
2
  export default _default;
package/es/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.78.2';
1
+ export default '4.79.0';
@@ -256,10 +256,14 @@ export function createInsightsMiddleware() {
256
256
  var insightsClientWithLocalCredentials = insightsClient;
257
257
  if (isModernInsightsClient(insightsClient)) {
258
258
  insightsClientWithLocalCredentials = function insightsClientWithLocalCredentials(method, payload) {
259
+ var _getAppIdAndApiKey3 = getAppIdAndApiKey(instantSearchInstance.client),
260
+ _getAppIdAndApiKey4 = _slicedToArray(_getAppIdAndApiKey3, 2),
261
+ latestAppId = _getAppIdAndApiKey4[0],
262
+ latestApiKey = _getAppIdAndApiKey4[1];
259
263
  var extraParams = {
260
264
  headers: {
261
- 'X-Algolia-Application-Id': appId,
262
- 'X-Algolia-API-Key': apiKey
265
+ 'X-Algolia-Application-Id': latestAppId,
266
+ 'X-Algolia-API-Key': latestApiKey
263
267
  }
264
268
  };
265
269
 
@@ -160,6 +160,11 @@ export type RefinementListWidgetParams = {
160
160
  * In this case, the surrounding tags will always be `<mark></mark>`.
161
161
  */
162
162
  searchableEscapeFacetValues?: boolean;
163
+ /**
164
+ * When activated, submitting the search box will select the first item in the list.
165
+ * @default true
166
+ */
167
+ searchableSelectOnSubmit?: boolean;
163
168
  /**
164
169
  * Templates to use for the widget.
165
170
  */
@@ -27,7 +27,8 @@ var renderer = function renderer(_ref) {
27
27
  showMore = _ref.showMore,
28
28
  searchable = _ref.searchable,
29
29
  searchablePlaceholder = _ref.searchablePlaceholder,
30
- searchableIsAlwaysActive = _ref.searchableIsAlwaysActive;
30
+ searchableIsAlwaysActive = _ref.searchableIsAlwaysActive,
31
+ searchableSelectOnSubmit = _ref.searchableSelectOnSubmit;
31
32
  return function (_ref2, isFirstRendering) {
32
33
  var refine = _ref2.refine,
33
34
  items = _ref2.items,
@@ -67,7 +68,8 @@ var renderer = function renderer(_ref) {
67
68
  toggleShowMore: toggleShowMore,
68
69
  isShowingMore: isShowingMore,
69
70
  hasExhaustiveItems: hasExhaustiveItems,
70
- canToggleShowMore: canToggleShowMore
71
+ canToggleShowMore: canToggleShowMore,
72
+ searchableSelectOnSubmit: searchableSelectOnSubmit
71
73
  }), containerNode);
72
74
  };
73
75
  };
@@ -107,6 +109,8 @@ var refinementList = function refinementList(widgetParams) {
107
109
  searchableEscapeFacetValues = _ref3$searchableEscap === void 0 ? true : _ref3$searchableEscap,
108
110
  _ref3$searchableIsAlw = _ref3.searchableIsAlwaysActive,
109
111
  searchableIsAlwaysActive = _ref3$searchableIsAlw === void 0 ? true : _ref3$searchableIsAlw,
112
+ _ref3$searchableSelec = _ref3.searchableSelectOnSubmit,
113
+ searchableSelectOnSubmit = _ref3$searchableSelec === void 0 ? true : _ref3$searchableSelec,
110
114
  _ref3$cssClasses = _ref3.cssClasses,
111
115
  userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses,
112
116
  _ref3$templates = _ref3.templates,
@@ -198,6 +202,7 @@ var refinementList = function refinementList(widgetParams) {
198
202
  searchable: searchable,
199
203
  searchablePlaceholder: searchablePlaceholder,
200
204
  searchableIsAlwaysActive: searchableIsAlwaysActive,
205
+ searchableSelectOnSubmit: searchableSelectOnSubmit,
201
206
  showMore: showMore
202
207
  });
203
208
  var makeWidget = connectRefinementList(specializedRenderer, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.78.2",
3
+ "version": "4.79.0",
4
4
  "description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
5
5
  "homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
6
6
  "types": "es/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "@types/google.maps": "^3.55.12",
32
32
  "@types/hogan.js": "^3.0.0",
33
33
  "@types/qs": "^6.5.3",
34
- "algoliasearch-helper": "3.25.0",
34
+ "algoliasearch-helper": "3.26.0",
35
35
  "hogan.js": "^3.0.2",
36
36
  "htm": "^3.0.0",
37
37
  "instantsearch-ui-components": "0.11.1",
@@ -56,9 +56,9 @@
56
56
  "watch:es": "yarn --silent build:es:base --watch"
57
57
  },
58
58
  "devDependencies": {
59
- "@instantsearch/mocks": "1.73.0",
60
- "@instantsearch/tests": "1.73.0",
61
- "@instantsearch/testutils": "1.62.0",
59
+ "@instantsearch/mocks": "1.75.0",
60
+ "@instantsearch/tests": "1.75.0",
61
+ "@instantsearch/testutils": "1.64.0",
62
62
  "@storybook/html": "5.3.9",
63
63
  "@types/scriptjs": "0.0.2",
64
64
  "algoliasearch": "5.1.1",
@@ -66,5 +66,5 @@
66
66
  "scriptjs": "2.5.9",
67
67
  "webpack": "4.47.0"
68
68
  },
69
- "gitHead": "f0df58b3039f06b840d2b1174e9d53baae46daeb"
69
+ "gitHead": "eeb0a611e331ae0905a641d167ebac38d2fe1735"
70
70
  }