@docsearch/react 3.0.0-alpha.32 → 3.0.0-alpha.36

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.
@@ -1,3 +1,10 @@
1
1
  import React from 'react';
2
- export declare type DocSearchButtonProps = React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
3
- export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "form" | "slot" | "style" | "title" | "children" | "key" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLButtonElement>>;
2
+ declare type Translations = Partial<{
3
+ buttonText: string;
4
+ buttonAriaLabel: string;
5
+ }>;
6
+ export declare type DocSearchButtonProps = React.ComponentProps<'button'> & {
7
+ translations?: Translations;
8
+ };
9
+ export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<DocSearchButtonProps, "form" | "slot" | "style" | "title" | "children" | "translations" | "key" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLButtonElement>>;
10
+ export {};
@@ -12,6 +12,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
12
12
 
13
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
14
 
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
+
17
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
+
15
19
  import React, { useEffect, useState } from 'react';
16
20
  import { ControlKeyIcon } from './icons/ControlKeyIcon';
17
21
  import { SearchIcon } from './icons/SearchIcon';
@@ -22,7 +26,16 @@ function isAppleDevice() {
22
26
  return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
23
27
  }
24
28
 
25
- export var DocSearchButton = React.forwardRef(function (props, ref) {
29
+ export var DocSearchButton = React.forwardRef(function (_ref, ref) {
30
+ var _ref$translations = _ref.translations,
31
+ translations = _ref$translations === void 0 ? {} : _ref$translations,
32
+ props = _objectWithoutProperties(_ref, ["translations"]);
33
+
34
+ var _translations$buttonT = translations.buttonText,
35
+ buttonText = _translations$buttonT === void 0 ? 'Search' : _translations$buttonT,
36
+ _translations$buttonA = translations.buttonAriaLabel,
37
+ buttonAriaLabel = _translations$buttonA === void 0 ? 'Search' : _translations$buttonA;
38
+
26
39
  var _useState = useState(null),
27
40
  _useState2 = _slicedToArray(_useState, 2),
28
41
  key = _useState2[0],
@@ -36,18 +49,18 @@ export var DocSearchButton = React.forwardRef(function (props, ref) {
36
49
  return /*#__PURE__*/React.createElement("button", _extends({
37
50
  type: "button",
38
51
  className: "DocSearch DocSearch-Button",
39
- "aria-label": "Search"
52
+ "aria-label": buttonAriaLabel
40
53
  }, props, {
41
54
  ref: ref
42
- }), /*#__PURE__*/React.createElement("div", {
55
+ }), /*#__PURE__*/React.createElement("span", {
43
56
  className: "DocSearch-Button-Container"
44
57
  }, /*#__PURE__*/React.createElement(SearchIcon, null), /*#__PURE__*/React.createElement("span", {
45
58
  className: "DocSearch-Button-Placeholder"
46
- }, "Search")), key !== null ? /*#__PURE__*/React.createElement("div", {
59
+ }, buttonText)), key !== null && /*#__PURE__*/React.createElement("span", {
47
60
  className: "DocSearch-Button-Keys"
48
61
  }, /*#__PURE__*/React.createElement("span", {
49
62
  className: "DocSearch-Button-Key"
50
63
  }, key === ACTION_KEY_DEFAULT ? /*#__PURE__*/React.createElement(ControlKeyIcon, null) : key), /*#__PURE__*/React.createElement("span", {
51
64
  className: "DocSearch-Button-Key"
52
- }, "K")) : null);
65
+ }, "K")));
53
66
  });
@@ -30,7 +30,7 @@ import { createStoredSearches } from './stored-searches';
30
30
  import { useSearchClient } from './useSearchClient';
31
31
  import { useTouchEvents } from './useTouchEvents';
32
32
  import { useTrapFocus } from './useTrapFocus';
33
- import { groupBy, identity, noop } from './utils';
33
+ import { groupBy, identity, noop, removeHighlightTags } from './utils';
34
34
  export function DocSearchModal(_ref) {
35
35
  var _ref$appId = _ref.appId,
36
36
  appId = _ref$appId === void 0 ? 'BH4D9OD16A' : _ref$appId,
@@ -65,7 +65,7 @@ export function DocSearchModal(_ref) {
65
65
  completion: null,
66
66
  context: {},
67
67
  isOpen: false,
68
- selectedItemId: null,
68
+ activeItemId: null,
69
69
  status: 'idle'
70
70
  }),
71
71
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -74,7 +74,7 @@ export function DocSearchModal(_ref) {
74
74
 
75
75
  var containerRef = React.useRef(null);
76
76
  var modalRef = React.useRef(null);
77
- var searchBoxRef = React.useRef(null);
77
+ var formElementRef = React.useRef(null);
78
78
  var dropdownRef = React.useRef(null);
79
79
  var inputRef = React.useRef(null);
80
80
  var snippetLength = React.useRef(10);
@@ -108,7 +108,7 @@ export function DocSearchModal(_ref) {
108
108
  var autocomplete = React.useMemo(function () {
109
109
  return createAutocomplete({
110
110
  id: 'docsearch',
111
- defaultSelectedItemId: 0,
111
+ defaultActiveItemId: 0,
112
112
  placeholder: placeholder,
113
113
  openOnFocus: true,
114
114
  initialState: {
@@ -135,6 +135,7 @@ export function DocSearchModal(_ref) {
135
135
  }
136
136
 
137
137
  return [{
138
+ sourceId: 'recentSearches',
138
139
  onSelect: function onSelect(_ref4) {
139
140
  var item = _ref4.item,
140
141
  event = _ref4.event;
@@ -152,6 +153,7 @@ export function DocSearchModal(_ref) {
152
153
  return recentSearches.getAll();
153
154
  }
154
155
  }, {
156
+ sourceId: 'favoriteSearches',
155
157
  onSelect: function onSelect(_ref6) {
156
158
  var item = _ref6.item,
157
159
  event = _ref6.event;
@@ -199,7 +201,7 @@ export function DocSearchModal(_ref) {
199
201
  var hits = results[0].hits;
200
202
  var nbHits = results[0].nbHits;
201
203
  var sources = groupBy(hits, function (hit) {
202
- return hit.hierarchy.lvl0;
204
+ return removeHighlightTags(hit);
203
205
  }); // We store the `lvl0`s to display them as search suggestions
204
206
  // in the “no results“ screen.
205
207
 
@@ -212,8 +214,9 @@ export function DocSearchModal(_ref) {
212
214
  setContext({
213
215
  nbHits: nbHits
214
216
  });
215
- return Object.values(sources).map(function (items) {
217
+ return Object.values(sources).map(function (items, index) {
216
218
  return {
219
+ sourceId: "hits".concat(index),
217
220
  onSelect: function onSelect(_ref8) {
218
221
  var item = _ref8.item,
219
222
  event = _ref8.event;
@@ -253,7 +256,7 @@ export function DocSearchModal(_ref) {
253
256
  useTouchEvents({
254
257
  getEnvironmentProps: getEnvironmentProps,
255
258
  panelElement: dropdownRef.current,
256
- searchBoxElement: searchBoxRef.current,
259
+ formElement: formElementRef.current,
257
260
  inputElement: inputRef.current
258
261
  });
259
262
  useTrapFocus({
@@ -329,7 +332,7 @@ export function DocSearchModal(_ref) {
329
332
  ref: modalRef
330
333
  }, /*#__PURE__*/React.createElement("header", {
331
334
  className: "DocSearch-SearchBar",
332
- ref: searchBoxRef
335
+ ref: formElementRef
333
336
  }, /*#__PURE__*/React.createElement(SearchBox, _extends({}, autocomplete, {
334
337
  state: state,
335
338
  autoFocus: initialQuery.length === 0,
@@ -1,8 +1,8 @@
1
- import { AutocompleteApi, AutocompleteState } from '@algolia/autocomplete-core';
1
+ import { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
2
2
  import React from 'react';
3
3
  import { DocSearchProps } from './DocSearch';
4
4
  import { StoredDocSearchHit } from './types';
5
- interface ResultsProps<TItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
5
+ interface ResultsProps<TItem extends BaseItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
6
6
  title: string;
7
7
  collection: AutocompleteState<TItem>['collections'][0];
8
8
  renderIcon(props: {
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import React from 'react';
4
4
  import { SelectIcon, SourceIcon } from './icons';
5
5
  import { Results } from './Results';
6
+ import { removeHighlightTags } from './utils';
6
7
  export function ResultsScreen(props) {
7
8
  return /*#__PURE__*/React.createElement("div", {
8
9
  className: "DocSearch-Dropdown-Container"
@@ -11,7 +12,7 @@ export function ResultsScreen(props) {
11
12
  return null;
12
13
  }
13
14
 
14
- var title = collection.items[0].hierarchy.lvl0;
15
+ var title = removeHighlightTags(collection.items[0]);
15
16
  return /*#__PURE__*/React.createElement(Results, _extends({}, props, {
16
17
  key: index,
17
18
  title: title,
@@ -1,9 +1,9 @@
1
- import { AutocompleteApi, AutocompleteState } from '@algolia/autocomplete-core';
1
+ import { AutocompleteApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
2
2
  import React from 'react';
3
3
  import { DocSearchProps } from './DocSearch';
4
4
  import { StoredSearchPlugin } from './stored-searches';
5
5
  import { InternalDocSearchHit, StoredDocSearchHit } from './types';
6
- export interface ScreenStateProps<TItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
6
+ export interface ScreenStateProps<TItem extends BaseItem> extends AutocompleteApi<TItem, React.FormEvent, React.MouseEvent, React.KeyboardEvent> {
7
7
  state: AutocompleteState<TItem>;
8
8
  recentSearches: StoredSearchPlugin<StoredDocSearchHit>;
9
9
  favoriteSearches: StoredSearchPlugin<StoredDocSearchHit>;
@@ -37,8 +37,7 @@ export function SearchBox(props) {
37
37
  }, props.getInputProps({
38
38
  inputElement: props.inputRef.current,
39
39
  autoFocus: props.autoFocus,
40
- maxLength: MAX_QUERY_SIZE,
41
- enterKeyHint: 'go'
40
+ maxLength: MAX_QUERY_SIZE
42
41
  }))), /*#__PURE__*/React.createElement("button", {
43
42
  type: "reset",
44
43
  title: "Clear the query",
@@ -28,7 +28,7 @@ interface DocSearchHitSnippetResult {
28
28
  hierarchy: DocSearchHitHighlightResultHierarchy;
29
29
  hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
30
30
  }
31
- export interface DocSearchHit {
31
+ export declare type DocSearchHit = {
32
32
  objectID: string;
33
33
  content: string | null;
34
34
  url: string;
@@ -64,5 +64,5 @@ export interface DocSearchHit {
64
64
  };
65
65
  };
66
66
  _distinctSeqID?: number;
67
- }
67
+ };
68
68
  export {};
@@ -2,8 +2,8 @@ import { AutocompleteApi } from '@algolia/autocomplete-core';
2
2
  interface UseTouchEventsProps {
3
3
  getEnvironmentProps: AutocompleteApi<any>['getEnvironmentProps'];
4
4
  panelElement: HTMLDivElement | null;
5
- searchBoxElement: HTMLDivElement | null;
5
+ formElement: HTMLDivElement | null;
6
6
  inputElement: HTMLInputElement | null;
7
7
  }
8
- export declare function useTouchEvents({ getEnvironmentProps, panelElement, searchBoxElement, inputElement, }: UseTouchEventsProps): void;
8
+ export declare function useTouchEvents({ getEnvironmentProps, panelElement, formElement, inputElement, }: UseTouchEventsProps): void;
9
9
  export {};
@@ -2,16 +2,16 @@ import React from 'react';
2
2
  export function useTouchEvents(_ref) {
3
3
  var getEnvironmentProps = _ref.getEnvironmentProps,
4
4
  panelElement = _ref.panelElement,
5
- searchBoxElement = _ref.searchBoxElement,
5
+ formElement = _ref.formElement,
6
6
  inputElement = _ref.inputElement;
7
7
  React.useEffect(function () {
8
- if (!(panelElement && searchBoxElement && inputElement)) {
8
+ if (!(panelElement && formElement && inputElement)) {
9
9
  return undefined;
10
10
  }
11
11
 
12
12
  var _getEnvironmentProps = getEnvironmentProps({
13
13
  panelElement: panelElement,
14
- searchBoxElement: searchBoxElement,
14
+ formElement: formElement,
15
15
  inputElement: inputElement
16
16
  }),
17
17
  onTouchStart = _getEnvironmentProps.onTouchStart,
@@ -23,5 +23,5 @@ export function useTouchEvents(_ref) {
23
23
  window.removeEventListener('touchstart', onTouchStart);
24
24
  window.removeEventListener('touchmove', onTouchMove);
25
25
  };
26
- }, [getEnvironmentProps, panelElement, searchBoxElement, inputElement]);
26
+ }, [getEnvironmentProps, panelElement, formElement, inputElement]);
27
27
  }
@@ -1,3 +1,4 @@
1
1
  export * from './groupBy';
2
2
  export * from './identity';
3
3
  export * from './noop';
4
+ export * from './removeHighlightTags';
@@ -1,3 +1,4 @@
1
1
  export * from './groupBy';
2
2
  export * from './identity';
3
- export * from './noop';
3
+ export * from './noop';
4
+ export * from './removeHighlightTags';
@@ -0,0 +1,2 @@
1
+ import { DocSearchHit, InternalDocSearchHit } from './../types';
2
+ export declare function removeHighlightTags(hit: DocSearchHit | InternalDocSearchHit): string;
@@ -0,0 +1,12 @@
1
+ var regexHighlightTags = /(<mark>|<\/mark>)/g;
2
+ var regexHasHighlightTags = RegExp(regexHighlightTags.source);
3
+ export function removeHighlightTags(hit) {
4
+ if (!hit.__docsearch_parent && !hit._highlightResult) {
5
+ return hit.hierarchy.lvl0;
6
+ }
7
+
8
+ var _ref = hit._highlightResult ? hit._highlightResult.hierarchy.lvl0 : hit.__docsearch_parent._highlightResult.hierarchy.lvl0,
9
+ value = _ref.value;
10
+
11
+ return value && regexHasHighlightTags.test(value) ? value.replace(regexHighlightTags, '') : value;
12
+ }
@@ -1 +1 @@
1
- export declare const version = "3.0.0-alpha.32";
1
+ export declare const version = "3.0.0-alpha.36";
@@ -1 +1 @@
1
- export var version = '3.0.0-alpha.32';
1
+ export var version = '3.0.0-alpha.36';