@docsearch/react 3.3.3 → 3.3.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.
@@ -6,7 +6,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
6
6
 
7
7
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
8
 
9
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
10
 
11
11
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
12
 
@@ -8,7 +8,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
8
8
 
9
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
10
 
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
12
 
13
13
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
14
 
@@ -14,7 +14,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
14
14
 
15
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
16
 
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
18
 
19
19
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
20
20
 
@@ -35,7 +35,7 @@ import { createStoredSearches } from './stored-searches';
35
35
  import { useSearchClient } from './useSearchClient';
36
36
  import { useTouchEvents } from './useTouchEvents';
37
37
  import { useTrapFocus } from './useTrapFocus';
38
- import { groupBy, identity, noop, removeHighlightTags } from './utils';
38
+ import { groupBy, identity, noop, removeHighlightTags, isModifierEvent } from './utils';
39
39
  export function DocSearchModal(_ref) {
40
40
  var appId = _ref.appId,
41
41
  apiKey = _ref.apiKey,
@@ -150,7 +150,7 @@ export function DocSearchModal(_ref) {
150
150
  event = _ref3.event;
151
151
  saveRecentSearch(item);
152
152
 
153
- if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
153
+ if (!isModifierEvent(event)) {
154
154
  onClose();
155
155
  }
156
156
  },
@@ -168,7 +168,7 @@ export function DocSearchModal(_ref) {
168
168
  event = _ref5.event;
169
169
  saveRecentSearch(item);
170
170
 
171
- if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
171
+ if (!isModifierEvent(event)) {
172
172
  onClose();
173
173
  }
174
174
  },
@@ -230,7 +230,7 @@ export function DocSearchModal(_ref) {
230
230
  event = _ref8.event;
231
231
  saveRecentSearch(item);
232
232
 
233
- if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
233
+ if (!isModifierEvent(event)) {
234
234
  onClose();
235
235
  }
236
236
  },
@@ -363,9 +363,12 @@ export function DocSearchModal(_ref) {
363
363
  inputRef: inputRef,
364
364
  translations: screenStateTranslations,
365
365
  getMissingResultsUrl: getMissingResultsUrl,
366
- onItemClick: function onItemClick(item) {
366
+ onItemClick: function onItemClick(item, event) {
367
367
  saveRecentSearch(item);
368
- onClose();
368
+
369
+ if (!isModifierEvent(event)) {
370
+ onClose();
371
+ }
369
372
  }
370
373
  }))), /*#__PURE__*/React.createElement("footer", {
371
374
  className: "DocSearch-Footer"
@@ -10,7 +10,7 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
10
10
 
11
11
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
12
 
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
14
 
15
15
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
16
 
@@ -14,7 +14,7 @@ interface ResultsProps<TItem extends BaseItem> extends AutocompleteApi<TItem, Re
14
14
  runDeleteTransition: (cb: () => void) => void;
15
15
  runFavoriteTransition: (cb: () => void) => void;
16
16
  }) => React.ReactNode;
17
- onItemClick: (item: TItem) => void;
17
+ onItemClick: (item: TItem, event: KeyboardEvent | MouseEvent) => void;
18
18
  hitComponent: DocSearchProps['hitComponent'];
19
19
  }
20
20
  export declare function Results<TItem extends StoredDocSearchHit>(props: ResultsProps<TItem>): JSX.Element | null;
@@ -4,7 +4,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
4
4
 
5
5
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
6
 
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
8
 
9
9
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
10
 
@@ -75,8 +75,8 @@ function Result(_ref) {
75
75
  }, getItemProps({
76
76
  item: item,
77
77
  source: collection.source,
78
- onClick: function onClick() {
79
- onItemClick(item);
78
+ onClick: function onClick(event) {
79
+ onItemClick(item, event);
80
80
  }
81
81
  })), /*#__PURE__*/React.createElement(Hit, {
82
82
  hit: item
@@ -15,7 +15,7 @@ export interface ScreenStateProps<TItem extends BaseItem> extends AutocompleteAp
15
15
  state: AutocompleteState<TItem>;
16
16
  recentSearches: StoredSearchPlugin<StoredDocSearchHit>;
17
17
  favoriteSearches: StoredSearchPlugin<StoredDocSearchHit>;
18
- onItemClick: (item: InternalDocSearchHit) => void;
18
+ onItemClick: (item: InternalDocSearchHit, event: KeyboardEvent | MouseEvent) => void;
19
19
  inputRef: React.MutableRefObject<HTMLInputElement | null>;
20
20
  hitComponent: DocSearchProps['hitComponent'];
21
21
  indexName: DocSearchProps['indexName'];