@docsearch/react 5.0.1 → 5.0.3
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/dist/esm/{AskAiScreenState-Sqbn60f2.d.ts → AskAiScreenState-DuzmHxUz.d.ts} +3 -3
- package/dist/esm/{DocSearch-BVqxFxTw.d.ts → DocSearch-2gNxdJcC.d.ts} +3 -3
- package/dist/esm/{DocSearchAskAiModal-DpB7pLCC.d.ts → DocSearchAskAiModal-BY3KtJ54.d.ts} +4 -4
- package/dist/esm/{DocSearchAskAiModal-2ci32vW6.js → DocSearchAskAiModal-BzQZxvTY.js} +33 -26
- package/dist/esm/{DocSearchAskAiModal-2ci32vW6.js.map → DocSearchAskAiModal-BzQZxvTY.js.map} +1 -1
- package/dist/esm/{DocSearchButton-CZM_jACU.d.ts → DocSearchButton-DyJd_QGM.d.ts} +2 -2
- package/dist/esm/askaiModal.d.ts +1 -1
- package/dist/esm/askaiModal.js +1 -1
- package/dist/esm/button.d.ts +1 -1
- package/dist/esm/docsearch.d.ts +1 -1
- package/dist/esm/docsearchAi.d.ts +2 -2
- package/dist/esm/docsearchAi.js +1 -1
- package/dist/esm/{index-Bqqv4HmN.d.ts → index-BijiN4hK.d.ts} +2 -2
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/modal.d.ts +1 -1
- package/dist/esm/sidepanel.d.ts +4 -4
- package/dist/esm/sidepanel.js +1 -1
- package/dist/esm/{useDocSearchKeyboardEvents-u23fFhR9.d.ts → useDocSearchKeyboardEvents-B7PKBkuX.d.ts} +2 -2
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +1 -1
- package/dist/esm/{useSuggestedQuestions-BjSZvxwr.js → useSuggestedQuestions-DitQZbae.js} +7 -3
- package/dist/esm/useSuggestedQuestions-DitQZbae.js.map +1 -0
- package/dist/esm/useTheme.d.ts +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/umd/index.js +80 -80
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/esm/useSuggestedQuestions-BjSZvxwr.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { _ as StoredSearchesSectionsTranslations, g as ErrorScreenTranslations, h as NoResultsScreenTranslations, m as ResultsScreenTranslations } from "./DocSearch-
|
|
1
|
+
import "./index-BijiN4hK.js";
|
|
2
|
+
import { _ as StoredSearchesSectionsTranslations, g as ErrorScreenTranslations, h as NoResultsScreenTranslations, m as ResultsScreenTranslations } from "./DocSearch-2gNxdJcC.js";
|
|
3
3
|
import React, { JSX } from "react";
|
|
4
4
|
import { AutocompleteState, BaseItem } from "@algolia/autocomplete-core";
|
|
5
5
|
import "@ai-sdk/react";
|
|
@@ -106,4 +106,4 @@ type AskAiScreenStateTranslations = Partial<{
|
|
|
106
106
|
}>;
|
|
107
107
|
//#endregion
|
|
108
108
|
export { NewConversationTranslations as n, ToolCallTranslations as r, AskAiScreenStateTranslations as t };
|
|
109
|
-
//# sourceMappingURL=AskAiScreenState-
|
|
109
|
+
//# sourceMappingURL=AskAiScreenState-DuzmHxUz.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as StoredDocSearchHit, d as DocSearchHit } from "./index-
|
|
1
|
+
import { a as StoredDocSearchHit, d as DocSearchHit } from "./index-BijiN4hK.js";
|
|
2
2
|
import { t as DocSearchTheme$1 } from "./DocSearchTheme-DvL4mf0D.js";
|
|
3
|
-
import { t as ButtonTranslations } from "./DocSearchButton-
|
|
3
|
+
import { t as ButtonTranslations } from "./DocSearchButton-DyJd_QGM.js";
|
|
4
4
|
import { DocSearchModalShortcuts, DocSearchRef, DocSearchRef as DocSearchRef$1 } from "@docsearch/core";
|
|
5
5
|
import React, { JSX } from "react";
|
|
6
6
|
import { AutocompleteOptions, AutocompleteState, BaseItem } from "@algolia/autocomplete-core";
|
|
@@ -269,4 +269,4 @@ declare const DocSearch$1: React.ForwardRefExoticComponent<DocSearchProps & Reac
|
|
|
269
269
|
declare function DocSearchInner(props: Omit<DocSearchProps, 'appId' | 'apiKey'>): JSX.Element;
|
|
270
270
|
//#endregion
|
|
271
271
|
export { StoredSearchesSectionsTranslations as _, DocSearchProps as a, InternalDocSearchHit as b, DocSearchTranslations as c, DocSearchModal as d, DocSearchModalProps as f, ErrorScreenTranslations as g, NoResultsScreenTranslations as h, DocSearchInner as i, HitComponentProps as l, ResultsScreenTranslations as m, DocSearchFacet as n, DocSearchRef$1 as o, ModalTranslations as p, DocSearchIndex as r, DocSearchTransformClient as s, DocSearch$1 as t, ResultsFooterComponentProps as u, FooterTranslations as v, FacetBarTranslations as y };
|
|
272
|
-
//# sourceMappingURL=DocSearch-
|
|
272
|
+
//# sourceMappingURL=DocSearch-2gNxdJcC.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { v as FooterTranslations, y as FacetBarTranslations } from "./DocSearch-
|
|
1
|
+
import "./index-BijiN4hK.js";
|
|
2
|
+
import { v as FooterTranslations, y as FacetBarTranslations } from "./DocSearch-2gNxdJcC.js";
|
|
3
3
|
import { DocSearchAIProps } from "./docsearchAi.js";
|
|
4
|
-
import { n as NewConversationTranslations, t as AskAiScreenStateTranslations } from "./AskAiScreenState-
|
|
4
|
+
import { n as NewConversationTranslations, t as AskAiScreenStateTranslations } from "./AskAiScreenState-DuzmHxUz.js";
|
|
5
5
|
import { OnAskAiToggle } from "@docsearch/core";
|
|
6
6
|
import React, { JSX } from "react";
|
|
7
7
|
import { AutocompleteState } from "@algolia/autocomplete-core";
|
|
@@ -45,4 +45,4 @@ type DocSearchAskAiModalProps = DocSearchAIProps & {
|
|
|
45
45
|
declare function DocSearchAskAiModal({ appId, apiKey, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, interceptAskAiEvent, isAskAiActive, recentSearchesLimit, recentSearchesWithFavoritesLimit, indices, facets, isHybridModeSupported, footerAction, ...props }: DocSearchAskAiModalProps): JSX.Element;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { DocSearchAskAiModalProps as n, DocSearchAskAiModalTranslations as r, DocSearchAskAiModal as t };
|
|
48
|
-
//# sourceMappingURL=DocSearchAskAiModal-
|
|
48
|
+
//# sourceMappingURL=DocSearchAskAiModal-BY3KtJ54.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { t as _objectSpread2 } from "./objectSpread2-BNmiQYyW.js";
|
|
|
2
2
|
import { C as noop, D as SOURCE_IDS, E as identity, O as getCollection, S as scrollTo, T as isModifierEvent, _ as Hit, a as NoResultsScreen, b as SearchBoxForm, c as Results, d as useRefreshOnInitialQuery, f as useModalRefs, g as useDocSearchFacets, h as useSendItemClickEvent, i as ResultsScreen, l as useStoredDocSearches, m as useInitialModalQuery, n as buildNoQuerySources, o as ErrorScreen, p as useModalEnvironment, r as buildQuerySources, s as StoredSearchesSections, t as normalizeDocSearchIndexes, u as useSaveRecentSearch, v as Footer, w as isQueryEmpty, x as FacetBar, y as ModalShell } from "./normalizeDocSearchIndexes-CFHzf-sx.js";
|
|
3
3
|
import { n as SearchIcon, t as _objectWithoutProperties } from "./objectWithoutProperties-phqYxDS0.js";
|
|
4
4
|
import { l as CloseIcon, m as LoadingIcon, p as SparklesIcon, t as useSearchClient } from "./useSearchClient-mIHVB6ga.js";
|
|
5
|
-
import { C as ConversationHistoryIcon, E as AlertIcon, S as NewConversationIcon, T as StopIcon, _ as showAskAiBlockingBannerNewConversationLink, a as MemoizedMarkdown, b as ConversationPromptSuggestions, c as buildDummyAskAiHit, d as getAskAiBlockingBannerMessage, f as getMessageContent, g as isThreadDepthError, h as isAskAiPromptBlockingError, i as groupConsecutiveToolResults, l as extractLinksFromMessage, m as isAgentStudioTokenOutputLimitError, n as useAskAi, o as ToolCall, p as isAIToolPart, r as Menu, s as EMPTY_TOOLS, t as useSuggestedQuestions, u as getAgentPromptSuggestions, v as SourcesPanel, w as MoreVerticalIcon, x as BackIcon, y as FeedbackActions } from "./useSuggestedQuestions-
|
|
5
|
+
import { C as ConversationHistoryIcon, E as AlertIcon, S as NewConversationIcon, T as StopIcon, _ as showAskAiBlockingBannerNewConversationLink, a as MemoizedMarkdown, b as ConversationPromptSuggestions, c as buildDummyAskAiHit, d as getAskAiBlockingBannerMessage, f as getMessageContent, g as isThreadDepthError, h as isAskAiPromptBlockingError, i as groupConsecutiveToolResults, l as extractLinksFromMessage, m as isAgentStudioTokenOutputLimitError, n as useAskAi, o as ToolCall, p as isAIToolPart, r as Menu, s as EMPTY_TOOLS, t as useSuggestedQuestions, u as getAgentPromptSuggestions, v as SourcesPanel, w as MoreVerticalIcon, x as BackIcon, y as FeedbackActions } from "./useSuggestedQuestions-DitQZbae.js";
|
|
6
6
|
import React, { Fragment, useMemo } from "react";
|
|
7
7
|
import { createAutocomplete } from "@algolia/autocomplete-core";
|
|
8
8
|
|
|
@@ -493,18 +493,16 @@ const EMPTY_SNIPPET_RESULT = {
|
|
|
493
493
|
hierarchy: EMPTY_HIERARCHY_HIGHLIGHT_RESULT,
|
|
494
494
|
hierarchy_camel: []
|
|
495
495
|
};
|
|
496
|
-
function buildRecentConversationSources({ conversations, disableUserPersonalization,
|
|
496
|
+
function buildRecentConversationSources({ conversations, disableUserPersonalization, handleSelectStoredConversation }) {
|
|
497
497
|
return [{
|
|
498
498
|
sourceId: SOURCE_IDS.recentConversations,
|
|
499
499
|
getItems() {
|
|
500
500
|
if (disableUserPersonalization) return [];
|
|
501
501
|
return conversations.getAll().slice(0, MAX_RECENT_CONVERSATIONS_DISPLAYED);
|
|
502
502
|
},
|
|
503
|
-
onSelect({ item }) {
|
|
504
|
-
if (item.
|
|
505
|
-
|
|
506
|
-
onAskAiToggle(true);
|
|
507
|
-
}
|
|
503
|
+
onSelect({ item, event }) {
|
|
504
|
+
if (item.type !== "askAI") return;
|
|
505
|
+
handleSelectStoredConversation(item, event);
|
|
508
506
|
}
|
|
509
507
|
}];
|
|
510
508
|
}
|
|
@@ -661,7 +659,7 @@ function DocSearchAskAiModal(_ref) {
|
|
|
661
659
|
recentSearchesWithFavoritesLimit
|
|
662
660
|
});
|
|
663
661
|
const [stoppedStream, setStoppedStream] = React.useState(false);
|
|
664
|
-
const { chatId, messages, status,
|
|
662
|
+
const { chatId, messages, status, sendMessage, stopAskAiStreaming, askAiError, sendFeedback, conversations, startNewConversation, restoreConversation } = useAskAi({
|
|
665
663
|
agentId: askAiConfigurationId,
|
|
666
664
|
apiKey: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.apiKey) || apiKey,
|
|
667
665
|
appId: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.appId) || appId,
|
|
@@ -755,6 +753,25 @@ function DocSearchAskAiModal(_ref) {
|
|
|
755
753
|
appId,
|
|
756
754
|
sendFeedback
|
|
757
755
|
]);
|
|
756
|
+
const handleSelectStoredConversation = React.useCallback((item, event) => {
|
|
757
|
+
if (isQueryEmpty(item.query) || !item.messages || item.messages.length < 1) return;
|
|
758
|
+
const hitMessages = item.messages;
|
|
759
|
+
const initialMessage = {
|
|
760
|
+
query: item.query,
|
|
761
|
+
messageId: hitMessages[0].id
|
|
762
|
+
};
|
|
763
|
+
restoreConversation(hitMessages, item.chatId);
|
|
764
|
+
if (interceptAskAiEvent === null || interceptAskAiEvent === void 0 ? void 0 : interceptAskAiEvent(initialMessage)) {
|
|
765
|
+
if (autocompleteRef.current) autocompleteRef.current.setQuery("");
|
|
766
|
+
event.preventDefault();
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
onAskAiToggle(true, initialMessage);
|
|
770
|
+
}, [
|
|
771
|
+
interceptAskAiEvent,
|
|
772
|
+
restoreConversation,
|
|
773
|
+
onAskAiToggle
|
|
774
|
+
]);
|
|
758
775
|
if (!autocompleteRef.current) autocompleteRef.current = createAutocomplete({
|
|
759
776
|
id: "docsearch",
|
|
760
777
|
defaultActiveItemId: 0,
|
|
@@ -780,8 +797,7 @@ function DocSearchAskAiModal(_ref) {
|
|
|
780
797
|
return [...canHandleAskAi ? buildRecentConversationSources({
|
|
781
798
|
conversations,
|
|
782
799
|
disableUserPersonalization,
|
|
783
|
-
|
|
784
|
-
onAskAiToggle
|
|
800
|
+
handleSelectStoredConversation
|
|
785
801
|
}) : [], ...noQuerySources];
|
|
786
802
|
}
|
|
787
803
|
const algoliaSourcesPromise = buildQuerySources({
|
|
@@ -835,10 +851,13 @@ function DocSearchAskAiModal(_ref) {
|
|
|
835
851
|
refresh
|
|
836
852
|
});
|
|
837
853
|
const hasCurrentMessages = messages.length > 0;
|
|
854
|
+
const previousIsAskAiActive = React.useRef(isAskAiActive);
|
|
838
855
|
React.useEffect(() => {
|
|
856
|
+
const wasAskAiActive = previousIsAskAiActive.current;
|
|
857
|
+
previousIsAskAiActive.current = isAskAiActive;
|
|
839
858
|
if (!isAskAiActive) {
|
|
840
859
|
autocomplete.refresh();
|
|
841
|
-
if (hasCurrentMessages) startNewConversation();
|
|
860
|
+
if (wasAskAiActive && hasCurrentMessages) startNewConversation();
|
|
842
861
|
}
|
|
843
862
|
}, [
|
|
844
863
|
isAskAiActive,
|
|
@@ -934,20 +953,8 @@ function DocSearchAskAiModal(_ref) {
|
|
|
934
953
|
onNewConversation: handleNewConversation,
|
|
935
954
|
onItemClick: (item, event) => {
|
|
936
955
|
if (item.type === "askAI" && item.query) {
|
|
937
|
-
if (item.anchor === "stored"
|
|
938
|
-
|
|
939
|
-
restoreConversation(hitMessages, item.chatId);
|
|
940
|
-
const initialMessage = {
|
|
941
|
-
query: item.query,
|
|
942
|
-
messageId: hitMessages[0].id
|
|
943
|
-
};
|
|
944
|
-
if (interceptAskAiEvent === null || interceptAskAiEvent === void 0 ? void 0 : interceptAskAiEvent(initialMessage)) {
|
|
945
|
-
if (autocompleteRef.current) autocompleteRef.current.setQuery("");
|
|
946
|
-
event.preventDefault();
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
onAskAiToggle(true, initialMessage);
|
|
950
|
-
} else handleSelectAskAiQuestion(true, item.query);
|
|
956
|
+
if (item.anchor === "stored") handleSelectStoredConversation(item, event);
|
|
957
|
+
else handleSelectAskAiQuestion(true, item.query);
|
|
951
958
|
setAskAiState("initial");
|
|
952
959
|
event.preventDefault();
|
|
953
960
|
return;
|
|
@@ -969,4 +976,4 @@ function DocSearchAskAiModal(_ref) {
|
|
|
969
976
|
|
|
970
977
|
//#endregion
|
|
971
978
|
export { DocSearchAskAiModal as t };
|
|
972
|
-
//# sourceMappingURL=DocSearchAskAiModal-
|
|
979
|
+
//# sourceMappingURL=DocSearchAskAiModal-BzQZxvTY.js.map
|