@asgard-js/react 0.0.1 → 0.0.2

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.
Files changed (34) hide show
  1. package/dist/components/chatbot/chatbot-body.d.ts.map +1 -1
  2. package/dist/components/chatbot/chatbot-footer.d.ts.map +1 -1
  3. package/dist/components/chatbot/chatbot-header.d.ts +5 -1
  4. package/dist/components/chatbot/chatbot-header.d.ts.map +1 -1
  5. package/dist/components/chatbot/chatbot.d.ts +7 -3
  6. package/dist/components/chatbot/chatbot.d.ts.map +1 -1
  7. package/dist/components/chatbot/profile-icon.d.ts +4 -0
  8. package/dist/components/chatbot/profile-icon.d.ts.map +1 -0
  9. package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts +1 -1
  10. package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts.map +1 -1
  11. package/dist/components/templates/avatar/avatar.d.ts.map +1 -1
  12. package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts +6 -1
  13. package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts.map +1 -1
  14. package/dist/components/templates/button-template/button-template.d.ts +1 -1
  15. package/dist/components/templates/button-template/button-template.d.ts.map +1 -1
  16. package/dist/components/templates/carousel-template/carousel-template.d.ts +1 -1
  17. package/dist/components/templates/carousel-template/carousel-template.d.ts.map +1 -1
  18. package/dist/components/templates/hint-template/hint-template.d.ts +1 -1
  19. package/dist/components/templates/hint-template/hint-template.d.ts.map +1 -1
  20. package/dist/components/templates/text-template/text-template.d.ts +1 -1
  21. package/dist/components/templates/text-template/text-template.d.ts.map +1 -1
  22. package/dist/context/asgard-service-context.d.ts +11 -5
  23. package/dist/context/asgard-service-context.d.ts.map +1 -1
  24. package/dist/hooks/index.d.ts +0 -1
  25. package/dist/hooks/index.d.ts.map +1 -1
  26. package/dist/hooks/use-channel.d.ts +9 -20
  27. package/dist/hooks/use-channel.d.ts.map +1 -1
  28. package/dist/index.js +337 -313
  29. package/dist/style.css +1 -1
  30. package/package.json +1 -1
  31. package/dist/components/message-box/message-box.d.ts +0 -9
  32. package/dist/components/message-box/message-box.d.ts.map +0 -1
  33. package/dist/hooks/use-chatbot-typing.d.ts +0 -11
  34. package/dist/hooks/use-chatbot-typing.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"chatbot-body.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-body.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAM7C,wBAAgB,WAAW,IAAI,SAAS,CAmBvC"}
1
+ {"version":3,"file":"chatbot-body.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-body.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAM7C,wBAAgB,WAAW,IAAI,SAAS,CA0BvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"chatbot-footer.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-footer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGV,MAAM,OAAO,CAAC;AAIf,wBAAgB,aAAa,IAAI,SAAS,CAkCzC"}
1
+ {"version":3,"file":"chatbot-footer.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-footer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGV,MAAM,OAAO,CAAC;AAIf,wBAAgB,aAAa,IAAI,SAAS,CAiDzC"}
@@ -1,4 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
2
 
3
- export declare function ChatbotHeader(): ReactNode;
3
+ interface ChatbotHeaderProps {
4
+ title: string;
5
+ }
6
+ export declare function ChatbotHeader(props: ChatbotHeaderProps): ReactNode;
7
+ export {};
4
8
  //# sourceMappingURL=chatbot-header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatbot-header.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,wBAAgB,aAAa,IAAI,SAAS,CAEzC"}
1
+ {"version":3,"file":"chatbot-header.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAclE"}
@@ -1,11 +1,15 @@
1
- import { ConversationMessage } from '../../hooks';
2
- import { ClientConfig } from '@asgard-js/core';
1
+ import { ClientConfig, ConversationMessage } from '@asgard-js/core';
3
2
  import { ReactNode } from 'react';
4
3
 
5
4
  interface ChatbotProps {
5
+ title: string;
6
6
  config: ClientConfig;
7
7
  customChannelId: string;
8
- initConversation?: ConversationMessage[];
8
+ initMessages?: ConversationMessage[];
9
+ fullScreen?: boolean;
10
+ options?: {
11
+ showDebugMessage?: boolean;
12
+ };
9
13
  }
10
14
  export declare function Chatbot(props: ChatbotProps): ReactNode;
11
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"chatbot.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAM/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,UAAU,YAAY;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC1C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CAetD"}
1
+ {"version":3,"file":"chatbot.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/chatbot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQpE,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CA0BtD"}
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ export declare function ProfileIcon(): ReactNode;
4
+ //# sourceMappingURL=profile-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-icon.d.ts","sourceRoot":"","sources":["../../../src/components/chatbot/profile-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,wBAAgB,WAAW,IAAI,SAAS,CA+BvC"}
@@ -1,4 +1,4 @@
1
- import { ConversationMessage } from '../../hooks';
1
+ import { ConversationMessage } from '@asgard-js/core';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  interface ConversationMessageRendererProps {
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-message-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-message-renderer/conversation-message-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAShD,UAAU,gCAAgC;IACxC,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gCAAgC,GACtC,SAAS,CAqBX"}
1
+ {"version":3,"file":"conversation-message-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-message-renderer/conversation-message-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iBAAiB,CAAC;AAQ3E,UAAU,gCAAgC;IACxC,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gCAAgC,GACtC,SAAS,CAqBX"}
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,wBAAgB,MAAM,IAAI,SAAS,CAqBlC"}
1
+ {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/avatar/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,wBAAgB,MAAM,IAAI,SAAS,CAoBlC"}
@@ -1,4 +1,9 @@
1
+ import { ConversationBotMessage } from '@asgard-js/core';
1
2
  import { ReactNode } from 'react';
2
3
 
3
- export declare function BotTypingBox(): ReactNode;
4
+ interface BotTypingBoxProps {
5
+ typingMessage: ConversationBotMessage;
6
+ }
7
+ export declare function BotTypingBox(props: BotTypingBoxProps): ReactNode;
8
+ export {};
4
9
  //# sourceMappingURL=bot-typing-box.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bot-typing-box.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/bot-typing-box/bot-typing-box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAQ/C,wBAAgB,YAAY,IAAI,SAAS,CA4BxC"}
1
+ {"version":3,"file":"bot-typing-box.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/bot-typing-box/bot-typing-box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAO/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,UAAU,iBAAiB;IACzB,aAAa,EAAE,sBAAsB,CAAC;CACvC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA+BhE"}
@@ -1,5 +1,5 @@
1
- import { ConversationBotMessage } from '../../../hooks';
2
1
  import { ReactNode } from 'react';
2
+ import { ConversationBotMessage } from '@asgard-js/core';
3
3
 
4
4
  interface ButtonTemplateProps {
5
5
  conversationMessage: ConversationBotMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"button-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/button-template/button-template.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAKnD,UAAU,mBAAmB;IAC3B,mBAAmB,EAAE,sBAAsB,CAAC;CAC7C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAiBpE"}
1
+ {"version":3,"file":"button-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/button-template/button-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKlC,UAAU,mBAAmB;IAC3B,mBAAmB,EAAE,sBAAsB,CAAC;CAC7C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAiBpE"}
@@ -1,4 +1,4 @@
1
- import { ConversationBotMessage } from '../../../hooks';
1
+ import { ConversationBotMessage } from '@asgard-js/core';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  interface CarouselTemplateProps {
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/carousel-template/carousel-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAQnD,UAAU,qBAAqB;IAC7B,mBAAmB,EAAE,sBAAsB,CAAC;CAC7C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAiBxE"}
1
+ {"version":3,"file":"carousel-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/carousel-template/carousel-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKlC,OAAO,EAEL,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAGzB,UAAU,qBAAqB;IAC7B,mBAAmB,EAAE,sBAAsB,CAAC;CAC7C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAiBxE"}
@@ -1,4 +1,4 @@
1
- import { ConversationMessage } from '../../../hooks';
1
+ import { ConversationMessage } from '@asgard-js/core';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  interface HintTemplateProps {
@@ -1 +1 @@
1
- {"version":3,"file":"hint-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/hint-template/hint-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIhD,UAAU,iBAAiB;IACzB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAehE"}
1
+ {"version":3,"file":"hint-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/hint-template/hint-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iBAAiB,CAAC;AAE3E,UAAU,iBAAiB;IACzB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAehE"}
@@ -1,4 +1,4 @@
1
- import { ConversationMessage } from '../../../hooks';
1
+ import { ConversationMessage } from '@asgard-js/core';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  interface TextTemplateProps {
@@ -1 +1 @@
1
- {"version":3,"file":"text-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/text-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAMhD,UAAU,iBAAiB;IACzB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA2BhE"}
1
+ {"version":3,"file":"text-template.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/text-template.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMtD,UAAU,iBAAiB;IACzB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CA2BhE"}
@@ -1,11 +1,14 @@
1
- import { ConversationMessage, UseChannelReturn, UseChatbotTypingReturn } from '../hooks';
1
+ import { UseChannelReturn } from '../hooks';
2
2
  import { DetailedHTMLProps, HTMLAttributes, ReactNode, RefObject } from 'react';
3
- import { AsgardServiceClient, ClientConfig } from '@asgard-js/core';
3
+ import { AsgardServiceClient, ClientConfig, ConversationBotMessage, ConversationMessage } from '@asgard-js/core';
4
4
 
5
- interface AsgardServiceContextType extends Pick<UseChatbotTypingReturn, 'isTyping' | 'displayText'>, Pick<UseChannelReturn, 'conversation' | 'sendMessage'> {
5
+ interface AsgardServiceContextType {
6
6
  client: AsgardServiceClient | null;
7
+ isConnecting: boolean;
8
+ messages: Map<string, ConversationMessage> | null;
9
+ typingMessages: Map<string, ConversationBotMessage> | null;
7
10
  messageBoxBottomRef: RefObject<HTMLDivElement>;
8
- isConnectionProcessing: boolean;
11
+ sendMessage: UseChannelReturn['sendMessage'];
9
12
  }
10
13
  export declare const AsgardServiceContext: import('react').Context<AsgardServiceContextType>;
11
14
  interface AsgardServiceContextProviderProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
@@ -14,7 +17,10 @@ interface AsgardServiceContextProviderProps extends DetailedHTMLProps<HTMLAttrib
14
17
  customChannelId: string;
15
18
  customMessageId?: string;
16
19
  delayTime?: number;
17
- initConversation?: ConversationMessage[];
20
+ options?: {
21
+ showDebugMessage?: boolean;
22
+ };
23
+ initMessages?: ConversationMessage[];
18
24
  }
19
25
  export declare function AsgardServiceContextProvider(props: AsgardServiceContextProviderProps): ReactNode;
20
26
  export declare function useAsgardContext(): AsgardServiceContextType;
@@ -1 +1 @@
1
- {"version":3,"file":"asgard-service-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-service-context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,SAAS,EAIV,MAAM,OAAO,CAAC;AACf,OAAO,EACL,mBAAmB,EAGnB,gBAAgB,EAEhB,sBAAsB,EACvB,MAAM,WAAW,CAAC;AAEnB,UAAU,wBACR,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,aAAa,CAAC,EAC9D,IAAI,CAAC,gBAAgB,EAAE,cAAc,GAAG,aAAa,CAAC;IACxD,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC/C,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,oBAAoB,mDAQ/B,CAAC;AAEH,UAAU,iCACR,SAAQ,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzE,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC1C;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,SAAS,CAqDX;AAED,wBAAgB,gBAAgB,IAAI,wBAAwB,CAE3D"}
1
+ {"version":3,"file":"asgard-service-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-service-context.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,SAAS,EAIV,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,UAAU,wBAAwB;IAChC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI,CAAC;IAC3D,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAC/C,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,oBAAoB,mDAO/B,CAAC;AAEH,UAAU,iCACR,SAAQ,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzE,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,SAAS,CAwCX;AAED,wBAAgB,gBAAgB,IAAI,wBAAwB,CAE3D"}
@@ -1,5 +1,4 @@
1
1
  export * from './use-asgard-service-client';
2
2
  export * from './use-channel';
3
- export * from './use-chatbot-typing';
4
3
  export * from './use-debounce';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
@@ -1,28 +1,17 @@
1
- import { UseChatbotTypingReturn } from './use-chatbot-typing';
2
- import { AsgardServiceClient, EventType, Message, SSEResponse } from '@asgard-js/core';
1
+ import { AsgardServiceClient, ConversationBotMessage, ConversationMessage, EventType, SseResponse } from '@asgard-js/core';
3
2
 
4
- export type ConversationUserMessage = {
5
- type: 'user';
6
- customMessageId?: string;
7
- text: string;
8
- time: Date;
9
- };
10
- export type ConversationBotMessage = {
11
- type: 'bot';
12
- eventType: EventType;
13
- message: Message;
14
- time: Date;
15
- };
16
- export type ConversationMessage = ConversationUserMessage | ConversationBotMessage;
17
- interface UseChannelProps extends Pick<UseChatbotTypingReturn, 'startTyping' | 'onTyping' | 'stopTyping'> {
3
+ interface UseChannelProps {
18
4
  client: AsgardServiceClient | null;
19
5
  customChannelId: string;
20
- initConversation?: ConversationMessage[];
21
- onResetChannelInit?: (event: SSEResponse<EventType.INIT>) => void;
6
+ initMessages?: ConversationMessage[];
7
+ options?: {
8
+ showDebugMessage?: boolean;
9
+ };
10
+ onResetChannelInit?: (event: SseResponse<EventType.INIT>) => void;
22
11
  }
23
12
  export interface UseChannelReturn {
24
- conversation: ConversationMessage[];
25
- isConnectionProcessing: boolean;
13
+ messages: Map<string, ConversationMessage> | null;
14
+ typingMessages: Map<string, ConversationBotMessage> | null;
26
15
  sendMessage: (text: string, customMessageId?: string) => void;
27
16
  }
28
17
  export declare function useChannel(props: UseChannelProps): UseChannelReturn;
@@ -1 +1 @@
1
- {"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,SAAS,EAET,OAAO,EACP,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,uBAAuB,GACvB,sBAAsB,CAAC;AAE3B,UAAU,eACR,SAAQ,IAAI,CACV,sBAAsB,EACtB,aAAa,GAAG,UAAU,GAAG,YAAY,CAC1C;IACD,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACzC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,sBAAsB,EAAE,OAAO,CAAC;IAChC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CA+GnE"}
1
+ {"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEnB,sBAAsB,EACtB,mBAAmB,EACnB,SAAS,EACT,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAGzB,UAAU,eAAe;IACvB,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,IAAI,CAAC;IAC3D,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAuEnE"}
package/dist/index.js CHANGED
@@ -1,238 +1,241 @@
1
- import { jsx as o, jsxs as i } from "react/jsx-runtime";
2
- import { useRef as q, useEffect as m, useState as C, useCallback as h, createContext as Q, useMemo as A, useContext as W } from "react";
3
- import { AsgardServiceClient as X, FetchSSEAction as z, EventType as S, MessageTemplateType as w } from "@asgard-js/core";
4
- function J(n) {
5
- const { config: t } = n, e = q(null);
6
- return e.current || (e.current = new X(t)), m(() => () => {
1
+ import { jsx as o, jsxs as r } from "react/jsx-runtime";
2
+ import { useRef as H, useEffect as y, useState as k, useCallback as g, useMemo as x, createContext as F, useContext as K } from "react";
3
+ import { AsgardServiceClient as Q, Conversation as W, MessageTemplateType as C } from "@asgard-js/core";
4
+ function V(n) {
5
+ var t, e, s = "";
6
+ if (typeof n == "string" || typeof n == "number") s += n;
7
+ else if (typeof n == "object") if (Array.isArray(n)) {
8
+ var c = n.length;
9
+ for (t = 0; t < c; t++) n[t] && (e = V(n[t])) && (s && (s += " "), s += e);
10
+ } else for (e in n) n[e] && (s && (s += " "), s += e);
11
+ return s;
12
+ }
13
+ function u() {
14
+ for (var n, t, e = 0, s = "", c = arguments.length; e < c; e++) (n = arguments[e]) && (t = V(n)) && (s && (s += " "), s += t);
15
+ return s;
16
+ }
17
+ function X(n) {
18
+ const { config: t } = n, e = H(null);
19
+ return e.current || (e.current = new Q(t)), y(() => () => {
7
20
  e.current && (e.current.close(), e.current = null);
8
21
  }, [t]), e.current;
9
22
  }
10
- function Y(n) {
11
- const {
12
- client: t,
13
- customChannelId: e,
14
- initConversation: s,
15
- onResetChannelInit: c,
16
- startTyping: l,
17
- onTyping: r,
18
- stopTyping: a
19
- } = n;
23
+ function G(n) {
24
+ const { client: t, customChannelId: e, initMessages: s, options: c } = n;
20
25
  if (!t)
21
26
  throw new Error("Client instance is required");
22
27
  if (!e)
23
28
  throw new Error("Custom channel id is required");
24
- const [_, u] = C(!1), [p, v] = C(
25
- s ?? []
29
+ const [a, _] = k(
30
+ new W({
31
+ messages: new Map(
32
+ s == null ? void 0 : s.map((i) => [i.messageId, i])
33
+ ),
34
+ typingMessages: null
35
+ })
26
36
  );
27
- m(() => {
28
- console.log("conversation", p);
29
- }, [p]), m(() => {
30
- t.setChannel(
31
- {
32
- customChannelId: e,
33
- customMessageId: "",
34
- text: ""
35
- },
36
- {
37
- onStart: () => u(!0),
38
- onCompleted: () => u(!1)
39
- }
40
- );
37
+ y(() => {
38
+ t.setChannel({
39
+ customChannelId: e,
40
+ customMessageId: ""
41
+ });
41
42
  }, [t, e]);
42
- const B = h(
43
- (d, g) => {
44
- v(
45
- (b) => b.concat({
46
- type: "user",
47
- customMessageId: g,
48
- text: d,
49
- time: /* @__PURE__ */ new Date()
50
- })
51
- ), t.sendMessage(
52
- {
53
- customChannelId: e,
54
- customMessageId: g,
55
- text: d
56
- },
57
- {
58
- onStart: () => u(!0),
59
- onCompleted: () => u(!1)
60
- }
61
- );
43
+ const l = g(
44
+ (i, h) => {
45
+ _((d) => {
46
+ const p = d.pushMessage(
47
+ d,
48
+ {
49
+ type: "user",
50
+ messageId: h ?? crypto.randomUUID(),
51
+ text: i,
52
+ time: /* @__PURE__ */ new Date()
53
+ }
54
+ );
55
+ return t.sendMessage(
56
+ {
57
+ customChannelId: e,
58
+ customMessageId: h,
59
+ text: i
60
+ },
61
+ {
62
+ onSseMessage: (N) => {
63
+ _(
64
+ (M) => p.onMessage(M, N, {
65
+ showDebugMessage: c == null ? void 0 : c.showDebugMessage
66
+ })
67
+ );
68
+ }
69
+ }
70
+ ), p;
71
+ });
62
72
  },
63
- [t, e]
73
+ [t, e, c]
74
+ );
75
+ return x(
76
+ () => ({
77
+ messages: a.messages,
78
+ typingMessages: a.typingMessages,
79
+ sendMessage: l
80
+ }),
81
+ [a, l]
64
82
  );
65
- return m(() => {
66
- c && t.on(z.RESET_CHANNEL, S.INIT, c);
67
- }, [t, c]), m(() => {
68
- t.on(z.NONE, S.MESSAGE_START, (d) => {
69
- l(d.fact.messageStart.message);
70
- });
71
- }, [t, l]), m(() => {
72
- t.on(z.NONE, S.MESSAGE_DELTA, (d) => {
73
- r(d.fact.messageDelta.message);
74
- });
75
- }, [t, r]), m(() => {
76
- t.on(z.NONE, S.MESSAGE_COMPLETE, (d) => {
77
- const { eventType: g, fact: b } = d, T = b.messageComplete.message;
78
- T.isDebug || v(
79
- (E) => E.concat({
80
- type: "bot",
81
- eventType: g,
82
- message: T,
83
- time: /* @__PURE__ */ new Date()
84
- })
85
- ), a();
86
- });
87
- }, [t, a]), {
88
- conversation: p,
89
- sendMessage: B,
90
- isConnectionProcessing: _
91
- };
92
83
  }
93
- function tt(n, t) {
94
- const [e, s] = C(n);
95
- return m(() => {
84
+ function J(n, t) {
85
+ const [e, s] = k(n);
86
+ return y(() => {
96
87
  const c = window.setTimeout(() => {
97
88
  s(n);
98
89
  }, t ?? 300);
99
90
  return () => clearTimeout(c);
100
91
  }, [n, t]), e;
101
92
  }
102
- function et() {
103
- const [n, t] = C(!1), [e, s] = C(null), c = h(() => t(!0), [t]), l = h((_) => {
104
- s((u) => (u ?? "") + _.text);
105
- }, []), r = h(() => {
106
- t(!1), s(null);
107
- }, [t]);
108
- return {
109
- isTyping: tt(n, 500),
110
- displayText: e,
111
- startTyping: c,
112
- onTyping: l,
113
- stopTyping: r
114
- };
115
- }
116
- const U = Q({
93
+ const E = F({
117
94
  client: null,
118
- isTyping: !1,
119
- displayText: null,
95
+ isConnecting: !1,
96
+ messages: null,
97
+ typingMessages: null,
120
98
  messageBoxBottomRef: { current: null },
121
- isConnectionProcessing: !1,
122
- conversation: [],
123
99
  sendMessage: () => {
124
100
  }
125
101
  });
126
- function nt(n) {
102
+ function Y(n) {
127
103
  const {
128
104
  children: t,
129
105
  config: e,
130
106
  customChannelId: s,
131
107
  customMessageId: c,
132
- delayTime: l,
133
- initConversation: r,
134
- ...a
135
- } = n, _ = q(null), u = J({ config: e }), { isTyping: p, displayText: v, startTyping: B, onTyping: d, stopTyping: g } = et(), { sendMessage: b, conversation: T, isConnectionProcessing: E } = Y({
136
- client: u,
108
+ delayTime: a,
109
+ initMessages: _,
110
+ options: l,
111
+ ...i
112
+ } = n, h = H(null), d = X({ config: e }), { messages: p, typingMessages: N, sendMessage: M } = G({
113
+ client: d,
137
114
  customChannelId: s,
138
- startTyping: B,
139
- onTyping: d,
140
- stopTyping: g,
141
- initConversation: r
142
- }), K = A(
115
+ initMessages: _,
116
+ options: l
117
+ }), L = x(
143
118
  () => ({
144
- client: u,
145
- isTyping: p,
146
- displayText: v,
147
- messageBoxBottomRef: _,
148
- isConnectionProcessing: E,
149
- conversation: T,
150
- sendMessage: b
119
+ client: d,
120
+ isConnecting: (d == null ? void 0 : d.isConnecting) ?? !1,
121
+ messages: p,
122
+ typingMessages: N,
123
+ sendMessage: M,
124
+ messageBoxBottomRef: h
151
125
  }),
152
- [
153
- u,
154
- T,
155
- v,
156
- _,
157
- E,
158
- p,
159
- b
160
- ]
126
+ [d, p, M, N]
161
127
  );
162
- return /* @__PURE__ */ o(U.Provider, { value: K, children: /* @__PURE__ */ o("div", { ...a, children: t }) });
128
+ return /* @__PURE__ */ o(E.Provider, { value: L, children: /* @__PURE__ */ o("div", { ...i, children: t }) });
163
129
  }
164
- function k() {
165
- return W(U);
130
+ function w() {
131
+ return K(E);
166
132
  }
167
- const ot = "_chatbot_header_uinpm_1", st = {
168
- chatbot_header: ot
133
+ const tt = "_chatbot_header_1xj9n_1", et = "_chatbot_header__content_1xj9n_1", ot = "_chatbot_header__title_1xj9n_9", nt = "_chatbot_header__extra_1xj9n_20", T = {
134
+ chatbot_header: tt,
135
+ chatbot_header__content: et,
136
+ chatbot_header__title: ot,
137
+ chatbot_header__extra: nt
169
138
  };
170
- function ct() {
171
- return /* @__PURE__ */ o("div", { className: st.chatbot_header, children: "Header" });
139
+ function st() {
140
+ return /* @__PURE__ */ r(
141
+ "svg",
142
+ {
143
+ width: "33",
144
+ height: "32",
145
+ viewBox: "0 0 33 32",
146
+ fill: "none",
147
+ xmlns: "http://www.w3.org/2000/svg",
148
+ children: [
149
+ /* @__PURE__ */ r("g", { "clip-path": "url(#clip0_3084_29383)", children: [
150
+ /* @__PURE__ */ o(
151
+ "path",
152
+ {
153
+ d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z",
154
+ fill: "#333333"
155
+ }
156
+ ),
157
+ /* @__PURE__ */ o(
158
+ "path",
159
+ {
160
+ "fill-rule": "evenodd",
161
+ "clip-rule": "evenodd",
162
+ d: "M16.5788 6.33398C19.8925 6.33398 22.5788 9.02028 22.5788 12.334C22.5788 14.2211 21.7075 15.9048 20.3453 17.0047C23.6487 18.3735 26.0607 21.6974 26.4106 25.6673H24.4569C24.0206 21.6274 20.9742 18.4911 17.2591 18.3397L16.9776 18.334H16.5788H15.8437C12.0019 18.334 8.81164 21.5258 8.36437 25.6673H6.41064C6.76857 21.607 9.28344 18.2225 12.7029 16.9143C11.4036 15.8137 10.5788 14.1701 10.5788 12.334C10.5788 9.02028 13.265 6.33398 16.5788 6.33398ZM16.5788 16.334C18.7879 16.334 20.5788 14.5431 20.5788 12.334C20.5788 10.1248 18.7879 8.33398 16.5788 8.33398C14.3696 8.33398 12.5788 10.1248 12.5788 12.334C12.5788 14.5431 14.3696 16.334 16.5788 16.334Z",
163
+ fill: "#8C8C8C"
164
+ }
165
+ )
166
+ ] }),
167
+ /* @__PURE__ */ o("defs", { children: /* @__PURE__ */ o("clipPath", { id: "clip0_3084_29383", children: /* @__PURE__ */ o(
168
+ "path",
169
+ {
170
+ d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z",
171
+ fill: "white"
172
+ }
173
+ ) }) })
174
+ ]
175
+ }
176
+ );
177
+ }
178
+ function ct(n) {
179
+ const { title: t } = n;
180
+ return /* @__PURE__ */ o("div", { className: T.chatbot_header, children: /* @__PURE__ */ r("div", { className: T.chatbot_header__content, children: [
181
+ /* @__PURE__ */ r("div", { className: T.chatbot_header__title, children: [
182
+ /* @__PURE__ */ o(st, {}),
183
+ /* @__PURE__ */ o("h4", { children: t })
184
+ ] }),
185
+ /* @__PURE__ */ o("div", { className: T.chatbot_header__extra })
186
+ ] }) });
172
187
  }
173
- const rt = "_chatbot_body_okhax_1", it = {
174
- chatbot_body: rt
175
- }, at = "_template_box_1ozig_1", f = {
176
- template_box: at,
188
+ const rt = "_chatbot_body_1f0gq_1", at = "_chatbot_body__content_1f0gq_7", $ = {
189
+ chatbot_body: rt,
190
+ chatbot_body__content: at
191
+ }, it = "_template_box_1ozig_1", m = {
192
+ template_box: it,
177
193
  "template_box--bot": "_template_box--bot_1ozig_7",
178
194
  "template_box--horizontal": "_template_box--horizontal_1ozig_7",
179
195
  "template_box--vertical": "_template_box--vertical_1ozig_10",
180
196
  "template_box--user": "_template_box--user_1ozig_14"
181
197
  };
182
- function L(n) {
183
- var t, e, s = "";
184
- if (typeof n == "string" || typeof n == "number") s += n;
185
- else if (typeof n == "object") if (Array.isArray(n)) {
186
- var c = n.length;
187
- for (t = 0; t < c; t++) n[t] && (e = L(n[t])) && (s && (s += " "), s += e);
188
- } else for (e in n) n[e] && (s && (s += " "), s += e);
189
- return s;
190
- }
191
- function x() {
192
- for (var n, t, e = 0, s = "", c = arguments.length; e < c; e++) (n = arguments[e]) && (t = L(n)) && (s && (s += " "), s += t);
193
- return s;
194
- }
195
- function M(n) {
196
- const { type: t, direction: e = "horizontal", children: s } = n, c = A(() => {
198
+ function v(n) {
199
+ const { type: t, direction: e = "horizontal", children: s } = n, c = x(() => {
197
200
  switch (t) {
198
201
  case "user":
199
- return x(f.template_box, f["template_box--user"]);
202
+ return u(m.template_box, m["template_box--user"]);
200
203
  case "bot":
201
204
  default:
202
- return x(
203
- f.template_box,
204
- f["template_box--bot"],
205
- e === "horizontal" ? f["template_box--horizontal"] : f["template_box--vertical"]
205
+ return u(
206
+ m.template_box,
207
+ m["template_box--bot"],
208
+ e === "horizontal" ? m["template_box--horizontal"] : m["template_box--vertical"]
206
209
  );
207
210
  }
208
211
  }, [e, t]);
209
212
  return /* @__PURE__ */ o("div", { className: c, children: s });
210
213
  }
211
- const lt = "_template_box_content_12ojl_1", _t = "_content_12ojl_7", D = {
214
+ const lt = "_template_box_content_12ojl_1", _t = "_content_12ojl_7", q = {
212
215
  template_box_content: lt,
213
216
  content: _t
214
- }, ut = "_quick_replies_box_19pe0_1", dt = "_quick_reply_19pe0_7", V = {
215
- quick_replies_box: ut,
216
- quick_reply: dt
217
+ }, dt = "_quick_replies_box_19pe0_1", ht = "_quick_reply_19pe0_7", S = {
218
+ quick_replies_box: dt,
219
+ quick_reply: ht
217
220
  };
218
- function mt(n) {
219
- const { quickReplies: t } = n, { sendMessage: e } = k(), s = h(
221
+ function ut(n) {
222
+ const { quickReplies: t } = n, { sendMessage: e } = w(), s = g(
220
223
  (c) => {
221
224
  e(c);
222
225
  },
223
226
  [e]
224
227
  );
225
- return t != null && t.length ? /* @__PURE__ */ o("div", { className: V.quick_replies_box, children: t.map((c) => /* @__PURE__ */ o(
228
+ return t != null && t.length ? /* @__PURE__ */ o("div", { className: S.quick_replies_box, children: t.map((c) => /* @__PURE__ */ o(
226
229
  "div",
227
230
  {
228
- className: V.quick_reply,
231
+ className: S.quick_reply,
229
232
  onClick: () => s(c.text),
230
233
  children: c.text
231
234
  },
232
235
  c.text
233
236
  )) }) : null;
234
237
  }
235
- function F(n) {
238
+ function O(n) {
236
239
  return n.toLocaleTimeString("zh-TW", {
237
240
  timeZone: "Asia/Taipei",
238
241
  hour: "2-digit",
@@ -240,32 +243,31 @@ function F(n) {
240
243
  hour12: !1
241
244
  });
242
245
  }
243
- const ht = "_time_rgg92_1", pt = {
244
- time: ht
246
+ const mt = "_time_rgg92_1", bt = {
247
+ time: mt
245
248
  };
246
- function $(n) {
249
+ function I(n) {
247
250
  const { time: t, className: e } = n;
248
- return t ? /* @__PURE__ */ o("div", { className: x(pt.time, e), children: F(t) }) : null;
251
+ return t ? /* @__PURE__ */ o("div", { className: u(bt.time, e), children: O(t) }) : null;
249
252
  }
250
- function H(n) {
253
+ function R(n) {
251
254
  const { quickReplies: t, time: e, children: s } = n;
252
- return /* @__PURE__ */ i("div", { className: D.template_box_content, children: [
253
- /* @__PURE__ */ i("div", { className: D.content, children: [
255
+ return /* @__PURE__ */ r("div", { className: q.template_box_content, children: [
256
+ /* @__PURE__ */ r("div", { className: q.content, children: [
254
257
  s,
255
- /* @__PURE__ */ o($, { time: e })
258
+ /* @__PURE__ */ o(I, { time: e })
256
259
  ] }),
257
- !!(t != null && t.length) && /* @__PURE__ */ o(mt, { quickReplies: t })
260
+ !!(t != null && t.length) && /* @__PURE__ */ o(ut, { quickReplies: t })
258
261
  ] });
259
262
  }
260
- const gt = "_bot_avatar_14r1r_1", bt = {
263
+ const gt = "_bot_avatar_14r1r_1", pt = {
261
264
  bot_avatar: gt
262
265
  };
263
- function I() {
264
- return /* @__PURE__ */ o("div", { className: bt.bot_avatar, children: /* @__PURE__ */ i(
266
+ function z() {
267
+ return /* @__PURE__ */ o("div", { className: pt.bot_avatar, children: /* @__PURE__ */ r(
265
268
  "svg",
266
269
  {
267
- width: "25",
268
- height: "24",
270
+ style: { width: "100%", height: "100%" },
269
271
  viewBox: "0 0 25 24",
270
272
  fill: "none",
271
273
  xmlns: "http://www.w3.org/2000/svg",
@@ -288,20 +290,20 @@ function I() {
288
290
  }
289
291
  ) });
290
292
  }
291
- const ft = "_text_1b4yq_1", yt = "_dot_1b4yq_18", Ct = "_blink_1b4yq_1", y = {
293
+ const ft = "_text_1djgp_1", Ct = "_dot_1djgp_18", xt = "_blink_1djgp_1", b = {
292
294
  text: ft,
293
- "text--bot": "_text--bot_1b4yq_7",
294
- "typing-indicator": "_typing-indicator_1b4yq_13",
295
- dot: yt,
296
- blink: Ct
295
+ "text--bot": "_text--bot_1djgp_7",
296
+ "typing-indicator": "_typing-indicator_1djgp_13",
297
+ dot: Ct,
298
+ blink: xt
297
299
  };
298
- function xt(n) {
299
- const { children: t, onResize: e } = n, s = q(null);
300
- return m(() => {
301
- const c = new ResizeObserver((l) => {
302
- for (const r of l) {
303
- const { width: a, height: _ } = r.contentRect;
304
- e(a, _);
300
+ function vt(n) {
301
+ const { children: t, onResize: e } = n, s = H(null);
302
+ return y(() => {
303
+ const c = new ResizeObserver((a) => {
304
+ for (const _ of a) {
305
+ const { width: l, height: i } = _.contentRect;
306
+ e(l, i);
305
307
  }
306
308
  });
307
309
  return s.current && c.observe(s.current), () => {
@@ -309,33 +311,33 @@ function xt(n) {
309
311
  };
310
312
  }, [s, e]), /* @__PURE__ */ o("div", { ref: s, children: t });
311
313
  }
312
- function vt() {
313
- const { isTyping: n, displayText: t, messageBoxBottomRef: e } = k(), s = h(() => {
314
- var c;
315
- (c = e.current) == null || c.scrollIntoView({ behavior: "smooth" });
316
- }, [e]);
317
- return n ? /* @__PURE__ */ i(M, { type: "bot", direction: "horizontal", children: [
318
- /* @__PURE__ */ o(I, {}),
319
- /* @__PURE__ */ o(H, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ o("div", { className: x(y.text, y["text--bot"]), children: /* @__PURE__ */ i(xt, { onResize: s, children: [
320
- /* @__PURE__ */ o("span", { children: t ?? "" }),
321
- n && /* @__PURE__ */ i("span", { className: y["typing-indicator"], children: [
322
- /* @__PURE__ */ o("div", { className: y.dot }),
323
- /* @__PURE__ */ o("div", { className: y.dot }),
324
- /* @__PURE__ */ o("div", { className: y.dot })
314
+ function yt(n) {
315
+ const { typingMessage: t } = n, { messageBoxBottomRef: e } = w(), s = g(() => {
316
+ var a;
317
+ (a = e.current) == null || a.scrollIntoView({ behavior: "smooth" });
318
+ }, [e]), c = J(t == null ? void 0 : t.isTyping, 500);
319
+ return c ? /* @__PURE__ */ r(v, { type: "bot", direction: "horizontal", children: [
320
+ /* @__PURE__ */ o(z, {}),
321
+ /* @__PURE__ */ o(R, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ o("div", { className: u(b.text, b["text--bot"]), children: /* @__PURE__ */ r(vt, { onResize: s, children: [
322
+ /* @__PURE__ */ o("span", { children: (t == null ? void 0 : t.typingText) ?? "" }),
323
+ c && /* @__PURE__ */ r("span", { className: b["typing-indicator"], children: [
324
+ /* @__PURE__ */ o("div", { className: b.dot }),
325
+ /* @__PURE__ */ o("div", { className: b.dot }),
326
+ /* @__PURE__ */ o("div", { className: b.dot })
325
327
  ] })
326
328
  ] }) }) })
327
329
  ] }) : null;
328
330
  }
329
- const Tt = "_card_root_1ygom_1", Nt = "_card_content_1ygom_10", wt = "_card_title_1ygom_17", Mt = "_card_description_1ygom_23", kt = "_card_actions_1ygom_37", N = {
330
- card_root: Tt,
331
+ const wt = "_card_root_1ygom_1", Nt = "_card_content_1ygom_10", Mt = "_card_title_1ygom_17", Tt = "_card_description_1ygom_23", jt = "_card_actions_1ygom_37", f = {
332
+ card_root: wt,
331
333
  card_content: Nt,
332
- card_title: wt,
333
- card_description: Mt,
334
- card_actions: kt
334
+ card_title: Mt,
335
+ card_description: Tt,
336
+ card_actions: jt
335
337
  };
336
- function G(n) {
337
- var r;
338
- const { template: t } = n, { sendMessage: e } = k(), s = A(() => (t == null ? void 0 : t.thumbnailImageUrl.replace(/^http:/, "").replace(/^https:/, "")) || "https://via.assets.so/img.jpg?w=200&h=270&tc=white&bg=#eeeeee", [t]), c = A(() => {
338
+ function P(n) {
339
+ var _;
340
+ const { template: t } = n, { sendMessage: e } = w(), s = x(() => (t == null ? void 0 : t.thumbnailImageUrl.replace(/^http:/, "").replace(/^https:/, "")) || "https://via.assets.so/img.jpg?w=200&h=270&tc=white&bg=#eeeeee", [t]), c = x(() => {
339
341
  switch (t == null ? void 0 : t.imageAspectRatio) {
340
342
  case "square":
341
343
  return "1 / 1";
@@ -343,20 +345,20 @@ function G(n) {
343
345
  default:
344
346
  return "1.51 / 1";
345
347
  }
346
- }, [t]), l = h(
347
- (a) => function() {
348
- switch (a.type) {
348
+ }, [t]), a = g(
349
+ (l) => function() {
350
+ switch (l.type) {
349
351
  case "message":
350
- e(a.text);
352
+ e(l.text);
351
353
  return;
352
354
  case "uri":
353
- window.open(a.uri, "_blank");
355
+ window.open(l.uri, "_blank");
354
356
  return;
355
357
  }
356
358
  },
357
359
  [e]
358
360
  );
359
- return /* @__PURE__ */ i("div", { className: N.card_root, children: [
361
+ return /* @__PURE__ */ r("div", { className: f.card_root, children: [
360
362
  (t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */ o(
361
363
  "img",
362
364
  {
@@ -370,164 +372,186 @@ function G(n) {
370
372
  }
371
373
  }
372
374
  ),
373
- /* @__PURE__ */ i("div", { className: N.card_content, children: [
374
- /* @__PURE__ */ o("h5", { className: N.card_title, children: t == null ? void 0 : t.title }),
375
- /* @__PURE__ */ o("div", { className: N.card_description, children: t == null ? void 0 : t.text }),
376
- /* @__PURE__ */ o("div", { className: N.card_actions, children: (r = t == null ? void 0 : t.buttons) == null ? void 0 : r.map((a, _) => /* @__PURE__ */ o("button", { onClick: l(a.action), children: a.label }, _)) })
375
+ /* @__PURE__ */ r("div", { className: f.card_content, children: [
376
+ /* @__PURE__ */ o("h5", { className: f.card_title, children: t == null ? void 0 : t.title }),
377
+ /* @__PURE__ */ o("div", { className: f.card_description, children: t == null ? void 0 : t.text }),
378
+ /* @__PURE__ */ o("div", { className: f.card_actions, children: (_ = t == null ? void 0 : t.buttons) == null ? void 0 : _.map((l, i) => /* @__PURE__ */ o("button", { onClick: a(l.action), children: l.label }, i)) })
377
379
  ] })
378
380
  ] });
379
381
  }
380
- function Et(n) {
382
+ function kt(n) {
381
383
  const { conversationMessage: t } = n, e = t.message.template;
382
- return /* @__PURE__ */ i(M, { type: "bot", direction: "horizontal", children: [
383
- /* @__PURE__ */ o(I, {}),
384
+ return /* @__PURE__ */ r(v, { type: "bot", direction: "horizontal", children: [
385
+ /* @__PURE__ */ o(z, {}),
384
386
  /* @__PURE__ */ o(
385
- H,
387
+ R,
386
388
  {
387
389
  time: t.time,
388
390
  quickReplies: e == null ? void 0 : e.quickReplies,
389
- children: /* @__PURE__ */ o(G, { template: e })
391
+ children: /* @__PURE__ */ o(P, { template: e })
390
392
  }
391
393
  )
392
394
  ] });
393
395
  }
394
- const zt = "_text_1p20y_1", St = "_content_1p20y_19", R = {
396
+ const zt = "_text_sbjtw_1", Bt = "_content_sbjtw_19", j = {
395
397
  text: zt,
396
- "text--user": "_text--user_1p20y_7",
397
- "text--bot": "_text--bot_1p20y_13",
398
- content: St
398
+ "text--user": "_text--user_sbjtw_7",
399
+ "text--bot": "_text--bot_sbjtw_13",
400
+ content: Bt
399
401
  };
400
- function O(n) {
402
+ function A(n) {
401
403
  var e;
402
404
  const { conversationMessage: t } = n;
403
- return t.type === "user" ? /* @__PURE__ */ i(M, { type: "user", direction: "horizontal", children: [
404
- /* @__PURE__ */ o("div", { className: x(R.text, R["text--user"]), children: t.text }),
405
- /* @__PURE__ */ o($, { time: t.time })
406
- ] }) : /* @__PURE__ */ i(M, { type: "bot", direction: "horizontal", children: [
407
- /* @__PURE__ */ o(I, {}),
405
+ return t.type === "user" ? /* @__PURE__ */ r(v, { type: "user", direction: "horizontal", children: [
406
+ /* @__PURE__ */ o("div", { className: u(j.text, j["text--user"]), children: t.text }),
407
+ /* @__PURE__ */ o(I, { time: t.time })
408
+ ] }) : /* @__PURE__ */ r(v, { type: "bot", direction: "horizontal", children: [
409
+ /* @__PURE__ */ o(z, {}),
408
410
  /* @__PURE__ */ o(
409
- H,
411
+ R,
410
412
  {
411
413
  time: t.time,
412
414
  quickReplies: (e = t.message.template) == null ? void 0 : e.quickReplies,
413
- children: /* @__PURE__ */ o("div", { className: x(R.text, R["text--bot"]), children: t.message.text })
415
+ children: /* @__PURE__ */ o("div", { className: u(j.text, j["text--bot"]), children: t.message.text })
414
416
  }
415
417
  )
416
418
  ] });
417
419
  }
418
- const Rt = "_carousel_root_sv1hc_1", At = "_carousel_time_sv1hc_12", P = {
419
- carousel_root: Rt,
420
- carousel_time: At
420
+ const Ht = "_carousel_root_sv1hc_1", It = "_carousel_time_sv1hc_12", Z = {
421
+ carousel_root: Ht,
422
+ carousel_time: It
421
423
  };
422
- function It(n) {
424
+ function Rt(n) {
423
425
  var s;
424
426
  const { conversationMessage: t } = n, e = t.message.template;
425
- return /* @__PURE__ */ i(M, { type: "bot", direction: "vertical", children: [
426
- /* @__PURE__ */ o(I, {}),
427
- /* @__PURE__ */ o("div", { className: P.carousel_root, children: (s = e.columns) == null ? void 0 : s.map((c, l) => /* @__PURE__ */ o(G, { template: c }, l)) }),
428
- /* @__PURE__ */ o($, { className: P.carousel_time, time: t.time })
427
+ return /* @__PURE__ */ r(v, { type: "bot", direction: "vertical", children: [
428
+ /* @__PURE__ */ o(z, {}),
429
+ /* @__PURE__ */ o("div", { className: Z.carousel_root, children: (s = e.columns) == null ? void 0 : s.map((c, a) => /* @__PURE__ */ o(P, { template: c }, a)) }),
430
+ /* @__PURE__ */ o(I, { className: Z.carousel_time, time: t.time })
429
431
  ] });
430
432
  }
431
- const Bt = "_hint_root_4opfe_1", qt = "_time_4opfe_15", Z = {
432
- hint_root: Bt,
433
+ const $t = "_hint_root_g119q_1", qt = "_time_g119q_14", U = {
434
+ hint_root: $t,
433
435
  time: qt
434
436
  };
435
- function $t(n) {
437
+ function St(n) {
436
438
  const { conversationMessage: t } = n;
437
439
  if (t.type === "user") return null;
438
440
  const e = t.message.template;
439
- return e.type !== w.HINT ? null : /* @__PURE__ */ i("div", { className: Z.hint_root, children: [
440
- /* @__PURE__ */ o("div", { className: Z.time, children: F(t.time) }),
441
+ return e.type !== C.HINT ? null : /* @__PURE__ */ r("div", { className: U.hint_root, children: [
442
+ /* @__PURE__ */ o("div", { className: U.time, children: O(t.time) }),
441
443
  e.text
442
444
  ] });
443
445
  }
444
- function Ht(n) {
446
+ function At(n) {
445
447
  const { conversationMessage: t } = n;
446
448
  if (t.type === "user")
447
- return /* @__PURE__ */ o(O, { conversationMessage: t });
449
+ return /* @__PURE__ */ o(A, { conversationMessage: t });
448
450
  const e = t.message.template;
449
451
  switch (e == null ? void 0 : e.type) {
450
- case w.TEXT:
451
- return /* @__PURE__ */ o(O, { conversationMessage: t });
452
- case w.HINT:
453
- return /* @__PURE__ */ o($t, { conversationMessage: t });
454
- case w.BUTTON:
455
- return /* @__PURE__ */ o(Et, { conversationMessage: t });
456
- case w.CAROUSEL:
457
- return /* @__PURE__ */ o(It, { conversationMessage: t });
452
+ case C.TEXT:
453
+ return /* @__PURE__ */ o(A, { conversationMessage: t });
454
+ case C.HINT:
455
+ return /* @__PURE__ */ o(St, { conversationMessage: t });
456
+ case C.BUTTON:
457
+ return /* @__PURE__ */ o(kt, { conversationMessage: t });
458
+ case C.CAROUSEL:
459
+ return /* @__PURE__ */ o(Rt, { conversationMessage: t });
458
460
  default:
459
461
  return /* @__PURE__ */ o("div", { children: "Unknown template" });
460
462
  }
461
463
  }
462
- function Dt() {
463
- const { conversation: n, messageBoxBottomRef: t } = k();
464
- return m(() => {
465
- var e;
466
- (e = t.current) == null || e.scrollIntoView({ behavior: "smooth" });
467
- }, [n, t]), /* @__PURE__ */ i("div", { className: it.chatbot_body, children: [
468
- n.map((e) => /* @__PURE__ */ o(
469
- Ht,
464
+ function Zt() {
465
+ const { messages: n, typingMessages: t, messageBoxBottomRef: e } = w();
466
+ return y(() => {
467
+ var s;
468
+ (s = e.current) == null || s.scrollIntoView({ behavior: "smooth" });
469
+ }, [n, e]), /* @__PURE__ */ o("div", { className: $.chatbot_body, children: /* @__PURE__ */ r("div", { className: $.chatbot_body__content, children: [
470
+ Array.from((n == null ? void 0 : n.values()) ?? []).map((s) => /* @__PURE__ */ o(
471
+ At,
470
472
  {
471
- conversationMessage: e
473
+ conversationMessage: s
472
474
  },
473
475
  crypto.randomUUID()
474
476
  )),
475
- /* @__PURE__ */ o(vt, {}),
476
- /* @__PURE__ */ o("div", { ref: t })
477
- ] });
477
+ Array.from((t == null ? void 0 : t.values()) ?? []).map((s) => /* @__PURE__ */ o(
478
+ yt,
479
+ {
480
+ typingMessage: s
481
+ },
482
+ crypto.randomUUID()
483
+ )),
484
+ /* @__PURE__ */ o("div", { ref: e })
485
+ ] }) });
478
486
  }
479
- const Vt = "_chatbot_footer_1i661_1", Ot = "_chatbot_input_1i661_5", j = {
480
- chatbot_footer: Vt,
481
- chatbot_input: Ot
487
+ const Ut = "_chatbot_footer_3box0_1", Dt = "_chatbot_footer__content_3box0_1", Vt = "_chatbot_textarea_3box0_8", B = {
488
+ chatbot_footer: Ut,
489
+ chatbot_footer__content: Dt,
490
+ chatbot_textarea: Vt
482
491
  };
483
- function Pt() {
484
- const { sendMessage: n, isConnectionProcessing: t } = k(), [e, s] = C(""), c = h(
485
- (r) => {
486
- s(r.target.value);
492
+ function Et() {
493
+ const { sendMessage: n, isConnecting: t } = w(), [e, s] = k(""), [c, a] = k(!1), _ = g(
494
+ (i) => {
495
+ const h = i.target, d = h.value;
496
+ h.style.height = "20px", d && (h.style.height = `${h.scrollHeight - 16}px`), s(i.target.value);
487
497
  },
488
498
  []
489
- ), l = h(
490
- (r) => {
491
- r.key === "Enter" && (n(e), s(""));
499
+ ), l = g(
500
+ (i) => {
501
+ i.key === "Enter" && !c && !t && (n(e), s(""));
492
502
  },
493
- [n, e]
503
+ [c, t, n, e]
494
504
  );
495
- return /* @__PURE__ */ o("div", { className: j.chatbot_footer, children: /* @__PURE__ */ o(
496
- "input",
505
+ return /* @__PURE__ */ o("div", { className: B.chatbot_footer, children: /* @__PURE__ */ o("div", { className: B.chatbot_footer__content, children: /* @__PURE__ */ o(
506
+ "textarea",
497
507
  {
498
- className: j.chatbot_input,
508
+ className: B.chatbot_textarea,
499
509
  disabled: t,
510
+ cols: 40,
500
511
  value: e,
501
512
  placeholder: "Enter message",
502
- onChange: c,
503
- onKeyDown: l
513
+ onChange: _,
514
+ onKeyDown: l,
515
+ onCompositionStart: () => a(!0),
516
+ onCompositionEnd: () => a(!1)
504
517
  }
505
- ) });
518
+ ) }) });
506
519
  }
507
- const Zt = "_chatbot_root_1tkt9_1", jt = {
508
- chatbot_root: Zt
520
+ const Ot = "_chatbot_root_1jllh_1", Pt = "_chatbot_root__fullScreen_1jllh_12", D = {
521
+ chatbot_root: Ot,
522
+ chatbot_root__fullScreen: Pt
509
523
  };
510
- function Gt(n) {
511
- const { config: t, customChannelId: e, initConversation: s } = n;
512
- return /* @__PURE__ */ i(
513
- nt,
524
+ function Qt(n) {
525
+ const {
526
+ title: t,
527
+ config: e,
528
+ customChannelId: s,
529
+ initMessages: c,
530
+ fullScreen: a = !1,
531
+ options: _
532
+ } = n;
533
+ return /* @__PURE__ */ r(
534
+ Y,
514
535
  {
515
- className: jt.chatbot_root,
516
- config: t,
517
- customChannelId: e,
518
- initConversation: s,
536
+ className: u(
537
+ D.chatbot_root,
538
+ a && D.chatbot_root__fullScreen
539
+ ),
540
+ config: e,
541
+ customChannelId: s,
542
+ initMessages: c,
543
+ options: _,
519
544
  children: [
520
- /* @__PURE__ */ o(ct, {}),
521
- /* @__PURE__ */ o(Dt, {}),
522
- /* @__PURE__ */ o(Pt, {})
545
+ /* @__PURE__ */ o(ct, { title: t }),
546
+ /* @__PURE__ */ o(Zt, {}),
547
+ /* @__PURE__ */ o(Et, {})
523
548
  ]
524
549
  }
525
550
  );
526
551
  }
527
552
  export {
528
- Gt as Chatbot,
529
- J as useAsgardServiceClient,
530
- Y as useChannel,
531
- et as useChatbotTyping,
532
- tt as useDebounce
553
+ Qt as Chatbot,
554
+ X as useAsgardServiceClient,
555
+ G as useChannel,
556
+ J as useDebounce
533
557
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- ._chatbot_header_uinpm_1{padding:16px}._chatbot_body_okhax_1{display:flex;flex-direction:column;padding:16px;gap:16px;border-top:1px solid #434343;border-bottom:1px solid #434343;overflow-x:hidden;overflow-y:scroll}._template_box_1ozig_1{width:100%;display:flex;gap:8px}._template_box--bot_1ozig_7._template_box--horizontal_1ozig_7{flex-direction:row}._template_box--bot_1ozig_7._template_box--vertical_1ozig_10{flex-direction:column}._template_box--user_1ozig_14{flex-direction:row-reverse}._template_box_content_12ojl_1{display:flex;flex-direction:column;gap:8px}._content_12ojl_7{display:flex;flex-direction:row;gap:8px}._quick_replies_box_19pe0_1{display:flex;flex-wrap:wrap;gap:8px}._quick_reply_19pe0_7{font-size:13px;padding:4px 8px;border-radius:8px;border:1px solid #434343;background:#58585833;color:#fff;cursor:pointer}._time_rgg92_1{display:flex;align-items:flex-end;font-size:12px;color:#8c8c8c}._bot_avatar_14r1r_1{flex:0 0 auto;width:24px;height:24px}._text_1b4yq_1{padding:8px 12px;border-radius:8px;color:#fff}._text--bot_1b4yq_7{max-width:223px;background:#585858;border-top-left-radius:0}._typing-indicator_1b4yq_13{display:inline-flex;align-items:flex-end;justify-content:center}._typing-indicator_1b4yq_13 ._dot_1b4yq_18{width:2px;height:2px;margin:0 2px;background-color:#fff;border-radius:50%;animation:_blink_1b4yq_1 1.4s infinite ease-in-out both}._typing-indicator_1b4yq_13 ._dot_1b4yq_18:nth-child(1){animation-delay:0s}._typing-indicator_1b4yq_13 ._dot_1b4yq_18:nth-child(2){animation-delay:.2s}._typing-indicator_1b4yq_13 ._dot_1b4yq_18:nth-child(3){animation-delay:.4s}@keyframes _blink_1b4yq_1{0%,80%,to{opacity:.2;transform:translateY(0)}40%{opacity:1;transform:translateY(-5px)}}._card_root_1ygom_1{width:255px;height:368px;max-height:380px;border-radius:8px;background:#333;overflow:hidden}._card_content_1ygom_10{display:flex;flex-direction:column;gap:8px;padding:12px}._card_title_1ygom_17{color:#fff;margin:0;font-size:15px}._card_description_1ygom_23{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;color:#8c8c8c;font-size:13px;font-weight:400;line-height:20px;text-underline-position:from-font;text-decoration-skip-ink:none;text-overflow:ellipsis}._card_actions_1ygom_37{display:flex;flex-direction:column;gap:8px}._card_actions_1ygom_37>button{width:100%;height:32px;line-height:32px;text-align:center;border:none;border-radius:4px;background:#4767eb;color:#fff;font-size:15px;cursor:pointer}._text_1p20y_1{padding:8px 12px;border-radius:8px;color:#fff}._text--user_1p20y_7{max-width:255px;background:#4767eb;border-top-right-radius:0}._text--bot_1p20y_13{max-width:223px;background:#585858;border-top-left-radius:0}._content_1p20y_19{display:flex;flex-direction:column;gap:8px}._carousel_root_sv1hc_1{width:100%;display:flex;flex-wrap:nowrap;overflow-x:scroll;gap:8px}._carousel_root_sv1hc_1>div{flex:0 0 auto}._carousel_time_sv1hc_12{justify-content:flex-end}._hint_root_4opfe_1{margin:0 auto;display:flex;flex-direction:column;align-items:center;max-width:304px;padding:4px 12px;gap:4px;border-radius:2px;background:#58585833;font-size:13px;color:#fff}._time_4opfe_15{font-size:12px;color:#8c8c8c}._chatbot_footer_1i661_1{padding:16px}._chatbot_input_1i661_5{height:20px;max-height:240px;padding:8px 8px 8px 12px;background:#1f1f1f;border:1px solid rgb(67,67,67);border-radius:2px;color:#8c8c8c}._chatbot_root_1tkt9_1{width:375px;height:640px;background-color:#141414;border-radius:8px;font-size:15px;display:grid;grid-template-rows:max-content auto max-content}
1
+ ._chatbot_header_1xj9n_1 ._chatbot_header__content_1xj9n_1{margin:0 auto;max-width:1200px;padding:16px;display:flex;justify-content:space-between}._chatbot_header__title_1xj9n_9{display:flex;flex-direction:row;align-items:center;gap:8px}._chatbot_header__title_1xj9n_9>h4{margin:0;color:#fff}._chatbot_header__extra_1xj9n_20{display:flex;flex-direction:row;align-items:center;gap:8px}._chatbot_body_1f0gq_1{border-top:1px solid #434343;border-bottom:1px solid #434343;overflow-x:hidden;overflow-y:scroll}._chatbot_body_1f0gq_1 ._chatbot_body__content_1f0gq_7{margin:0 auto;display:flex;flex-direction:column;padding:16px;gap:16px;max-width:1200px}._template_box_1ozig_1{width:100%;display:flex;gap:8px}._template_box--bot_1ozig_7._template_box--horizontal_1ozig_7{flex-direction:row}._template_box--bot_1ozig_7._template_box--vertical_1ozig_10{flex-direction:column}._template_box--user_1ozig_14{flex-direction:row-reverse}._template_box_content_12ojl_1{display:flex;flex-direction:column;gap:8px}._content_12ojl_7{display:flex;flex-direction:row;gap:8px}._quick_replies_box_19pe0_1{display:flex;flex-wrap:wrap;gap:8px}._quick_reply_19pe0_7{font-size:13px;padding:4px 8px;border-radius:8px;border:1px solid #434343;background:#58585833;color:#fff;cursor:pointer}._time_rgg92_1{display:flex;align-items:flex-end;font-size:12px;color:#8c8c8c}._bot_avatar_14r1r_1{flex:0 0 auto;width:24px;height:24px}._text_1djgp_1{padding:8px 12px;border-radius:8px;color:#fff}._text--bot_1djgp_7{max-width:70%;background:#585858;border-top-left-radius:0}._typing-indicator_1djgp_13{display:inline-flex;align-items:flex-end;justify-content:center}._typing-indicator_1djgp_13 ._dot_1djgp_18{width:2px;height:2px;margin:0 2px;background-color:#fff;border-radius:50%;animation:_blink_1djgp_1 1.4s infinite ease-in-out both}._typing-indicator_1djgp_13 ._dot_1djgp_18:nth-child(1){animation-delay:0s}._typing-indicator_1djgp_13 ._dot_1djgp_18:nth-child(2){animation-delay:.2s}._typing-indicator_1djgp_13 ._dot_1djgp_18:nth-child(3){animation-delay:.4s}@keyframes _blink_1djgp_1{0%,80%,to{opacity:.2;transform:translateY(0)}40%{opacity:1;transform:translateY(-5px)}}._card_root_1ygom_1{width:255px;height:368px;max-height:380px;border-radius:8px;background:#333;overflow:hidden}._card_content_1ygom_10{display:flex;flex-direction:column;gap:8px;padding:12px}._card_title_1ygom_17{color:#fff;margin:0;font-size:15px}._card_description_1ygom_23{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;color:#8c8c8c;font-size:13px;font-weight:400;line-height:20px;text-underline-position:from-font;text-decoration-skip-ink:none;text-overflow:ellipsis}._card_actions_1ygom_37{display:flex;flex-direction:column;gap:8px}._card_actions_1ygom_37>button{width:100%;height:32px;line-height:32px;text-align:center;border:none;border-radius:4px;background:#4767eb;color:#fff;font-size:15px;cursor:pointer}._text_sbjtw_1{padding:8px 12px;border-radius:8px;color:#fff}._text--user_sbjtw_7{max-width:75%;background:#4767eb;border-top-right-radius:0}._text--bot_sbjtw_13{max-width:70%;background:#585858;border-top-left-radius:0}._content_sbjtw_19{display:flex;flex-direction:column;gap:8px}._carousel_root_sv1hc_1{width:100%;display:flex;flex-wrap:nowrap;overflow-x:scroll;gap:8px}._carousel_root_sv1hc_1>div{flex:0 0 auto}._carousel_time_sv1hc_12{justify-content:flex-end}._hint_root_g119q_1{margin:0 auto;display:flex;flex-direction:column;align-items:center;padding:4px 12px;gap:4px;border-radius:2px;background:#58585833;font-size:13px;color:#fff}._time_g119q_14{font-size:12px;color:#8c8c8c}._chatbot_footer_3box0_1 ._chatbot_footer__content_3box0_1{margin:0 auto;max-width:1200px;padding:16px;gap:16px}._chatbot_textarea_3box0_8{font:inherit;width:calc(100% - 20px);height:20px;max-height:240px;padding:8px 8px 8px 12px;background:#1f1f1f;border:1px solid rgb(67,67,67);border-radius:2px;color:#8c8c8c;resize:none;overflow:hidden}._chatbot_root_1jllh_1{min-width:375px;width:100%;height:100%;background-color:#141414;border-radius:8px;font-size:15px;display:grid;grid-template-rows:max-content auto max-content}._chatbot_root__fullScreen_1jllh_12{position:fixed;top:0;left:0;right:0;bottom:0;z-index:9999;border-radius:0}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,9 +0,0 @@
1
- import { ConversationMessage } from '../../hooks';
2
- import { ReactNode } from 'react';
3
-
4
- interface MessageBoxProps {
5
- conversationMessage: ConversationMessage;
6
- }
7
- export declare function MessageBox(props: MessageBoxProps): ReactNode;
8
- export {};
9
- //# sourceMappingURL=message-box.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message-box.d.ts","sourceRoot":"","sources":["../../../src/components/message-box/message-box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAKhD,UAAU,eAAe;IACvB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAsC5D"}
@@ -1,11 +0,0 @@
1
- import { Message } from '@asgard-js/core';
2
-
3
- export interface UseChatbotTypingReturn {
4
- isTyping: boolean;
5
- displayText: string | null;
6
- startTyping: (message: Message) => void;
7
- onTyping: (message: Message) => void;
8
- stopTyping: () => void;
9
- }
10
- export declare function useChatbotTyping(): UseChatbotTypingReturn;
11
- //# sourceMappingURL=use-chatbot-typing.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-chatbot-typing.d.ts","sourceRoot":"","sources":["../../src/hooks/use-chatbot-typing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI1C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,gBAAgB,IAAI,sBAAsB,CAwBzD"}