@docsearch/js 5.0.2 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! @docsearch/js 5.0.2 (UNRELEASED ad8e8d9) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
1
+ /*! @docsearch/js 5.0.4 (UNRELEASED 74f5805) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
2
  import React$1, { JSX } from "react";
3
3
  import { JSONSchema7 } from "json-schema";
4
4
  //#region ../docsearch-core/dist/esm/useKeyboardShortcuts.d.ts
@@ -8793,7 +8793,138 @@ interface DocSearchProps$1 {
8793
8793
  resultBadgeKey?: string;
8794
8794
  }
8795
8795
  //#endregion
8796
- //#region ../docsearch-react/dist/esm/docsearchAi.d.ts
8796
+ //#region ../docsearch-react/dist/esm/DocSearchAI-DKtAqje2.d.ts
8797
+ //#region src/components/ToolCall.d.ts
8798
+ type ToolCallTranslations = {
8799
+ /** Text shown while assistant is preparing tool call. */
8800
+ preToolCallText: string;
8801
+ /** Text shown while assistant is performing search tool call. */
8802
+ searchingText: string;
8803
+ /** Text shown while assistant is finished performing tool call. */
8804
+ toolCallResultText: string;
8805
+ /** Text shown when the agent saved related information to memory. */
8806
+ savedMemoryToolResultText: string;
8807
+ /** Text shown when the agent used the memory tool to enhance results. */
8808
+ memoryToolResultText: string;
8809
+ };
8810
+ //#endregion
8811
+ //#region src/AskAiScreen.d.ts
8812
+ type AskAiScreenTranslations = Partial<Omit<ToolCallTranslations, 'searchingText' | 'toolCallResultText'> & {
8813
+ disclaimerText: string;
8814
+ /** Text shown describing a singular related source. */
8815
+ relatedSourcesText: string;
8816
+ /** Text shown describing multiple related sources. */
8817
+ relatedSourcesTextPlural: string;
8818
+ thinkingText: string;
8819
+ copyButtonText: string;
8820
+ copyButtonCopiedText: string;
8821
+ copyButtonTitle: string;
8822
+ likeButtonTitle: string;
8823
+ dislikeButtonTitle: string;
8824
+ thanksForFeedbackText: string;
8825
+ feedbackPanelTitle: string;
8826
+ feedbackDetailsPlaceholder: string;
8827
+ feedbackDisclaimerText: string;
8828
+ feedbackSubmitButtonText: string;
8829
+ feedbackCloseButtonTitle: string;
8830
+ feedbackTagIncorrect: string;
8831
+ feedbackTagNotWhatIAsked: string;
8832
+ feedbackTagSlowOrBuggy: string;
8833
+ feedbackTagStyleOrTone: string;
8834
+ feedbackTagSafetyOrLegal: string;
8835
+ feedbackTagOther: string;
8836
+ /**
8837
+ * Text shown while assistant is performing search tool call. Maps to
8838
+ * `ToolCallTranslations.searchingText`.
8839
+ */
8840
+ duringToolCallText: string;
8841
+ /**
8842
+ * Text shown while assistant is finished performing tool call. Maps to
8843
+ * `ToolCallTranslations.toolCallResultText`.
8844
+ */
8845
+ afterToolCallText: string;
8846
+ /**
8847
+ * Build the full jsx element for the aggregated search block. If provided,
8848
+ * completely overrides the default english renderer.
8849
+ */
8850
+ aggregatedToolCallNode?: (queries: string[], onSearchQueryClick: (query: string) => void) => React$1.ReactNode;
8851
+ /**
8852
+ * Generate the list connective parts only (backwards compatibility).
8853
+ * Receives full list of queries and should return translation parts for
8854
+ * before/after/separators. Example: (qs) => ({ before: 'searched for ',
8855
+ * separator: ', ', lastSeparator: ' and ', after: '' }).
8856
+ */
8857
+ aggregatedToolCallText?: (queries: string[]) => {
8858
+ before?: string;
8859
+ separator?: string;
8860
+ lastSeparator?: string;
8861
+ after?: string;
8862
+ };
8863
+ /** Message that's shown when user has stopped the streaming of a message. */
8864
+ stoppedStreamingText: string;
8865
+ /** Error title shown if there is an error while chatting. */
8866
+ errorTitleText: string;
8867
+ /** Message shown when thread depth limit is exceeded (AI-217 error). */
8868
+ threadDepthExceededMessage: string;
8869
+ /** Button text for starting a new conversation after thread depth error. */
8870
+ startNewConversationButtonText: string;
8871
+ suggestedPromptsTitleText: string;
8872
+ }>;
8873
+ //#endregion
8874
+ //#region src/components/ui/RecentConversationsResults.d.ts
8875
+ type RecentConversationsResultsTranslations = Partial<{
8876
+ recentConversationsTitle: string;
8877
+ removeRecentConversationButtonTitle: string;
8878
+ }>;
8879
+ //#endregion
8880
+ //#region src/components/AskAiStartScreen.d.ts
8881
+ type AskAiStartScreenTranslations = RecentConversationsResultsTranslations & StoredSearchesSectionsTranslations;
8882
+ //#endregion
8883
+ //#region src/NewConversationScreen.d.ts
8884
+ type NewConversationTranslations = Partial<{
8885
+ newConversationTitle: string;
8886
+ newConversationDescription: string;
8887
+ }>;
8888
+ //#endregion
8889
+ //#region src/AskAiScreenState.d.ts
8890
+ type AskAiScreenStateTranslations = Partial<{
8891
+ errorScreen: ErrorScreenTranslations;
8892
+ startScreen: AskAiStartScreenTranslations;
8893
+ noResultsScreen: NoResultsScreenTranslations;
8894
+ resultsScreen: ResultsScreenTranslations;
8895
+ askAiScreen: AskAiScreenTranslations;
8896
+ newConversation: NewConversationTranslations;
8897
+ }>;
8898
+ //#endregion
8899
+ //#region src/components/AskAiSearchBox.d.ts
8900
+ type AskAiSearchBoxTranslations = Partial<{
8901
+ clearButtonTitle: string;
8902
+ clearButtonAriaLabel: string;
8903
+ closeButtonText: string;
8904
+ closeButtonAriaLabel: string;
8905
+ placeholderText: string;
8906
+ placeholderTextAskAi: string;
8907
+ placeholderTextAskAiStreaming: string;
8908
+ enterKeyHint: string;
8909
+ enterKeyHintAskAi: string;
8910
+ searchInputLabel: string;
8911
+ backToKeywordSearchButtonText: string;
8912
+ backToKeywordSearchButtonAriaLabel: string;
8913
+ newConversationPlaceholder: string;
8914
+ conversationHistoryTitle: string;
8915
+ startNewConversationText: string;
8916
+ viewConversationHistoryText: string;
8917
+ threadDepthErrorPlaceholder: string;
8918
+ }>;
8919
+ //#endregion
8920
+ //#region src/DocSearchAskAiModal.d.ts
8921
+ type DocSearchAskAiModalTranslations = AskAiScreenStateTranslations & Partial<{
8922
+ searchBox: AskAiSearchBoxTranslations;
8923
+ newConversation: NewConversationTranslations;
8924
+ footer: FooterTranslations;
8925
+ facets: FacetBarTranslations;
8926
+ }>;
8927
+ //#endregion
8797
8928
  //#region src/DocSearchAI.d.ts
8798
8929
  interface AskAiSearchParameters {
8799
8930
  facetFilters?: string[];
@@ -8892,7 +9023,11 @@ interface DocSearchAskAi {
8892
9023
  */
8893
9024
  promptSuggestions?: PromptSuggestions;
8894
9025
  }
8895
- interface DocSearchAIProps$1 extends DocSearchProps$1 {
9026
+ type DocSearchAITranslations = Partial<{
9027
+ button: DocSearchTranslations['button'];
9028
+ modal: DocSearchAskAiModalTranslations;
9029
+ }>;
9030
+ interface DocSearchAIProps$1 extends Omit<DocSearchProps$1, 'translations'> {
8896
9031
  /**
8897
9032
  * Configuration or assistant id to enable ask ai mode. Pass a string
8898
9033
  * assistant id or a full config object.
@@ -8907,6 +9042,7 @@ interface DocSearchAIProps$1 extends DocSearchProps$1 {
8907
9042
  * `@docsearch/sidepanel-js`) without flicker.
8908
9043
  */
8909
9044
  interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
9045
+ translations?: DocSearchAITranslations;
8910
9046
  }
8911
9047
  //#endregion
8912
9048
  //#region ../../node_modules/.bun/preact@11.0.0-beta.0/node_modules/preact/src/index.d.ts
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @docsearch/js 5.0.2 (UNRELEASED ad8e8d9) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
1
+ /*! @docsearch/js 5.0.4 (UNRELEASED 74f5805) | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
2
  //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp$1 = Object.defineProperty;
@@ -1188,7 +1188,7 @@ function DocSearchButtonKey({ reactsToKey, children }) {
1188
1188
 
1189
1189
  //#endregion
1190
1190
  //#region ../docsearch-react/dist/esm/version.js
1191
- const version$2 = "5.0.2";
1191
+ const version$2 = "5.0.4";
1192
1192
 
1193
1193
  //#endregion
1194
1194
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/OverloadYield.js
@@ -31462,7 +31462,7 @@ function createAutocomplete(options) {
31462
31462
  }
31463
31463
 
31464
31464
  //#endregion
31465
- //#region ../docsearch-react/dist/esm/DocSearchAskAiModal-mjZ_EYK1.js
31465
+ //#region ../docsearch-react/dist/esm/DocSearchAskAiModal-BzQZxvTY.js
31466
31466
  init_compat();
31467
31467
  function MessageIcon() {
31468
31468
  return /* @__PURE__ */ En.createElement("svg", {
@@ -31920,18 +31920,16 @@ const EMPTY_SNIPPET_RESULT = {
31920
31920
  hierarchy: EMPTY_HIERARCHY_HIGHLIGHT_RESULT,
31921
31921
  hierarchy_camel: []
31922
31922
  };
31923
- function buildRecentConversationSources({ conversations, disableUserPersonalization, setMessages, onAskAiToggle }) {
31923
+ function buildRecentConversationSources({ conversations, disableUserPersonalization, handleSelectStoredConversation }) {
31924
31924
  return [{
31925
31925
  sourceId: SOURCE_IDS.recentConversations,
31926
31926
  getItems() {
31927
31927
  if (disableUserPersonalization) return [];
31928
31928
  return conversations.getAll().slice(0, MAX_RECENT_CONVERSATIONS_DISPLAYED);
31929
31929
  },
31930
- onSelect({ item }) {
31931
- if (item.messages) {
31932
- setMessages(item.messages);
31933
- onAskAiToggle(true);
31934
- }
31930
+ onSelect({ item, event }) {
31931
+ if (item.type !== "askAI") return;
31932
+ handleSelectStoredConversation(item, event);
31935
31933
  }
31936
31934
  }];
31937
31935
  }
@@ -32085,7 +32083,7 @@ function DocSearchAskAiModal(_ref) {
32085
32083
  recentSearchesWithFavoritesLimit
32086
32084
  });
32087
32085
  const [stoppedStream, setStoppedStream] = En.useState(false);
32088
- const { chatId, messages, status, setMessages, sendMessage, stopAskAiStreaming, askAiError, sendFeedback, conversations, startNewConversation, restoreConversation } = useAskAi({
32086
+ const { chatId, messages, status, sendMessage, stopAskAiStreaming, askAiError, sendFeedback, conversations, startNewConversation, restoreConversation } = useAskAi({
32089
32087
  agentId: askAiConfigurationId,
32090
32088
  apiKey: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.apiKey) || apiKey,
32091
32089
  appId: (askAiConfig === null || askAiConfig === void 0 ? void 0 : askAiConfig.appId) || appId,
@@ -32179,6 +32177,25 @@ function DocSearchAskAiModal(_ref) {
32179
32177
  appId,
32180
32178
  sendFeedback
32181
32179
  ]);
32180
+ const handleSelectStoredConversation = En.useCallback((item, event) => {
32181
+ if (isQueryEmpty(item.query) || !item.messages || item.messages.length < 1) return;
32182
+ const hitMessages = item.messages;
32183
+ const initialMessage = {
32184
+ query: item.query,
32185
+ messageId: hitMessages[0].id
32186
+ };
32187
+ restoreConversation(hitMessages, item.chatId);
32188
+ if (interceptAskAiEvent === null || interceptAskAiEvent === void 0 ? void 0 : interceptAskAiEvent(initialMessage)) {
32189
+ if (autocompleteRef.current) autocompleteRef.current.setQuery("");
32190
+ event.preventDefault();
32191
+ return;
32192
+ }
32193
+ onAskAiToggle(true, initialMessage);
32194
+ }, [
32195
+ interceptAskAiEvent,
32196
+ restoreConversation,
32197
+ onAskAiToggle
32198
+ ]);
32182
32199
  if (!autocompleteRef.current) autocompleteRef.current = createAutocomplete({
32183
32200
  id: "docsearch",
32184
32201
  defaultActiveItemId: 0,
@@ -32204,8 +32221,7 @@ function DocSearchAskAiModal(_ref) {
32204
32221
  return [...canHandleAskAi ? buildRecentConversationSources({
32205
32222
  conversations,
32206
32223
  disableUserPersonalization,
32207
- setMessages,
32208
- onAskAiToggle
32224
+ handleSelectStoredConversation
32209
32225
  }) : [], ...noQuerySources];
32210
32226
  }
32211
32227
  const algoliaSourcesPromise = buildQuerySources({
@@ -32361,20 +32377,8 @@ function DocSearchAskAiModal(_ref) {
32361
32377
  onNewConversation: handleNewConversation,
32362
32378
  onItemClick: (item, event) => {
32363
32379
  if (item.type === "askAI" && item.query) {
32364
- if (item.anchor === "stored" && "messages" in item) {
32365
- const hitMessages = item.messages;
32366
- restoreConversation(hitMessages, item.chatId);
32367
- const initialMessage = {
32368
- query: item.query,
32369
- messageId: hitMessages[0].id
32370
- };
32371
- if (interceptAskAiEvent === null || interceptAskAiEvent === void 0 ? void 0 : interceptAskAiEvent(initialMessage)) {
32372
- if (autocompleteRef.current) autocompleteRef.current.setQuery("");
32373
- event.preventDefault();
32374
- return;
32375
- }
32376
- onAskAiToggle(true, initialMessage);
32377
- } else handleSelectAskAiQuestion(true, item.query);
32380
+ if (item.anchor === "stored") handleSelectStoredConversation(item, event);
32381
+ else handleSelectAskAiQuestion(true, item.query);
32378
32382
  setAskAiState("initial");
32379
32383
  event.preventDefault();
32380
32384
  return;