instantsearch.js 4.64.1 → 4.64.3

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.
@@ -29,6 +29,7 @@ var defaultProps = {
29
29
  showLoadingIndicator: true,
30
30
  autofocus: false,
31
31
  searchAsYouType: true,
32
+ ignoreCompositionEvents: false,
32
33
  isSearchStalled: false,
33
34
  disabled: false,
34
35
  ariaLabel: 'Search',
@@ -58,7 +59,7 @@ var SearchBox = /*#__PURE__*/function (_Component) {
58
59
  refine = _this$props.refine,
59
60
  onChange = _this$props.onChange;
60
61
  var query = event.target.value;
61
- if (event.type === 'compositionend' || !event.isComposing) {
62
+ if (!(_this.props.ignoreCompositionEvents && event.isComposing)) {
62
63
  if (searchAsYouType) {
63
64
  refine(query);
64
65
  }
@@ -69,7 +69,9 @@ var connectAutocomplete = function connectAutocomplete(renderFn) {
69
69
  scopedResult.results.hits = escapeHTML ? (0, _utils.escapeHits)(scopedResult.results.hits) : scopedResult.results.hits;
70
70
  var sendEvent = (0, _utils.createSendEventForHits)({
71
71
  instantSearchInstance: instantSearchInstance,
72
- index: scopedResult.results.index,
72
+ getIndex: function getIndex() {
73
+ return scopedResult.results.index;
74
+ },
73
75
  widgetType: _this.$$type
74
76
  });
75
77
  return {
@@ -155,7 +155,9 @@ var connectGeoSearch = function connectGeoSearch(renderFn) {
155
155
  if (!sendEvent) {
156
156
  sendEvent = (0, _utils.createSendEventForHits)({
157
157
  instantSearchInstance: instantSearchInstance,
158
- index: helper.getIndex(),
158
+ getIndex: function getIndex() {
159
+ return helper.getIndex();
160
+ },
159
161
  widgetType: $$type
160
162
  });
161
163
  }
@@ -54,13 +54,17 @@ var connectHits = function connectHits(renderFn) {
54
54
  if (!sendEvent) {
55
55
  sendEvent = (0, _utils.createSendEventForHits)({
56
56
  instantSearchInstance: instantSearchInstance,
57
- index: helper.getIndex(),
57
+ getIndex: function getIndex() {
58
+ return helper.getIndex();
59
+ },
58
60
  widgetType: this.$$type
59
61
  });
60
62
  }
61
63
  if (!bindEvent) {
62
64
  bindEvent = (0, _utils.createBindEventForHits)({
63
- index: helper.getIndex(),
65
+ getIndex: function getIndex() {
66
+ return helper.getIndex();
67
+ },
64
68
  widgetType: this.$$type,
65
69
  instantSearchInstance: instantSearchInstance
66
70
  });
@@ -161,11 +161,15 @@ var connectInfiniteHits = function connectInfiniteHits(renderFn) {
161
161
  showMore = getShowMore(helper);
162
162
  sendEvent = (0, _utils.createSendEventForHits)({
163
163
  instantSearchInstance: instantSearchInstance,
164
- index: helper.getIndex(),
164
+ getIndex: function getIndex() {
165
+ return helper.getIndex();
166
+ },
165
167
  widgetType: this.$$type
166
168
  });
167
169
  bindEvent = (0, _utils.createBindEventForHits)({
168
- index: helper.getIndex(),
170
+ getIndex: function getIndex() {
171
+ return helper.getIndex();
172
+ },
169
173
  widgetType: this.$$type,
170
174
  instantSearchInstance: instantSearchInstance
171
175
  });
@@ -28,7 +28,7 @@ function chunk(arr) {
28
28
  return chunks;
29
29
  }
30
30
  function _buildEventPayloadsForHits(_ref) {
31
- var index = _ref.index,
31
+ var getIndex = _ref.getIndex,
32
32
  widgetType = _ref.widgetType,
33
33
  methodName = _ref.methodName,
34
34
  args = _ref.args,
@@ -85,7 +85,7 @@ function _buildEventPayloadsForHits(_ref) {
85
85
  eventType: eventType,
86
86
  payload: _objectSpread({
87
87
  eventName: eventName || 'Hits Viewed',
88
- index: index,
88
+ index: getIndex(),
89
89
  objectIDs: objectIDsByChunk[i]
90
90
  }, additionalData),
91
91
  hits: batch,
@@ -100,7 +100,7 @@ function _buildEventPayloadsForHits(_ref) {
100
100
  eventType: eventType,
101
101
  payload: _objectSpread({
102
102
  eventName: eventName || 'Hit Clicked',
103
- index: index,
103
+ index: getIndex(),
104
104
  queryID: queryID,
105
105
  objectIDs: objectIDsByChunk[i],
106
106
  positions: positionsByChunk[i]
@@ -117,7 +117,7 @@ function _buildEventPayloadsForHits(_ref) {
117
117
  eventType: eventType,
118
118
  payload: _objectSpread({
119
119
  eventName: eventName || 'Hit Converted',
120
- index: index,
120
+ index: getIndex(),
121
121
  queryID: queryID,
122
122
  objectIDs: objectIDsByChunk[i]
123
123
  }, additionalData),
@@ -133,7 +133,7 @@ function _buildEventPayloadsForHits(_ref) {
133
133
  }
134
134
  function createSendEventForHits(_ref2) {
135
135
  var instantSearchInstance = _ref2.instantSearchInstance,
136
- index = _ref2.index,
136
+ getIndex = _ref2.getIndex,
137
137
  widgetType = _ref2.widgetType;
138
138
  var sentEvents = {};
139
139
  var timer = undefined;
@@ -143,7 +143,7 @@ function createSendEventForHits(_ref2) {
143
143
  }
144
144
  var payloads = _buildEventPayloadsForHits({
145
145
  widgetType: widgetType,
146
- index: index,
146
+ getIndex: getIndex,
147
147
  methodName: 'sendEvent',
148
148
  args: args,
149
149
  instantSearchInstance: instantSearchInstance
@@ -163,7 +163,7 @@ function createSendEventForHits(_ref2) {
163
163
  return sendEventForHits;
164
164
  }
165
165
  function createBindEventForHits(_ref3) {
166
- var index = _ref3.index,
166
+ var getIndex = _ref3.getIndex,
167
167
  widgetType = _ref3.widgetType,
168
168
  instantSearchInstance = _ref3.instantSearchInstance;
169
169
  var bindEventForHits = function bindEventForHits() {
@@ -172,7 +172,7 @@ function createBindEventForHits(_ref3) {
172
172
  }
173
173
  var payloads = _buildEventPayloadsForHits({
174
174
  widgetType: widgetType,
175
- index: index,
175
+ getIndex: getIndex,
176
176
  methodName: 'bindEvent',
177
177
  args: args,
178
178
  instantSearchInstance: instantSearchInstance
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '4.64.1';
7
+ var _default = '4.64.3';
8
8
  exports.default = _default;
@@ -29,6 +29,7 @@ var renderer = function renderer(_ref) {
29
29
  templates = _ref.templates,
30
30
  autofocus = _ref.autofocus,
31
31
  searchAsYouType = _ref.searchAsYouType,
32
+ ignoreCompositionEvents = _ref.ignoreCompositionEvents,
32
33
  showReset = _ref.showReset,
33
34
  showSubmit = _ref.showSubmit,
34
35
  showLoadingIndicator = _ref.showLoadingIndicator;
@@ -42,6 +43,7 @@ var renderer = function renderer(_ref) {
42
43
  autofocus: autofocus,
43
44
  refine: refine,
44
45
  searchAsYouType: searchAsYouType,
46
+ ignoreCompositionEvents: ignoreCompositionEvents,
45
47
  templates: templates,
46
48
  showSubmit: showSubmit,
47
49
  showReset: showReset,
@@ -72,6 +74,8 @@ var searchBox = function searchBox(widgetParams) {
72
74
  autofocus = _ref3$autofocus === void 0 ? false : _ref3$autofocus,
73
75
  _ref3$searchAsYouType = _ref3.searchAsYouType,
74
76
  searchAsYouType = _ref3$searchAsYouType === void 0 ? true : _ref3$searchAsYouType,
77
+ _ref3$ignoreCompositi = _ref3.ignoreCompositionEvents,
78
+ ignoreCompositionEvents = _ref3$ignoreCompositi === void 0 ? false : _ref3$ignoreCompositi,
75
79
  _ref3$showReset = _ref3.showReset,
76
80
  showReset = _ref3$showReset === void 0 ? true : _ref3$showReset,
77
81
  _ref3$showSubmit = _ref3.showSubmit,
@@ -120,6 +124,7 @@ var searchBox = function searchBox(widgetParams) {
120
124
  templates: templates,
121
125
  autofocus: autofocus,
122
126
  searchAsYouType: searchAsYouType,
127
+ ignoreCompositionEvents: ignoreCompositionEvents,
123
128
  showReset: showReset,
124
129
  showSubmit: showSubmit,
125
130
  showLoadingIndicator: showLoadingIndicator
@@ -4822,6 +4822,12 @@ declare type SearchBoxWidgetParams = {
4822
4822
  * once `<Enter>` is pressed only.
4823
4823
  */
4824
4824
  searchAsYouType?: boolean;
4825
+ /**
4826
+ * Whether to update the search state in the middle of a
4827
+ * composition session.
4828
+ * @default false
4829
+ */
4830
+ ignoreCompositionEvents?: boolean;
4825
4831
  /**
4826
4832
  * Whether to show the reset button
4827
4833
  */
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.64.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.64.3 | © 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) :
@@ -801,7 +801,7 @@
801
801
  return chunks;
802
802
  }
803
803
  function _buildEventPayloadsForHits(_ref) {
804
- var index = _ref.index,
804
+ var getIndex = _ref.getIndex,
805
805
  widgetType = _ref.widgetType,
806
806
  methodName = _ref.methodName,
807
807
  args = _ref.args,
@@ -854,7 +854,7 @@
854
854
  eventType: eventType,
855
855
  payload: _objectSpread2({
856
856
  eventName: eventName || 'Hits Viewed',
857
- index: index,
857
+ index: getIndex(),
858
858
  objectIDs: objectIDsByChunk[i]
859
859
  }, additionalData),
860
860
  hits: batch,
@@ -869,7 +869,7 @@
869
869
  eventType: eventType,
870
870
  payload: _objectSpread2({
871
871
  eventName: eventName || 'Hit Clicked',
872
- index: index,
872
+ index: getIndex(),
873
873
  queryID: queryID,
874
874
  objectIDs: objectIDsByChunk[i],
875
875
  positions: positionsByChunk[i]
@@ -886,7 +886,7 @@
886
886
  eventType: eventType,
887
887
  payload: _objectSpread2({
888
888
  eventName: eventName || 'Hit Converted',
889
- index: index,
889
+ index: getIndex(),
890
890
  queryID: queryID,
891
891
  objectIDs: objectIDsByChunk[i]
892
892
  }, additionalData),
@@ -900,7 +900,7 @@
900
900
  }
901
901
  function createSendEventForHits(_ref2) {
902
902
  var instantSearchInstance = _ref2.instantSearchInstance,
903
- index = _ref2.index,
903
+ getIndex = _ref2.getIndex,
904
904
  widgetType = _ref2.widgetType;
905
905
  var sentEvents = {};
906
906
  var timer = undefined;
@@ -910,7 +910,7 @@
910
910
  }
911
911
  var payloads = _buildEventPayloadsForHits({
912
912
  widgetType: widgetType,
913
- index: index,
913
+ getIndex: getIndex,
914
914
  methodName: 'sendEvent',
915
915
  args: args,
916
916
  instantSearchInstance: instantSearchInstance
@@ -930,7 +930,7 @@
930
930
  return sendEventForHits;
931
931
  }
932
932
  function createBindEventForHits(_ref3) {
933
- var index = _ref3.index,
933
+ var getIndex = _ref3.getIndex,
934
934
  widgetType = _ref3.widgetType,
935
935
  instantSearchInstance = _ref3.instantSearchInstance;
936
936
  var bindEventForHits = function bindEventForHits() {
@@ -939,7 +939,7 @@
939
939
  }
940
940
  var payloads = _buildEventPayloadsForHits({
941
941
  widgetType: widgetType,
942
- index: index,
942
+ getIndex: getIndex,
943
943
  methodName: 'bindEvent',
944
944
  args: args,
945
945
  instantSearchInstance: instantSearchInstance
@@ -2669,13 +2669,17 @@
2669
2669
  if (!sendEvent) {
2670
2670
  sendEvent = createSendEventForHits({
2671
2671
  instantSearchInstance: instantSearchInstance,
2672
- index: helper.getIndex(),
2672
+ getIndex: function getIndex() {
2673
+ return helper.getIndex();
2674
+ },
2673
2675
  widgetType: this.$$type
2674
2676
  });
2675
2677
  }
2676
2678
  if (!bindEvent) {
2677
2679
  bindEvent = createBindEventForHits({
2678
- index: helper.getIndex(),
2680
+ getIndex: function getIndex() {
2681
+ return helper.getIndex();
2682
+ },
2679
2683
  widgetType: this.$$type,
2680
2684
  instantSearchInstance: instantSearchInstance
2681
2685
  });
@@ -3212,11 +3216,15 @@
3212
3216
  showMore = getShowMore(helper);
3213
3217
  sendEvent = createSendEventForHits({
3214
3218
  instantSearchInstance: instantSearchInstance,
3215
- index: helper.getIndex(),
3219
+ getIndex: function getIndex() {
3220
+ return helper.getIndex();
3221
+ },
3216
3222
  widgetType: this.$$type
3217
3223
  });
3218
3224
  bindEvent = createBindEventForHits({
3219
- index: helper.getIndex(),
3225
+ getIndex: function getIndex() {
3226
+ return helper.getIndex();
3227
+ },
3220
3228
  widgetType: this.$$type,
3221
3229
  instantSearchInstance: instantSearchInstance
3222
3230
  });
@@ -5651,7 +5659,9 @@
5651
5659
  if (!sendEvent) {
5652
5660
  sendEvent = createSendEventForHits({
5653
5661
  instantSearchInstance: instantSearchInstance,
5654
- index: helper.getIndex(),
5662
+ getIndex: function getIndex() {
5663
+ return helper.getIndex();
5664
+ },
5655
5665
  widgetType: $$type$4
5656
5666
  });
5657
5667
  }
@@ -11976,7 +11986,9 @@
11976
11986
  scopedResult.results.hits = escapeHTML ? escapeHits(scopedResult.results.hits) : scopedResult.results.hits;
11977
11987
  var sendEvent = createSendEventForHits({
11978
11988
  instantSearchInstance: instantSearchInstance,
11979
- index: scopedResult.results.index,
11989
+ getIndex: function getIndex() {
11990
+ return scopedResult.results.index;
11991
+ },
11980
11992
  widgetType: _this.$$type
11981
11993
  });
11982
11994
  return {
@@ -14890,7 +14902,7 @@
14890
14902
  };
14891
14903
  }
14892
14904
 
14893
- var version$1 = '4.64.1';
14905
+ var version$1 = '4.64.3';
14894
14906
 
14895
14907
  var withUsage$r = createDocumentationMessageGenerator({
14896
14908
  name: 'instantsearch'
@@ -18039,6 +18051,7 @@
18039
18051
  showLoadingIndicator: true,
18040
18052
  autofocus: false,
18041
18053
  searchAsYouType: true,
18054
+ ignoreCompositionEvents: false,
18042
18055
  isSearchStalled: false,
18043
18056
  disabled: false,
18044
18057
  ariaLabel: 'Search',
@@ -18068,7 +18081,7 @@
18068
18081
  refine = _this$props.refine,
18069
18082
  onChange = _this$props.onChange;
18070
18083
  var query = event.target.value;
18071
- if (event.type === 'compositionend' || !event.isComposing) {
18084
+ if (!(_this.props.ignoreCompositionEvents && event.isComposing)) {
18072
18085
  if (searchAsYouType) {
18073
18086
  refine(query);
18074
18087
  }
@@ -21826,6 +21839,7 @@
21826
21839
  templates = _ref.templates,
21827
21840
  autofocus = _ref.autofocus,
21828
21841
  searchAsYouType = _ref.searchAsYouType,
21842
+ ignoreCompositionEvents = _ref.ignoreCompositionEvents,
21829
21843
  showReset = _ref.showReset,
21830
21844
  showSubmit = _ref.showSubmit,
21831
21845
  showLoadingIndicator = _ref.showLoadingIndicator;
@@ -21839,6 +21853,7 @@
21839
21853
  autofocus: autofocus,
21840
21854
  refine: refine,
21841
21855
  searchAsYouType: searchAsYouType,
21856
+ ignoreCompositionEvents: ignoreCompositionEvents,
21842
21857
  templates: templates,
21843
21858
  showSubmit: showSubmit,
21844
21859
  showReset: showReset,
@@ -21869,6 +21884,8 @@
21869
21884
  autofocus = _ref3$autofocus === void 0 ? false : _ref3$autofocus,
21870
21885
  _ref3$searchAsYouType = _ref3.searchAsYouType,
21871
21886
  searchAsYouType = _ref3$searchAsYouType === void 0 ? true : _ref3$searchAsYouType,
21887
+ _ref3$ignoreCompositi = _ref3.ignoreCompositionEvents,
21888
+ ignoreCompositionEvents = _ref3$ignoreCompositi === void 0 ? false : _ref3$ignoreCompositi,
21872
21889
  _ref3$showReset = _ref3.showReset,
21873
21890
  showReset = _ref3$showReset === void 0 ? true : _ref3$showReset,
21874
21891
  _ref3$showSubmit = _ref3.showSubmit,
@@ -21917,6 +21934,7 @@
21917
21934
  templates: templates,
21918
21935
  autofocus: autofocus,
21919
21936
  searchAsYouType: searchAsYouType,
21937
+ ignoreCompositionEvents: ignoreCompositionEvents,
21920
21938
  showReset: showReset,
21921
21939
  showSubmit: showSubmit,
21922
21940
  showLoadingIndicator: showLoadingIndicator