@glodon-aiot/chat-app-sdk 0.0.9 → 0.0.11

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/es/index.esm.js CHANGED
@@ -7905,6 +7905,9 @@ ___CSS_LOADER_EXPORT___.push([module.id, `:root {
7905
7905
  .coze-chat-sdk :is(.ml-\\[10px\\]) {
7906
7906
  margin-left: 10px;
7907
7907
  }
7908
+ .coze-chat-sdk :is(.ml-\\[12px\\]) {
7909
+ margin-left: 12px;
7910
+ }
7908
7911
  .coze-chat-sdk :is(.ml-\\[24px\\]) {
7909
7912
  margin-left: 24px;
7910
7913
  }
@@ -8354,8 +8357,8 @@ ___CSS_LOADER_EXPORT___.push([module.id, `:root {
8354
8357
  .coze-chat-sdk :is(.max-w-\\[86px\\]) {
8355
8358
  max-width: 86px;
8356
8359
  }
8357
- .coze-chat-sdk :is(.max-w-\\[calc\\(100\\%-44px\\)\\]) {
8358
- max-width: calc(100% - 44px);
8360
+ .coze-chat-sdk :is(.max-w-\\[calc\\(100\\%-80px\\)\\]) {
8361
+ max-width: calc(100% - 80px);
8359
8362
  }
8360
8363
  .coze-chat-sdk :is(.max-w-\\[calc\\(100vw-170px\\)\\]) {
8361
8364
  max-width: calc(100vw - 170px);
@@ -12040,6 +12043,13 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.d154f5c739f5d241 {
12040
12043
  margin-top: 7px;
12041
12044
  text-align: left;
12042
12045
  }
12046
+ .c75111d65e24bd5c {
12047
+ font-size: 14px;
12048
+ font-weight: 400;
12049
+ color: #666;
12050
+ margin-bottom: 8px;
12051
+ line-height: 20px;
12052
+ }
12043
12053
  .ec8cba872a7913bf {
12044
12054
  padding-right: 25px;
12045
12055
  padding-left: 69px;
@@ -12086,6 +12096,8 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.d154f5c739f5d241 {
12086
12096
  // Exports
12087
12097
  ___CSS_LOADER_EXPORT___.locals = {
12088
12098
  "suggestions": `d154f5c739f5d241`,
12099
+ "suggestion-hint": `c75111d65e24bd5c`,
12100
+ "suggestionHint": `c75111d65e24bd5c`,
12089
12101
  "suggestions-pc": `ec8cba872a7913bf`,
12090
12102
  "suggestionsPc": `ec8cba872a7913bf`,
12091
12103
  "suggestions-mobile": `a120a1527cefe48f`,
@@ -132711,7 +132723,8 @@ const getChatConfig = (chatClientId, cozeChatOption)=>{
132711
132723
  ]),
132712
132724
  footer: ui === null || ui === void 0 ? void 0 : ui.footer,
132713
132725
  header: ui === null || ui === void 0 ? void 0 : ui.header,
132714
- conversations: ui === null || ui === void 0 ? void 0 : ui.conversations
132726
+ conversations: ui === null || ui === void 0 ? void 0 : ui.conversations,
132727
+ showUserInfo: ui === null || ui === void 0 ? void 0 : ui.showUserInfo
132715
132728
  },
132716
132729
  auth: pick(auth || {}, [
132717
132730
  'type',
@@ -299838,7 +299851,6 @@ const default_avatar_namespaceObject = "data:image/png;base64,iVBORw0KGgoAAAANSU
299838
299851
  */
299839
299852
  const messageBoxContainerVariants = cva([
299840
299853
  'flex',
299841
- 'flex-row',
299842
299854
  'my-0'
299843
299855
  ], {
299844
299856
  variants: {
@@ -299849,7 +299861,18 @@ const messageBoxContainerVariants = cva([
299849
299861
  false: [
299850
299862
  'mx-[24px]'
299851
299863
  ]
299864
+ },
299865
+ isSentMessage: {
299866
+ true: [
299867
+ 'flex-row-reverse'
299868
+ ],
299869
+ false: [
299870
+ 'flex-row'
299871
+ ]
299852
299872
  }
299873
+ },
299874
+ defaultVariants: {
299875
+ isSentMessage: false
299853
299876
  }
299854
299877
  });
299855
299878
  const botNicknameVariants = cva([
@@ -300085,6 +300108,8 @@ const MessageBoxWrap = (props)=>{
300085
300108
  const messageFooterRef = (0,react.useRef)(null);
300086
300109
  const eventCenter = useUiKitEventCenter();
300087
300110
  const isMobileLayout = layout === common_Layout.MOBILE;
300111
+ // 判断是否为发送消息:发送消息通常使用 'primary' 主题
300112
+ const isSentMessage = theme === 'primary';
300088
300113
  const refreshContainerWidthConditionally = use_event_callback_useEventCallback(()=>{
300089
300114
  if (!messageContainerRef.current || !messageFooterRef.current) {
300090
300115
  return;
@@ -300141,24 +300166,31 @@ const MessageBoxWrap = (props)=>{
300141
300166
  children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
300142
300167
  // chat-uikit-message-box-container chat-uikit-message-box-container-pc
300143
300168
  className: classnames_default()(messageBoxContainerVariants({
300144
- isMobileLayout
300169
+ isMobileLayout,
300170
+ isSentMessage
300145
300171
  }), messageBoxWrapperClassname),
300146
300172
  children: [
300147
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
300173
+ showUserInfo ? /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
300148
300174
  // chat-uikit-message-box-container__avatar-wrap
300149
- className: "mr-[12px] w-32px h-32px",
300150
- children: showUserInfo ? /*#__PURE__*/ (0,jsx_runtime.jsx)(AvatarWrap, {
300175
+ className: classnames_default()('w-32px h-32px', {
300176
+ 'ml-[12px]': isSentMessage,
300177
+ 'mr-[12px]': !isSentMessage
300178
+ }),
300179
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(AvatarWrap, {
300151
300180
  children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Avatar, {
300152
300181
  // chat-uikit-message-box-container__avatar-wrap__avatar
300153
300182
  size: "small",
300154
300183
  src: botAvatar,
300155
300184
  onError: ()=>setBotAvatar(default_avatar_namespaceObject)
300156
300185
  })
300157
- }) : null
300158
- }),
300186
+ })
300187
+ }) : null,
300159
300188
  /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
300160
300189
  // chat-uikit-message-box-container__message
300161
- className: "flex-1 max-w-[calc(100%-44px)]",
300190
+ className: classnames_default()('flex-1', {
300191
+ 'max-w-[calc(100%-80px)]': true,
300192
+ 'flex justify-end': isSentMessage
300193
+ }),
300162
300194
  children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
300163
300195
  // chat-uikit-message-box-container__message__message-box
300164
300196
  className: "relative flex flex-col w-fit max-w-full",
@@ -300244,6 +300276,11 @@ const MessageBoxWrap = (props)=>{
300244
300276
  theme
300245
300277
  })
300246
300278
  }), layout === common_Layout.MOBILE ? '!text-[16px]' : ''),
300279
+ style: {
300280
+ borderRadius: isSentMessage ? '10px 0px 10px 10px' : ' 0px 10px 10px 10px',
300281
+ background: isSentMessage ? '#F4F4F4' : 'none',
300282
+ padding: isSentMessage ? '10px' : '0px'
300283
+ },
300247
300284
  children: /*#__PURE__*/ (0,jsx_runtime.jsx)(error_boundary_ErrorBoundary, {
300248
300285
  errorBoundaryName: "chat-message-box-children",
300249
300286
  FallbackComponent: fallback_FallbackComponent,
@@ -383323,7 +383360,7 @@ const Suggestions = (param)=>{
383323
383360
  if (selectable) {
383324
383361
  return null;
383325
383362
  }
383326
- return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
383363
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
383327
383364
  "data-testid": "chat-area.suggestion-list",
383328
383365
  className: classnames_default()(components_suggestion_index_module.suggestions, {
383329
383366
  // Adapt mobile end to solve the suggestion margin problem
@@ -383336,19 +383373,25 @@ const Suggestions = (param)=>{
383336
383373
  width: messageWidth,
383337
383374
  order: ORDER_FOR_SUGGESTIONS
383338
383375
  },
383339
- children: suggestions.map((sug)=>/*#__PURE__*/ (0,jsx_runtime.jsx)(SuggestionItem, {
383340
- className: classnames_default()({
383341
- '!mb-0': suggestionsShowMode === bot_common_SuggestedQuestionsShowMode.All
383342
- }),
383343
- readonly: readonly,
383344
- message: {
383345
- content_obj: sug,
383346
- sender_id: senderId
383347
- },
383348
- onSuggestionClick: onSubmit,
383349
- showBackground: showBackground,
383350
- color: getSuggestionColorByTheme(theme)
383351
- }, sug))
383376
+ children: [
383377
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
383378
+ className: components_suggestion_index_module["suggestion-hint"],
383379
+ children: "猜你想问:"
383380
+ }),
383381
+ suggestions.map((sug)=>/*#__PURE__*/ (0,jsx_runtime.jsx)(SuggestionItem, {
383382
+ className: classnames_default()({
383383
+ '!mb-0': suggestionsShowMode === bot_common_SuggestedQuestionsShowMode.All
383384
+ }),
383385
+ readonly: readonly,
383386
+ message: {
383387
+ content_obj: sug,
383388
+ sender_id: senderId
383389
+ },
383390
+ onSuggestionClick: onSubmit,
383391
+ showBackground: showBackground,
383392
+ color: getSuggestionColorByTheme(theme)
383393
+ }, sug))
383394
+ ]
383352
383395
  });
383353
383396
  };
383354
383397
  SuggestionInChat.displayName = 'ChatAreaSuggestionInChat';
@@ -422118,15 +422161,43 @@ var custom_components_message_box_index_module_update = injectStylesIntoStyleTag
422118
422161
 
422119
422162
  // coze-chat-message-wrapper coze-chat-hover-message-wrapper 用于element获取,不可删除
422120
422163
  const UIKitMessageBoxPlugin = (param)=>{
422121
- let { messageType, classname, ...props } = param;
422164
+ let { messageType, classname, showUserInfo: propsShowUserInfo, ...props } = param;
422122
422165
  return /*#__PURE__*/ (0,jsx_runtime.jsx)(MessageBox, {
422123
422166
  ...props,
422124
422167
  classname: classnames_default()(classname, 'w-full'),
422168
+ showUserInfo: propsShowUserInfo ?? false,
422125
422169
  isHoverShowUserInfo: false,
422126
422170
  messageBoxWrapperClassname: classnames_default()('coze-chat-message-wrapper', plugin_custom_components_message_box_index_module["message-box-wrapper"]),
422127
422171
  messageHoverWrapperClassName: 'w-full flex justify-end right-[0px] coze-chat-hover-message-wrapper'
422128
422172
  });
422129
422173
  };
422174
+ /**
422175
+ * 创建 UIKitMessageBoxPlugin 组件,通过闭包访问 bizContext 配置
422176
+ */ const createUIKitMessageBoxPlugin = (bizContext)=>{
422177
+ // 如果配置中明确设置了 showUserInfo,则使用配置值;否则使用 props 传递的值
422178
+ const configuredShowUserInfo = bizContext.showUserInfo;
422179
+ console.log('[createUIKitMessageBoxPlugin] bizContext:', {
422180
+ showUserInfo: configuredShowUserInfo,
422181
+ bizContext
422182
+ });
422183
+ return (param)=>{
422184
+ let { messageType, classname, showUserInfo: propsShowUserInfo, ...props } = param;
422185
+ const finalShowUserInfo = configuredShowUserInfo !== undefined ? configuredShowUserInfo : propsShowUserInfo ?? false;
422186
+ console.log('[UIKitMessageBoxPlugin] render:', {
422187
+ configuredShowUserInfo,
422188
+ propsShowUserInfo,
422189
+ finalShowUserInfo
422190
+ });
422191
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(MessageBox, {
422192
+ ...props,
422193
+ classname: classnames_default()(classname, 'w-full'),
422194
+ showUserInfo: finalShowUserInfo,
422195
+ isHoverShowUserInfo: false,
422196
+ messageBoxWrapperClassname: classnames_default()('coze-chat-message-wrapper', plugin_custom_components_message_box_index_module["message-box-wrapper"]),
422197
+ messageHoverWrapperClassName: 'w-full flex justify-end right-[0px] coze-chat-hover-message-wrapper'
422198
+ });
422199
+ };
422200
+ };
422130
422201
 
422131
422202
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/plugin/plugin.ts
422132
422203
  /*
@@ -422163,6 +422234,16 @@ const UIKitMessageBoxPlugin = (param)=>{
422163
422234
 
422164
422235
 
422165
422236
  class plugin_plugin_BizPlugin extends WriteableChatAreaPlugin {
422237
+ /**
422238
+ * 创建自定义组件,允许传入 bizContext 来访问配置
422239
+ */ static createCustomComponents(bizContext) {
422240
+ return createCustomComponents({
422241
+ UIKitMessageBoxPlugin: createUIKitMessageBoxPlugin(bizContext),
422242
+ MessageGroupFooter: UIKitMessageGroupFooterPlugin,
422243
+ MessageBoxFooter: UIKitMessageBoxFooter,
422244
+ MessageBoxHoverSlot: UIKitMessageBoxHoverSlot
422245
+ });
422246
+ }
422166
422247
  constructor(...args){
422167
422248
  super(...args), /**
422168
422249
  * 插件类型
@@ -422197,7 +422278,20 @@ class plugin_plugin_BizPlugin extends WriteableChatAreaPlugin {
422197
422278
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
422198
422279
  * See the License for the specific language governing permissions and
422199
422280
  * limitations under the License.
422200
- */
422281
+ */ function coz_sdk_plugin_define_property(obj, key, value) {
422282
+ if (key in obj) {
422283
+ Object.defineProperty(obj, key, {
422284
+ value: value,
422285
+ enumerable: true,
422286
+ configurable: true,
422287
+ writable: true
422288
+ });
422289
+ } else {
422290
+ obj[key] = value;
422291
+ }
422292
+ return obj;
422293
+ }
422294
+
422201
422295
  const getCozeSdkPlugin = (props)=>{
422202
422296
  // eslint-disable-next-line @typescript-eslint/naming-convention
422203
422297
  const WebsdkChatExtraBodyPlugin = {
@@ -422210,7 +422304,11 @@ const getCozeSdkPlugin = (props)=>{
422210
422304
  },
422211
422305
  /**
422212
422306
  * 插件本体
422213
- */ Plugin: plugin_plugin_BizPlugin
422307
+ */ Plugin: class extends plugin_plugin_BizPlugin {
422308
+ constructor(...args){
422309
+ super(...args), coz_sdk_plugin_define_property(this, "customComponents", plugin_plugin_BizPlugin.createCustomComponents(props));
422310
+ }
422311
+ }
422214
422312
  };
422215
422313
  return WebsdkChatExtraBodyPlugin;
422216
422314
  };
@@ -422658,7 +422756,7 @@ const ChatProviderFuncComp = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
422658
422756
  });
422659
422757
  const ChatProviderImpl = (param)=>{
422660
422758
  let { children, plugins } = param;
422661
- var _chatConfig_appInfo, _chatConfig_ui_chatBot, _chatConfig_ui;
422759
+ var _chatConfig_ui, _chatConfig_appInfo, _chatConfig_ui_chatBot, _chatConfig_ui1;
422662
422760
  const refLastIsError = (0,react.useRef)(false);
422663
422761
  const { refreshToken } = useChatCozeSdk();
422664
422762
  const { initError, setInitError } = useChatAppStore(shallow_useShallow((s)=>({
@@ -422691,12 +422789,19 @@ const ChatProviderImpl = (param)=>{
422691
422789
  const isShowBackground = useIsShowBackground();
422692
422790
  const { ChatBackgroundPlugin } = useBgBackgroundPlugin();
422693
422791
  // plugin初始化
422792
+ const showUserInfoConfig = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_ui = chatConfig.ui) === null || _chatConfig_ui === void 0 ? void 0 : _chatConfig_ui.showUserInfo;
422793
+ console.log('[ChatProviderImpl] showUserInfo config:', {
422794
+ showUserInfoConfig,
422795
+ chatConfigUi: chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.ui,
422796
+ finalValue: showUserInfoConfig ?? false
422797
+ });
422694
422798
  const cozeSdkChatPlugin = getCozeSdkPlugin({
422695
422799
  refreshToken,
422696
422800
  regenerateMessageByUserMessageId: (id)=>{
422697
422801
  var _refChatFunc_current_regenerateMessageByUserMessageId, _refChatFunc_current;
422698
422802
  (_refChatFunc_current = refChatFunc.current) === null || _refChatFunc_current === void 0 ? void 0 : (_refChatFunc_current_regenerateMessageByUserMessageId = _refChatFunc_current.regenerateMessageByUserMessageId) === null || _refChatFunc_current_regenerateMessageByUserMessageId === void 0 ? void 0 : _refChatFunc_current_regenerateMessageByUserMessageId.call(_refChatFunc_current, id);
422699
- }
422803
+ },
422804
+ showUserInfo: showUserInfoConfig ?? false
422700
422805
  });
422701
422806
  const SDKUploadPlugin = (0,react.useMemo)(()=>{
422702
422807
  var _chatConfig_appInfo;
@@ -422776,7 +422881,7 @@ const ChatProviderImpl = (param)=>{
422776
422881
  showFunctionCallDetail: false,
422777
422882
  uploadPlugin: SDKUploadPlugin,
422778
422883
  ignoreMessageConfigList: allIgnorableMessageTypes,
422779
- isShowFunctionCallBox: (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_ui = chatConfig.ui) === null || _chatConfig_ui === void 0 ? void 0 : (_chatConfig_ui_chatBot = _chatConfig_ui.chatBot) === null || _chatConfig_ui_chatBot === void 0 ? void 0 : _chatConfig_ui_chatBot.isNeedFunctionCallMessage) ?? true
422884
+ isShowFunctionCallBox: (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_ui1 = chatConfig.ui) === null || _chatConfig_ui1 === void 0 ? void 0 : (_chatConfig_ui_chatBot = _chatConfig_ui1.chatBot) === null || _chatConfig_ui_chatBot === void 0 ? void 0 : _chatConfig_ui_chatBot.isNeedFunctionCallMessage) ?? true
422780
422885
  },
422781
422886
  pluginRegistryList: [
422782
422887
  cozeSdkChatPlugin,