react-instantsearch 7.5.3 → 7.5.5

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.
@@ -8,7 +8,7 @@ exports.SearchBox = SearchBox;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactInstantsearchCore = require("react-instantsearch-core");
10
10
  var _SearchBox = require("../ui/SearchBox");
11
- var _excluded = ["queryHook", "searchAsYouType", "translations"];
11
+ var _excluded = ["queryHook", "searchAsYouType", "ignoreCompositionEvents", "translations"];
12
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -29,6 +29,8 @@ function SearchBox(_ref) {
29
29
  var queryHook = _ref.queryHook,
30
30
  _ref$searchAsYouType = _ref.searchAsYouType,
31
31
  searchAsYouType = _ref$searchAsYouType === void 0 ? true : _ref$searchAsYouType,
32
+ _ref$ignoreCompositio = _ref.ignoreCompositionEvents,
33
+ ignoreCompositionEvents = _ref$ignoreCompositio === void 0 ? false : _ref$ignoreCompositio,
32
34
  translations = _ref.translations,
33
35
  props = _objectWithoutProperties(_ref, _excluded);
34
36
  var _useSearchBox = (0, _reactInstantsearchCore.useSearchBox)({
@@ -45,9 +47,9 @@ function SearchBox(_ref) {
45
47
  setInputValue = _useState2[1];
46
48
  var inputRef = (0, _react.useRef)(null);
47
49
  function setQuery(newQuery) {
48
- var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
50
+ var isComposing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
49
51
  setInputValue(newQuery);
50
- if (searchAsYouType && compositionComplete) {
52
+ if (searchAsYouType && !(ignoreCompositionEvents && isComposing)) {
51
53
  refine(newQuery);
52
54
  }
53
55
  }
@@ -58,8 +60,7 @@ function SearchBox(_ref) {
58
60
  }
59
61
  }
60
62
  function onChange(event) {
61
- var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
62
- setQuery(event.currentTarget.value, compositionComplete);
63
+ setQuery(event.currentTarget.value, event.nativeEvent.isComposing);
63
64
  }
64
65
  function onSubmit(event) {
65
66
  if (!searchAsYouType) {
@@ -7,7 +7,13 @@ export type SearchBoxProps = Omit<SearchBoxUiComponentProps, Exclude<keyof UiPro
7
7
  * @default true
8
8
  */
9
9
  searchAsYouType?: boolean;
10
+ /**
11
+ * Whether to update the search state in the middle of a
12
+ * composition session.
13
+ * @default false
14
+ */
15
+ ignoreCompositionEvents?: boolean;
10
16
  translations?: Partial<UiProps['translations']>;
11
17
  };
12
- export declare function SearchBox({ queryHook, searchAsYouType, translations, ...props }: SearchBoxProps): JSX.Element;
18
+ export declare function SearchBox({ queryHook, searchAsYouType, ignoreCompositionEvents, translations, ...props }: SearchBoxProps): JSX.Element;
13
19
  export {};
@@ -1,5 +1,5 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["queryHook", "searchAsYouType", "translations"];
2
+ var _excluded = ["queryHook", "searchAsYouType", "ignoreCompositionEvents", "translations"];
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -21,6 +21,8 @@ export function SearchBox(_ref) {
21
21
  var queryHook = _ref.queryHook,
22
22
  _ref$searchAsYouType = _ref.searchAsYouType,
23
23
  searchAsYouType = _ref$searchAsYouType === void 0 ? true : _ref$searchAsYouType,
24
+ _ref$ignoreCompositio = _ref.ignoreCompositionEvents,
25
+ ignoreCompositionEvents = _ref$ignoreCompositio === void 0 ? false : _ref$ignoreCompositio,
24
26
  translations = _ref.translations,
25
27
  props = _objectWithoutProperties(_ref, _excluded);
26
28
  var _useSearchBox = useSearchBox({
@@ -37,9 +39,9 @@ export function SearchBox(_ref) {
37
39
  setInputValue = _useState2[1];
38
40
  var inputRef = useRef(null);
39
41
  function setQuery(newQuery) {
40
- var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
42
+ var isComposing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
41
43
  setInputValue(newQuery);
42
- if (searchAsYouType && compositionComplete) {
44
+ if (searchAsYouType && !(ignoreCompositionEvents && isComposing)) {
43
45
  refine(newQuery);
44
46
  }
45
47
  }
@@ -50,8 +52,7 @@ export function SearchBox(_ref) {
50
52
  }
51
53
  }
52
54
  function onChange(event) {
53
- var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
54
- setQuery(event.currentTarget.value, compositionComplete);
55
+ setQuery(event.currentTarget.value, event.nativeEvent.isComposing);
55
56
  }
56
57
  function onSubmit(event) {
57
58
  if (!searchAsYouType) {
@@ -7,7 +7,7 @@
7
7
 
8
8
  var React__default = 'default' in React ? React['default'] : React;
9
9
 
10
- var version = '7.5.3';
10
+ var version = '7.5.5';
11
11
 
12
12
  // Copyright Joyent, Inc. and other Node contributors.
13
13
  //
@@ -6800,7 +6800,7 @@
6800
6800
  return chunks;
6801
6801
  }
6802
6802
  function _buildEventPayloadsForHits(_ref) {
6803
- var index = _ref.index,
6803
+ var getIndex = _ref.getIndex,
6804
6804
  widgetType = _ref.widgetType,
6805
6805
  methodName = _ref.methodName,
6806
6806
  args = _ref.args,
@@ -6853,7 +6853,7 @@
6853
6853
  eventType: eventType,
6854
6854
  payload: _objectSpread$2({
6855
6855
  eventName: eventName || 'Hits Viewed',
6856
- index: index,
6856
+ index: getIndex(),
6857
6857
  objectIDs: objectIDsByChunk[i]
6858
6858
  }, additionalData),
6859
6859
  hits: batch,
@@ -6868,7 +6868,7 @@
6868
6868
  eventType: eventType,
6869
6869
  payload: _objectSpread$2({
6870
6870
  eventName: eventName || 'Hit Clicked',
6871
- index: index,
6871
+ index: getIndex(),
6872
6872
  queryID: queryID,
6873
6873
  objectIDs: objectIDsByChunk[i],
6874
6874
  positions: positionsByChunk[i]
@@ -6885,7 +6885,7 @@
6885
6885
  eventType: eventType,
6886
6886
  payload: _objectSpread$2({
6887
6887
  eventName: eventName || 'Hit Converted',
6888
- index: index,
6888
+ index: getIndex(),
6889
6889
  queryID: queryID,
6890
6890
  objectIDs: objectIDsByChunk[i]
6891
6891
  }, additionalData),
@@ -6899,7 +6899,7 @@
6899
6899
  }
6900
6900
  function createSendEventForHits(_ref2) {
6901
6901
  var instantSearchInstance = _ref2.instantSearchInstance,
6902
- index = _ref2.index,
6902
+ getIndex = _ref2.getIndex,
6903
6903
  widgetType = _ref2.widgetType;
6904
6904
  var sentEvents = {};
6905
6905
  var timer = undefined;
@@ -6909,7 +6909,7 @@
6909
6909
  }
6910
6910
  var payloads = _buildEventPayloadsForHits({
6911
6911
  widgetType: widgetType,
6912
- index: index,
6912
+ getIndex: getIndex,
6913
6913
  methodName: 'sendEvent',
6914
6914
  args: args,
6915
6915
  instantSearchInstance: instantSearchInstance
@@ -6929,7 +6929,7 @@
6929
6929
  return sendEventForHits;
6930
6930
  }
6931
6931
  function createBindEventForHits(_ref3) {
6932
- var index = _ref3.index,
6932
+ var getIndex = _ref3.getIndex,
6933
6933
  widgetType = _ref3.widgetType,
6934
6934
  instantSearchInstance = _ref3.instantSearchInstance;
6935
6935
  var bindEventForHits = function bindEventForHits() {
@@ -6938,7 +6938,7 @@
6938
6938
  }
6939
6939
  var payloads = _buildEventPayloadsForHits({
6940
6940
  widgetType: widgetType,
6941
- index: index,
6941
+ getIndex: getIndex,
6942
6942
  methodName: 'bindEvent',
6943
6943
  args: args,
6944
6944
  instantSearchInstance: instantSearchInstance
@@ -12204,7 +12204,7 @@
12204
12204
  };
12205
12205
  }
12206
12206
 
12207
- var version$3 = '4.64.1';
12207
+ var version$3 = '4.64.3';
12208
12208
 
12209
12209
  function _typeof$o(obj) {
12210
12210
  "@babel/helpers - typeof";
@@ -14305,7 +14305,9 @@
14305
14305
  if (!sendEvent) {
14306
14306
  sendEvent = createSendEventForHits({
14307
14307
  instantSearchInstance: instantSearchInstance,
14308
- index: helper.getIndex(),
14308
+ getIndex: function getIndex() {
14309
+ return helper.getIndex();
14310
+ },
14309
14311
  widgetType: $$type
14310
14312
  });
14311
14313
  }
@@ -14832,13 +14834,17 @@
14832
14834
  if (!sendEvent) {
14833
14835
  sendEvent = createSendEventForHits({
14834
14836
  instantSearchInstance: instantSearchInstance,
14835
- index: helper.getIndex(),
14837
+ getIndex: function getIndex() {
14838
+ return helper.getIndex();
14839
+ },
14836
14840
  widgetType: this.$$type
14837
14841
  });
14838
14842
  }
14839
14843
  if (!bindEvent) {
14840
14844
  bindEvent = createBindEventForHits({
14841
- index: helper.getIndex(),
14845
+ getIndex: function getIndex() {
14846
+ return helper.getIndex();
14847
+ },
14842
14848
  widgetType: this.$$type,
14843
14849
  instantSearchInstance: instantSearchInstance
14844
14850
  });
@@ -15366,11 +15372,15 @@
15366
15372
  showMore = getShowMore(helper);
15367
15373
  sendEvent = createSendEventForHits({
15368
15374
  instantSearchInstance: instantSearchInstance,
15369
- index: helper.getIndex(),
15375
+ getIndex: function getIndex() {
15376
+ return helper.getIndex();
15377
+ },
15370
15378
  widgetType: this.$$type
15371
15379
  });
15372
15380
  bindEvent = createBindEventForHits({
15373
- index: helper.getIndex(),
15381
+ getIndex: function getIndex() {
15382
+ return helper.getIndex();
15383
+ },
15374
15384
  widgetType: this.$$type,
15375
15385
  instantSearchInstance: instantSearchInstance
15376
15386
  });
@@ -20344,11 +20354,13 @@
20344
20354
  }));
20345
20355
  }
20346
20356
 
20347
- var _excluded$E = ["queryHook", "searchAsYouType", "translations"];
20357
+ var _excluded$E = ["queryHook", "searchAsYouType", "ignoreCompositionEvents", "translations"];
20348
20358
  function SearchBox$1(_ref) {
20349
20359
  var queryHook = _ref.queryHook,
20350
20360
  _ref$searchAsYouType = _ref.searchAsYouType,
20351
20361
  searchAsYouType = _ref$searchAsYouType === void 0 ? true : _ref$searchAsYouType,
20362
+ _ref$ignoreCompositio = _ref.ignoreCompositionEvents,
20363
+ ignoreCompositionEvents = _ref$ignoreCompositio === void 0 ? false : _ref$ignoreCompositio,
20352
20364
  translations = _ref.translations,
20353
20365
  props = _objectWithoutProperties$c(_ref, _excluded$E);
20354
20366
  var _useSearchBox = useSearchBox({
@@ -20365,9 +20377,9 @@
20365
20377
  setInputValue = _useState2[1];
20366
20378
  var inputRef = React.useRef(null);
20367
20379
  function setQuery(newQuery) {
20368
- var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
20380
+ var isComposing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
20369
20381
  setInputValue(newQuery);
20370
- if (searchAsYouType && compositionComplete) {
20382
+ if (searchAsYouType && !(ignoreCompositionEvents && isComposing)) {
20371
20383
  refine(newQuery);
20372
20384
  }
20373
20385
  }
@@ -20378,8 +20390,7 @@
20378
20390
  }
20379
20391
  }
20380
20392
  function onChange(event) {
20381
- var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
20382
- setQuery(event.currentTarget.value, compositionComplete);
20393
+ setQuery(event.currentTarget.value, event.nativeEvent.isComposing);
20383
20394
  }
20384
20395
  function onSubmit(event) {
20385
20396
  if (!searchAsYouType) {