react-instantsearch 7.43.0 → 7.44.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.
@@ -9,7 +9,7 @@ export declare function createDefaultTools<TObject extends RecordWithObjectID>(i
9
9
  type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
10
10
  type UiProps = Pick<ChatUiProps, 'open' | 'headerProps' | 'messagesProps' | 'promptProps' | 'suggestionsProps' | 'headerComponent' | 'promptComponent' | 'suggestionsComponent' | 'layoutComponent' | 'sendMessage' | 'regenerate' | 'stop' | 'error'>;
11
11
  type UserHeaderProps = Omit<ChatUiProps['headerProps'], 'onClose'>;
12
- type UserMessagesProps = Omit<ChatUiProps['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef' | 'messageComponent' | 'leadingComponent' | 'footerComponent' | 'suggestionsComponent' | 'translations' | 'classNames'>;
12
+ type UserMessagesProps<TUiMessage extends UIMessage = UIMessage> = Omit<ChatUiProps<TUiMessage>['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef' | 'messageComponent' | 'leadingComponent' | 'footerComponent' | 'suggestionsComponent' | 'translations' | 'classNames'>;
13
13
  type UserPromptProps = Omit<ChatUiProps['promptProps'], 'value' | 'onInput' | 'onSubmit' | 'headerComponent' | 'footerComponent'>;
14
14
  export type Tool = UserClientSideTool;
15
15
  export type Tools = UserClientSideTools;
@@ -18,7 +18,7 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
18
18
  tools?: UserClientSideTools;
19
19
  getSearchPageURL?: (nextUiState: IndexUiState) => string;
20
20
  headerProps?: UserHeaderProps;
21
- messagesProps?: UserMessagesProps;
21
+ messagesProps?: UserMessagesProps<TUiMessage>;
22
22
  promptProps?: UserPromptProps;
23
23
  layoutComponent?: (props: ChatLayoutOwnProps) => JSX.Element;
24
24
  headerComponent?: ChatUiProps['headerComponent'];
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch 7.43.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch 7.44.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -24,7 +24,7 @@
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
26
 
27
- var version$2 = '7.43.0';
27
+ var version$2 = '7.44.0';
28
28
 
29
29
  function _define_property(obj, key, value) {
30
30
  if (key in obj) {
@@ -9223,7 +9223,7 @@
9223
9223
  });
9224
9224
  }
9225
9225
 
9226
- var version = '4.110.0';
9226
+ var version = '4.111.0';
9227
9227
 
9228
9228
  var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
9229
9229
  function getCookie(name) {
@@ -21491,7 +21491,7 @@
21491
21491
  // Keep in sync with packages/instantsearch.js/src/lib/chat/index.ts
21492
21492
  var SearchIndexToolType = 'algolia_search_index';
21493
21493
  function createChatMessageComponent(param) {
21494
- var createElement = param.createElement;
21494
+ var createElement = param.createElement, Fragment = param.Fragment;
21495
21495
  var Button = createButtonComponent({
21496
21496
  createElement: createElement
21497
21497
  });
@@ -21500,7 +21500,7 @@
21500
21500
  });
21501
21501
  return function ChatMessage(userProps) {
21502
21502
  var _messages_;
21503
- var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, messages = userProps.messages, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, _userProps_showReasoning = userProps.showReasoning, showReasoning = _userProps_showReasoning === void 0 ? false : _userProps_showReasoning, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, props = _object_without_properties(userProps, [
21503
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, TextComponent = userProps.textComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, messages = userProps.messages, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, _userProps_showReasoning = userProps.showReasoning, showReasoning = _userProps_showReasoning === void 0 ? false : _userProps_showReasoning, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, props = _object_without_properties(userProps, [
21504
21504
  "classNames",
21505
21505
  "message",
21506
21506
  "status",
@@ -21511,6 +21511,7 @@
21511
21511
  "leadingComponent",
21512
21512
  "actionsComponent",
21513
21513
  "footerComponent",
21514
+ "textComponent",
21514
21515
  "tools",
21515
21516
  "indexUiState",
21516
21517
  "setIndexUiState",
@@ -21576,6 +21577,17 @@
21576
21577
  if (part.text.startsWith('<context>') && part.text.endsWith('</context>')) {
21577
21578
  return null;
21578
21579
  }
21580
+ if (TextComponent) {
21581
+ return /*#__PURE__*/ createElement(Fragment, {
21582
+ key: "".concat(message.id, "-").concat(index)
21583
+ }, /*#__PURE__*/ createElement(TextComponent, {
21584
+ part: part,
21585
+ message: message,
21586
+ messages: messages,
21587
+ status: status,
21588
+ partIndex: index
21589
+ }));
21590
+ }
21579
21591
  if (!parseMarkdown) {
21580
21592
  // Render the literal text. The `ais-ChatMessage-text` class applies
21581
21593
  // `white-space: pre-wrap` to preserve the newlines that markdown
@@ -21905,15 +21917,13 @@
21905
21917
  }
21906
21918
  var messageProps = message.role === 'user' ? userMessageProps : assistantMessageProps;
21907
21919
  var defaultActions = message.role === 'user' ? undefined : defaultAssistantActions;
21908
- return /*#__PURE__*/ createElement(ChatMessage, _object_spread({
21920
+ return /*#__PURE__*/ createElement(ChatMessage, _object_spread_props(_object_spread({
21909
21921
  side: message.role === 'user' ? 'right' : 'left',
21910
21922
  variant: message.role === 'user' ? 'neutral' : 'subtle',
21911
- message: message,
21912
21923
  status: status,
21913
21924
  tools: tools,
21914
21925
  indexUiState: indexUiState,
21915
21926
  setIndexUiState: setIndexUiState,
21916
- messages: messages,
21917
21927
  onClose: onClose,
21918
21928
  actions: defaultActions,
21919
21929
  actionsComponent: actionsComponent,
@@ -21921,7 +21931,10 @@
21921
21931
  classNames: classNames,
21922
21932
  translations: messageTranslations,
21923
21933
  suggestionsElement: suggestionsElement
21924
- }, messageProps));
21934
+ }, messageProps), {
21935
+ message: message,
21936
+ messages: messages
21937
+ }));
21925
21938
  };
21926
21939
  }
21927
21940
  function createChatMessagesComponent(param) {
@@ -21948,6 +21961,10 @@
21948
21961
  var messageProps = props.message.role === 'user' ? props.userMessageProps : props.assistantMessageProps;
21949
21962
  var showReasoning = messageProps === null || messageProps === void 0 ? void 0 : messageProps.showReasoning;
21950
21963
  var parseMarkdown = messageProps === null || messageProps === void 0 ? void 0 : messageProps.parseMarkdown;
21964
+ var textComponent = messageProps === null || messageProps === void 0 ? void 0 : messageProps.textComponent;
21965
+ // Custom text components receive the conversation, so their completed rows
21966
+ // must update with it. Keep the default renderer's streaming optimization.
21967
+ var textComponentMessages = textComponent ? props.messages : undefined;
21951
21968
  // Object-level fallback, matching the render: the spread replaces
21952
21969
  // `translations` wholesale, and it copies a key holding `undefined` too. Both
21953
21970
  // are why this resolves by own-key presence rather than key by key.
@@ -21974,6 +21991,8 @@
21974
21991
  messageFeedback,
21975
21992
  showReasoning,
21976
21993
  parseMarkdown,
21994
+ textComponent,
21995
+ textComponentMessages,
21977
21996
  reasoningLabel,
21978
21997
  reasoningClassName,
21979
21998
  reasoningHeaderClassName,