@chatsdk-dev/elements 0.1.2 → 0.2.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/dist/{api-CIYPz72L.d.ts → api-BP4g92-0.d.ts} +1 -1
- package/dist/{api-CIYPz72L.d.ts.map → api-BP4g92-0.d.ts.map} +1 -1
- package/dist/approval-BODP4NVA.d.ts +5 -0
- package/dist/approval-BODP4NVA.d.ts.map +1 -0
- package/dist/avatar-CK5WGu6N.d.ts +5 -0
- package/dist/avatar-CK5WGu6N.d.ts.map +1 -0
- package/dist/{callbacks-PIvHXeEI.d.ts → callbacks-CQelTSwD.d.ts} +1 -1
- package/dist/{callbacks-PIvHXeEI.d.ts.map → callbacks-CQelTSwD.d.ts.map} +1 -1
- package/dist/chat-element-BbBl5CDM.d.ts +131 -0
- package/dist/chat-element-BbBl5CDM.d.ts.map +1 -0
- package/dist/chat-error-CST-PRdq.d.ts +15 -0
- package/dist/chat-error-CST-PRdq.d.ts.map +1 -0
- package/dist/{chatsdk-provider-BhlChLFd.d.ts → chatsdk-provider-t1GEgRPY.d.ts} +2 -2
- package/dist/chatsdk-provider-t1GEgRPY.d.ts.map +1 -0
- package/dist/{config-CqihvSgz.d.ts → config-BGIY5Hkg.d.ts} +20 -19
- package/dist/config-BGIY5Hkg.d.ts.map +1 -0
- package/dist/config-Wk7C7AJs.js +95 -0
- package/dist/config-Wk7C7AJs.js.map +1 -0
- package/dist/config-f4Go--5s.d.ts +194 -0
- package/dist/config-f4Go--5s.d.ts.map +1 -0
- package/dist/content-BoiPVwgM.d.ts +10 -0
- package/dist/content-BoiPVwgM.d.ts.map +1 -0
- package/dist/{context-aSaHw-ac.d.ts → context-D4dOffYT.d.ts} +1 -1
- package/dist/context-D4dOffYT.d.ts.map +1 -0
- package/dist/conversation-CtpcctHL.d.ts +8 -0
- package/dist/conversation-CtpcctHL.d.ts.map +1 -0
- package/dist/copy-BPB94kUd.d.ts +5 -0
- package/dist/copy-BPB94kUd.d.ts.map +1 -0
- package/dist/{element-provider-C_nBsftD.d.ts → element-provider-C95jVJV9.d.ts} +4 -5
- package/dist/element-provider-C95jVJV9.d.ts.map +1 -0
- package/dist/features/chat/chat-element.d.ts +2 -2
- package/dist/features/chat/chat-element.js +2 -2
- package/dist/features/chat/conversation/conversation.d.ts +2 -0
- package/dist/features/chat/conversation/conversation.js +73 -0
- package/dist/features/chat/conversation/conversation.js.map +1 -0
- package/dist/features/chat/conversation/message/activity.d.ts +12 -0
- package/dist/features/chat/conversation/message/activity.d.ts.map +1 -0
- package/dist/features/chat/conversation/message/activity.js +48 -0
- package/dist/features/chat/conversation/message/activity.js.map +1 -0
- package/dist/features/chat/conversation/message/approval.d.ts +2 -0
- package/dist/features/chat/conversation/message/approval.js +62 -0
- package/dist/features/chat/conversation/message/approval.js.map +1 -0
- package/dist/features/chat/conversation/message/avatar.d.ts +2 -0
- package/dist/features/chat/conversation/message/avatar.js +18 -0
- package/dist/features/chat/conversation/message/avatar.js.map +1 -0
- package/dist/features/chat/conversation/message/content.d.ts +2 -0
- package/dist/features/chat/conversation/message/content.js +11 -0
- package/dist/features/chat/conversation/message/content.js.map +1 -0
- package/dist/features/chat/conversation/message/copy.d.ts +2 -0
- package/dist/features/chat/conversation/message/copy.js +30 -0
- package/dist/features/chat/conversation/message/copy.js.map +1 -0
- package/dist/features/chat/conversation/message/feedback.d.ts +2 -0
- package/dist/features/chat/conversation/message/feedback.js +36 -0
- package/dist/features/chat/conversation/message/feedback.js.map +1 -0
- package/dist/features/chat/conversation/message/footer.d.ts +2 -0
- package/dist/features/chat/conversation/message/footer.js +20 -0
- package/dist/features/chat/conversation/message/footer.js.map +1 -0
- package/dist/features/chat/conversation/message/frame.d.ts +2 -0
- package/dist/features/chat/conversation/message/frame.js +18 -0
- package/dist/features/chat/conversation/message/frame.js.map +1 -0
- package/dist/features/chat/conversation/message/index.d.ts +2 -0
- package/dist/features/chat/conversation/message/index.js +2 -0
- package/dist/features/chat/conversation/message/index.parts.d.ts +22 -0
- package/dist/features/chat/conversation/message/index.parts.d.ts.map +1 -0
- package/dist/features/chat/conversation/message/index.parts.js +36 -0
- package/dist/features/chat/conversation/message/index.parts.js.map +1 -0
- package/dist/features/chat/conversation/message/message.d.ts +1 -0
- package/dist/features/chat/conversation/message/message.js +1 -0
- package/dist/features/chat/conversation/message/part.d.ts +2 -0
- package/dist/features/chat/conversation/message/part.js +35 -0
- package/dist/features/chat/conversation/message/part.js.map +1 -0
- package/dist/features/chat/conversation/message/provider.d.ts +2 -0
- package/dist/features/chat/conversation/message/provider.js +26 -0
- package/dist/features/chat/conversation/message/provider.js.map +1 -0
- package/dist/features/chat/conversation/message/reasoning.d.ts +2 -0
- package/dist/features/chat/conversation/message/reasoning.js +33 -0
- package/dist/features/chat/conversation/message/reasoning.js.map +1 -0
- package/dist/features/chat/conversation/message/sources.d.ts +2 -0
- package/dist/features/chat/conversation/message/sources.js +20 -0
- package/dist/features/chat/conversation/message/sources.js.map +1 -0
- package/dist/features/chat/conversation/message/text.d.ts +2 -0
- package/dist/features/chat/conversation/message/text.js +29 -0
- package/dist/features/chat/conversation/message/text.js.map +1 -0
- package/dist/features/chat/conversation/message/timestamp.d.ts +2 -0
- package/dist/features/chat/conversation/message/timestamp.js +36 -0
- package/dist/features/chat/conversation/message/timestamp.js.map +1 -0
- package/dist/features/chat/conversation/message/tool.d.ts +2 -0
- package/dist/features/chat/conversation/message/tool.js +56 -0
- package/dist/features/chat/conversation/message/tool.js.map +1 -0
- package/dist/features/chat/error/chat-error.d.ts +2 -0
- package/dist/features/chat/error/chat-error.js +46 -0
- package/dist/features/chat/error/chat-error.js.map +1 -0
- package/dist/features/chat/frame/frame.d.ts +2 -0
- package/dist/features/chat/frame/frame.js +52 -0
- package/dist/features/chat/frame/frame.js.map +1 -0
- package/dist/features/chat/frame/header-menu.d.ts +8 -0
- package/dist/features/chat/frame/header-menu.d.ts.map +1 -0
- package/dist/features/chat/{chat-header/chat-menu.js → frame/header-menu.js} +12 -13
- package/dist/features/chat/frame/header-menu.js.map +1 -0
- package/dist/features/chat/frame/header.d.ts +2 -0
- package/dist/features/chat/frame/header.js +50 -0
- package/dist/features/chat/frame/header.js.map +1 -0
- package/dist/features/chat/history/history-empty.d.ts +8 -0
- package/dist/features/chat/history/history-empty.d.ts.map +1 -0
- package/dist/features/chat/{chat-history/chat-history-empty.js → history/history-empty.js} +9 -8
- package/dist/features/chat/history/history-empty.js.map +1 -0
- package/dist/features/chat/history/history.d.ts +2 -0
- package/dist/features/chat/history/history.js +65 -0
- package/dist/features/chat/history/history.js.map +1 -0
- package/dist/features/chat/history/use-history.d.ts +2 -0
- package/dist/features/chat/history/use-history.js +30 -0
- package/dist/features/chat/history/use-history.js.map +1 -0
- package/dist/features/chat/index.d.ts +2 -2
- package/dist/features/chat/index.js +29 -2
- package/dist/features/chat/index.js.map +1 -0
- package/dist/features/chat/index.parts.d.ts +9 -0
- package/dist/features/chat/index.parts.js +24 -0
- package/dist/features/chat/index.parts.js.map +1 -0
- package/dist/features/chat/main/main.d.ts +2 -0
- package/dist/features/chat/main/main.js +40 -0
- package/dist/features/chat/main/main.js.map +1 -0
- package/dist/features/chat/main/prompt-input.d.ts +2 -0
- package/dist/features/chat/main/prompt-input.js +70 -0
- package/dist/features/chat/main/prompt-input.js.map +1 -0
- package/dist/features/chat/main/use-create-new-chat.d.ts +2 -0
- package/dist/features/chat/main/use-create-new-chat.js +24 -0
- package/dist/features/chat/main/use-create-new-chat.js.map +1 -0
- package/dist/features/chat/main/use-prompt-input.d.ts +2 -0
- package/dist/features/chat/main/use-prompt-input.js +27 -0
- package/dist/features/chat/main/use-prompt-input.js.map +1 -0
- package/dist/features/chat/provider/provider.d.ts +2 -0
- package/dist/features/chat/provider/provider.js +3 -0
- package/dist/features/chat/provider/use-ai-sdk-chat.d.ts +26 -0
- package/dist/features/chat/provider/use-ai-sdk-chat.d.ts.map +1 -0
- package/dist/features/chat/provider/use-ai-sdk-chat.js +3 -0
- package/dist/features/chat/provider/use-create-chat-store.d.ts +2 -0
- package/dist/features/chat/provider/use-create-chat-store.js +42 -0
- package/dist/features/chat/provider/use-create-chat-store.js.map +1 -0
- package/dist/features/chat/provider/use-visible-messages.d.ts +13 -0
- package/dist/features/chat/provider/use-visible-messages.d.ts.map +1 -0
- package/dist/features/chat/provider/use-visible-messages.js +23 -0
- package/dist/features/chat/provider/use-visible-messages.js.map +1 -0
- package/dist/features/chat/queries/query-keys.d.ts +3 -3
- package/dist/features/chat/queries/query-keys.d.ts.map +1 -1
- package/dist/features/chat/queries/query-keys.js +5 -5
- package/dist/features/chat/queries/query-keys.js.map +1 -1
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts +13 -14
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts.map +1 -1
- package/dist/features/chat/queries/use-create-conversation-mutation.js +4 -4
- package/dist/features/chat/queries/use-create-conversation-mutation.js.map +1 -1
- package/dist/features/chat/queries/use-get-agent-query.d.ts +2 -0
- package/dist/features/chat/queries/use-get-agent-query.js +2 -0
- package/dist/features/chat/queries/use-get-conversation-query.d.ts +2 -72
- package/dist/features/chat/queries/use-get-conversation-query.js +1 -1
- package/dist/features/chat/queries/use-list-conversations-query.d.ts +2 -33
- package/dist/features/chat/queries/use-list-conversations-query.js +23 -1
- package/dist/features/chat/queries/use-list-conversations-query.js.map +1 -0
- package/dist/features/chat/queries/use-record-feedback-mutation.d.ts +26 -0
- package/dist/features/chat/queries/use-record-feedback-mutation.d.ts.map +1 -0
- package/dist/features/chat/queries/use-record-feedback-mutation.js +2 -0
- package/dist/features/chat/utils.d.ts +7 -2
- package/dist/features/chat/utils.d.ts.map +1 -1
- package/dist/features/chat/utils.js +12 -1
- package/dist/features/chat/utils.js.map +1 -1
- package/dist/features/data-fetching/use-api-client.d.ts +1 -3
- package/dist/features/data-fetching/use-api-client.d.ts.map +1 -1
- package/dist/features/data-fetching/use-api-client.js +1 -1
- package/dist/features/element/chatsdk-provider.d.ts +1 -1
- package/dist/features/element/chatsdk-provider.js +5 -5
- package/dist/features/element/chatsdk-provider.js.map +1 -1
- package/dist/features/element/element-provider.d.ts +1 -1
- package/dist/features/element/element-provider.js +14 -9
- package/dist/features/element/element-provider.js.map +1 -1
- package/dist/features/element/store.d.ts +1 -1
- package/dist/features/element/store.js.map +1 -1
- package/dist/features/element/types/api.d.ts +1 -1
- package/dist/features/element/types/callbacks.d.ts +1 -1
- package/dist/features/element/types/config.d.ts +1 -1
- package/dist/features/element/types/context.d.ts +1 -1
- package/dist/features/element/types/locale.d.ts +1 -1
- package/dist/features/element/types/theme.d.ts +1 -1
- package/dist/features/element/types/translations.d.ts +1 -1
- package/dist/features/element/use-element-config.d.ts +14 -33
- package/dist/features/element/use-element-config.d.ts.map +1 -1
- package/dist/features/element/use-element-config.js +7 -15
- package/dist/features/element/use-element-config.js.map +1 -1
- package/dist/features/element/use-merge-global-config.d.ts +6 -7
- package/dist/features/element/use-merge-global-config.d.ts.map +1 -1
- package/dist/features/element/use-merge-global-config.js +2 -2
- package/dist/features/element/use-merge-global-config.js.map +1 -1
- package/dist/features/element/utils.d.ts +1 -1
- package/dist/features/element/utils.js.map +1 -1
- package/dist/features/errors/use-app-error-message.d.ts +2 -0
- package/dist/features/errors/use-app-error-message.js +25 -0
- package/dist/features/errors/use-app-error-message.js.map +1 -0
- package/dist/features/logging/logger-provider.d.ts +2 -0
- package/dist/features/logging/logger-provider.js +20 -0
- package/dist/features/logging/logger-provider.js.map +1 -0
- package/dist/feedback-hofC2MHC.d.ts +5 -0
- package/dist/feedback-hofC2MHC.d.ts.map +1 -0
- package/dist/footer-BdcVsDmw.d.ts +11 -0
- package/dist/footer-BdcVsDmw.d.ts.map +1 -0
- package/dist/frame-BCN71hMj.d.ts +17 -0
- package/dist/frame-BCN71hMj.d.ts.map +1 -0
- package/dist/frame-D_ce2ErP.d.ts +10 -0
- package/dist/frame-D_ce2ErP.d.ts.map +1 -0
- package/dist/header-BDGB3zKD.d.ts +8 -0
- package/dist/header-BDGB3zKD.d.ts.map +1 -0
- package/dist/history-DDUj4LMJ.d.ts +8 -0
- package/dist/history-DDUj4LMJ.d.ts.map +1 -0
- package/dist/i18n/config.d.ts +1 -1
- package/dist/i18n/config.js +1 -1
- package/dist/i18n/i18next.d.ts +1 -1377
- package/dist/i18n/i18next.d.ts.map +1 -1
- package/dist/i18n/i18next.js +1 -2
- package/dist/i18n/i18next.js.map +1 -1
- package/dist/i18n/utils.d.ts +1 -1
- package/dist/i18n/utils.d.ts.map +1 -1
- package/dist/i18n/utils.js.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.js +12 -59
- package/dist/index.js.map +1 -1
- package/dist/{locale-W5Kyyi4X.d.ts → locale-v_zPGRhE.d.ts} +2 -2
- package/dist/locale-v_zPGRhE.d.ts.map +1 -0
- package/dist/logger-provider-whBIV3Gt.d.ts +16 -0
- package/dist/logger-provider-whBIV3Gt.d.ts.map +1 -0
- package/dist/main-D8VgMjmL.d.ts +15 -0
- package/dist/main-D8VgMjmL.d.ts.map +1 -0
- package/dist/part-C8ZA6iZn.d.ts +25 -0
- package/dist/part-C8ZA6iZn.d.ts.map +1 -0
- package/dist/prompt-input-bclKhGu3.d.ts +15 -0
- package/dist/prompt-input-bclKhGu3.d.ts.map +1 -0
- package/dist/provider-CkkKc2aq.d.ts +21 -0
- package/dist/provider-CkkKc2aq.d.ts.map +1 -0
- package/dist/provider-Cps0PPXa.js +383 -0
- package/dist/provider-Cps0PPXa.js.map +1 -0
- package/dist/reasoning-BRNu_n6T.d.ts +5 -0
- package/dist/reasoning-BRNu_n6T.d.ts.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/sources-BXoSxNYc.d.ts +5 -0
- package/dist/sources-BXoSxNYc.d.ts.map +1 -0
- package/dist/{store-CGX9oRlE.d.ts → store-CkswgmIQ.d.ts} +8 -10
- package/dist/store-CkswgmIQ.d.ts.map +1 -0
- package/dist/styles.css +1677 -948
- package/dist/text-Cio_Hj_h.d.ts +5 -0
- package/dist/text-Cio_Hj_h.d.ts.map +1 -0
- package/dist/{theme-Cb-RBWbR.d.ts → theme-K7rbPHc1.d.ts} +1 -1
- package/dist/{theme-Cb-RBWbR.d.ts.map → theme-K7rbPHc1.d.ts.map} +1 -1
- package/dist/timestamp-CbU3bLa3.d.ts +5 -0
- package/dist/timestamp-CbU3bLa3.d.ts.map +1 -0
- package/dist/tool-DskTWxZb.d.ts +5 -0
- package/dist/tool-DskTWxZb.d.ts.map +1 -0
- package/dist/use-app-error-message-DAHQ4oR_.d.ts +12 -0
- package/dist/use-app-error-message-DAHQ4oR_.d.ts.map +1 -0
- package/dist/use-create-chat-store-Ccd5tvho.d.ts +26 -0
- package/dist/use-create-chat-store-Ccd5tvho.d.ts.map +1 -0
- package/dist/use-create-new-chat-H4kM3hPt.d.ts +7 -0
- package/dist/use-create-new-chat-H4kM3hPt.d.ts.map +1 -0
- package/dist/use-get-agent-query-hQ4uOjfL.d.ts +10 -0
- package/dist/use-get-agent-query-hQ4uOjfL.d.ts.map +1 -0
- package/dist/use-get-conversation-query-D5bRlewH.d.ts +73 -0
- package/dist/use-get-conversation-query-D5bRlewH.d.ts.map +1 -0
- package/dist/use-history-DH2KkVDP.d.ts +30 -0
- package/dist/use-history-DH2KkVDP.d.ts.map +1 -0
- package/dist/use-list-conversations-query-Ny-nP5cZ.d.ts +29 -0
- package/dist/use-list-conversations-query-Ny-nP5cZ.d.ts.map +1 -0
- package/package.json +27 -24
- package/dist/chat-element-CCsDDFif.js +0 -441
- package/dist/chat-element-CCsDDFif.js.map +0 -1
- package/dist/chat-element-CSpa62Te.d.ts +0 -53
- package/dist/chat-element-CSpa62Te.d.ts.map +0 -1
- package/dist/chatsdk-provider-BhlChLFd.d.ts.map +0 -1
- package/dist/common/utils.d.ts +0 -14
- package/dist/common/utils.d.ts.map +0 -1
- package/dist/common/utils.js +0 -26
- package/dist/common/utils.js.map +0 -1
- package/dist/components/info-card.d.ts +0 -23
- package/dist/components/info-card.d.ts.map +0 -1
- package/dist/components/info-card.js +0 -38
- package/dist/components/info-card.js.map +0 -1
- package/dist/config-BigIL6TQ.js +0 -29
- package/dist/config-BigIL6TQ.js.map +0 -1
- package/dist/config-CqihvSgz.d.ts.map +0 -1
- package/dist/config-D_jVTH_D.d.ts +0 -58
- package/dist/config-D_jVTH_D.d.ts.map +0 -1
- package/dist/context-aSaHw-ac.d.ts.map +0 -1
- package/dist/element-provider-C_nBsftD.d.ts.map +0 -1
- package/dist/features/chat/chat-card.d.ts +0 -7
- package/dist/features/chat/chat-card.d.ts.map +0 -1
- package/dist/features/chat/chat-card.js +0 -2
- package/dist/features/chat/chat-header/chat-header.d.ts +0 -12
- package/dist/features/chat/chat-header/chat-header.d.ts.map +0 -1
- package/dist/features/chat/chat-header/chat-header.js +0 -2
- package/dist/features/chat/chat-header/chat-menu.d.ts +0 -7
- package/dist/features/chat/chat-header/chat-menu.d.ts.map +0 -1
- package/dist/features/chat/chat-header/chat-menu.js.map +0 -1
- package/dist/features/chat/chat-history/chat-history-empty.d.ts +0 -7
- package/dist/features/chat/chat-history/chat-history-empty.d.ts.map +0 -1
- package/dist/features/chat/chat-history/chat-history-empty.js.map +0 -1
- package/dist/features/chat/chat-history/chat-history.d.ts +0 -7
- package/dist/features/chat/chat-history/chat-history.d.ts.map +0 -1
- package/dist/features/chat/chat-history/chat-history.js +0 -2
- package/dist/features/chat/chat-main/chat-main.d.ts +0 -10
- package/dist/features/chat/chat-main/chat-main.d.ts.map +0 -1
- package/dist/features/chat/chat-main/chat-main.js +0 -3
- package/dist/features/chat/chat-main/use-chat.d.ts +0 -23
- package/dist/features/chat/chat-main/use-chat.d.ts.map +0 -1
- package/dist/features/chat/chat-main/use-chat.js +0 -3
- package/dist/features/chat/chat-main/use-initial-messages.d.ts +0 -22
- package/dist/features/chat/chat-main/use-initial-messages.d.ts.map +0 -1
- package/dist/features/chat/chat-main/use-initial-messages.js +0 -2
- package/dist/features/chat/chat-prompt-input.d.ts +0 -24
- package/dist/features/chat/chat-prompt-input.d.ts.map +0 -1
- package/dist/features/chat/chat-prompt-input.js +0 -3
- package/dist/features/chat/chat.context.d.ts +0 -28
- package/dist/features/chat/chat.context.d.ts.map +0 -1
- package/dist/features/chat/chat.context.js +0 -10
- package/dist/features/chat/chat.context.js.map +0 -1
- package/dist/features/chat/queries/use-get-chat-query.d.ts +0 -13
- package/dist/features/chat/queries/use-get-chat-query.d.ts.map +0 -1
- package/dist/features/chat/queries/use-get-chat-query.js +0 -2
- package/dist/features/chat/queries/use-get-conversation-query.d.ts.map +0 -1
- package/dist/features/chat/queries/use-list-conversations-query.d.ts.map +0 -1
- package/dist/features/chat/store.d.ts +0 -15
- package/dist/features/chat/store.d.ts.map +0 -1
- package/dist/features/chat/store.js +0 -15
- package/dist/features/chat/store.js.map +0 -1
- package/dist/features/logger/logger.d.ts +0 -2
- package/dist/features/logger/logger.js +0 -15
- package/dist/features/logger/logger.js.map +0 -1
- package/dist/locale-W5Kyyi4X.d.ts.map +0 -1
- package/dist/logger-BvmhODdq.d.ts +0 -11
- package/dist/logger-BvmhODdq.d.ts.map +0 -1
- package/dist/store-CGX9oRlE.d.ts.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMessage } from "./provider.js";
|
|
3
|
+
import { createContext, use } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/features/chat/conversation/message/part.tsx
|
|
6
|
+
function usePart(type) {
|
|
7
|
+
const ctx = use(PartContext);
|
|
8
|
+
if (!ctx) throw new Error("usePart must be used within Message.Parts");
|
|
9
|
+
return normalizePartType(ctx.part.type) === type ? ctx : null;
|
|
10
|
+
}
|
|
11
|
+
const PartContext = createContext(null);
|
|
12
|
+
function PartProvider({ part, index, children }) {
|
|
13
|
+
return /* @__PURE__ */ jsx(PartContext, {
|
|
14
|
+
value: {
|
|
15
|
+
part,
|
|
16
|
+
index
|
|
17
|
+
},
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function normalizePartType(type) {
|
|
22
|
+
return type === "dynamic-tool" || type.startsWith("tool-") ? "tool" : type;
|
|
23
|
+
}
|
|
24
|
+
function MessageParts({ children }) {
|
|
25
|
+
const { message } = useMessage();
|
|
26
|
+
return message.parts.map((part, index) => /* @__PURE__ */ jsx(PartProvider, {
|
|
27
|
+
part,
|
|
28
|
+
index,
|
|
29
|
+
children
|
|
30
|
+
}, `${message.id}-${index}`));
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { MessageParts, PartProvider, usePart };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"part.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/part.tsx"],"sourcesContent":["\"use client\";\n\nimport type { UIMessage } from \"ai\";\nimport { createContext, use } from \"react\";\n\nimport { useMessage } from \"./provider\";\n\ntype Part = UIMessage[\"parts\"][number];\n\n// A renderer claims a part by calling this; null = \"not mine, render nothing\".\nexport function usePart(type: string): { part: Part; index: number } | null {\n const ctx = use(PartContext);\n if (!ctx) throw new Error(\"usePart must be used within Message.Parts\");\n return normalizePartType(ctx.part.type as string) === type ? ctx : null;\n}\n\nconst PartContext = createContext<{ part: Part; index: number } | null>(null);\n\nexport function PartProvider({\n part,\n index,\n children,\n}: {\n part: Part;\n index: number;\n children: React.ReactNode;\n}) {\n return <PartContext value={{ part, index }}>{children}</PartContext>;\n}\n\n// dynamic-tool + tool-* collapse to \"tool\"\nfunction normalizePartType(type: string): string {\n return type === \"dynamic-tool\" || type.startsWith(\"tool-\") ? \"tool\" : type;\n}\n\nexport function MessageParts({ children }: { children: React.ReactNode }) {\n const { message } = useMessage();\n\n return message.parts.map((part, index) => (\n <PartProvider key={`${message.id}-${index}`} part={part} index={index}>\n {children}\n </PartProvider>\n ));\n}\n"],"mappings":";;;;;AAUA,SAAgB,QAAQ,MAAoD;CAC1E,MAAM,MAAM,IAAI,WAAW;CAC3B,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,2CAA2C;CACrE,OAAO,kBAAkB,IAAI,KAAK,IAAc,MAAM,OAAO,MAAM;AACrE;AAEA,MAAM,cAAc,cAAoD,IAAI;AAE5E,SAAgB,aAAa,EAC3B,MACA,OACA,YAKC;CACD,OAAO,oBAAC,aAAD;EAAa,OAAO;GAAE;GAAM;EAAM;EAAI;CAAsB,CAAA;AACrE;AAGA,SAAS,kBAAkB,MAAsB;CAC/C,OAAO,SAAS,kBAAkB,KAAK,WAAW,OAAO,IAAI,SAAS;AACxE;AAEA,SAAgB,aAAa,EAAE,YAA2C;CACxE,MAAM,EAAE,YAAY,WAAW;CAE/B,OAAO,QAAQ,MAAM,KAAK,MAAM,UAC9B,oBAAC,cAAD;EAAmD;EAAa;EAC7D;CACW,GAFK,GAAG,QAAQ,GAAG,GAAG,OAEtB,CACf;AACH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/features/chat/conversation/message/provider.tsx
|
|
5
|
+
const Context = createContext(null);
|
|
6
|
+
function useMessage() {
|
|
7
|
+
const value = use(Context);
|
|
8
|
+
if (!value) throw new Error("Message.* must be used within a Message.Provider");
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function MessageProvider({ message, messageIndex, children }) {
|
|
12
|
+
const value = useMemo(() => {
|
|
13
|
+
return {
|
|
14
|
+
message,
|
|
15
|
+
isFirst: messageIndex === 0
|
|
16
|
+
};
|
|
17
|
+
}, [message, messageIndex]);
|
|
18
|
+
return /* @__PURE__ */ jsx(Context, {
|
|
19
|
+
value,
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { MessageProvider, useMessage };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/provider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { UIMessage } from \"ai\";\nimport { createContext, use, useMemo } from \"react\";\n\nexport interface MessageContextValue {\n message: UIMessage;\n isFirst: boolean;\n}\n\nconst Context = createContext<MessageContextValue | null>(null);\n\nexport function useMessage(): MessageContextValue {\n const value = use(Context);\n if (!value) {\n throw new Error(\"Message.* must be used within a Message.Provider\");\n }\n return value;\n}\n\nexport interface ProviderProps {\n message: UIMessage;\n messageIndex: number;\n children: React.ReactNode;\n}\n\nexport function MessageProvider({\n message,\n messageIndex,\n children,\n}: ProviderProps) {\n const value = useMemo<MessageContextValue>(() => {\n return {\n message,\n isFirst: messageIndex === 0,\n };\n }, [message, messageIndex]);\n\n return <Context value={value}>{children}</Context>;\n}\n"],"mappings":";;;;AAUA,MAAM,UAAU,cAA0C,IAAI;AAE9D,SAAgB,aAAkC;CAChD,MAAM,QAAQ,IAAI,OAAO;CACzB,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,kDAAkD;CAEpE,OAAO;AACT;AAQA,SAAgB,gBAAgB,EAC9B,SACA,cACA,YACgB;CAChB,MAAM,QAAQ,cAAmC;EAC/C,OAAO;GACL;GACA,SAAS,iBAAiB;EAC5B;CACF,GAAG,CAAC,SAAS,YAAY,CAAC;CAE1B,OAAO,oBAAC,SAAD;EAAgB;EAAQ;CAAkB,CAAA;AACnD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { i as useChat } from "../../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { useMessage } from "./provider.js";
|
|
3
|
+
import { usePart } from "./part.js";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Reasoning, ReasoningContent, ReasoningTrigger } from "@chatsdk-dev/ui/molecules/ai/reasoning";
|
|
7
|
+
//#region src/features/chat/conversation/message/reasoning.tsx
|
|
8
|
+
function MessageReasoning() {
|
|
9
|
+
const { t } = useTranslation("chatsdk_elements");
|
|
10
|
+
const { status } = useChat();
|
|
11
|
+
const { message } = useMessage();
|
|
12
|
+
const claimed = usePart("reasoning");
|
|
13
|
+
if (!claimed) return null;
|
|
14
|
+
const part = claimed.part;
|
|
15
|
+
const isStreaming = status === "streaming" && part.state === "streaming";
|
|
16
|
+
const text = part.text ?? "";
|
|
17
|
+
return /* @__PURE__ */ jsxs(Reasoning, {
|
|
18
|
+
className: "w-full",
|
|
19
|
+
isStreaming,
|
|
20
|
+
children: [/* @__PURE__ */ jsx(ReasoningTrigger, { getThinkingMessage: (isStreaming, duration) => {
|
|
21
|
+
if (isStreaming || duration === 0) return /* @__PURE__ */ jsx("span", {
|
|
22
|
+
className: "shimmer shimmer-duration-1000 text-muted-foreground",
|
|
23
|
+
children: t("conversation.reasoning.thinking")
|
|
24
|
+
});
|
|
25
|
+
if (duration === void 0) return /* @__PURE__ */ jsx("p", { children: t("conversation.reasoning.thought-brief") });
|
|
26
|
+
return /* @__PURE__ */ jsx("p", { children: t("conversation.reasoning.thought-for", { seconds: duration }) });
|
|
27
|
+
} }), /* @__PURE__ */ jsx(ReasoningContent, { children: text })]
|
|
28
|
+
}, `${message.id}-${claimed.index}`);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { MessageReasoning };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=reasoning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/reasoning.tsx"],"sourcesContent":["import { useTranslation } from \"react-i18next\";\n\nimport {\n Reasoning,\n ReasoningContent,\n ReasoningTrigger,\n} from \"@chatsdk-dev/ui/molecules/ai/reasoning\";\n\nimport { useChat } from \"../../provider/provider\";\nimport { usePart } from \"./part\";\nimport { useMessage } from \"./provider\";\n\nexport function MessageReasoning() {\n const { t } = useTranslation(\"chatsdk_elements\");\n const { status } = useChat();\n const { message } = useMessage();\n\n const claimed = usePart(\"reasoning\");\n if (!claimed) return null;\n\n const part = claimed.part as { text?: string; state?: string };\n // Per-part state, not message-level: an approval continuation appends parts\n // to the SAME message, so \"last message && streaming\" would re-shimmer that\n // message's earlier reasoning panels and overwrite their durations. The\n // status guard keeps an aborted stream from shimmering forever.\n const isStreaming = status === \"streaming\" && part.state === \"streaming\";\n\n const text = part.text ?? \"\";\n return (\n <Reasoning\n key={`${message.id}-${claimed.index}`}\n className=\"w-full\"\n isStreaming={isStreaming}\n >\n <ReasoningTrigger\n getThinkingMessage={(isStreaming, duration) => {\n if (isStreaming || duration === 0) {\n return (\n <span className=\"shimmer shimmer-duration-1000 text-muted-foreground\">\n {t(\"conversation.reasoning.thinking\")}\n </span>\n );\n }\n if (duration === undefined) {\n return <p>{t(\"conversation.reasoning.thought-brief\")}</p>;\n }\n return (\n <p>\n {t(\"conversation.reasoning.thought-for\", {\n seconds: duration,\n })}\n </p>\n );\n }}\n />\n <ReasoningContent>{text}</ReasoningContent>\n </Reasoning>\n );\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,mBAAmB;CACjC,MAAM,EAAE,MAAM,eAAe,kBAAkB;CAC/C,MAAM,EAAE,WAAW,QAAQ;CAC3B,MAAM,EAAE,YAAY,WAAW;CAE/B,MAAM,UAAU,QAAQ,WAAW;CACnC,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,OAAO,QAAQ;CAKrB,MAAM,cAAc,WAAW,eAAe,KAAK,UAAU;CAE7D,MAAM,OAAO,KAAK,QAAQ;CAC1B,OACE,qBAAC,WAAD;EAEE,WAAU;EACG;YAHf,CAKE,oBAAC,kBAAD,EACE,qBAAqB,aAAa,aAAa;GAC7C,IAAI,eAAe,aAAa,GAC9B,OACE,oBAAC,QAAD;IAAM,WAAU;cACb,EAAE,iCAAiC;GAChC,CAAA;GAGV,IAAI,aAAa,KAAA,GACf,OAAO,oBAAC,KAAD,EAAA,UAAI,EAAE,sCAAsC,EAAK,CAAA;GAE1D,OACE,oBAAC,KAAD,EAAA,UACG,EAAE,sCAAsC,EACvC,SAAS,SACX,CAAC,EACA,CAAA;EAEP,EACD,CAAA,GACD,oBAAC,kBAAD,EAAA,UAAmB,KAAuB,CAAA,CACjC;IA1BJ,GAAG,QAAQ,GAAG,GAAG,QAAQ,OA0BrB;AAEf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMessage } from "./provider.js";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import * as Elements from "@chatsdk-dev/ui/molecules/ai/sources";
|
|
5
|
+
//#region src/features/chat/conversation/message/sources.tsx
|
|
6
|
+
function MessageSources() {
|
|
7
|
+
const { t } = useTranslation("chatsdk_elements");
|
|
8
|
+
const { message } = useMessage();
|
|
9
|
+
return message.role === "assistant" && message.parts.filter((part) => part.type === "source-url").length > 0 && /* @__PURE__ */ jsxs(Elements.Sources, { children: [/* @__PURE__ */ jsx(Elements.SourcesTrigger, {
|
|
10
|
+
count: message.parts.filter((part) => part.type === "source-url").length,
|
|
11
|
+
label: t("conversation.sources.used", { count: message.parts.filter((part) => part.type === "source-url").length })
|
|
12
|
+
}), message.parts.filter((part) => part.type === "source-url").map((part, i) => /* @__PURE__ */ jsx(Elements.SourcesContent, { children: /* @__PURE__ */ jsx(Elements.Source, {
|
|
13
|
+
href: part.url,
|
|
14
|
+
title: part.url
|
|
15
|
+
}, `${message.id}-${i}`) }, `${message.id}-${i}`))] });
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MessageSources };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/sources.tsx"],"sourcesContent":["import { useTranslation } from \"react-i18next\";\n\nimport * as Elements from \"@chatsdk-dev/ui/molecules/ai/sources\";\n\nimport { useMessage } from \"./provider\";\n\nexport function MessageSources() {\n const { t } = useTranslation(\"chatsdk_elements\");\n const { message } = useMessage();\n\n const isAssistant = message.role === \"assistant\";\n\n return (\n isAssistant &&\n message.parts.filter((part) => part.type === \"source-url\").length > 0 && (\n <Elements.Sources>\n <Elements.SourcesTrigger\n count={\n message.parts.filter((part) => part.type === \"source-url\").length\n }\n label={t(\"conversation.sources.used\", {\n count: message.parts.filter((part) => part.type === \"source-url\")\n .length,\n })}\n />\n {message.parts\n .filter((part) => part.type === \"source-url\")\n .map((part, i) => (\n <Elements.SourcesContent key={`${message.id}-${i}`}>\n <Elements.Source\n key={`${message.id}-${i}`}\n href={part.url}\n title={part.url}\n />\n </Elements.SourcesContent>\n ))}\n </Elements.Sources>\n )\n );\n}\n"],"mappings":";;;;;AAMA,SAAgB,iBAAiB;CAC/B,MAAM,EAAE,MAAM,eAAe,kBAAkB;CAC/C,MAAM,EAAE,YAAY,WAAW;CAI/B,OAFoB,QAAQ,SAAS,eAInC,QAAQ,MAAM,QAAQ,SAAS,KAAK,SAAS,YAAY,CAAC,CAAC,SAAS,KAClE,qBAAC,SAAS,SAAV,EAAA,UAAA,CACE,oBAAC,SAAS,gBAAV;EACE,OACE,QAAQ,MAAM,QAAQ,SAAS,KAAK,SAAS,YAAY,CAAC,CAAC;EAE7D,OAAO,EAAE,6BAA6B,EACpC,OAAO,QAAQ,MAAM,QAAQ,SAAS,KAAK,SAAS,YAAY,CAAC,CAC9D,OACL,CAAC;CACF,CAAA,GACA,QAAQ,MACN,QAAQ,SAAS,KAAK,SAAS,YAAY,CAAC,CAC5C,KAAK,MAAM,MACV,oBAAC,SAAS,gBAAV,EAAA,UACE,oBAAC,SAAS,QAAV;EAEE,MAAM,KAAK;EACX,OAAO,KAAK;CACb,GAHM,GAAG,QAAQ,GAAG,GAAG,GAGvB,EACsB,GANK,GAAG,QAAQ,GAAG,GAAG,GAMtB,CAC1B,CACa,EAAA,CAAA;AAGxB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMessage } from "./provider.js";
|
|
3
|
+
import { usePart } from "./part.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { cn } from "@chatsdk-dev/ui/lib/utils";
|
|
6
|
+
import { Bubble, BubbleContent } from "@chatsdk-dev/ui/atoms/bubble";
|
|
7
|
+
import { MessageResponse } from "@chatsdk-dev/ui/molecules/ai/response";
|
|
8
|
+
//#region src/features/chat/conversation/message/text.tsx
|
|
9
|
+
function MessageText() {
|
|
10
|
+
const { message } = useMessage();
|
|
11
|
+
const claimed = usePart("text");
|
|
12
|
+
if (!claimed) return null;
|
|
13
|
+
const text = claimed.part.text;
|
|
14
|
+
if (!text) return null;
|
|
15
|
+
const isUser = message.role === "user";
|
|
16
|
+
return /* @__PURE__ */ jsx(Bubble, {
|
|
17
|
+
variant: isUser ? "default" : "muted",
|
|
18
|
+
align: isUser ? "end" : "start",
|
|
19
|
+
className: cn(!isUser && "w-full max-w-full"),
|
|
20
|
+
children: /* @__PURE__ */ jsx(BubbleContent, {
|
|
21
|
+
className: cn(!isUser && "w-full"),
|
|
22
|
+
children: /* @__PURE__ */ jsx(MessageResponse, { children: text })
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MessageText };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/text.tsx"],"sourcesContent":["\"use client\";\n\nimport { Bubble, BubbleContent } from \"@chatsdk-dev/ui/atoms/bubble\";\nimport { cn } from \"@chatsdk-dev/ui/lib/utils\";\nimport { MessageResponse } from \"@chatsdk-dev/ui/molecules/ai/response\";\n\nimport { usePart } from \"./part\";\nimport { useMessage } from \"./provider\";\n\nexport function MessageText() {\n const { message } = useMessage();\n const claimed = usePart(\"text\");\n if (!claimed) return null;\n\n const text = (claimed.part as { text?: string }).text;\n if (!text) return null;\n\n const isUser = message.role === \"user\";\n // Assistant answers stay a wide panel (fill the column); user messages hug.\n return (\n <Bubble\n variant={isUser ? \"default\" : \"muted\"}\n align={isUser ? \"end\" : \"start\"}\n className={cn(!isUser && \"w-full max-w-full\")}\n >\n <BubbleContent className={cn(!isUser && \"w-full\")}>\n <MessageResponse>{text}</MessageResponse>\n </BubbleContent>\n </Bubble>\n );\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,cAAc;CAC5B,MAAM,EAAE,YAAY,WAAW;CAC/B,MAAM,UAAU,QAAQ,MAAM;CAC9B,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,OAAQ,QAAQ,KAA2B;CACjD,IAAI,CAAC,MAAM,OAAO;CAElB,MAAM,SAAS,QAAQ,SAAS;CAEhC,OACE,oBAAC,QAAD;EACE,SAAS,SAAS,YAAY;EAC9B,OAAO,SAAS,QAAQ;EACxB,WAAW,GAAG,CAAC,UAAU,mBAAmB;YAE5C,oBAAC,eAAD;GAAe,WAAW,GAAG,CAAC,UAAU,QAAQ;aAC9C,oBAAC,iBAAD,EAAA,UAAkB,KAAsB,CAAA;EAC3B,CAAA;CACT,CAAA;AAEZ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMessage } from "./provider.js";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Text } from "@chatsdk-dev/ui/atoms/typography/text";
|
|
6
|
+
import { renderRelativeTime } from "@chatsdk-dev/ui/lib/utils";
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@chatsdk-dev/ui/atoms/tooltip";
|
|
8
|
+
import { Separator } from "@chatsdk-dev/ui/atoms/separator";
|
|
9
|
+
//#region src/features/chat/conversation/message/timestamp.tsx
|
|
10
|
+
function MessageTimestamp() {
|
|
11
|
+
const { t, i18n } = useTranslation("chatsdk_elements");
|
|
12
|
+
const { message } = useMessage();
|
|
13
|
+
const at = message.metadata?._creationTime;
|
|
14
|
+
if (!at) return null;
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
className: "flex flex-row items-center pr-1 min-h-7",
|
|
17
|
+
children: [/* @__PURE__ */ jsxs(Tooltip, {
|
|
18
|
+
delay: 750,
|
|
19
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(Text, {
|
|
20
|
+
className: "text-xs text-zinc-500",
|
|
21
|
+
children: renderRelativeTime({
|
|
22
|
+
date: new Date(at),
|
|
23
|
+
locale: i18n.language,
|
|
24
|
+
nowLabel: t("just-now")
|
|
25
|
+
})
|
|
26
|
+
}) }), /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: new Date(at).toLocaleString() }) })]
|
|
27
|
+
}), /* @__PURE__ */ jsx(Separator, {
|
|
28
|
+
orientation: "vertical",
|
|
29
|
+
className: "ml-3 h-3!"
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { MessageTimestamp };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=timestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamp.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/timestamp.tsx"],"sourcesContent":["\"use client\";\n\nimport { useTranslation } from \"react-i18next\";\n\nimport { Separator } from \"@chatsdk-dev/ui/atoms/separator\";\nimport { Text } from \"@chatsdk-dev/ui/atoms/typography/text\";\nimport { renderRelativeTime } from \"@chatsdk-dev/ui/lib/utils\";\nimport { useMessage } from \"./provider\";\n\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@chatsdk-dev/ui/atoms/tooltip\";\n\nexport function MessageTimestamp() {\n const { t, i18n } = useTranslation(\"chatsdk_elements\");\n const { message } = useMessage();\n const at = (message.metadata as { _creationTime?: number } | undefined)\n ?._creationTime;\n if (!at) return null;\n\n return (\n <div className=\"flex flex-row items-center pr-1 min-h-7\">\n <Tooltip delay={750}>\n <TooltipTrigger>\n <Text className=\"text-xs text-zinc-500\">\n {renderRelativeTime({\n date: new Date(at),\n locale: i18n.language,\n nowLabel: t(\"just-now\"),\n })}\n </Text>\n </TooltipTrigger>\n <TooltipContent>\n <p>{new Date(at).toLocaleString()}</p>\n </TooltipContent>\n </Tooltip>\n <Separator orientation=\"vertical\" className=\"ml-3 h-3!\" />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,mBAAmB;CACjC,MAAM,EAAE,GAAG,SAAS,eAAe,kBAAkB;CACrD,MAAM,EAAE,YAAY,WAAW;CAC/B,MAAM,KAAM,QAAQ,UAChB;CACJ,IAAI,CAAC,IAAI,OAAO;CAEhB,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAAC,SAAD;GAAS,OAAO;aAAhB,CACE,oBAAC,gBAAD,EAAA,UACE,oBAAC,MAAD;IAAM,WAAU;cACb,mBAAmB;KAClB,MAAM,IAAI,KAAK,EAAE;KACjB,QAAQ,KAAK;KACb,UAAU,EAAE,UAAU;IACxB,CAAC;GACG,CAAA,EACQ,CAAA,GAChB,oBAAC,gBAAD,EAAA,UACE,oBAAC,KAAD,EAAA,UAAI,IAAI,KAAK,EAAE,CAAC,CAAC,eAAe,EAAK,CAAA,EACvB,CAAA,CACT;MACT,oBAAC,WAAD;GAAW,aAAY;GAAW,WAAU;EAAa,CAAA,CACtD;;AAET"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePart } from "./part.js";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { getToolName } from "ai";
|
|
6
|
+
import { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput } from "@chatsdk-dev/ui/molecules/ai/tool";
|
|
7
|
+
//#region src/features/chat/conversation/message/tool.tsx
|
|
8
|
+
function useToolStatusLabels() {
|
|
9
|
+
const { t } = useTranslation("chatsdk_elements");
|
|
10
|
+
return {
|
|
11
|
+
"approval-requested": t("conversation.tool.status.approval-requested"),
|
|
12
|
+
"approval-responded": t("conversation.tool.status.approval-responded"),
|
|
13
|
+
"input-available": t("conversation.tool.status.input-available"),
|
|
14
|
+
"input-streaming": t("conversation.tool.status.input-streaming"),
|
|
15
|
+
"output-available": t("conversation.tool.status.output-available"),
|
|
16
|
+
"output-denied": t("conversation.tool.status.output-denied"),
|
|
17
|
+
"output-error": t("conversation.tool.status.output-error")
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function MessageTool() {
|
|
21
|
+
const { t } = useTranslation("chatsdk_elements");
|
|
22
|
+
const statusLabels = useToolStatusLabels();
|
|
23
|
+
const claimed = usePart("tool");
|
|
24
|
+
if (!claimed) return null;
|
|
25
|
+
const part = claimed.part;
|
|
26
|
+
const toolPart = part;
|
|
27
|
+
const isDynamic = part.type === "dynamic-tool";
|
|
28
|
+
const title = toolPart.title ?? getToolName(toolPart);
|
|
29
|
+
return /* @__PURE__ */ jsxs(Tool, {
|
|
30
|
+
className: isDynamic ? void 0 : "w-full flex-1",
|
|
31
|
+
children: [isDynamic ? /* @__PURE__ */ jsx(ToolHeader, {
|
|
32
|
+
type: "dynamic-tool",
|
|
33
|
+
state: toolPart.state,
|
|
34
|
+
toolName: part.toolName,
|
|
35
|
+
title,
|
|
36
|
+
statusLabels
|
|
37
|
+
}) : /* @__PURE__ */ jsx(ToolHeader, {
|
|
38
|
+
type: toolPart.type,
|
|
39
|
+
state: toolPart.state,
|
|
40
|
+
title,
|
|
41
|
+
statusLabels
|
|
42
|
+
}), /* @__PURE__ */ jsxs(ToolContent, { children: [toolPart.input != null && /* @__PURE__ */ jsx(ToolInput, {
|
|
43
|
+
input: toolPart.input,
|
|
44
|
+
label: t("conversation.tool.parameters")
|
|
45
|
+
}), /* @__PURE__ */ jsx(ToolOutput, {
|
|
46
|
+
output: toolPart.output,
|
|
47
|
+
errorText: toolPart.errorText,
|
|
48
|
+
outputLabel: t("conversation.tool.result"),
|
|
49
|
+
errorLabel: t("conversation.tool.error")
|
|
50
|
+
})] })]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { MessageTool };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","names":[],"sources":["../../../../../src/features/chat/conversation/message/tool.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ToolUIPart } from \"ai\";\nimport { getToolName } from \"ai\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n Tool,\n ToolContent,\n ToolHeader,\n ToolInput,\n ToolOutput,\n type ToolPart,\n} from \"@chatsdk-dev/ui/molecules/ai/tool\";\n\nimport { usePart } from \"./part\";\n\nfunction useToolStatusLabels(): Record<ToolPart[\"state\"], string> {\n const { t } = useTranslation(\"chatsdk_elements\");\n return {\n \"approval-requested\": t(\"conversation.tool.status.approval-requested\"),\n \"approval-responded\": t(\"conversation.tool.status.approval-responded\"),\n \"input-available\": t(\"conversation.tool.status.input-available\"),\n \"input-streaming\": t(\"conversation.tool.status.input-streaming\"),\n \"output-available\": t(\"conversation.tool.status.output-available\"),\n \"output-denied\": t(\"conversation.tool.status.output-denied\"),\n \"output-error\": t(\"conversation.tool.status.output-error\"),\n };\n}\n\nexport function MessageTool() {\n const { t } = useTranslation(\"chatsdk_elements\");\n const statusLabels = useToolStatusLabels();\n const claimed = usePart(\"tool\");\n if (!claimed) return null;\n\n const part = claimed.part;\n const toolPart = part as unknown as ToolUIPart;\n const isDynamic = part.type === \"dynamic-tool\";\n const title = (toolPart as ToolPart).title ?? getToolName(toolPart);\n\n return (\n <Tool className={isDynamic ? undefined : \"w-full flex-1\"}>\n {isDynamic ? (\n <ToolHeader\n type=\"dynamic-tool\"\n state={toolPart.state}\n toolName={(part as { toolName: string }).toolName}\n title={title}\n statusLabels={statusLabels}\n />\n ) : (\n <ToolHeader\n type={toolPart.type}\n state={toolPart.state}\n title={title}\n statusLabels={statusLabels}\n />\n )}\n <ToolContent>\n {toolPart.input != null && (\n <ToolInput\n input={toolPart.input}\n label={t(\"conversation.tool.parameters\")}\n />\n )}\n <ToolOutput\n output={toolPart.output}\n errorText={toolPart.errorText}\n outputLabel={t(\"conversation.tool.result\")}\n errorLabel={t(\"conversation.tool.error\")}\n />\n </ToolContent>\n </Tool>\n );\n}\n"],"mappings":";;;;;;;AAiBA,SAAS,sBAAyD;CAChE,MAAM,EAAE,MAAM,eAAe,kBAAkB;CAC/C,OAAO;EACL,sBAAsB,EAAE,6CAA6C;EACrE,sBAAsB,EAAE,6CAA6C;EACrE,mBAAmB,EAAE,0CAA0C;EAC/D,mBAAmB,EAAE,0CAA0C;EAC/D,oBAAoB,EAAE,2CAA2C;EACjE,iBAAiB,EAAE,wCAAwC;EAC3D,gBAAgB,EAAE,uCAAuC;CAC3D;AACF;AAEA,SAAgB,cAAc;CAC5B,MAAM,EAAE,MAAM,eAAe,kBAAkB;CAC/C,MAAM,eAAe,oBAAoB;CACzC,MAAM,UAAU,QAAQ,MAAM;CAC9B,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,OAAO,QAAQ;CACrB,MAAM,WAAW;CACjB,MAAM,YAAY,KAAK,SAAS;CAChC,MAAM,QAAS,SAAsB,SAAS,YAAY,QAAQ;CAElE,OACE,qBAAC,MAAD;EAAM,WAAW,YAAY,KAAA,IAAY;YAAzC,CACG,YACC,oBAAC,YAAD;GACE,MAAK;GACL,OAAO,SAAS;GAChB,UAAW,KAA8B;GAClC;GACO;EACf,CAAA,IAED,oBAAC,YAAD;GACE,MAAM,SAAS;GACf,OAAO,SAAS;GACT;GACO;EACf,CAAA,GAEH,qBAAC,aAAD,EAAA,UAAA,CACG,SAAS,SAAS,QACjB,oBAAC,WAAD;GACE,OAAO,SAAS;GAChB,OAAO,EAAE,8BAA8B;EACxC,CAAA,GAEH,oBAAC,YAAD;GACE,QAAQ,SAAS;GACjB,WAAW,SAAS;GACpB,aAAa,EAAE,0BAA0B;GACzC,YAAY,EAAE,yBAAyB;EACxC,CAAA,CACU,EAAA,CAAA,CACT;;AAEV"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { i as useChat } from "../../../provider-Cps0PPXa.js";
|
|
3
|
+
import { useAppErrorMessage } from "../../errors/use-app-error-message.js";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { isRetryable } from "@chatsdk-dev/agent";
|
|
7
|
+
import { RefreshCw, X } from "lucide-react";
|
|
8
|
+
import { Alert, AlertDescription } from "@chatsdk-dev/ui/atoms/alert";
|
|
9
|
+
import { Button } from "@chatsdk-dev/ui/atoms/button";
|
|
10
|
+
//#region src/features/chat/error/chat-error.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Inline banner for a stream/transport failure. Renders nothing until the
|
|
13
|
+
* session reports an `appError`; then shows localized copy with a Dismiss
|
|
14
|
+
* action and — only when the error is retryable (network/rate-limit/5xx) — a
|
|
15
|
+
* Retry that re-runs the last turn. The optimistic user message survives the
|
|
16
|
+
* failure, so retry resends it.
|
|
17
|
+
*/
|
|
18
|
+
function Error() {
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
const { appError, retryLastMessage, dismissError } = useChat();
|
|
21
|
+
const getMessage = useAppErrorMessage();
|
|
22
|
+
if (!appError) return null;
|
|
23
|
+
return /* @__PURE__ */ jsxs(Alert, {
|
|
24
|
+
variant: "destructive",
|
|
25
|
+
className: "mx-4 mb-2 w-auto",
|
|
26
|
+
children: [/* @__PURE__ */ jsx(AlertDescription, { children: getMessage(appError) }), /* @__PURE__ */ jsxs("div", {
|
|
27
|
+
className: "col-start-1 mt-1.5 flex gap-2",
|
|
28
|
+
children: [isRetryable(appError) && /* @__PURE__ */ jsxs(Button, {
|
|
29
|
+
size: "sm",
|
|
30
|
+
variant: "outline",
|
|
31
|
+
onClick: retryLastMessage,
|
|
32
|
+
children: [/* @__PURE__ */ jsx(RefreshCw, {}), t("errors.retry")]
|
|
33
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
34
|
+
size: "sm",
|
|
35
|
+
variant: "ghost",
|
|
36
|
+
onClick: dismissError,
|
|
37
|
+
children: [/* @__PURE__ */ jsx(X, {}), t("errors.dismiss")]
|
|
38
|
+
})]
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
Error.displayName = "ChatError";
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Error };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=chat-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-error.js","names":[],"sources":["../../../../src/features/chat/error/chat-error.tsx"],"sourcesContent":["\"use client\";\n\nimport { RefreshCw, X } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { isRetryable } from \"@chatsdk-dev/agent\";\nimport { Alert, AlertDescription } from \"@chatsdk-dev/ui/atoms/alert\";\nimport { Button } from \"@chatsdk-dev/ui/atoms/button\";\n\nimport { useAppErrorMessage } from \"../../errors/use-app-error-message\";\nimport { useChat } from \"../provider/provider\";\n\n/**\n * Inline banner for a stream/transport failure. Renders nothing until the\n * session reports an `appError`; then shows localized copy with a Dismiss\n * action and — only when the error is retryable (network/rate-limit/5xx) — a\n * Retry that re-runs the last turn. The optimistic user message survives the\n * failure, so retry resends it.\n */\nexport function Error() {\n const { t } = useTranslation();\n const { appError, retryLastMessage, dismissError } = useChat();\n const getMessage = useAppErrorMessage();\n\n if (!appError) return null;\n\n return (\n <Alert variant=\"destructive\" className=\"mx-4 mb-2 w-auto\">\n <AlertDescription>{getMessage(appError)}</AlertDescription>\n <div className=\"col-start-1 mt-1.5 flex gap-2\">\n {isRetryable(appError) && (\n <Button size=\"sm\" variant=\"outline\" onClick={retryLastMessage}>\n <RefreshCw />\n {t(\"errors.retry\")}\n </Button>\n )}\n <Button size=\"sm\" variant=\"ghost\" onClick={dismissError}>\n <X />\n {t(\"errors.dismiss\")}\n </Button>\n </div>\n </Alert>\n );\n}\n\nError.displayName = \"ChatError\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAgB,QAAQ;CACtB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,UAAU,kBAAkB,iBAAiB,QAAQ;CAC7D,MAAM,aAAa,mBAAmB;CAEtC,IAAI,CAAC,UAAU,OAAO;CAEtB,OACE,qBAAC,OAAD;EAAO,SAAQ;EAAc,WAAU;YAAvC,CACE,oBAAC,kBAAD,EAAA,UAAmB,WAAW,QAAQ,EAAoB,CAAA,GAC1D,qBAAC,OAAD;GAAK,WAAU;aAAf,CACG,YAAY,QAAQ,KACnB,qBAAC,QAAD;IAAQ,MAAK;IAAK,SAAQ;IAAU,SAAS;cAA7C,CACE,oBAAC,WAAD,CAAY,CAAA,GACX,EAAE,cAAc,CACX;OAEV,qBAAC,QAAD;IAAQ,MAAK;IAAK,SAAQ;IAAQ,SAAS;cAA3C,CACE,oBAAC,GAAD,CAAI,CAAA,GACH,EAAE,gBAAgB,CACb;KACL;IACA;;AAEX;AAEA,MAAM,cAAc"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { c as useElementComponent, f as useGetAgentQuery } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { useListConversationsQuery } from "../queries/use-list-conversations-query.js";
|
|
3
|
+
import { useAppErrorMessage } from "../../errors/use-app-error-message.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { RefreshCw } from "lucide-react";
|
|
8
|
+
import { Alert, AlertDescription } from "@chatsdk-dev/ui/atoms/alert";
|
|
9
|
+
import { Button } from "@chatsdk-dev/ui/atoms/button";
|
|
10
|
+
import { Card } from "@chatsdk-dev/ui/atoms/card";
|
|
11
|
+
import { DotsLoader } from "@chatsdk-dev/ui/atoms/dots-loader";
|
|
12
|
+
//#region src/features/chat/frame/frame.tsx
|
|
13
|
+
function Frame({ className, children }) {
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
const { agentId } = useElementComponent();
|
|
16
|
+
const { isLoading, isError, error, refetch, data: chat } = useGetAgentQuery({ agentId });
|
|
17
|
+
useListConversationsQuery({ agentId });
|
|
18
|
+
const getMessage = useAppErrorMessage();
|
|
19
|
+
const canCreateMessage = (chat?.agentSettingsCore?.allowedModels?.length ?? 0) > 0;
|
|
20
|
+
if (!isError && !canCreateMessage && chat?.agentSettingsSurface?.hideChatWhenInsufficientCredits) return null;
|
|
21
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
22
|
+
className: className ?? "min-w-[320px] h-[640px] w-[412px] flex flex-col relative p-0 rounded-lg gap-0",
|
|
23
|
+
children: [
|
|
24
|
+
isLoading && /* @__PURE__ */ jsx("div", {
|
|
25
|
+
className: "absolute inset-0 flex items-center justify-center z-10 bg-card rounded-lg",
|
|
26
|
+
children: /* @__PURE__ */ jsx(DotsLoader, {})
|
|
27
|
+
}),
|
|
28
|
+
!isLoading && isError && /* @__PURE__ */ jsx("div", {
|
|
29
|
+
className: "absolute inset-0 z-10 flex items-center justify-center bg-card rounded-lg p-4",
|
|
30
|
+
children: /* @__PURE__ */ jsxs(Alert, {
|
|
31
|
+
variant: "destructive",
|
|
32
|
+
className: "w-auto",
|
|
33
|
+
children: [/* @__PURE__ */ jsx(AlertDescription, { children: getMessage(error) }), /* @__PURE__ */ jsx("div", {
|
|
34
|
+
className: "col-start-1 mt-1.5",
|
|
35
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
36
|
+
size: "sm",
|
|
37
|
+
variant: "outline",
|
|
38
|
+
onClick: () => void refetch(),
|
|
39
|
+
children: [/* @__PURE__ */ jsx(RefreshCw, {}), t("errors.retry")]
|
|
40
|
+
})
|
|
41
|
+
})]
|
|
42
|
+
})
|
|
43
|
+
}),
|
|
44
|
+
!isLoading && !isError && children
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
Frame.displayName = "ChatFrame";
|
|
49
|
+
//#endregion
|
|
50
|
+
export { Frame };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.js","names":[],"sources":["../../../../src/features/chat/frame/frame.tsx"],"sourcesContent":["import React from \"react\";\nimport { RefreshCw } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Alert, AlertDescription } from \"@chatsdk-dev/ui/atoms/alert\";\nimport { Button } from \"@chatsdk-dev/ui/atoms/button\";\nimport { Card } from \"@chatsdk-dev/ui/atoms/card\";\nimport { DotsLoader } from \"@chatsdk-dev/ui/atoms/dots-loader\";\n\nimport { useAppErrorMessage } from \"../../errors/use-app-error-message\";\nimport { useElementComponent } from \"../provider/provider\";\nimport { useGetAgentQuery } from \"../queries/use-get-agent-query\";\nimport { useListConversationsQuery } from \"../queries/use-list-conversations-query\";\n\ninterface FrameProps {\n className?: string;\n children: React.ReactNode;\n}\n\nexport function Frame({ className, children }: FrameProps) {\n const { t } = useTranslation();\n const { agentId } = useElementComponent();\n const {\n isLoading,\n isError,\n error,\n refetch,\n data: chat,\n } = useGetAgentQuery({ agentId });\n // Prefetch conversations list so Header/History can read from cache.\n useListConversationsQuery({ agentId });\n const getMessage = useAppErrorMessage();\n\n const canCreateMessage =\n (chat?.agentSettingsCore?.allowedModels?.length ?? 0) > 0;\n\n if (\n !isError &&\n !canCreateMessage &&\n chat?.agentSettingsSurface?.hideChatWhenInsufficientCredits\n ) {\n return null;\n }\n\n return (\n <Card\n className={\n className ??\n \"min-w-[320px] h-[640px] w-[412px] flex flex-col relative p-0 rounded-lg gap-0\"\n }\n >\n {isLoading && (\n <div className=\"absolute inset-0 flex items-center justify-center z-10 bg-card rounded-lg\">\n <DotsLoader />\n </div>\n )}\n {/* Config fetch failed — surface it with a retry instead of an endless\n loader. getMessage (parseAppError) maps a connection failure to\n network_unreachable. */}\n {!isLoading && isError && (\n <div className=\"absolute inset-0 z-10 flex items-center justify-center bg-card rounded-lg p-4\">\n <Alert variant=\"destructive\" className=\"w-auto\">\n <AlertDescription>{getMessage(error)}</AlertDescription>\n <div className=\"col-start-1 mt-1.5\">\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => void refetch()}\n >\n <RefreshCw />\n {t(\"errors.retry\")}\n </Button>\n </div>\n </Alert>\n </div>\n )}\n {!isLoading && !isError && children}\n </Card>\n );\n}\n\nFrame.displayName = \"ChatFrame\";\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,MAAM,EAAE,WAAW,YAAwB;CACzD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,YAAY,oBAAoB;CACxC,MAAM,EACJ,WACA,SACA,OACA,SACA,MAAM,SACJ,iBAAiB,EAAE,QAAQ,CAAC;CAEhC,0BAA0B,EAAE,QAAQ,CAAC;CACrC,MAAM,aAAa,mBAAmB;CAEtC,MAAM,oBACH,MAAM,mBAAmB,eAAe,UAAU,KAAK;CAE1D,IACE,CAAC,WACD,CAAC,oBACD,MAAM,sBAAsB,iCAE5B,OAAO;CAGT,OACE,qBAAC,MAAD;EACE,WACE,aACA;YAHJ;GAMG,aACC,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,YAAD,CAAa,CAAA;GACV,CAAA;GAKN,CAAC,aAAa,WACb,oBAAC,OAAD;IAAK,WAAU;cACb,qBAAC,OAAD;KAAO,SAAQ;KAAc,WAAU;eAAvC,CACE,oBAAC,kBAAD,EAAA,UAAmB,WAAW,KAAK,EAAoB,CAAA,GACvD,oBAAC,OAAD;MAAK,WAAU;gBACb,qBAAC,QAAD;OACE,MAAK;OACL,SAAQ;OACR,eAAe,KAAK,QAAQ;iBAH9B,CAKE,oBAAC,WAAD,CAAY,CAAA,GACX,EAAE,cAAc,CACX;;KACL,CAAA,CACA;;GACJ,CAAA;GAEN,CAAC,aAAa,CAAC,WAAW;EACvB;;AAEV;AAEA,MAAM,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-menu.d.ts","names":[],"sources":["../../../../src/features/chat/frame/header-menu.tsx"],"mappings":";iBAcgB,UAAA,oBAAU,GAAA,CAAA,OAAA;AAAA,kBAAV,UAAA;EAAA,IAAU,WAAA;AAAA"}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { useChatStore } from "
|
|
2
|
-
import {
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { a as useChatStore } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { useCreateNewChat } from "../main/use-create-new-chat.js";
|
|
4
3
|
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Ellipsis } from "lucide-react";
|
|
5
6
|
import { buttonVariants } from "@chatsdk-dev/ui/atoms/button";
|
|
6
7
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@chatsdk-dev/ui/atoms/dropdown-menu";
|
|
7
|
-
//#region src/features/chat/
|
|
8
|
-
function
|
|
8
|
+
//#region src/features/chat/frame/header-menu.tsx
|
|
9
|
+
function HeaderMenu() {
|
|
9
10
|
const { t } = useTranslation();
|
|
10
|
-
const
|
|
11
|
+
const setTab = useChatStore((state) => state.setTab);
|
|
12
|
+
const { createNewChat } = useCreateNewChat();
|
|
11
13
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
12
14
|
className: buttonVariants({ variant: "transparent" }),
|
|
13
15
|
children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
|
|
14
16
|
}), /* @__PURE__ */ jsxs(DropdownMenuContent, { children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
15
|
-
onClick:
|
|
16
|
-
setConversationType("new");
|
|
17
|
-
setSelectedConversationId();
|
|
18
|
-
setTab("chat");
|
|
19
|
-
},
|
|
17
|
+
onClick: createNewChat,
|
|
20
18
|
children: t("header.menu.new-conversation-menu-item-label")
|
|
21
19
|
}), /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
22
20
|
onClick: () => setTab("history"),
|
|
23
21
|
children: t("header.menu.history-menu-item-label")
|
|
24
22
|
})] })] });
|
|
25
23
|
}
|
|
24
|
+
HeaderMenu.displayName = "ChatHeaderMenu";
|
|
26
25
|
//#endregion
|
|
27
|
-
export {
|
|
26
|
+
export { HeaderMenu };
|
|
28
27
|
|
|
29
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=header-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-menu.js","names":[],"sources":["../../../../src/features/chat/frame/header-menu.tsx"],"sourcesContent":["import { Ellipsis } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { buttonVariants } from \"@chatsdk-dev/ui/atoms/button\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"@chatsdk-dev/ui/atoms/dropdown-menu\";\n\nimport { useCreateNewChat } from \"../main/use-create-new-chat\";\nimport { useChatStore } from \"../provider/provider\";\n\nexport function HeaderMenu() {\n const { t } = useTranslation();\n const setTab = useChatStore((state) => state.setTab);\n\n const { createNewChat } = useCreateNewChat();\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n className={buttonVariants({ variant: \"transparent\" })}\n >\n <Ellipsis className=\"size-4\" />\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuItem onClick={createNewChat}>\n {t(\"header.menu.new-conversation-menu-item-label\")}\n </DropdownMenuItem>\n <DropdownMenuItem onClick={() => setTab(\"history\")}>\n {t(\"header.menu.history-menu-item-label\")}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nHeaderMenu.displayName = \"ChatHeaderMenu\";\n"],"mappings":";;;;;;;;AAcA,SAAgB,aAAa;CAC3B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,SAAS,cAAc,UAAU,MAAM,MAAM;CAEnD,MAAM,EAAE,kBAAkB,iBAAiB;CAE3C,OACE,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,qBAAD;EACE,WAAW,eAAe,EAAE,SAAS,cAAc,CAAC;YAEpD,oBAAC,UAAD,EAAU,WAAU,SAAU,CAAA;CACX,CAAA,GACrB,qBAAC,qBAAD,EAAA,UAAA,CACE,oBAAC,kBAAD;EAAkB,SAAS;YACxB,EAAE,8CAA8C;CACjC,CAAA,GAClB,oBAAC,kBAAD;EAAkB,eAAe,OAAO,SAAS;YAC9C,EAAE,qCAAqC;CACxB,CAAA,CACC,EAAA,CAAA,CACT,EAAA,CAAA;AAElB;AAEA,WAAW,cAAc"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { a as useChatStore, c as useElementComponent, f as useGetAgentQuery } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { HeaderMenu } from "./header-menu.js";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ArrowLeft } from "lucide-react";
|
|
6
|
+
import { Button } from "@chatsdk-dev/ui/atoms/button";
|
|
7
|
+
import { CardHeader, CardTitle } from "@chatsdk-dev/ui/atoms/card";
|
|
8
|
+
import { Text } from "@chatsdk-dev/ui/atoms/typography/text";
|
|
9
|
+
//#region src/features/chat/frame/header.tsx
|
|
10
|
+
function Header() {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const { agentId } = useElementComponent();
|
|
13
|
+
const tab = useChatStore((s) => s.tab);
|
|
14
|
+
const setTab = useChatStore((s) => s.setTab);
|
|
15
|
+
const { data } = useGetAgentQuery({ agentId });
|
|
16
|
+
const name = data?.agentSettingsAppearance?.displayName;
|
|
17
|
+
const iconUrl = data?.agentSettingsAppearance?.icon?.url;
|
|
18
|
+
return /* @__PURE__ */ jsxs(CardHeader, {
|
|
19
|
+
className: "flex h-14 items-center justify-between rounded-t-lg bg-primary px-4! mx-[-1px] mt-[-1px] text-primary-foreground ",
|
|
20
|
+
children: [/* @__PURE__ */ jsxs(CardTitle, { children: [tab === "chat" && /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
className: "flex items-center gap-2",
|
|
22
|
+
children: [iconUrl && /* @__PURE__ */ jsx("img", {
|
|
23
|
+
src: iconUrl,
|
|
24
|
+
alt: "Chat Icon",
|
|
25
|
+
className: "inline-block w-4 h-4"
|
|
26
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
27
|
+
variant: "h1",
|
|
28
|
+
className: "flex items-center gap-2 text-sm text-primary-foreground",
|
|
29
|
+
children: name
|
|
30
|
+
})]
|
|
31
|
+
}), tab === "history" && /* @__PURE__ */ jsxs("div", {
|
|
32
|
+
className: "flex items-center gap-2",
|
|
33
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
34
|
+
onClick: () => setTab("chat"),
|
|
35
|
+
variant: "transparent",
|
|
36
|
+
className: "p-0!",
|
|
37
|
+
children: /* @__PURE__ */ jsx(ArrowLeft, { className: "size-4" })
|
|
38
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
39
|
+
variant: "h1",
|
|
40
|
+
className: "flex items-center gap-2 text-sm text-primary-foreground",
|
|
41
|
+
children: t("header.history-tab-label")
|
|
42
|
+
})]
|
|
43
|
+
})] }), tab === "chat" && /* @__PURE__ */ jsx(HeaderMenu, {})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
Header.displayName = "ChatHeader";
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Header };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","names":[],"sources":["../../../../src/features/chat/frame/header.tsx"],"sourcesContent":["import { ArrowLeft } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"@chatsdk-dev/ui/atoms/button\";\nimport { CardHeader, CardTitle } from \"@chatsdk-dev/ui/atoms/card\";\nimport { Text } from \"@chatsdk-dev/ui/atoms/typography/text\";\n\nimport { useChatStore, useElementComponent } from \"../provider/provider\";\nimport { useGetAgentQuery } from \"../queries/use-get-agent-query\";\nimport { HeaderMenu } from \"./header-menu\";\n\nexport function Header() {\n const { t } = useTranslation();\n const { agentId } = useElementComponent();\n const tab = useChatStore((s) => s.tab);\n const setTab = useChatStore((s) => s.setTab);\n const { data } = useGetAgentQuery({ agentId });\n // TODO: fix initial loading visuals here (uncached image)\n\n const name = data?.agentSettingsAppearance?.displayName;\n const iconUrl = data?.agentSettingsAppearance?.icon?.url;\n return (\n <CardHeader className=\"flex h-14 items-center justify-between rounded-t-lg bg-primary px-4! mx-[-1px] mt-[-1px] text-primary-foreground \">\n <CardTitle>\n {tab === \"chat\" && (\n <div className=\"flex items-center gap-2\">\n {iconUrl && (\n <img\n src={iconUrl}\n alt=\"Chat Icon\"\n className=\"inline-block w-4 h-4\"\n />\n )}\n <Text\n variant=\"h1\"\n className=\"flex items-center gap-2 text-sm text-primary-foreground\"\n >\n {name}\n </Text>\n </div>\n )}\n {tab === \"history\" && (\n <div className=\"flex items-center gap-2\">\n <Button\n onClick={() => setTab(\"chat\")}\n variant=\"transparent\"\n className=\"p-0!\"\n >\n <ArrowLeft className=\"size-4\" />\n </Button>\n <Text\n variant=\"h1\"\n className=\"flex items-center gap-2 text-sm text-primary-foreground\"\n >\n {t(\"header.history-tab-label\")}\n </Text>\n </div>\n )}\n </CardTitle>\n {tab === \"chat\" && <HeaderMenu />}\n </CardHeader>\n );\n}\n\nHeader.displayName = \"ChatHeader\";\n"],"mappings":";;;;;;;;;AAWA,SAAgB,SAAS;CACvB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,YAAY,oBAAoB;CACxC,MAAM,MAAM,cAAc,MAAM,EAAE,GAAG;CACrC,MAAM,SAAS,cAAc,MAAM,EAAE,MAAM;CAC3C,MAAM,EAAE,SAAS,iBAAiB,EAAE,QAAQ,CAAC;CAG7C,MAAM,OAAO,MAAM,yBAAyB;CAC5C,MAAM,UAAU,MAAM,yBAAyB,MAAM;CACrD,OACE,qBAAC,YAAD;EAAY,WAAU;YAAtB,CACE,qBAAC,WAAD,EAAA,UAAA,CACG,QAAQ,UACP,qBAAC,OAAD;GAAK,WAAU;aAAf,CACG,WACC,oBAAC,OAAD;IACE,KAAK;IACL,KAAI;IACJ,WAAU;GACX,CAAA,GAEH,oBAAC,MAAD;IACE,SAAQ;IACR,WAAU;cAET;GACG,CAAA,CACH;MAEN,QAAQ,aACP,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,QAAD;IACE,eAAe,OAAO,MAAM;IAC5B,SAAQ;IACR,WAAU;cAEV,oBAAC,WAAD,EAAW,WAAU,SAAU,CAAA;GACzB,CAAA,GACR,oBAAC,MAAD;IACE,SAAQ;IACR,WAAU;cAET,EAAE,0BAA0B;GACzB,CAAA,CACH;IAEE,EAAA,CAAA,GACV,QAAQ,UAAU,oBAAC,YAAD,CAAa,CAAA,CACtB;;AAEhB;AAEA,OAAO,cAAc"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/features/chat/history/history-empty.d.ts
|
|
2
|
+
declare function HistoryEmpty(): import("react").JSX.Element;
|
|
3
|
+
declare namespace HistoryEmpty {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { HistoryEmpty };
|
|
8
|
+
//# sourceMappingURL=history-empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-empty.d.ts","names":[],"sources":["../../../../src/features/chat/history/history-empty.tsx"],"mappings":";iBAWgB,YAAA,oBAAY,GAAA,CAAA,OAAA;AAAA,kBAAZ,YAAA;EAAA,IAAY,WAAA;AAAA"}
|