@docsearch/react 3.6.0 → 3.6.2

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.
Files changed (96) hide show
  1. package/button.js +1 -1
  2. package/dist/esm/index.d.ts +195 -5
  3. package/dist/esm/index.js +1 -5
  4. package/dist/umd/index.js +2 -2
  5. package/dist/umd/index.js.map +1 -1
  6. package/modal.js +1 -1
  7. package/package.json +6 -7
  8. package/dist/esm/AlgoliaLogo.d.ts +0 -8
  9. package/dist/esm/AlgoliaLogo.js +0 -54
  10. package/dist/esm/DocSearch.d.ts +0 -36
  11. package/dist/esm/DocSearch.js +0 -62
  12. package/dist/esm/DocSearchButton.d.ts +0 -9
  13. package/dist/esm/DocSearchButton.js +0 -109
  14. package/dist/esm/DocSearchModal.d.ts +0 -14
  15. package/dist/esm/DocSearchModal.js +0 -418
  16. package/dist/esm/ErrorScreen.d.ts +0 -9
  17. package/dist/esm/ErrorScreen.js +0 -19
  18. package/dist/esm/Footer.d.ts +0 -15
  19. package/dist/esm/Footer.js +0 -77
  20. package/dist/esm/Hit.d.ts +0 -8
  21. package/dist/esm/Hit.js +0 -8
  22. package/dist/esm/NoResultsScreen.d.ts +0 -13
  23. package/dist/esm/NoResultsScreen.js +0 -67
  24. package/dist/esm/Results.d.ts +0 -21
  25. package/dist/esm/Results.js +0 -123
  26. package/dist/esm/ResultsScreen.d.ts +0 -5
  27. package/dist/esm/ResultsScreen.js +0 -55
  28. package/dist/esm/ScreenState.d.ts +0 -27
  29. package/dist/esm/ScreenState.js +0 -49
  30. package/dist/esm/SearchBox.d.ts +0 -21
  31. package/dist/esm/SearchBox.js +0 -76
  32. package/dist/esm/Snippet.d.ts +0 -14
  33. package/dist/esm/Snippet.js +0 -35
  34. package/dist/esm/StartScreen.d.ts +0 -16
  35. package/dist/esm/StartScreen.js +0 -119
  36. package/dist/esm/__tests__/api.test.js +0 -460
  37. package/dist/esm/constants.d.ts +0 -1
  38. package/dist/esm/constants.js +0 -1
  39. package/dist/esm/icons/ControlKeyIcon.d.ts +0 -1
  40. package/dist/esm/icons/ControlKeyIcon.js +0 -14
  41. package/dist/esm/icons/ErrorIcon.d.ts +0 -1
  42. package/dist/esm/icons/ErrorIcon.js +0 -15
  43. package/dist/esm/icons/GoToExternalIcon.d.ts +0 -1
  44. package/dist/esm/icons/GoToExternalIcon.js +0 -11
  45. package/dist/esm/icons/LoadingIcon.d.ts +0 -1
  46. package/dist/esm/icons/LoadingIcon.js +0 -28
  47. package/dist/esm/icons/NoResultsIcon.d.ts +0 -1
  48. package/dist/esm/icons/NoResultsIcon.js +0 -15
  49. package/dist/esm/icons/RecentIcon.d.ts +0 -1
  50. package/dist/esm/icons/RecentIcon.js +0 -18
  51. package/dist/esm/icons/ResetIcon.d.ts +0 -1
  52. package/dist/esm/icons/ResetIcon.js +0 -15
  53. package/dist/esm/icons/SearchIcon.d.ts +0 -1
  54. package/dist/esm/icons/SearchIcon.js +0 -17
  55. package/dist/esm/icons/SelectIcon.d.ts +0 -1
  56. package/dist/esm/icons/SelectIcon.js +0 -19
  57. package/dist/esm/icons/SourceIcon.d.ts +0 -3
  58. package/dist/esm/icons/SourceIcon.js +0 -57
  59. package/dist/esm/icons/StarIcon.d.ts +0 -1
  60. package/dist/esm/icons/StarIcon.js +0 -14
  61. package/dist/esm/icons/index.d.ts +0 -10
  62. package/dist/esm/icons/index.js +0 -10
  63. package/dist/esm/stored-searches.d.ts +0 -12
  64. package/dist/esm/stored-searches.js +0 -75
  65. package/dist/esm/types/DocSearchHit.d.ts +0 -75
  66. package/dist/esm/types/DocSearchHit.js +0 -1
  67. package/dist/esm/types/DocSearchState.d.ts +0 -10
  68. package/dist/esm/types/DocSearchState.js +0 -1
  69. package/dist/esm/types/InternalDocSearchHit.d.ts +0 -4
  70. package/dist/esm/types/InternalDocSearchHit.js +0 -1
  71. package/dist/esm/types/StoredDocSearchHit.d.ts +0 -2
  72. package/dist/esm/types/StoredDocSearchHit.js +0 -1
  73. package/dist/esm/types/index.d.ts +0 -4
  74. package/dist/esm/types/index.js +0 -4
  75. package/dist/esm/useDocSearchKeyboardEvents.d.ts +0 -9
  76. package/dist/esm/useDocSearchKeyboardEvents.js +0 -55
  77. package/dist/esm/useSearchClient.d.ts +0 -2
  78. package/dist/esm/useSearchClient.js +0 -20
  79. package/dist/esm/useTouchEvents.d.ts +0 -9
  80. package/dist/esm/useTouchEvents.js +0 -27
  81. package/dist/esm/useTrapFocus.d.ts +0 -5
  82. package/dist/esm/useTrapFocus.js +0 -34
  83. package/dist/esm/utils/groupBy.d.ts +0 -1
  84. package/dist/esm/utils/groupBy.js +0 -17
  85. package/dist/esm/utils/identity.d.ts +0 -1
  86. package/dist/esm/utils/identity.js +0 -3
  87. package/dist/esm/utils/index.d.ts +0 -5
  88. package/dist/esm/utils/index.js +0 -5
  89. package/dist/esm/utils/isModifierEvent.d.ts +0 -5
  90. package/dist/esm/utils/isModifierEvent.js +0 -8
  91. package/dist/esm/utils/noop.d.ts +0 -1
  92. package/dist/esm/utils/noop.js +0 -1
  93. package/dist/esm/utils/removeHighlightTags.d.ts +0 -2
  94. package/dist/esm/utils/removeHighlightTags.js +0 -16
  95. package/dist/esm/version.d.ts +0 -1
  96. package/dist/esm/version.js +0 -1
@@ -1,57 +0,0 @@
1
- import React from 'react';
2
-
3
- var LvlIcon = function LvlIcon() {
4
- return /*#__PURE__*/React.createElement("svg", {
5
- width: "20",
6
- height: "20",
7
- viewBox: "0 0 20 20"
8
- }, /*#__PURE__*/React.createElement("path", {
9
- d: "M17 6v12c0 .52-.2 1-1 1H4c-.7 0-1-.33-1-1V2c0-.55.42-1 1-1h8l5 5zM14 8h-3.13c-.51 0-.87-.34-.87-.87V4",
10
- stroke: "currentColor",
11
- fill: "none",
12
- fillRule: "evenodd",
13
- strokeLinejoin: "round"
14
- }));
15
- };
16
-
17
- export function SourceIcon(props) {
18
- switch (props.type) {
19
- case 'lvl1':
20
- return /*#__PURE__*/React.createElement(LvlIcon, null);
21
-
22
- case 'content':
23
- return /*#__PURE__*/React.createElement(ContentIcon, null);
24
-
25
- default:
26
- return /*#__PURE__*/React.createElement(AnchorIcon, null);
27
- }
28
- }
29
-
30
- function AnchorIcon() {
31
- return /*#__PURE__*/React.createElement("svg", {
32
- width: "20",
33
- height: "20",
34
- viewBox: "0 0 20 20"
35
- }, /*#__PURE__*/React.createElement("path", {
36
- d: "M13 13h4-4V8H7v5h6v4-4H7V8H3h4V3v5h6V3v5h4-4v5zm-6 0v4-4H3h4z",
37
- stroke: "currentColor",
38
- fill: "none",
39
- fillRule: "evenodd",
40
- strokeLinecap: "round",
41
- strokeLinejoin: "round"
42
- }));
43
- }
44
-
45
- function ContentIcon() {
46
- return /*#__PURE__*/React.createElement("svg", {
47
- width: "20",
48
- height: "20",
49
- viewBox: "0 0 20 20"
50
- }, /*#__PURE__*/React.createElement("path", {
51
- d: "M17 5H3h14zm0 5H3h14zm0 5H3h14z",
52
- stroke: "currentColor",
53
- fill: "none",
54
- fillRule: "evenodd",
55
- strokeLinejoin: "round"
56
- }));
57
- }
@@ -1 +0,0 @@
1
- export declare function StarIcon(): JSX.Element;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- export function StarIcon() {
3
- return /*#__PURE__*/React.createElement("svg", {
4
- width: "20",
5
- height: "20",
6
- viewBox: "0 0 20 20"
7
- }, /*#__PURE__*/React.createElement("path", {
8
- d: "M10 14.2L5 17l1-5.6-4-4 5.5-.7 2.5-5 2.5 5 5.6.8-4 4 .9 5.5z",
9
- stroke: "currentColor",
10
- fill: "none",
11
- fillRule: "evenodd",
12
- strokeLinejoin: "round"
13
- }));
14
- }
@@ -1,10 +0,0 @@
1
- export * from './GoToExternalIcon';
2
- export * from './LoadingIcon';
3
- export * from './RecentIcon';
4
- export * from './ResetIcon';
5
- export * from './SearchIcon';
6
- export * from './SelectIcon';
7
- export * from './SourceIcon';
8
- export * from './StarIcon';
9
- export * from './ErrorIcon';
10
- export * from './NoResultsIcon';
@@ -1,10 +0,0 @@
1
- export * from './GoToExternalIcon';
2
- export * from './LoadingIcon';
3
- export * from './RecentIcon';
4
- export * from './ResetIcon';
5
- export * from './SearchIcon';
6
- export * from './SelectIcon';
7
- export * from './SourceIcon';
8
- export * from './StarIcon';
9
- export * from './ErrorIcon';
10
- export * from './NoResultsIcon';
@@ -1,12 +0,0 @@
1
- import type { StoredDocSearchHit } from './types';
2
- declare type CreateStoredSearchesOptions = {
3
- key: string;
4
- limit?: number;
5
- };
6
- export declare type StoredSearchPlugin<TItem> = {
7
- add: (item: TItem) => void;
8
- remove: (item: TItem) => void;
9
- getAll: () => TItem[];
10
- };
11
- export declare function createStoredSearches<TItem extends StoredDocSearchHit>({ key, limit, }: CreateStoredSearchesOptions): StoredSearchPlugin<TItem>;
12
- export {};
@@ -1,75 +0,0 @@
1
- var _excluded = ["_highlightResult", "_snippetResult"];
2
-
3
- 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; }
4
-
5
- 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; }
6
-
7
- function isLocalStorageSupported() {
8
- var key = '__TEST_KEY__';
9
-
10
- try {
11
- localStorage.setItem(key, '');
12
- localStorage.removeItem(key);
13
- return true;
14
- } catch (error) {
15
- return false;
16
- }
17
- }
18
-
19
- function createStorage(key) {
20
- if (isLocalStorageSupported() === false) {
21
- return {
22
- setItem: function setItem() {},
23
- getItem: function getItem() {
24
- return [];
25
- }
26
- };
27
- }
28
-
29
- return {
30
- setItem: function setItem(item) {
31
- return window.localStorage.setItem(key, JSON.stringify(item));
32
- },
33
- getItem: function getItem() {
34
- var item = window.localStorage.getItem(key);
35
- return item ? JSON.parse(item) : [];
36
- }
37
- };
38
- }
39
-
40
- export function createStoredSearches(_ref) {
41
- var key = _ref.key,
42
- _ref$limit = _ref.limit,
43
- limit = _ref$limit === void 0 ? 5 : _ref$limit;
44
- var storage = createStorage(key);
45
- var items = storage.getItem().slice(0, limit);
46
- return {
47
- add: function add(item) {
48
- var _ref2 = item,
49
- _highlightResult = _ref2._highlightResult,
50
- _snippetResult = _ref2._snippetResult,
51
- hit = _objectWithoutProperties(_ref2, _excluded);
52
-
53
- var isQueryAlreadySaved = items.findIndex(function (x) {
54
- return x.objectID === hit.objectID;
55
- });
56
-
57
- if (isQueryAlreadySaved > -1) {
58
- items.splice(isQueryAlreadySaved, 1);
59
- }
60
-
61
- items.unshift(hit);
62
- items = items.slice(0, limit);
63
- storage.setItem(items);
64
- },
65
- remove: function remove(item) {
66
- items = items.filter(function (x) {
67
- return x.objectID !== item.objectID;
68
- });
69
- storage.setItem(items);
70
- },
71
- getAll: function getAll() {
72
- return items;
73
- }
74
- };
75
- }
@@ -1,75 +0,0 @@
1
- declare type ContentType = 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
2
- interface DocSearchHitAttributeHighlightResult {
3
- value: string;
4
- matchLevel: 'full' | 'none' | 'partial';
5
- matchedWords: string[];
6
- fullyHighlighted?: boolean;
7
- }
8
- interface DocSearchHitHighlightResultHierarchy {
9
- lvl0: DocSearchHitAttributeHighlightResult;
10
- lvl1: DocSearchHitAttributeHighlightResult;
11
- lvl2: DocSearchHitAttributeHighlightResult;
12
- lvl3: DocSearchHitAttributeHighlightResult;
13
- lvl4: DocSearchHitAttributeHighlightResult;
14
- lvl5: DocSearchHitAttributeHighlightResult;
15
- lvl6: DocSearchHitAttributeHighlightResult;
16
- }
17
- interface DocSearchHitHighlightResult {
18
- content: DocSearchHitAttributeHighlightResult;
19
- hierarchy: DocSearchHitHighlightResultHierarchy;
20
- hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
21
- }
22
- interface DocSearchHitAttributeSnippetResult {
23
- value: string;
24
- matchLevel: 'full' | 'none' | 'partial';
25
- }
26
- interface DocSearchHitSnippetResult {
27
- content: DocSearchHitAttributeSnippetResult;
28
- hierarchy: DocSearchHitHighlightResultHierarchy;
29
- hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
30
- }
31
- export declare type DocSearchHit = {
32
- objectID: string;
33
- content: string | null;
34
- url: string;
35
- url_without_anchor: string;
36
- type: ContentType;
37
- anchor: string | null;
38
- hierarchy: {
39
- lvl0: string;
40
- lvl1: string;
41
- lvl2: string | null;
42
- lvl3: string | null;
43
- lvl4: string | null;
44
- lvl5: string | null;
45
- lvl6: string | null;
46
- };
47
- _highlightResult: DocSearchHitHighlightResult;
48
- _snippetResult: DocSearchHitSnippetResult;
49
- _rankingInfo?: {
50
- promoted: boolean;
51
- nbTypos: number;
52
- firstMatchedWord: number;
53
- proximityDistance?: number;
54
- geoDistance: number;
55
- geoPrecision?: number;
56
- nbExactWords: number;
57
- words: number;
58
- filters: number;
59
- userScore: number;
60
- matchedGeoLocation?: {
61
- lat: number;
62
- lng: number;
63
- distance: number;
64
- };
65
- };
66
- _distinctSeqID?: number;
67
- __autocomplete_indexName?: string;
68
- __autocomplete_queryID?: string;
69
- __autocomplete_algoliaCredentials?: {
70
- appId: string;
71
- apiKey: string;
72
- };
73
- __autocomplete_id?: number;
74
- };
75
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import type { AutocompleteContext, AutocompleteInsightsApi, AutocompleteState, BaseItem } from '@algolia/autocomplete-core';
2
- interface DocSearchContext extends AutocompleteContext {
3
- algoliaInsightsPlugin?: {
4
- insights: AutocompleteInsightsApi;
5
- };
6
- }
7
- export interface DocSearchState<TItem extends BaseItem> extends AutocompleteState<TItem> {
8
- context: DocSearchContext;
9
- }
10
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import type { DocSearchHit } from './DocSearchHit';
2
- export declare type InternalDocSearchHit = DocSearchHit & {
3
- __docsearch_parent: InternalDocSearchHit | null;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { DocSearchHit } from './DocSearchHit';
2
- export declare type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export * from './DocSearchHit';
2
- export * from './DocSearchState';
3
- export * from './InternalDocSearchHit';
4
- export * from './StoredDocSearchHit';
@@ -1,4 +0,0 @@
1
- export * from './DocSearchHit';
2
- export * from './DocSearchState';
3
- export * from './InternalDocSearchHit';
4
- export * from './StoredDocSearchHit';
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- export interface UseDocSearchKeyboardEventsProps {
3
- isOpen: boolean;
4
- onOpen: () => void;
5
- onClose: () => void;
6
- onInput?: (event: KeyboardEvent) => void;
7
- searchButtonRef?: React.RefObject<HTMLButtonElement>;
8
- }
9
- export declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, searchButtonRef, }: UseDocSearchKeyboardEventsProps): void;
@@ -1,55 +0,0 @@
1
- import React from 'react';
2
-
3
- function isEditingContent(event) {
4
- var element = event.target;
5
- var tagName = element.tagName;
6
- return element.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA';
7
- }
8
-
9
- export function useDocSearchKeyboardEvents(_ref) {
10
- var isOpen = _ref.isOpen,
11
- onOpen = _ref.onOpen,
12
- onClose = _ref.onClose,
13
- onInput = _ref.onInput,
14
- searchButtonRef = _ref.searchButtonRef;
15
- React.useEffect(function () {
16
- function onKeyDown(event) {
17
- var _event$key;
18
-
19
- function open() {
20
- // We check that no other DocSearch modal is showing before opening
21
- // another one.
22
- if (!document.body.classList.contains('DocSearch--active')) {
23
- onOpen();
24
- }
25
- }
26
-
27
- if (event.keyCode === 27 && isOpen || // The `Cmd+K` shortcut both opens and closes the modal.
28
- // We need to check for `event.key` because it can be `undefined` with
29
- // Chrome's autofill feature.
30
- // See https://github.com/paperjs/paper.js/issues/1398
31
- ((_event$key = event.key) === null || _event$key === void 0 ? void 0 : _event$key.toLowerCase()) === 'k' && (event.metaKey || event.ctrlKey) || // The `/` shortcut opens but doesn't close the modal because it's
32
- // a character.
33
- !isEditingContent(event) && event.key === '/' && !isOpen) {
34
- event.preventDefault();
35
-
36
- if (isOpen) {
37
- onClose();
38
- } else if (!document.body.classList.contains('DocSearch--active')) {
39
- open();
40
- }
41
- }
42
-
43
- if (searchButtonRef && searchButtonRef.current === document.activeElement && onInput) {
44
- if (/[a-zA-Z0-9]/.test(String.fromCharCode(event.keyCode))) {
45
- onInput(event);
46
- }
47
- }
48
- }
49
-
50
- window.addEventListener('keydown', onKeyDown);
51
- return function () {
52
- window.removeEventListener('keydown', onKeyDown);
53
- };
54
- }, [isOpen, onOpen, onClose, onInput, searchButtonRef]);
55
- }
@@ -1,2 +0,0 @@
1
- import type { SearchClient } from 'algoliasearch/lite';
2
- export declare function useSearchClient(appId: string, apiKey: string, transformSearchClient: (searchClient: SearchClient) => SearchClient): SearchClient;
@@ -1,20 +0,0 @@
1
- import algoliasearch from 'algoliasearch/dist/algoliasearch-lite.esm.browser';
2
- import React from 'react';
3
- import { version } from './version';
4
- export function useSearchClient(appId, apiKey, transformSearchClient) {
5
- var searchClient = React.useMemo(function () {
6
- var client = algoliasearch(appId, apiKey);
7
- client.addAlgoliaAgent('docsearch', version); // Since DocSearch.js relies on DocSearch React with an alias to Preact,
8
- // we cannot add the `docsearch-react` user agent by default, otherwise
9
- // it would also be sent on a DocSearch.js integration.
10
- // We therefore only add the `docsearch-react` user agent if `docsearch.js`
11
- // is not present.
12
-
13
- if (/docsearch.js \(.*\)/.test(client.transporter.userAgent.value) === false) {
14
- client.addAlgoliaAgent('docsearch-react', version);
15
- }
16
-
17
- return transformSearchClient(client);
18
- }, [appId, apiKey, transformSearchClient]);
19
- return searchClient;
20
- }
@@ -1,9 +0,0 @@
1
- import type { AutocompleteApi } from '@algolia/autocomplete-core';
2
- interface UseTouchEventsProps {
3
- getEnvironmentProps: AutocompleteApi<any>['getEnvironmentProps'];
4
- panelElement: HTMLDivElement | null;
5
- formElement: HTMLDivElement | null;
6
- inputElement: HTMLInputElement | null;
7
- }
8
- export declare function useTouchEvents({ getEnvironmentProps, panelElement, formElement, inputElement, }: UseTouchEventsProps): void;
9
- export {};
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- export function useTouchEvents(_ref) {
3
- var getEnvironmentProps = _ref.getEnvironmentProps,
4
- panelElement = _ref.panelElement,
5
- formElement = _ref.formElement,
6
- inputElement = _ref.inputElement;
7
- React.useEffect(function () {
8
- if (!(panelElement && formElement && inputElement)) {
9
- return undefined;
10
- }
11
-
12
- var _getEnvironmentProps = getEnvironmentProps({
13
- panelElement: panelElement,
14
- formElement: formElement,
15
- inputElement: inputElement
16
- }),
17
- onTouchStart = _getEnvironmentProps.onTouchStart,
18
- onTouchMove = _getEnvironmentProps.onTouchMove;
19
-
20
- window.addEventListener('touchstart', onTouchStart);
21
- window.addEventListener('touchmove', onTouchMove);
22
- return function () {
23
- window.removeEventListener('touchstart', onTouchStart);
24
- window.removeEventListener('touchmove', onTouchMove);
25
- };
26
- }, [getEnvironmentProps, panelElement, formElement, inputElement]);
27
- }
@@ -1,5 +0,0 @@
1
- interface UseTrapFocusProps {
2
- container: HTMLElement | null;
3
- }
4
- export declare function useTrapFocus({ container }: UseTrapFocusProps): void;
5
- export {};
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- export function useTrapFocus(_ref) {
3
- var container = _ref.container;
4
- React.useEffect(function () {
5
- if (!container) {
6
- return undefined;
7
- }
8
-
9
- var focusableElements = container.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), input:not([disabled])');
10
- var firstElement = focusableElements[0];
11
- var lastElement = focusableElements[focusableElements.length - 1];
12
-
13
- function trapFocus(event) {
14
- if (event.key !== 'Tab') {
15
- return;
16
- }
17
-
18
- if (event.shiftKey) {
19
- if (document.activeElement === firstElement) {
20
- event.preventDefault();
21
- lastElement.focus();
22
- }
23
- } else if (document.activeElement === lastElement) {
24
- event.preventDefault();
25
- firstElement.focus();
26
- }
27
- }
28
-
29
- container.addEventListener('keydown', trapFocus);
30
- return function () {
31
- container.removeEventListener('keydown', trapFocus);
32
- };
33
- }, [container]);
34
- }
@@ -1 +0,0 @@
1
- export declare function groupBy<TValue extends Record<string, unknown>>(values: TValue[], predicate: (value: TValue) => string, maxResultsPerGroup?: number): Record<string, TValue[]>;
@@ -1,17 +0,0 @@
1
- export function groupBy(values, predicate, maxResultsPerGroup) {
2
- return values.reduce(function (acc, item) {
3
- var key = predicate(item);
4
-
5
- if (!acc.hasOwnProperty(key)) {
6
- acc[key] = [];
7
- } // We limit each section to show 5 hits maximum.
8
- // This acts as a frontend alternative to `distinct`.
9
-
10
-
11
- if (acc[key].length < (maxResultsPerGroup || 5)) {
12
- acc[key].push(item);
13
- }
14
-
15
- return acc;
16
- }, {});
17
- }
@@ -1 +0,0 @@
1
- export declare function identity<TParam>(x: TParam): TParam;
@@ -1,3 +0,0 @@
1
- export function identity(x) {
2
- return x;
3
- }
@@ -1,5 +0,0 @@
1
- export * from './groupBy';
2
- export * from './identity';
3
- export * from './isModifierEvent';
4
- export * from './noop';
5
- export * from './removeHighlightTags';
@@ -1,5 +0,0 @@
1
- export * from './groupBy';
2
- export * from './identity';
3
- export * from './isModifierEvent';
4
- export * from './noop';
5
- export * from './removeHighlightTags';
@@ -1,5 +0,0 @@
1
- /**
2
- * Detect when an event is modified with a special key to let the browser
3
- * trigger its default behavior.
4
- */
5
- export declare function isModifierEvent<TEvent extends KeyboardEvent | MouseEvent>(event: TEvent): boolean;
@@ -1,8 +0,0 @@
1
- /**
2
- * Detect when an event is modified with a special key to let the browser
3
- * trigger its default behavior.
4
- */
5
- export function isModifierEvent(event) {
6
- var isMiddleClick = event.button === 1;
7
- return isMiddleClick || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
8
- }
@@ -1 +0,0 @@
1
- export declare function noop(..._args: any[]): void;
@@ -1 +0,0 @@
1
- export function noop() {}
@@ -1,2 +0,0 @@
1
- import type { DocSearchHit, InternalDocSearchHit } from '../types';
2
- export declare function removeHighlightTags(hit: DocSearchHit | InternalDocSearchHit): string;
@@ -1,16 +0,0 @@
1
- var regexHighlightTags = /(<mark>|<\/mark>)/g;
2
- var regexHasHighlightTags = RegExp(regexHighlightTags.source);
3
- export function removeHighlightTags(hit) {
4
- var _internalDocSearchHit, _hit$_highlightResult;
5
-
6
- var internalDocSearchHit = hit;
7
-
8
- if (!internalDocSearchHit.__docsearch_parent && !hit._highlightResult) {
9
- return hit.hierarchy.lvl0;
10
- }
11
-
12
- var _ref = (internalDocSearchHit.__docsearch_parent ? (_internalDocSearchHit = internalDocSearchHit.__docsearch_parent) === null || _internalDocSearchHit === void 0 || (_internalDocSearchHit = _internalDocSearchHit._highlightResult) === null || _internalDocSearchHit === void 0 || (_internalDocSearchHit = _internalDocSearchHit.hierarchy) === null || _internalDocSearchHit === void 0 ? void 0 : _internalDocSearchHit.lvl0 : (_hit$_highlightResult = hit._highlightResult) === null || _hit$_highlightResult === void 0 || (_hit$_highlightResult = _hit$_highlightResult.hierarchy) === null || _hit$_highlightResult === void 0 ? void 0 : _hit$_highlightResult.lvl0) || {},
13
- value = _ref.value;
14
-
15
- return value && regexHasHighlightTags.test(value) ? value.replace(regexHighlightTags, '') : value;
16
- }
@@ -1 +0,0 @@
1
- export declare const version = "3.6.0";
@@ -1 +0,0 @@
1
- export var version = '3.6.0';