@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.
- package/button.js +1 -1
- package/dist/esm/index.d.ts +195 -5
- package/dist/esm/index.js +1 -5
- package/dist/umd/index.js +2 -2
- package/dist/umd/index.js.map +1 -1
- package/modal.js +1 -1
- package/package.json +6 -7
- package/dist/esm/AlgoliaLogo.d.ts +0 -8
- package/dist/esm/AlgoliaLogo.js +0 -54
- package/dist/esm/DocSearch.d.ts +0 -36
- package/dist/esm/DocSearch.js +0 -62
- package/dist/esm/DocSearchButton.d.ts +0 -9
- package/dist/esm/DocSearchButton.js +0 -109
- package/dist/esm/DocSearchModal.d.ts +0 -14
- package/dist/esm/DocSearchModal.js +0 -418
- package/dist/esm/ErrorScreen.d.ts +0 -9
- package/dist/esm/ErrorScreen.js +0 -19
- package/dist/esm/Footer.d.ts +0 -15
- package/dist/esm/Footer.js +0 -77
- package/dist/esm/Hit.d.ts +0 -8
- package/dist/esm/Hit.js +0 -8
- package/dist/esm/NoResultsScreen.d.ts +0 -13
- package/dist/esm/NoResultsScreen.js +0 -67
- package/dist/esm/Results.d.ts +0 -21
- package/dist/esm/Results.js +0 -123
- package/dist/esm/ResultsScreen.d.ts +0 -5
- package/dist/esm/ResultsScreen.js +0 -55
- package/dist/esm/ScreenState.d.ts +0 -27
- package/dist/esm/ScreenState.js +0 -49
- package/dist/esm/SearchBox.d.ts +0 -21
- package/dist/esm/SearchBox.js +0 -76
- package/dist/esm/Snippet.d.ts +0 -14
- package/dist/esm/Snippet.js +0 -35
- package/dist/esm/StartScreen.d.ts +0 -16
- package/dist/esm/StartScreen.js +0 -119
- package/dist/esm/__tests__/api.test.js +0 -460
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/icons/ControlKeyIcon.d.ts +0 -1
- package/dist/esm/icons/ControlKeyIcon.js +0 -14
- package/dist/esm/icons/ErrorIcon.d.ts +0 -1
- package/dist/esm/icons/ErrorIcon.js +0 -15
- package/dist/esm/icons/GoToExternalIcon.d.ts +0 -1
- package/dist/esm/icons/GoToExternalIcon.js +0 -11
- package/dist/esm/icons/LoadingIcon.d.ts +0 -1
- package/dist/esm/icons/LoadingIcon.js +0 -28
- package/dist/esm/icons/NoResultsIcon.d.ts +0 -1
- package/dist/esm/icons/NoResultsIcon.js +0 -15
- package/dist/esm/icons/RecentIcon.d.ts +0 -1
- package/dist/esm/icons/RecentIcon.js +0 -18
- package/dist/esm/icons/ResetIcon.d.ts +0 -1
- package/dist/esm/icons/ResetIcon.js +0 -15
- package/dist/esm/icons/SearchIcon.d.ts +0 -1
- package/dist/esm/icons/SearchIcon.js +0 -17
- package/dist/esm/icons/SelectIcon.d.ts +0 -1
- package/dist/esm/icons/SelectIcon.js +0 -19
- package/dist/esm/icons/SourceIcon.d.ts +0 -3
- package/dist/esm/icons/SourceIcon.js +0 -57
- package/dist/esm/icons/StarIcon.d.ts +0 -1
- package/dist/esm/icons/StarIcon.js +0 -14
- package/dist/esm/icons/index.d.ts +0 -10
- package/dist/esm/icons/index.js +0 -10
- package/dist/esm/stored-searches.d.ts +0 -12
- package/dist/esm/stored-searches.js +0 -75
- package/dist/esm/types/DocSearchHit.d.ts +0 -75
- package/dist/esm/types/DocSearchHit.js +0 -1
- package/dist/esm/types/DocSearchState.d.ts +0 -10
- package/dist/esm/types/DocSearchState.js +0 -1
- package/dist/esm/types/InternalDocSearchHit.d.ts +0 -4
- package/dist/esm/types/InternalDocSearchHit.js +0 -1
- package/dist/esm/types/StoredDocSearchHit.d.ts +0 -2
- package/dist/esm/types/StoredDocSearchHit.js +0 -1
- package/dist/esm/types/index.d.ts +0 -4
- package/dist/esm/types/index.js +0 -4
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +0 -9
- package/dist/esm/useDocSearchKeyboardEvents.js +0 -55
- package/dist/esm/useSearchClient.d.ts +0 -2
- package/dist/esm/useSearchClient.js +0 -20
- package/dist/esm/useTouchEvents.d.ts +0 -9
- package/dist/esm/useTouchEvents.js +0 -27
- package/dist/esm/useTrapFocus.d.ts +0 -5
- package/dist/esm/useTrapFocus.js +0 -34
- package/dist/esm/utils/groupBy.d.ts +0 -1
- package/dist/esm/utils/groupBy.js +0 -17
- package/dist/esm/utils/identity.d.ts +0 -1
- package/dist/esm/utils/identity.js +0 -3
- package/dist/esm/utils/index.d.ts +0 -5
- package/dist/esm/utils/index.js +0 -5
- package/dist/esm/utils/isModifierEvent.d.ts +0 -5
- package/dist/esm/utils/isModifierEvent.js +0 -8
- package/dist/esm/utils/noop.d.ts +0 -1
- package/dist/esm/utils/noop.js +0 -1
- package/dist/esm/utils/removeHighlightTags.d.ts +0 -2
- package/dist/esm/utils/removeHighlightTags.js +0 -16
- package/dist/esm/version.d.ts +0 -1
- package/dist/esm/version.js +0 -1
package/modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DocSearchModal } from './dist/esm
|
|
1
|
+
export { DocSearchModal } from './dist/esm';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsearch/react",
|
|
3
3
|
"description": "React package for DocSearch, the best search experience for docs.",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docsearch.algolia.com",
|
|
7
7
|
"repository": "algolia/docsearch",
|
|
@@ -25,17 +25,16 @@
|
|
|
25
25
|
"jsdelivr": "dist/umd/index.js",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build:clean": "rm -rf ./dist",
|
|
28
|
-
"build:
|
|
29
|
-
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/esm",
|
|
30
|
-
"build:
|
|
31
|
-
"
|
|
32
|
-
"on:change": "concurrently \"yarn build:esm\" \"yarn build:types\"",
|
|
28
|
+
"build:clean-types": "rm -rf ./dist/esm/types",
|
|
29
|
+
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/esm/types",
|
|
30
|
+
"build": "yarn build:clean && yarn build:types && rollup --config && yarn build:clean-types",
|
|
31
|
+
"on:change": "yarn build",
|
|
33
32
|
"watch": "watch \"yarn on:change\" --ignoreDirectoryPattern \"/dist/\""
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"@algolia/autocomplete-core": "1.9.3",
|
|
37
36
|
"@algolia/autocomplete-preset-algolia": "1.9.3",
|
|
38
|
-
"@docsearch/css": "3.6.
|
|
37
|
+
"@docsearch/css": "3.6.2",
|
|
39
38
|
"algoliasearch": "^4.19.1"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
package/dist/esm/AlgoliaLogo.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export function AlgoliaLogo(_ref) {
|
|
3
|
-
var _ref$translations = _ref.translations,
|
|
4
|
-
translations = _ref$translations === void 0 ? {} : _ref$translations;
|
|
5
|
-
var _translations$searchB = translations.searchByText,
|
|
6
|
-
searchByText = _translations$searchB === void 0 ? 'Search by' : _translations$searchB;
|
|
7
|
-
return /*#__PURE__*/React.createElement("a", {
|
|
8
|
-
href: "https://www.algolia.com/ref/docsearch/?utm_source=".concat(window.location.hostname, "&utm_medium=referral&utm_content=powered_by&utm_campaign=docsearch"),
|
|
9
|
-
target: "_blank",
|
|
10
|
-
rel: "noopener noreferrer"
|
|
11
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
12
|
-
className: "DocSearch-Label"
|
|
13
|
-
}, searchByText), /*#__PURE__*/React.createElement("svg", {
|
|
14
|
-
width: "77",
|
|
15
|
-
height: "19",
|
|
16
|
-
"aria-label": "Algolia",
|
|
17
|
-
role: "img",
|
|
18
|
-
id: "Layer_1",
|
|
19
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
20
|
-
viewBox: "0 0 2196.2 500"
|
|
21
|
-
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("style", null, ".cls-1,.cls-2{fill:#003dff;}.cls-2{fill-rule:evenodd;}")), /*#__PURE__*/React.createElement("path", {
|
|
22
|
-
className: "cls-2",
|
|
23
|
-
d: "M1070.38,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z"
|
|
24
|
-
}), /*#__PURE__*/React.createElement("rect", {
|
|
25
|
-
className: "cls-1",
|
|
26
|
-
x: "1845.88",
|
|
27
|
-
y: "104.73",
|
|
28
|
-
width: "62.58",
|
|
29
|
-
height: "277.9",
|
|
30
|
-
rx: "5.9",
|
|
31
|
-
ry: "5.9"
|
|
32
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
33
|
-
className: "cls-2",
|
|
34
|
-
d: "M1851.78,71.38h50.77c3.26,0,5.9-2.64,5.9-5.9V5.9c0-3.62-3.24-6.39-6.82-5.83l-50.77,7.95c-2.87,.45-4.99,2.92-4.99,5.83v51.62c0,3.26,2.64,5.9,5.9,5.9Z"
|
|
35
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
36
|
-
className: "cls-2",
|
|
37
|
-
d: "M1764.03,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z"
|
|
38
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
39
|
-
className: "cls-2",
|
|
40
|
-
d: "M1631.95,142.72c-11.14-12.25-24.83-21.65-40.78-28.31-15.92-6.53-33.26-9.85-52.07-9.85-18.78,0-36.15,3.17-51.92,9.85-15.59,6.66-29.29,16.05-40.76,28.31-11.47,12.23-20.38,26.87-26.76,44.03-6.38,17.17-9.24,37.37-9.24,58.36,0,20.99,3.19,36.87,9.55,54.21,6.38,17.32,15.14,32.11,26.45,44.36,11.29,12.23,24.83,21.62,40.6,28.46,15.77,6.83,40.12,10.33,52.4,10.48,12.25,0,36.78-3.82,52.7-10.48,15.92-6.68,29.46-16.23,40.78-28.46,11.29-12.25,20.05-27.04,26.25-44.36,6.22-17.34,9.24-33.22,9.24-54.21,0-20.99-3.34-41.19-10.03-58.36-6.38-17.17-15.14-31.8-26.43-44.03Zm-44.43,163.75c-11.47,15.75-27.56,23.7-48.09,23.7-20.55,0-36.63-7.8-48.1-23.7-11.47-15.75-17.21-34.01-17.21-61.2,0-26.89,5.59-49.14,17.06-64.87,11.45-15.75,27.54-23.52,48.07-23.52,20.55,0,36.63,7.78,48.09,23.52,11.47,15.57,17.36,37.98,17.36,64.87,0,27.19-5.72,45.3-17.19,61.2Z"
|
|
41
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
42
|
-
className: "cls-2",
|
|
43
|
-
d: "M894.42,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z"
|
|
44
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
45
|
-
className: "cls-2",
|
|
46
|
-
d: "M2133.97,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z"
|
|
47
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
48
|
-
className: "cls-2",
|
|
49
|
-
d: "M1314.05,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-11.79,18.34-19.6,39.64-22.11,62.59-.58,5.3-.88,10.68-.88,16.14s.31,11.15,.93,16.59c4.28,38.09,23.14,71.61,50.66,94.52,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47h0c17.99,0,34.61-5.93,48.16-15.97,16.29-11.58,28.88-28.54,34.48-47.75v50.26h-.11v11.08c0,21.84-5.71,38.27-17.34,49.36-11.61,11.08-31.04,16.63-58.25,16.63-11.12,0-28.79-.59-46.6-2.41-2.83-.29-5.46,1.5-6.27,4.22l-12.78,43.11c-1.02,3.46,1.27,7.02,4.83,7.53,21.52,3.08,42.52,4.68,54.65,4.68,48.91,0,85.16-10.75,108.89-32.21,21.48-19.41,33.15-48.89,35.2-88.52V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,64.1s.65,139.13,0,143.36c-12.08,9.77-27.11,13.59-43.49,14.7-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-1.32,0-2.63-.03-3.94-.1-40.41-2.11-74.52-37.26-74.52-79.38,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33Z"
|
|
50
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
51
|
-
className: "cls-1",
|
|
52
|
-
d: "M249.83,0C113.3,0,2,110.09,.03,246.16c-2,138.19,110.12,252.7,248.33,253.5,42.68,.25,83.79-10.19,120.3-30.03,3.56-1.93,4.11-6.83,1.08-9.51l-23.38-20.72c-4.75-4.21-11.51-5.4-17.36-2.92-25.48,10.84-53.17,16.38-81.71,16.03-111.68-1.37-201.91-94.29-200.13-205.96,1.76-110.26,92-199.41,202.67-199.41h202.69V407.41l-115-102.18c-3.72-3.31-9.42-2.66-12.42,1.31-18.46,24.44-48.53,39.64-81.93,37.34-46.33-3.2-83.87-40.5-87.34-86.81-4.15-55.24,39.63-101.52,94-101.52,49.18,0,89.68,37.85,93.91,85.95,.38,4.28,2.31,8.27,5.52,11.12l29.95,26.55c3.4,3.01,8.79,1.17,9.63-3.3,2.16-11.55,2.92-23.58,2.07-35.92-4.82-70.34-61.8-126.93-132.17-131.26-80.68-4.97-148.13,58.14-150.27,137.25-2.09,77.1,61.08,143.56,138.19,145.26,32.19,.71,62.03-9.41,86.14-26.95l150.26,133.2c6.44,5.71,16.61,1.14,16.61-7.47V9.48C499.66,4.25,495.42,0,490.18,0H249.83Z"
|
|
53
|
-
})));
|
|
54
|
-
}
|
package/dist/esm/DocSearch.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
|
|
2
|
-
import type { SearchOptions } from '@algolia/client-search';
|
|
3
|
-
import type { SearchClient } from 'algoliasearch/lite';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import type { DocSearchHit, InternalDocSearchHit, StoredDocSearchHit } from './types';
|
|
6
|
-
import type { ButtonTranslations, ModalTranslations } from '.';
|
|
7
|
-
export declare type DocSearchTranslations = Partial<{
|
|
8
|
-
button: ButtonTranslations;
|
|
9
|
-
modal: ModalTranslations;
|
|
10
|
-
}>;
|
|
11
|
-
export interface DocSearchProps {
|
|
12
|
-
appId: string;
|
|
13
|
-
apiKey: string;
|
|
14
|
-
indexName: string;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
searchParameters?: SearchOptions;
|
|
17
|
-
maxResultsPerGroup?: number;
|
|
18
|
-
transformItems?: (items: DocSearchHit[]) => DocSearchHit[];
|
|
19
|
-
hitComponent?: (props: {
|
|
20
|
-
hit: InternalDocSearchHit | StoredDocSearchHit;
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}) => JSX.Element;
|
|
23
|
-
resultsFooterComponent?: (props: {
|
|
24
|
-
state: AutocompleteState<InternalDocSearchHit>;
|
|
25
|
-
}) => JSX.Element | null;
|
|
26
|
-
transformSearchClient?: (searchClient: SearchClient) => SearchClient;
|
|
27
|
-
disableUserPersonalization?: boolean;
|
|
28
|
-
initialQuery?: string;
|
|
29
|
-
navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];
|
|
30
|
-
translations?: DocSearchTranslations;
|
|
31
|
-
getMissingResultsUrl?: ({ query }: {
|
|
32
|
-
query: string;
|
|
33
|
-
}) => string;
|
|
34
|
-
insights?: AutocompleteOptions<InternalDocSearchHit>['insights'];
|
|
35
|
-
}
|
|
36
|
-
export declare function DocSearch(props: DocSearchProps): JSX.Element;
|
package/dist/esm/DocSearch.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || 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); }
|
|
2
|
-
|
|
3
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import { createPortal } from 'react-dom';
|
|
17
|
-
import { DocSearchButton } from './DocSearchButton';
|
|
18
|
-
import { DocSearchModal } from './DocSearchModal';
|
|
19
|
-
import { useDocSearchKeyboardEvents } from './useDocSearchKeyboardEvents';
|
|
20
|
-
export function DocSearch(props) {
|
|
21
|
-
var _props$translations, _props$translations2;
|
|
22
|
-
|
|
23
|
-
var searchButtonRef = React.useRef(null);
|
|
24
|
-
|
|
25
|
-
var _React$useState = React.useState(false),
|
|
26
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
27
|
-
isOpen = _React$useState2[0],
|
|
28
|
-
setIsOpen = _React$useState2[1];
|
|
29
|
-
|
|
30
|
-
var _React$useState3 = React.useState((props === null || props === void 0 ? void 0 : props.initialQuery) || undefined),
|
|
31
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
32
|
-
initialQuery = _React$useState4[0],
|
|
33
|
-
setInitialQuery = _React$useState4[1];
|
|
34
|
-
|
|
35
|
-
var onOpen = React.useCallback(function () {
|
|
36
|
-
setIsOpen(true);
|
|
37
|
-
}, [setIsOpen]);
|
|
38
|
-
var onClose = React.useCallback(function () {
|
|
39
|
-
setIsOpen(false);
|
|
40
|
-
}, [setIsOpen]);
|
|
41
|
-
var onInput = React.useCallback(function (event) {
|
|
42
|
-
setIsOpen(true);
|
|
43
|
-
setInitialQuery(event.key);
|
|
44
|
-
}, [setIsOpen, setInitialQuery]);
|
|
45
|
-
useDocSearchKeyboardEvents({
|
|
46
|
-
isOpen: isOpen,
|
|
47
|
-
onOpen: onOpen,
|
|
48
|
-
onClose: onClose,
|
|
49
|
-
onInput: onInput,
|
|
50
|
-
searchButtonRef: searchButtonRef
|
|
51
|
-
});
|
|
52
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DocSearchButton, {
|
|
53
|
-
ref: searchButtonRef,
|
|
54
|
-
translations: props === null || props === void 0 || (_props$translations = props.translations) === null || _props$translations === void 0 ? void 0 : _props$translations.button,
|
|
55
|
-
onClick: onOpen
|
|
56
|
-
}), isOpen && createPortal( /*#__PURE__*/React.createElement(DocSearchModal, _extends({}, props, {
|
|
57
|
-
initialScrollY: window.scrollY,
|
|
58
|
-
initialQuery: initialQuery,
|
|
59
|
-
translations: props === null || props === void 0 || (_props$translations2 = props.translations) === null || _props$translations2 === void 0 ? void 0 : _props$translations2.modal,
|
|
60
|
-
onClose: onClose
|
|
61
|
-
})), document.body));
|
|
62
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare type ButtonTranslations = Partial<{
|
|
3
|
-
buttonText: string;
|
|
4
|
-
buttonAriaLabel: string;
|
|
5
|
-
}>;
|
|
6
|
-
export declare type DocSearchButtonProps = React.ComponentProps<'button'> & {
|
|
7
|
-
translations?: ButtonTranslations;
|
|
8
|
-
};
|
|
9
|
-
export declare const DocSearchButton: React.ForwardRefExoticComponent<Pick<DocSearchButtonProps, "translations" | "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
var _excluded = ["translations"];
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign || 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
|
-
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
|
|
7
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
import React, { useEffect, useState } from 'react';
|
|
22
|
-
import { ControlKeyIcon } from './icons/ControlKeyIcon';
|
|
23
|
-
import { SearchIcon } from './icons/SearchIcon';
|
|
24
|
-
var ACTION_KEY_DEFAULT = 'Ctrl';
|
|
25
|
-
var ACTION_KEY_APPLE = '⌘';
|
|
26
|
-
|
|
27
|
-
function isAppleDevice() {
|
|
28
|
-
return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export var DocSearchButton = React.forwardRef(function (_ref, ref) {
|
|
32
|
-
var _ref$translations = _ref.translations,
|
|
33
|
-
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
34
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
-
|
|
36
|
-
var _translations$buttonT = translations.buttonText,
|
|
37
|
-
buttonText = _translations$buttonT === void 0 ? 'Search' : _translations$buttonT,
|
|
38
|
-
_translations$buttonA = translations.buttonAriaLabel,
|
|
39
|
-
buttonAriaLabel = _translations$buttonA === void 0 ? 'Search' : _translations$buttonA;
|
|
40
|
-
|
|
41
|
-
var _useState = useState(null),
|
|
42
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
-
key = _useState2[0],
|
|
44
|
-
setKey = _useState2[1];
|
|
45
|
-
|
|
46
|
-
useEffect(function () {
|
|
47
|
-
if (typeof navigator !== 'undefined') {
|
|
48
|
-
isAppleDevice() ? setKey(ACTION_KEY_APPLE) : setKey(ACTION_KEY_DEFAULT);
|
|
49
|
-
}
|
|
50
|
-
}, []);
|
|
51
|
-
return /*#__PURE__*/React.createElement("button", _extends({
|
|
52
|
-
type: "button",
|
|
53
|
-
className: "DocSearch DocSearch-Button",
|
|
54
|
-
"aria-label": buttonAriaLabel
|
|
55
|
-
}, props, {
|
|
56
|
-
ref: ref
|
|
57
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
58
|
-
className: "DocSearch-Button-Container"
|
|
59
|
-
}, /*#__PURE__*/React.createElement(SearchIcon, null), /*#__PURE__*/React.createElement("span", {
|
|
60
|
-
className: "DocSearch-Button-Placeholder"
|
|
61
|
-
}, buttonText)), /*#__PURE__*/React.createElement("span", {
|
|
62
|
-
className: "DocSearch-Button-Keys"
|
|
63
|
-
}, key !== null && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DocSearchButtonKey, {
|
|
64
|
-
reactsToKey: key === ACTION_KEY_DEFAULT ? ACTION_KEY_DEFAULT : 'Meta'
|
|
65
|
-
}, key === ACTION_KEY_DEFAULT ? /*#__PURE__*/React.createElement(ControlKeyIcon, null) : key), /*#__PURE__*/React.createElement(DocSearchButtonKey, {
|
|
66
|
-
reactsToKey: "k"
|
|
67
|
-
}, "K"))));
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
function DocSearchButtonKey(_ref2) {
|
|
71
|
-
var reactsToKey = _ref2.reactsToKey,
|
|
72
|
-
children = _ref2.children;
|
|
73
|
-
|
|
74
|
-
var _useState3 = useState(false),
|
|
75
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
76
|
-
isKeyDown = _useState4[0],
|
|
77
|
-
setIsKeyDown = _useState4[1];
|
|
78
|
-
|
|
79
|
-
useEffect(function () {
|
|
80
|
-
if (!reactsToKey) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function handleKeyDown(e) {
|
|
85
|
-
if (e.key === reactsToKey) {
|
|
86
|
-
setIsKeyDown(true);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function handleKeyUp(e) {
|
|
91
|
-
if (e.key === reactsToKey || // keyup doesn't fire when Command is held down,
|
|
92
|
-
// workaround is to mark key as also released when Command is released
|
|
93
|
-
// See https://stackoverflow.com/a/73419500
|
|
94
|
-
e.key === 'Meta') {
|
|
95
|
-
setIsKeyDown(false);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
100
|
-
window.addEventListener('keyup', handleKeyUp);
|
|
101
|
-
return function () {
|
|
102
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
103
|
-
window.removeEventListener('keyup', handleKeyUp);
|
|
104
|
-
};
|
|
105
|
-
}, [reactsToKey]);
|
|
106
|
-
return /*#__PURE__*/React.createElement("kbd", {
|
|
107
|
-
className: isKeyDown ? 'DocSearch-Button-Key DocSearch-Button-Key--pressed' : 'DocSearch-Button-Key'
|
|
108
|
-
}, children);
|
|
109
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DocSearchProps } from './DocSearch';
|
|
2
|
-
import type { FooterTranslations } from './Footer';
|
|
3
|
-
import type { ScreenStateTranslations } from './ScreenState';
|
|
4
|
-
import type { SearchBoxTranslations } from './SearchBox';
|
|
5
|
-
export declare type ModalTranslations = Partial<{
|
|
6
|
-
searchBox: SearchBoxTranslations;
|
|
7
|
-
footer: FooterTranslations;
|
|
8
|
-
}> & ScreenStateTranslations;
|
|
9
|
-
export declare type DocSearchModalProps = DocSearchProps & {
|
|
10
|
-
initialScrollY: number;
|
|
11
|
-
onClose?: () => void;
|
|
12
|
-
translations?: ModalTranslations;
|
|
13
|
-
};
|
|
14
|
-
export declare function DocSearchModal({ appId, apiKey, indexName, placeholder, searchParameters, maxResultsPerGroup, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, }: DocSearchModalProps): JSX.Element;
|