@docsearch/react 4.6.2 → 5.0.0-beta.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.
- package/README.md +0 -2
- package/dist/esm/AskAiScreenState-D0IZsCMJ.d.ts +106 -0
- package/dist/esm/DocSearch-Dq5Utfyb.d.ts +295 -0
- package/dist/esm/DocSearchAskAiModal-BwbMrrHv.d.ts +48 -0
- package/dist/esm/DocSearchAskAiModal-CCrk6YLb.js +954 -0
- package/dist/esm/DocSearchAskAiModal-CCrk6YLb.js.map +1 -0
- package/dist/esm/DocSearchButton-CRlNPf5k.d.ts +18 -0
- package/dist/esm/DocSearchButton-CaxxOzQU.js +71 -0
- package/dist/esm/DocSearchButton-CaxxOzQU.js.map +1 -0
- package/dist/esm/DocSearchModal-CpvDjo1O.js +250 -0
- package/dist/esm/DocSearchModal-CpvDjo1O.js.map +1 -0
- package/dist/esm/DocSearchTheme-DvL4mf0D.d.ts +5 -0
- package/dist/esm/askaiModal.d.ts +2 -0
- package/dist/esm/askaiModal.js +3 -0
- package/dist/esm/button.d.ts +2 -0
- package/dist/esm/button.js +3 -0
- package/dist/esm/docsearchAi.d.ts +220 -0
- package/dist/esm/docsearchAi.js +34 -0
- package/dist/esm/docsearchAi.js.map +1 -0
- package/dist/esm/index-Dl8FMlR5.d.ts +223 -0
- package/dist/esm/index.d.ts +9 -567
- package/dist/esm/index.js +35 -3
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/keyboard-BkSdCzTU.js +9 -0
- package/dist/esm/keyboard-BkSdCzTU.js.map +1 -0
- package/dist/esm/keyboardShortcuts-C-lx6Xt7.js +25 -0
- package/dist/esm/keyboardShortcuts-C-lx6Xt7.js.map +1 -0
- package/dist/esm/modal.d.ts +2 -0
- package/dist/esm/modal.js +3 -0
- package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js +1240 -0
- package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js.map +1 -0
- package/dist/esm/objectSpread2-BNmiQYyW.js +67 -0
- package/dist/esm/objectWithoutProperties-phqYxDS0.js +53 -0
- package/dist/esm/objectWithoutProperties-phqYxDS0.js.map +1 -0
- package/dist/esm/sidepanel.d.ts +395 -0
- package/dist/esm/sidepanel.js +773 -0
- package/dist/esm/sidepanel.js.map +1 -0
- package/dist/esm/useDocSearchKeyboardEvents-68G8dw6c.d.ts +43 -0
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +2 -41
- package/dist/esm/useDocSearchKeyboardEvents.js +43 -1
- package/dist/esm/useDocSearchKeyboardEvents.js.map +1 -0
- package/dist/esm/useSearchClient-mIHVB6ga.js +433 -0
- package/dist/esm/useSearchClient-mIHVB6ga.js.map +1 -0
- package/dist/esm/useSuggestedQuestions-D2TGVPsI.js +1112 -0
- package/dist/esm/useSuggestedQuestions-D2TGVPsI.js.map +1 -0
- package/dist/esm/useTheme.d.ts +7 -6
- package/dist/esm/useTheme.js +21 -1
- package/dist/esm/useTheme.js.map +1 -0
- package/dist/esm/version.d.ts +4 -2
- package/dist/esm/version.js +6 -1
- package/dist/esm/version.js.map +1 -0
- package/dist/umd/index.js +175 -5
- package/dist/umd/index.js.map +1 -1
- package/package.json +31 -34
- package/style/askai.js +1 -0
- package/button.js +0 -1
- package/dist/esm/DocSearchButton.d.ts +0 -18
- package/dist/esm/DocSearchButton.js +0 -1
- package/dist/esm/DocSearchModal.d.ts +0 -448
- package/dist/esm/DocSearchModal.js +0 -3
- package/dist/esm/Sidepanel.d.ts +0 -349
- package/dist/esm/Sidepanel.js +0 -3
- package/dist/umd/DocSearchModal.js +0 -5
- package/dist/umd/DocSearchModal.js.map +0 -1
- package/dist/umd/DocsearchButton.js +0 -3
- package/dist/umd/DocsearchButton.js.map +0 -1
- package/dist/umd/Sidepanel.js +0 -5
- package/dist/umd/Sidepanel.js.map +0 -1
- package/dist/umd/useDocSearchKeyboardEvents.js +0 -3
- package/dist/umd/useDocSearchKeyboardEvents.js.map +0 -1
- package/dist/umd/useTheme.js +0 -3
- package/dist/umd/useTheme.js.map +0 -1
- package/dist/umd/version.js +0 -3
- package/dist/umd/version.js.map +0 -1
- package/modal.js +0 -1
- package/sidepanel.js +0 -1
- package/useDocSearchKeyboardEvents.js +0 -1
- package/useTheme.js +0 -1
- package/version.js +0 -1
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": "
|
|
4
|
+
"version": "5.0.0-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docsearch.algolia.com",
|
|
7
7
|
"repository": {
|
|
@@ -16,60 +16,57 @@
|
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"files": [
|
|
18
18
|
"dist/",
|
|
19
|
-
"button.js",
|
|
20
|
-
"modal.js",
|
|
21
|
-
"useTheme.js",
|
|
22
|
-
"useDocSearchKeyboardEvents.js",
|
|
23
|
-
"version.js",
|
|
24
|
-
"sidepanel.js",
|
|
25
19
|
"style/"
|
|
26
20
|
],
|
|
27
21
|
"exports": {
|
|
28
22
|
".": "./dist/esm/index.js",
|
|
29
|
-
"./
|
|
30
|
-
"./
|
|
31
|
-
"./
|
|
23
|
+
"./askaiModal": "./dist/esm/askaiModal.js",
|
|
24
|
+
"./button": "./dist/esm/button.js",
|
|
25
|
+
"./docsearchAi": "./dist/esm/docsearchAi.js",
|
|
26
|
+
"./modal": "./dist/esm/modal.js",
|
|
27
|
+
"./sidepanel": "./dist/esm/sidepanel.js",
|
|
32
28
|
"./useDocSearchKeyboardEvents": "./dist/esm/useDocSearchKeyboardEvents.js",
|
|
33
29
|
"./useTheme": "./dist/esm/useTheme.js",
|
|
34
30
|
"./version": "./dist/esm/version.js",
|
|
35
|
-
"./
|
|
36
|
-
"./style/
|
|
31
|
+
"./style": "./style/index.js",
|
|
32
|
+
"./style/askai": "./style/askai.js",
|
|
33
|
+
"./style/button": "./style/button.js",
|
|
34
|
+
"./style/modal": "./style/modal.js",
|
|
35
|
+
"./style/sidepanel": "./style/sidepanel.js",
|
|
36
|
+
"./style/variables": "./style/variables.js"
|
|
37
37
|
},
|
|
38
38
|
"source": "src/index.ts",
|
|
39
|
-
"types": "dist/esm/index.d.ts",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
39
|
+
"types": "./dist/esm/index.d.ts",
|
|
40
|
+
"main": "./dist/esm/index.js",
|
|
41
|
+
"module": "./dist/esm/index.js",
|
|
42
42
|
"umd:main": "dist/umd/index.js",
|
|
43
43
|
"unpkg": "dist/umd/index.js",
|
|
44
44
|
"jsdelivr": "dist/umd/index.js",
|
|
45
45
|
"scripts": {
|
|
46
|
-
"build
|
|
47
|
-
"
|
|
48
|
-
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/esm/types",
|
|
49
|
-
"build:source": "rollup --config --bundleConfigAsCjs",
|
|
50
|
-
"build:dts": "rollup --config rollup.dts.config.js --bundleConfigAsCjs",
|
|
51
|
-
"build": "yarn build:clean && yarn build:types && yarn build:source && yarn build:dts && yarn build:clean-types",
|
|
52
|
-
"on:change": "yarn build",
|
|
53
|
-
"watch": "nodemon --watch src --ext ts,tsx,js,jsx,json --ignore dist/ --ignore node_modules/ --verbose --delay 250ms --exec \"yarn on:change\""
|
|
46
|
+
"build": "tsdown",
|
|
47
|
+
"watch": "tsdown --watch"
|
|
54
48
|
},
|
|
55
49
|
"dependencies": {
|
|
56
|
-
"@algolia/autocomplete-core": "1.19.2",
|
|
57
|
-
"@docsearch/core": "4.6.2",
|
|
58
|
-
"@docsearch/css": "4.6.2"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
50
|
"@ai-sdk/react": "^2.0.30",
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
51
|
+
"@algolia/autocomplete-core": "1.19.2",
|
|
52
|
+
"@base-ui/react": "^1.5.0",
|
|
53
|
+
"@docsearch/core": "5.0.0-beta.0",
|
|
54
|
+
"@docsearch/css": "5.0.0-beta.0",
|
|
65
55
|
"ai": "^5.0.30",
|
|
66
56
|
"algoliasearch": "^5.28.0",
|
|
67
57
|
"marked": "^16.3.0",
|
|
68
|
-
"nodemon": "^3.1.0",
|
|
69
|
-
"rollup-plugin-dts": "^6.2.1",
|
|
70
|
-
"vitest": "3.0.9",
|
|
71
58
|
"zod": "^4.1.8"
|
|
72
59
|
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@algolia/autocomplete-core": "1.19.2",
|
|
62
|
+
"@docsearch/core": "5.0.0-beta.0",
|
|
63
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
64
|
+
"@testing-library/react": "16.2.0",
|
|
65
|
+
"preact": "11.0.0-beta.0",
|
|
66
|
+
"tsdown": "0.22.7",
|
|
67
|
+
"typescript": "5.7.3",
|
|
68
|
+
"vitest": "3.0.2"
|
|
69
|
+
},
|
|
73
70
|
"peerDependencies": {
|
|
74
71
|
"@types/react": ">= 16.8.0 < 20.0.0",
|
|
75
72
|
"react": ">= 16.8.0 < 20.0.0",
|
package/style/askai.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@docsearch/css/dist/_askai.css';
|
package/button.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DocSearchButton } from './dist/esm/DocSearchButton.js';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DocSearchModalShortcuts } from '@docsearch/core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
type DocSearchTheme = 'dark' | 'light';
|
|
5
|
-
|
|
6
|
-
type ButtonTranslations = Partial<{
|
|
7
|
-
buttonText: string;
|
|
8
|
-
buttonAriaLabel: string;
|
|
9
|
-
}>;
|
|
10
|
-
type DocSearchButtonProps = React.ComponentProps<'button'> & {
|
|
11
|
-
theme?: DocSearchTheme;
|
|
12
|
-
translations?: ButtonTranslations;
|
|
13
|
-
keyboardShortcuts?: DocSearchModalShortcuts;
|
|
14
|
-
};
|
|
15
|
-
declare const DocSearchButton: React.ForwardRefExoticComponent<Omit<DocSearchButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
16
|
-
|
|
17
|
-
export { DocSearchButton };
|
|
18
|
-
export type { ButtonTranslations, DocSearchButtonProps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e,{useEffect as t,useState as r}from"react";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(null,arguments)}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach(function(t){o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,c,i=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(i.push(n.value),i.length!==t);l=!0);}catch(e){u=!0,o=e}finally{try{if(!l&&null!=r.return&&(c=r.return(),Object(c)!==c))return}finally{if(u)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var u={"Ctrl/Cmd+K":!0,"/":!0};function f(t){var r=t.size,n=void 0===r?20:r,o=t.color,a=void 0===o?"currentColor":o;return e.createElement("svg",{width:n,height:n,className:"DocSearch-Search-Icon",viewBox:"0 0 24 24","aria-hidden":"true"},e.createElement("circle",{cx:"11",cy:"11",r:"8",stroke:a,fill:"none",strokeWidth:"1.4"}),e.createElement("path",{d:"m21 21-4.3-4.3",stroke:a,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}))}var s="Ctrl";var m=["translations","keyboardShortcuts"],d=e.forwardRef(function(n,o){var c,d,v,b=n.translations,h=void 0===b?{}:b,p=n.keyboardShortcuts,O=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(n,m),w=h.buttonText,g=void 0===w?"Search":w,S=h.buttonAriaLabel,E=void 0===S?"Search":S,j=(c=p,i(i({},u),c)),k=l(r(null),2),P=k[0],D=k[1];d={theme:O.theme},v=d.theme,t(function(){if(v){var e=document.documentElement.dataset.theme;if(v!==e)return document.documentElement.dataset.theme=v,function(){void 0===e?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}}},[v]),t(function(){"undefined"!=typeof navigator&&(/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?D("⌘"):D(s))},[]);var C=l(P===s?[s,"Control","Ctrl"]:["Meta","Meta","⌘"],3),K=C[0],B=C[1],x=C[2],A=j["Ctrl/Cmd+K"],L="".concat(B,"+k");return e.createElement("button",a({type:"button",className:"DocSearch DocSearch-Button","aria-label":A?"".concat(E," (").concat(L,")"):E,"aria-keyshortcuts":A?L:void 0},O,{ref:o}),e.createElement("span",{className:"DocSearch-Button-Container"},e.createElement(f,null),e.createElement("span",{className:"DocSearch-Button-Placeholder"},g)),e.createElement("span",{className:"DocSearch-Button-Keys"},null!==P&&A&&e.createElement(e.Fragment,null,e.createElement(y,{reactsToKey:K},x),e.createElement(y,{reactsToKey:"k"},"K"))))});function y(n){var o=n.reactsToKey,a=n.children,c=l(r(!1),2),i=c[0],u=c[1];return t(function(){if(o)return window.addEventListener("keydown",e),window.addEventListener("keyup",t),function(){window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)};function e(e){e.key===o&&u(!0)}function t(e){e.key!==o&&"Meta"!==e.key||u(!1)}},[o]),e.createElement("kbd",{className:i?"DocSearch-Button-Key DocSearch-Button-Key--pressed":"DocSearch-Button-Key"+("Ctrl"===o?" DocSearch-Button-Key--ctrl":"")},a)}export{d as DocSearchButton};
|
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
import { InitialAskAiMessage, DocSearchModalShortcuts, OnAskAiToggle } from '@docsearch/core';
|
|
2
|
-
import React, { JSX } from 'react';
|
|
3
|
-
import { AutocompleteState, AutocompleteOptions } from '@algolia/autocomplete-core';
|
|
4
|
-
import { SearchParamsObject, LiteClient } from 'algoliasearch/lite';
|
|
5
|
-
|
|
6
|
-
type ContentType = 'askAI' | 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
|
|
7
|
-
interface DocSearchHitAttributeHighlightResult {
|
|
8
|
-
value: string;
|
|
9
|
-
matchLevel: 'full' | 'none' | 'partial';
|
|
10
|
-
matchedWords: string[];
|
|
11
|
-
fullyHighlighted?: boolean;
|
|
12
|
-
}
|
|
13
|
-
interface DocSearchHitHighlightResultHierarchy {
|
|
14
|
-
lvl0: DocSearchHitAttributeHighlightResult;
|
|
15
|
-
lvl1: DocSearchHitAttributeHighlightResult;
|
|
16
|
-
lvl2: DocSearchHitAttributeHighlightResult;
|
|
17
|
-
lvl3: DocSearchHitAttributeHighlightResult;
|
|
18
|
-
lvl4: DocSearchHitAttributeHighlightResult;
|
|
19
|
-
lvl5: DocSearchHitAttributeHighlightResult;
|
|
20
|
-
lvl6: DocSearchHitAttributeHighlightResult;
|
|
21
|
-
}
|
|
22
|
-
interface DocSearchHitHighlightResult {
|
|
23
|
-
content: DocSearchHitAttributeHighlightResult;
|
|
24
|
-
hierarchy: DocSearchHitHighlightResultHierarchy;
|
|
25
|
-
hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
|
|
26
|
-
}
|
|
27
|
-
interface DocSearchHitAttributeSnippetResult {
|
|
28
|
-
value: string;
|
|
29
|
-
matchLevel: 'full' | 'none' | 'partial';
|
|
30
|
-
}
|
|
31
|
-
interface DocSearchHitSnippetResult {
|
|
32
|
-
content: DocSearchHitAttributeSnippetResult;
|
|
33
|
-
hierarchy: DocSearchHitHighlightResultHierarchy;
|
|
34
|
-
hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
|
|
35
|
-
}
|
|
36
|
-
declare type DocSearchHit = {
|
|
37
|
-
objectID: string;
|
|
38
|
-
content: string | null;
|
|
39
|
-
query?: string;
|
|
40
|
-
url: string;
|
|
41
|
-
url_without_anchor: string;
|
|
42
|
-
type: ContentType;
|
|
43
|
-
anchor: string | null;
|
|
44
|
-
hierarchy: {
|
|
45
|
-
lvl0: string;
|
|
46
|
-
lvl1: string;
|
|
47
|
-
lvl2: string | null;
|
|
48
|
-
lvl3: string | null;
|
|
49
|
-
lvl4: string | null;
|
|
50
|
-
lvl5: string | null;
|
|
51
|
-
lvl6: string | null;
|
|
52
|
-
};
|
|
53
|
-
_highlightResult: DocSearchHitHighlightResult;
|
|
54
|
-
_snippetResult: DocSearchHitSnippetResult;
|
|
55
|
-
_rankingInfo?: {
|
|
56
|
-
promoted: boolean;
|
|
57
|
-
nbTypos: number;
|
|
58
|
-
firstMatchedWord: number;
|
|
59
|
-
proximityDistance?: number;
|
|
60
|
-
geoDistance: number;
|
|
61
|
-
geoPrecision?: number;
|
|
62
|
-
nbExactWords: number;
|
|
63
|
-
words: number;
|
|
64
|
-
filters: number;
|
|
65
|
-
userScore: number;
|
|
66
|
-
matchedGeoLocation?: {
|
|
67
|
-
lat: number;
|
|
68
|
-
lng: number;
|
|
69
|
-
distance: number;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
_distinctSeqID?: number;
|
|
73
|
-
__autocomplete_indexName?: string;
|
|
74
|
-
__autocomplete_queryID?: string;
|
|
75
|
-
__autocomplete_algoliaCredentials?: {
|
|
76
|
-
appId: string;
|
|
77
|
-
apiKey: string;
|
|
78
|
-
};
|
|
79
|
-
__autocomplete_id?: number;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
type DocSearchTheme = 'dark' | 'light';
|
|
83
|
-
|
|
84
|
-
type InternalDocSearchHit = DocSearchHit & {
|
|
85
|
-
__docsearch_parent: InternalDocSearchHit | null;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
|
|
89
|
-
|
|
90
|
-
type ButtonTranslations = Partial<{
|
|
91
|
-
buttonText: string;
|
|
92
|
-
buttonAriaLabel: string;
|
|
93
|
-
}>;
|
|
94
|
-
|
|
95
|
-
type DocSearchTranslations = Partial<{
|
|
96
|
-
button: ButtonTranslations;
|
|
97
|
-
modal: ModalTranslations;
|
|
98
|
-
}>;
|
|
99
|
-
type DocSearchTransformClient = {
|
|
100
|
-
search: LiteClient['search'];
|
|
101
|
-
addAlgoliaAgent: LiteClient['addAlgoliaAgent'];
|
|
102
|
-
transporter: Pick<LiteClient['transporter'], 'algoliaAgent'>;
|
|
103
|
-
};
|
|
104
|
-
type AskAiSearchParameters = {
|
|
105
|
-
facetFilters?: string[];
|
|
106
|
-
filters?: string;
|
|
107
|
-
attributesToRetrieve?: string[];
|
|
108
|
-
restrictSearchableAttributes?: string[];
|
|
109
|
-
distinct?: boolean | number | string;
|
|
110
|
-
};
|
|
111
|
-
type AgentStudioSearchParameters = Record<string, Omit<AskAiSearchParameters, 'facetFilters'>>;
|
|
112
|
-
type DocSearchAskAi = {
|
|
113
|
-
/**
|
|
114
|
-
* The index name to use for the ask AI feature. Your assistant will search this index for relevant documents.
|
|
115
|
-
* If not provided, the index name will be used.
|
|
116
|
-
*/
|
|
117
|
-
indexName?: string;
|
|
118
|
-
/**
|
|
119
|
-
* The API key to use for the ask AI feature. Your assistant will use this API key to search the index.
|
|
120
|
-
* If not provided, the API key will be used.
|
|
121
|
-
*/
|
|
122
|
-
apiKey?: string;
|
|
123
|
-
/**
|
|
124
|
-
* The app ID to use for the ask AI feature. Your assistant will use this app ID to search the index.
|
|
125
|
-
* If not provided, the app ID will be used.
|
|
126
|
-
*/
|
|
127
|
-
appId?: string;
|
|
128
|
-
/**
|
|
129
|
-
* The assistant ID to use for the ask AI feature.
|
|
130
|
-
*/
|
|
131
|
-
assistantId: string;
|
|
132
|
-
/**
|
|
133
|
-
* Enables displaying suggested questions on Ask AI's new conversation screen.
|
|
134
|
-
*
|
|
135
|
-
* @default false
|
|
136
|
-
*/
|
|
137
|
-
suggestedQuestions?: boolean;
|
|
138
|
-
useStagingEnv?: boolean;
|
|
139
|
-
} & ({
|
|
140
|
-
/**
|
|
141
|
-
* **Experimental:** Whether to use Agent Studio as the chat backend.
|
|
142
|
-
*
|
|
143
|
-
* This is an experimental feature and its API may change without notice in future releases.
|
|
144
|
-
* Use with caution in production environments.
|
|
145
|
-
*
|
|
146
|
-
* @default false
|
|
147
|
-
*/
|
|
148
|
-
agentStudio?: never;
|
|
149
|
-
/**
|
|
150
|
-
* The search parameters to use for the ask AI feature.
|
|
151
|
-
*
|
|
152
|
-
* **NOTE**: If using `agentStudio = true`, the `searchParameters` object is
|
|
153
|
-
* keyed by the index name.
|
|
154
|
-
*/
|
|
155
|
-
searchParameters?: AskAiSearchParameters;
|
|
156
|
-
} | {
|
|
157
|
-
agentStudio: false;
|
|
158
|
-
searchParameters?: AskAiSearchParameters;
|
|
159
|
-
} | {
|
|
160
|
-
agentStudio: true;
|
|
161
|
-
/**
|
|
162
|
-
* The search parameters to use for the ask AI feature.
|
|
163
|
-
* Keyed by the index name.
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* {
|
|
167
|
-
* "INDEX_NAME": { distinct: false }
|
|
168
|
-
* }
|
|
169
|
-
*/
|
|
170
|
-
searchParameters?: AgentStudioSearchParameters;
|
|
171
|
-
});
|
|
172
|
-
interface DocSearchIndex {
|
|
173
|
-
name: string;
|
|
174
|
-
searchParameters?: SearchParamsObject;
|
|
175
|
-
}
|
|
176
|
-
interface DocSearchProps {
|
|
177
|
-
/**
|
|
178
|
-
* Algolia application id used by the search client.
|
|
179
|
-
*/
|
|
180
|
-
appId: string;
|
|
181
|
-
/**
|
|
182
|
-
* Public api key with search permissions for the index.
|
|
183
|
-
*/
|
|
184
|
-
apiKey: string;
|
|
185
|
-
/**
|
|
186
|
-
* Name of the algolia index to query.
|
|
187
|
-
*
|
|
188
|
-
* @deprecated `indexName` will be removed in a future version. Please use `indices` property going forward.
|
|
189
|
-
*/
|
|
190
|
-
indexName?: string;
|
|
191
|
-
/**
|
|
192
|
-
* List of indices and _optional_ searchParameters to be used for search.
|
|
193
|
-
*
|
|
194
|
-
* @see {@link https://docsearch.algolia.com/docs/api#indices}
|
|
195
|
-
*/
|
|
196
|
-
indices?: Array<DocSearchIndex | string>;
|
|
197
|
-
/**
|
|
198
|
-
* Configuration or assistant id to enable ask ai mode. Pass a string assistant id or a full config object.
|
|
199
|
-
*/
|
|
200
|
-
askAi?: DocSearchAskAi | string;
|
|
201
|
-
/**
|
|
202
|
-
* Intercept Ask AI requests (e.g. Submitting a prompt or selecting a suggested question).
|
|
203
|
-
*
|
|
204
|
-
* Return `true` to prevent the default modal Ask AI flow (no toggle, no sendMessage).
|
|
205
|
-
* Useful to route Ask AI into a different UI (e.g. `@docsearch/sidepanel-js`) without flicker.
|
|
206
|
-
*/
|
|
207
|
-
interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
|
|
208
|
-
/**
|
|
209
|
-
* Theme overrides applied to the modal and related components.
|
|
210
|
-
*/
|
|
211
|
-
theme?: DocSearchTheme;
|
|
212
|
-
/**
|
|
213
|
-
* Placeholder text for the search input.
|
|
214
|
-
*/
|
|
215
|
-
placeholder?: string;
|
|
216
|
-
/**
|
|
217
|
-
* Additional algolia search parameters to merge into each query.
|
|
218
|
-
*
|
|
219
|
-
* @deprecated `searchParameters` will be removed in a future version. Please use `indices` property going forward.
|
|
220
|
-
*/
|
|
221
|
-
searchParameters?: SearchParamsObject;
|
|
222
|
-
/**
|
|
223
|
-
* Maximum number of hits to display per source/group.
|
|
224
|
-
*/
|
|
225
|
-
maxResultsPerGroup?: number;
|
|
226
|
-
/**
|
|
227
|
-
* Hook to post-process hits before rendering.
|
|
228
|
-
*/
|
|
229
|
-
transformItems?: (items: DocSearchHit[]) => DocSearchHit[];
|
|
230
|
-
/**
|
|
231
|
-
* Custom component to render an individual hit.
|
|
232
|
-
* Supports template patterns:
|
|
233
|
-
* - HTML strings with html helper: (props, { html }) => html`<div>...</div>`
|
|
234
|
-
* - JSX templates: (props) => <div>...</div>
|
|
235
|
-
* - Function-based templates: (props) => string | JSX.Element | Function.
|
|
236
|
-
*/
|
|
237
|
-
hitComponent?: (props: {
|
|
238
|
-
hit: InternalDocSearchHit | StoredDocSearchHit;
|
|
239
|
-
children: React.ReactNode;
|
|
240
|
-
}, helpers?: {
|
|
241
|
-
html: (template: TemplateStringsArray, ...values: any[]) => any;
|
|
242
|
-
}) => JSX.Element;
|
|
243
|
-
/**
|
|
244
|
-
* Custom component rendered at the bottom of the results panel.
|
|
245
|
-
* Supports template patterns:
|
|
246
|
-
* - HTML strings with html helper: (props, { html }) => html`<div>...</div>`
|
|
247
|
-
* - JSX templates: (props) => <div>...</div>
|
|
248
|
-
* - Function-based templates: (props) => string | JSX.Element | Function.
|
|
249
|
-
*/
|
|
250
|
-
resultsFooterComponent?: (props: {
|
|
251
|
-
state: AutocompleteState<InternalDocSearchHit>;
|
|
252
|
-
}, helpers?: {
|
|
253
|
-
html: (template: TemplateStringsArray, ...values: any[]) => any;
|
|
254
|
-
}) => JSX.Element | null;
|
|
255
|
-
/**
|
|
256
|
-
* Hook to wrap or modify the algolia search client.
|
|
257
|
-
*/
|
|
258
|
-
transformSearchClient?: (searchClient: DocSearchTransformClient) => DocSearchTransformClient;
|
|
259
|
-
/**
|
|
260
|
-
* Disable storage and usage of recent and favorite searches.
|
|
261
|
-
*/
|
|
262
|
-
disableUserPersonalization?: boolean;
|
|
263
|
-
/**
|
|
264
|
-
* Query string to prefill when opening the modal.
|
|
265
|
-
*/
|
|
266
|
-
initialQuery?: string;
|
|
267
|
-
/**
|
|
268
|
-
* Custom navigator for controlling link navigation.
|
|
269
|
-
*/
|
|
270
|
-
navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];
|
|
271
|
-
/**
|
|
272
|
-
* Localized strings for the button and modal ui.
|
|
273
|
-
*/
|
|
274
|
-
translations?: DocSearchTranslations;
|
|
275
|
-
/**
|
|
276
|
-
* Builds a url to report missing results for a given query.
|
|
277
|
-
*/
|
|
278
|
-
getMissingResultsUrl?: ({ query }: {
|
|
279
|
-
query: string;
|
|
280
|
-
}) => string;
|
|
281
|
-
/**
|
|
282
|
-
* Insights client integration options to send analytics events.
|
|
283
|
-
*/
|
|
284
|
-
insights?: AutocompleteOptions<InternalDocSearchHit>['insights'];
|
|
285
|
-
/**
|
|
286
|
-
* The container element where the modal should be portaled to. Defaults to document.body.
|
|
287
|
-
*/
|
|
288
|
-
portalContainer?: DocumentFragment | Element;
|
|
289
|
-
/**
|
|
290
|
-
* Limit of how many recent searches should be saved/displayed..
|
|
291
|
-
*
|
|
292
|
-
* @default 7
|
|
293
|
-
*/
|
|
294
|
-
recentSearchesLimit?: number;
|
|
295
|
-
/**
|
|
296
|
-
* Limit of how many recent searches should be saved/displayed when there are favorited searches..
|
|
297
|
-
*
|
|
298
|
-
* @default 4
|
|
299
|
-
*/
|
|
300
|
-
recentSearchesWithFavoritesLimit?: number;
|
|
301
|
-
/**
|
|
302
|
-
* Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.
|
|
303
|
-
*
|
|
304
|
-
* @default `{ 'Ctrl/Cmd+K': true, '/': true }`
|
|
305
|
-
*/
|
|
306
|
-
keyboardShortcuts?: DocSearchModalShortcuts;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
type FooterTranslations = Partial<{
|
|
310
|
-
selectText: string;
|
|
311
|
-
submitQuestionText: string;
|
|
312
|
-
selectKeyAriaLabel: string;
|
|
313
|
-
navigateText: string;
|
|
314
|
-
navigateUpKeyAriaLabel: string;
|
|
315
|
-
navigateDownKeyAriaLabel: string;
|
|
316
|
-
closeText: string;
|
|
317
|
-
backToSearchText: string;
|
|
318
|
-
closeKeyAriaLabel: string;
|
|
319
|
-
poweredByText: string;
|
|
320
|
-
}>;
|
|
321
|
-
|
|
322
|
-
type NewConversationTranslations = Partial<{
|
|
323
|
-
newConversationTitle: string;
|
|
324
|
-
newConversationDescription: string;
|
|
325
|
-
}>;
|
|
326
|
-
|
|
327
|
-
type AskAiScreenTranslations = Partial<{
|
|
328
|
-
disclaimerText: string;
|
|
329
|
-
relatedSourcesText: string;
|
|
330
|
-
thinkingText: string;
|
|
331
|
-
copyButtonText: string;
|
|
332
|
-
copyButtonCopiedText: string;
|
|
333
|
-
copyButtonTitle: string;
|
|
334
|
-
likeButtonTitle: string;
|
|
335
|
-
dislikeButtonTitle: string;
|
|
336
|
-
thanksForFeedbackText: string;
|
|
337
|
-
preToolCallText: string;
|
|
338
|
-
duringToolCallText: string;
|
|
339
|
-
afterToolCallText: string;
|
|
340
|
-
/**
|
|
341
|
-
* Build the full jsx element for the aggregated search block.
|
|
342
|
-
* If provided, completely overrides the default english renderer.
|
|
343
|
-
*/
|
|
344
|
-
aggregatedToolCallNode?: (queries: string[], onSearchQueryClick: (query: string) => void) => React.ReactNode;
|
|
345
|
-
/**
|
|
346
|
-
* Generate the list connective parts only (backwards compatibility).
|
|
347
|
-
* Receives full list of queries and should return translation parts for before/after/separators.
|
|
348
|
-
* Example: (qs) => ({ before: 'searched for ', separator: ', ', lastSeparator: ' and ', after: '' }).
|
|
349
|
-
*/
|
|
350
|
-
aggregatedToolCallText?: (queries: string[]) => {
|
|
351
|
-
before?: string;
|
|
352
|
-
separator?: string;
|
|
353
|
-
lastSeparator?: string;
|
|
354
|
-
after?: string;
|
|
355
|
-
};
|
|
356
|
-
/**
|
|
357
|
-
* Message that's shown when user has stopped the streaming of a message.
|
|
358
|
-
*/
|
|
359
|
-
stoppedStreamingText: string;
|
|
360
|
-
/**
|
|
361
|
-
* Error title shown if there is an error while chatting.
|
|
362
|
-
*/
|
|
363
|
-
errorTitleText: string;
|
|
364
|
-
/**
|
|
365
|
-
* Message shown when thread depth limit is exceeded (AI-217 error).
|
|
366
|
-
*/
|
|
367
|
-
threadDepthExceededMessage: string;
|
|
368
|
-
/**
|
|
369
|
-
* Button text for starting a new conversation after thread depth error.
|
|
370
|
-
*/
|
|
371
|
-
startNewConversationButtonText: string;
|
|
372
|
-
}>;
|
|
373
|
-
|
|
374
|
-
type ErrorScreenTranslations = Partial<{
|
|
375
|
-
titleText: string;
|
|
376
|
-
helpText: string;
|
|
377
|
-
}>;
|
|
378
|
-
|
|
379
|
-
type NoResultsScreenTranslations = Partial<{
|
|
380
|
-
noResultsText: string;
|
|
381
|
-
suggestedQueryText: string;
|
|
382
|
-
reportMissingResultsText: string;
|
|
383
|
-
reportMissingResultsLinkText: string;
|
|
384
|
-
}>;
|
|
385
|
-
|
|
386
|
-
type ResultsScreenTranslations = Partial<{
|
|
387
|
-
askAiPlaceholder: string;
|
|
388
|
-
noResultsAskAiPlaceholder: string;
|
|
389
|
-
}>;
|
|
390
|
-
|
|
391
|
-
type StartScreenTranslations = Partial<{
|
|
392
|
-
recentSearchesTitle: string;
|
|
393
|
-
noRecentSearchesText: string;
|
|
394
|
-
saveRecentSearchButtonTitle: string;
|
|
395
|
-
removeRecentSearchButtonTitle: string;
|
|
396
|
-
favoriteSearchesTitle: string;
|
|
397
|
-
removeFavoriteSearchButtonTitle: string;
|
|
398
|
-
recentConversationsTitle: string;
|
|
399
|
-
removeRecentConversationButtonTitle: string;
|
|
400
|
-
}>;
|
|
401
|
-
|
|
402
|
-
type ScreenStateTranslations = Partial<{
|
|
403
|
-
errorScreen: ErrorScreenTranslations;
|
|
404
|
-
startScreen: StartScreenTranslations;
|
|
405
|
-
noResultsScreen: NoResultsScreenTranslations;
|
|
406
|
-
resultsScreen: ResultsScreenTranslations;
|
|
407
|
-
askAiScreen: AskAiScreenTranslations;
|
|
408
|
-
newConversation: NewConversationTranslations;
|
|
409
|
-
}>;
|
|
410
|
-
|
|
411
|
-
type SearchBoxTranslations = Partial<{
|
|
412
|
-
clearButtonTitle: string;
|
|
413
|
-
clearButtonAriaLabel: string;
|
|
414
|
-
closeButtonText: string;
|
|
415
|
-
closeButtonAriaLabel: string;
|
|
416
|
-
placeholderText: string;
|
|
417
|
-
placeholderTextAskAi: string;
|
|
418
|
-
placeholderTextAskAiStreaming: string;
|
|
419
|
-
enterKeyHint: string;
|
|
420
|
-
enterKeyHintAskAi: string;
|
|
421
|
-
searchInputLabel: string;
|
|
422
|
-
backToKeywordSearchButtonText: string;
|
|
423
|
-
backToKeywordSearchButtonAriaLabel: string;
|
|
424
|
-
newConversationPlaceholder: string;
|
|
425
|
-
conversationHistoryTitle: string;
|
|
426
|
-
startNewConversationText: string;
|
|
427
|
-
viewConversationHistoryText: string;
|
|
428
|
-
threadDepthErrorPlaceholder: string;
|
|
429
|
-
}>;
|
|
430
|
-
|
|
431
|
-
type ModalTranslations = Partial<{
|
|
432
|
-
searchBox: SearchBoxTranslations;
|
|
433
|
-
newConversation: NewConversationTranslations;
|
|
434
|
-
footer: FooterTranslations;
|
|
435
|
-
}> & ScreenStateTranslations;
|
|
436
|
-
type DocSearchModalProps = DocSearchProps & {
|
|
437
|
-
initialScrollY: number;
|
|
438
|
-
onAskAiToggle: OnAskAiToggle;
|
|
439
|
-
interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
|
|
440
|
-
onClose?: () => void;
|
|
441
|
-
isAskAiActive?: boolean;
|
|
442
|
-
translations?: ModalTranslations;
|
|
443
|
-
isHybridModeSupported?: boolean;
|
|
444
|
-
};
|
|
445
|
-
declare function DocSearchModal({ appId, apiKey, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, interceptAskAiEvent, isAskAiActive, recentSearchesLimit, recentSearchesWithFavoritesLimit, indices, indexName, searchParameters, isHybridModeSupported, ...props }: DocSearchModalProps): JSX.Element;
|
|
446
|
-
|
|
447
|
-
export { DocSearchModal };
|
|
448
|
-
export type { DocSearchModalProps, ModalTranslations };
|