react-instantsearch 7.4.0 → 7.5.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.
@@ -28,7 +28,7 @@ function HierarchicalList(_ref) {
28
28
  }, items.map(function (item) {
29
29
  return /*#__PURE__*/_react.default.createElement("li", {
30
30
  key: item.value,
31
- className: (0, _cx.cx)('ais-HierarchicalMenu-item', classNames.item, item.data && item.data.length > 0 && (0, _cx.cx)('ais-HierarchicalMenu-item--parent', classNames.parentItem), item.isRefined && (0, _cx.cx)('ais-HierarchicalMenu-item--selected', classNames.selectedItem))
31
+ className: (0, _cx.cx)('ais-HierarchicalMenu-item', classNames.item, item.isRefined && (0, _cx.cx)('ais-HierarchicalMenu-item--selected', classNames.selectedItem), item.data && item.data.length > 0 && (0, _cx.cx)('ais-HierarchicalMenu-item--parent', classNames.parentItem))
32
32
  }, /*#__PURE__*/_react.default.createElement("a", {
33
33
  className: (0, _cx.cx)('ais-HierarchicalMenu-link', classNames.link, item.isRefined && (0, _cx.cx)('ais-HierarchicalMenu-link--selected', classNames.selectedItemLink)),
34
34
  href: createURL(item.value),
@@ -132,6 +132,7 @@ function SearchBox(_ref7) {
132
132
  type: "search",
133
133
  value: value,
134
134
  onChange: onChange,
135
+ onCompositionEnd: onChange,
135
136
  autoFocus: autoFocus
136
137
  }), /*#__PURE__*/_react.default.createElement("button", {
137
138
  className: (0, _cx.cx)('ais-SearchBox-submit', classNames.submit),
@@ -65,15 +65,19 @@ function RefinementList(_ref) {
65
65
  setInputValue = _useState2[1];
66
66
  var inputRef = (0, _react.useRef)(null);
67
67
  function setQuery(newQuery) {
68
+ var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
68
69
  setInputValue(newQuery);
69
- searchForItems(newQuery);
70
+ if (compositionComplete) {
71
+ searchForItems(newQuery);
72
+ }
70
73
  }
71
74
  function onRefine(item) {
72
75
  refine(item.value);
73
76
  setQuery('');
74
77
  }
75
78
  function onChange(event) {
76
- setQuery(event.currentTarget.value);
79
+ var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
80
+ setQuery(event.currentTarget.value, compositionComplete);
77
81
  }
78
82
  function onReset() {
79
83
  setQuery('');
@@ -45,8 +45,9 @@ function SearchBox(_ref) {
45
45
  setInputValue = _useState2[1];
46
46
  var inputRef = (0, _react.useRef)(null);
47
47
  function setQuery(newQuery) {
48
+ var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
48
49
  setInputValue(newQuery);
49
- if (searchAsYouType) {
50
+ if (searchAsYouType && compositionComplete) {
50
51
  refine(newQuery);
51
52
  }
52
53
  }
@@ -57,7 +58,8 @@ function SearchBox(_ref) {
57
58
  }
58
59
  }
59
60
  function onChange(event) {
60
- setQuery(event.currentTarget.value);
61
+ var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
62
+ setQuery(event.currentTarget.value, compositionComplete);
61
63
  }
62
64
  function onSubmit(event) {
63
65
  if (!searchAsYouType) {
@@ -21,7 +21,7 @@ function HierarchicalList(_ref) {
21
21
  }, items.map(function (item) {
22
22
  return /*#__PURE__*/React.createElement("li", {
23
23
  key: item.value,
24
- className: cx('ais-HierarchicalMenu-item', classNames.item, item.data && item.data.length > 0 && cx('ais-HierarchicalMenu-item--parent', classNames.parentItem), item.isRefined && cx('ais-HierarchicalMenu-item--selected', classNames.selectedItem))
24
+ className: cx('ais-HierarchicalMenu-item', classNames.item, item.isRefined && cx('ais-HierarchicalMenu-item--selected', classNames.selectedItem), item.data && item.data.length > 0 && cx('ais-HierarchicalMenu-item--parent', classNames.parentItem))
25
25
  }, /*#__PURE__*/React.createElement("a", {
26
26
  className: cx('ais-HierarchicalMenu-link', classNames.link, item.isRefined && cx('ais-HierarchicalMenu-link--selected', classNames.selectedItemLink)),
27
27
  href: createURL(item.value),
@@ -50,7 +50,8 @@ export type SearchBoxTranslations = {
50
50
  */
51
51
  resetButtonTitle: string;
52
52
  };
53
- export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onReset' | 'onChange'> & Pick<React.ComponentProps<'form'>, 'onSubmit'> & Required<Pick<React.ComponentProps<'form'>, 'onReset'>> & Pick<React.ComponentProps<'input'>, 'placeholder' | 'onChange' | 'autoFocus'> & {
53
+ export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onReset' | 'onChange'> & Pick<React.ComponentProps<'form'>, 'onSubmit'> & Required<Pick<React.ComponentProps<'form'>, 'onReset'>> & Pick<React.ComponentProps<'input'>, 'placeholder' | 'autoFocus'> & {
54
+ onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => void;
54
55
  formRef?: React.RefObject<HTMLFormElement>;
55
56
  inputRef: React.RefObject<HTMLInputElement>;
56
57
  isSearchStalled: boolean;
@@ -125,6 +125,7 @@ export function SearchBox(_ref7) {
125
125
  type: "search",
126
126
  value: value,
127
127
  onChange: onChange,
128
+ onCompositionEnd: onChange,
128
129
  autoFocus: autoFocus
129
130
  }), /*#__PURE__*/React.createElement("button", {
130
131
  className: cx('ais-SearchBox-submit', classNames.submit),
@@ -57,15 +57,19 @@ export function RefinementList(_ref) {
57
57
  setInputValue = _useState2[1];
58
58
  var inputRef = useRef(null);
59
59
  function setQuery(newQuery) {
60
+ var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
60
61
  setInputValue(newQuery);
61
- searchForItems(newQuery);
62
+ if (compositionComplete) {
63
+ searchForItems(newQuery);
64
+ }
62
65
  }
63
66
  function onRefine(item) {
64
67
  refine(item.value);
65
68
  setQuery('');
66
69
  }
67
70
  function onChange(event) {
68
- setQuery(event.currentTarget.value);
71
+ var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
72
+ setQuery(event.currentTarget.value, compositionComplete);
69
73
  }
70
74
  function onReset() {
71
75
  setQuery('');
@@ -37,8 +37,9 @@ export function SearchBox(_ref) {
37
37
  setInputValue = _useState2[1];
38
38
  var inputRef = useRef(null);
39
39
  function setQuery(newQuery) {
40
+ var compositionComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
40
41
  setInputValue(newQuery);
41
- if (searchAsYouType) {
42
+ if (searchAsYouType && compositionComplete) {
42
43
  refine(newQuery);
43
44
  }
44
45
  }
@@ -49,7 +50,8 @@ export function SearchBox(_ref) {
49
50
  }
50
51
  }
51
52
  function onChange(event) {
52
- setQuery(event.currentTarget.value);
53
+ var compositionComplete = event.type === 'compositionend' || !event.nativeEvent.isComposing;
54
+ setQuery(event.currentTarget.value, compositionComplete);
53
55
  }
54
56
  function onSubmit(event) {
55
57
  if (!searchAsYouType) {