@anker-in/campaign-ui 0.0.33-alpha2 → 0.0.33-alpha3
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/cjs/components/chat/Markdown.d.ts +5 -0
- package/dist/cjs/components/chat/Messages.d.ts +3 -0
- package/dist/cjs/components/chat/Response.d.ts +2 -0
- package/dist/cjs/components/chat/action.d.ts +6 -2
- package/dist/cjs/components/chat/action.js +1 -1
- package/dist/cjs/components/chat/action.js.map +3 -3
- package/dist/cjs/components/chat/button.d.ts +3 -0
- package/dist/cjs/components/chat/button.js +2 -0
- package/dist/cjs/components/chat/button.js.map +7 -0
- package/dist/cjs/components/chat/index.d.ts +16 -2
- package/dist/cjs/components/chat/index.js +1 -5
- package/dist/cjs/components/chat/index.js.map +3 -3
- package/dist/cjs/components/chat/markdown.js +2 -0
- package/dist/cjs/components/chat/markdown.js.map +7 -0
- package/dist/cjs/components/chat/marksdown.d.ts +5 -0
- package/dist/cjs/components/chat/message.d.ts +2 -0
- package/dist/cjs/components/chat/messages.js +2 -0
- package/dist/cjs/components/chat/messages.js.map +7 -0
- package/dist/cjs/components/chat/props.d.ts +43 -0
- package/dist/cjs/components/chat/props.js +2 -0
- package/dist/cjs/components/chat/props.js.map +7 -0
- package/dist/cjs/components/chat/response copy.d.ts +2 -0
- package/dist/cjs/components/chat/response.js +2 -0
- package/dist/cjs/components/chat/response.js.map +7 -0
- package/dist/cjs/components/chat/rresponse.d.ts +2 -0
- package/dist/cjs/components/chat/suggestions.d.ts +3 -0
- package/dist/cjs/components/chat/suggestions.js +2 -0
- package/dist/cjs/components/chat/suggestions.js.map +7 -0
- package/dist/cjs/stories/chat.stories.d.ts +1 -0
- package/dist/cjs/stories/chat.stories.js +1 -1
- package/dist/cjs/stories/chat.stories.js.map +3 -3
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/chat/Markdown.d.ts +5 -0
- package/dist/esm/components/chat/Messages.d.ts +3 -0
- package/dist/esm/components/chat/Response.d.ts +2 -0
- package/dist/esm/components/chat/action.d.ts +6 -2
- package/dist/esm/components/chat/action.js +1 -1
- package/dist/esm/components/chat/action.js.map +3 -3
- package/dist/esm/components/chat/button.d.ts +3 -0
- package/dist/esm/components/chat/button.js +2 -0
- package/dist/esm/components/chat/button.js.map +7 -0
- package/dist/esm/components/chat/index.d.ts +16 -2
- package/dist/esm/components/chat/index.js +1 -5
- package/dist/esm/components/chat/index.js.map +3 -3
- package/dist/esm/components/chat/markdown.js +2 -0
- package/dist/esm/components/chat/markdown.js.map +7 -0
- package/dist/esm/components/chat/marksdown.d.ts +5 -0
- package/dist/esm/components/chat/message.d.ts +2 -0
- package/dist/esm/components/chat/messages.js +2 -0
- package/dist/esm/components/chat/messages.js.map +7 -0
- package/dist/esm/components/chat/props.d.ts +43 -0
- package/dist/esm/components/chat/props.js +2 -0
- package/dist/esm/components/chat/props.js.map +7 -0
- package/dist/esm/components/chat/response copy.d.ts +2 -0
- package/dist/esm/components/chat/response.js +2 -0
- package/dist/esm/components/chat/response.js.map +7 -0
- package/dist/esm/components/chat/rresponse.d.ts +2 -0
- package/dist/esm/components/chat/suggestions.d.ts +3 -0
- package/dist/esm/components/chat/suggestions.js +2 -0
- package/dist/esm/components/chat/suggestions.js.map +7 -0
- package/dist/esm/stories/chat.stories.d.ts +1 -0
- package/dist/esm/stories/chat.stories.js +1 -1
- package/dist/esm/stories/chat.stories.js.map +2 -2
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/chat/action.tsx +32 -11
- package/src/components/chat/button.tsx +23 -0
- package/src/components/chat/index.tsx +77 -67
- package/src/components/chat/markdown.tsx +36 -0
- package/src/components/chat/messages.tsx +167 -0
- package/src/components/chat/props.ts +51 -0
- package/src/components/chat/response.tsx +17 -0
- package/src/components/chat/suggestions.tsx +34 -0
- package/src/stories/chat.stories.tsx +4 -4
- package/src/styles/css/messages.css +4 -0
- package/src/styles/css/suggestions.css +1 -0
- package/dist/cjs/components/chat/chatContext.js +0 -2
- package/dist/cjs/components/chat/chatContext.js.map +0 -7
- package/dist/cjs/components/theme.js +0 -2
- package/dist/cjs/components/theme.js.map +0 -7
- package/dist/esm/components/chat/chatContext.js +0 -2
- package/dist/esm/components/chat/chatContext.js.map +0 -7
- package/dist/esm/components/theme.js +0 -2
- package/dist/esm/components/theme.js.map +0 -7
- package/src/components/chat/chatContext.tsx +0 -161
|
@@ -2,13 +2,17 @@ import React from 'react';
|
|
|
2
2
|
interface Message {
|
|
3
3
|
content: string;
|
|
4
4
|
role: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
scope?: any;
|
|
7
|
+
arguments?: any;
|
|
5
8
|
}
|
|
6
9
|
export interface ActionProps {
|
|
7
10
|
start?: string;
|
|
8
11
|
history: Message[];
|
|
9
|
-
|
|
12
|
+
addtocartRender?: string | ((_props: any) => React.ReactElement);
|
|
13
|
+
productRender?: string | ((_props: any) => React.ReactElement);
|
|
10
14
|
signupRender?: string | ((_props: any) => React.ReactElement);
|
|
11
15
|
children?: React.ReactNode;
|
|
12
16
|
}
|
|
13
|
-
export declare const CopilotAction: ({ history,
|
|
17
|
+
export declare const CopilotAction: ({ start, history, addtocartRender, productRender, signupRender, children, }: ActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
18
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var i in e)m(t,i,{get:e[i],enumerable:!0})},A=(t,e,i,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of y(e))!R.call(t,a)&&a!==i&&m(t,a,{get:()=>e[a],enumerable:!(d=l(e,a))||d.enumerable});return t};var w=t=>A(m({},"__esModule",{value:!0}),t);var E={};h(E,{CopilotAction:()=>C});module.exports=w(E);var c=require("react/jsx-runtime"),N=require("react"),g=require("react"),s=require("@copilotkit/react-core"),o=require("@copilotkit/runtime-client-gql");const C=({start:t,history:e,addtocartRender:i,productRender:d,signupRender:a,children:u})=>{const{setMessages:f}=(0,s.useCopilotChat)();return(0,g.useEffect)(()=>{const r=e?.filter(p=>p?.content||p?.arguments);if(r?.length>0){const p=r?.map(n=>n?.name&&n?.arguments?(console.log("value?.name && value?.arguments",n?.name,n?.arguments),new o.ActionExecutionMessage({name:n?.name,arguments:n?.arguments,scope:n?.scope})):new o.TextMessage({...n,role:n?.role==="user"?o.Role.User:o.Role.Assistant}));f(p)}},[e]),(0,s.useCopilotAction)({name:"add_cart",description:"add tocart",parameters:[{sku:"",handle:""}],render:i||(r=>(0,c.jsx)("div",{children:JSON.stringify(r)})),handler:function(){}}),(0,s.useCopilotAction)({name:"buynow",description:"buy now",parameters:[{sku:"",handle:""}],render:d||(r=>(0,c.jsx)("div",{children:JSON.stringify(r)})),handler:function(){}}),(0,s.useCopilotAction)({name:"signup",description:"signup",parameters:[{name:"signup"}],render:a||(r=>(0,c.jsx)("div",{children:JSON.stringify(r)})),handler:function(){}}),(0,s.useCopilotReadable)({description:"Today's date",value:new Date().toLocaleDateString()}),(0,c.jsx)("div",{children:u})};
|
|
2
2
|
//# sourceMappingURL=action.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/chat/action.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\nimport { useEffect } from 'react'\nimport { useCopilotChat, useCopilotAction, useCopilotReadable } from '@copilotkit/react-core'\nimport {
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["action_exports", "__export", "CopilotAction", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_core", "
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { useEffect } from 'react'\nimport { useCopilotChat, useCopilotAction, useCopilotReadable } from '@copilotkit/react-core'\nimport { Role, ActionExecutionMessage, TextMessage } from '@copilotkit/runtime-client-gql'\n\ninterface Message {\n content: string\n role: string\n name?: string\n scope?: any\n arguments?: any\n}\n\nexport interface ActionProps {\n start?: string\n history: Message[]\n addtocartRender?: string | ((_props: any) => React.ReactElement)\n productRender?: string | ((_props: any) => React.ReactElement)\n signupRender?: string | ((_props: any) => React.ReactElement)\n children?: React.ReactNode\n}\n\nexport const CopilotAction = ({\n start,\n history,\n addtocartRender,\n productRender,\n signupRender,\n children,\n}: ActionProps) => {\n const { setMessages } = useCopilotChat()\n\n useEffect(() => {\n const originhistory = history?.filter(value => value?.content || value?.arguments)\n if (originhistory?.length > 0) {\n const content = originhistory?.map(value => {\n if (value?.name && value?.arguments) {\n console.log('value?.name && value?.arguments', value?.name, value?.arguments)\n return new ActionExecutionMessage({\n name: value?.name,\n arguments: value?.arguments,\n scope: value?.scope,\n })\n }\n return new TextMessage({\n ...value,\n role: value?.role === 'user' ? Role.User : Role.Assistant,\n })\n })\n setMessages(content)\n }\n }, [history])\n\n useCopilotAction({\n name: 'add_cart',\n description: 'add tocart',\n parameters: [{ sku: '', handle: '' }] as any,\n render: addtocartRender || (props => <div>{JSON.stringify(props)}</div>),\n handler: function () {\n // console.log('buynow-props', props)\n },\n })\n\n useCopilotAction({\n name: 'buynow',\n description: 'buy now',\n parameters: [{ sku: '', handle: '' }] as any,\n render: productRender || (props => <div>{JSON.stringify(props)}</div>),\n handler: function () {\n // console.log('buynow-props', props)\n },\n })\n\n useCopilotAction({\n name: 'signup',\n description: 'signup',\n parameters: [\n {\n name: 'signup',\n },\n ] as any,\n render: signupRender || (props => <div>{JSON.stringify(props)}</div>),\n handler: function () {\n // console.log('signup-props', props)\n },\n })\n\n useCopilotReadable({\n description: \"Today's date\",\n value: new Date().toLocaleDateString(),\n })\n\n return <div>{children}</div>\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAA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AQN,IAAiBM,MAAS,OAAC,OAAK,cAAK,UAAUA,CAAK,EAAE,GAC9D,QAAS,UAAY,CAErB,CACF,CAAC,KAED,sBAAmB,CACjB,YAAa,eACb,MAAO,IAAI,KAAK,EAAE,mBAAmB,CACvC,CAAC,KAEM,OAAC,OAAK,SAAAL,EAAS,CACxB",
|
|
6
|
+
"names": ["action_exports", "__export", "CopilotAction", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_core", "import_runtime_client_gql", "start", "history", "addtocartRender", "productRender", "signupRender", "children", "setMessages", "originhistory", "value", "content", "props"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var r=(t,o)=>{for(var n in o)e(t,n,{get:o[n],enumerable:!0})},B=(t,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of u(o))!a.call(t,c)&&c!==n&&e(t,c,{get:()=>o[c],enumerable:!(s=p(o,c))||s.enumerable});return t};var m=t=>B(e({},"__esModule",{value:!0}),t);var f={};r(f,{default:()=>d});module.exports=m(f);var i=require("react/jsx-runtime"),l=require("@copilotkit/react-ui");const I=({setOpen:t,setOpenTip:o})=>{const n=(0,l.useChatContext)();return(0,i.jsxs)("button",{onClick:()=>{t(!0),o(!1)},className:"copilotKitButton ","aria-label":"Open Chat",children:[(0,i.jsx)("div",{className:"copilotKitButtonIcon copilotKitButtonIconOpen",children:n.icons.openIcon}),(0,i.jsx)("div",{className:"copilotKitButtonIcon copilotKitButtonIconClose",children:n.icons.closeIcon})]})};var d=I;
|
|
2
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/chat/button.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useChatContext } from '@copilotkit/react-ui'\n\nimport type { ButtonProps } from './props.js'\n\nconst DefaultButton = ({ setOpen, setOpenTip }: ButtonProps) => {\n const context = useChatContext()\n\n return (\n <button\n onClick={() => {\n setOpen(true)\n setOpenTip(false)\n }}\n className=\"copilotKitButton \"\n aria-label=\"Open Chat\"\n >\n <div className=\"copilotKitButtonIcon copilotKitButtonIconOpen\">{context.icons.openIcon}</div>\n <div className=\"copilotKitButtonIcon copilotKitButtonIconClose\">{context.icons.closeIcon}</div>\n </button>\n )\n}\n\nexport default DefaultButton\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAQI,IAAAI,EAAA,6BARJC,EAA+B,gCAI/B,MAAMC,EAAgB,CAAC,CAAE,QAAAC,EAAS,WAAAC,CAAW,IAAmB,CAC9D,MAAMC,KAAU,kBAAe,EAE/B,SACE,QAAC,UACC,QAAS,IAAM,CACbF,EAAQ,EAAI,EACZC,EAAW,EAAK,CAClB,EACA,UAAU,oBACV,aAAW,YAEX,oBAAC,OAAI,UAAU,gDAAiD,SAAAC,EAAQ,MAAM,SAAS,KACvF,OAAC,OAAI,UAAU,iDAAkD,SAAAA,EAAQ,MAAM,UAAU,GAC3F,CAEJ,EAEA,IAAOP,EAAQI",
|
|
6
|
+
"names": ["button_exports", "__export", "button_default", "__toCommonJS", "import_jsx_runtime", "import_react_ui", "DefaultButton", "setOpen", "setOpenTip", "context"]
|
|
7
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export interface ChatProps {
|
|
2
3
|
title: string;
|
|
3
4
|
runtimeUrl: string;
|
|
@@ -5,20 +6,33 @@ export interface ChatProps {
|
|
|
5
6
|
/** GA 的 client id
|
|
6
7
|
*/
|
|
7
8
|
user_id: string;
|
|
9
|
+
/** 是否登陆用户 0 or 1
|
|
10
|
+
*/
|
|
11
|
+
account?: string;
|
|
12
|
+
/** 用户浏览器语言
|
|
13
|
+
*/
|
|
14
|
+
locale?: string;
|
|
8
15
|
/** ?a=1&b=2
|
|
9
16
|
*/
|
|
10
17
|
query?: string;
|
|
18
|
+
/** 'follow' or 'unfollow' | true or false
|
|
19
|
+
*/
|
|
20
|
+
showResponseButton?: string | boolean;
|
|
21
|
+
/** 加购卡片,接受参数: {"status":"complete","args":[{"sku":"A3936031","handle":"space-a40-a3936031"}],"result":""}
|
|
22
|
+
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
23
|
+
*/
|
|
24
|
+
addtocartRender?: string | ((_props: any) => React.ReactElement);
|
|
11
25
|
/** 产品卡片,接受参数: {"status":"complete","args":[{"sku":"A3936031","handle":"space-a40-a3936031"}],"result":""}
|
|
12
26
|
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
13
27
|
*/
|
|
14
|
-
|
|
28
|
+
productRender?: string | ((_props: any) => React.ReactElement);
|
|
15
29
|
/** 订阅卡片,接受参数:
|
|
16
30
|
* 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
|
|
17
31
|
*/
|
|
18
32
|
signupRender?: string | ((_props: any) => React.ReactElement);
|
|
19
33
|
/** CopilotPopup 自定义参数,参考:https://docs.copilotkit.ai/reference/components/CopilotPopup */
|
|
20
34
|
popup?: any;
|
|
21
|
-
/** 文案,{"popupTip": "Hi ! Welcome to soundcore Innovations live chat!"} */
|
|
35
|
+
/** 文案,{"popupTip": "Hi ! Welcome to soundcore Innovations live chat!", "popupTipTimeout": [3000, 6000]} */
|
|
22
36
|
lang?: any;
|
|
23
37
|
/** 参考此文档:https://docs.copilotkit.ai/concepts/customize-look-and-feel */
|
|
24
38
|
style?: any;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
.copilotKitMessage.copilotKitAssistantMessage:has(.copilotKitMarkdown:empty) {
|
|
3
|
-
display: none;
|
|
4
|
-
}
|
|
5
|
-
`}),a&&i&&(0,t.jsx)(f.CopilotKit,{runtimeUrl:`${i}/copilotkit/chat`,showDevConsole:!1,headers:{user_id:a||"",shopify_domain:n},children:(0,t.jsx)(C.CopilotPopup,{...p,labels:{title:e||"DTC Live Chat",initial:c||""},makeSystemMessage:()=>c||"",Button:({open:r,setOpen:d})=>{const m=p?.Button;return(0,s.useEffect)(()=>_(r),[r]),(0,t.jsxs)(t.Fragment,{children:[h?.popupTip&&g&&!k&&(0,t.jsx)("div",{className:"copilotKitPopup copilotKitPopupTip",children:(0,t.jsx)("button",{onClick:()=>{d(!0),l(!1)},"aria-label":"Open Chat",className:"copilotKitPopupTipContent",children:h?.popupTip})}),m&&(0,t.jsx)(m,{open:r,setOpen:d,setOpenTip:l}),!m&&(0,t.jsxs)("button",{onClick:()=>{d(!0),l(!1)},className:"copilotKitButton ","aria-label":"Open Chat",children:[(0,t.jsx)("div",{className:"copilotKitButtonIcon copilotKitButtonIconOpen",children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:(0,t.jsx)("g",{transform:"translate(24, 0) scale(-1, 1)",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z",clipRule:"evenodd"})})})}),(0,t.jsx)("div",{className:"copilotKitButtonIcon copilotKitButtonIconClose",children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",width:"24",height:"24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})})]})]})},children:(0,t.jsx)(v.CopilotAction,{start:c,history:P,buynowRender:K,signupRender:R})})})]})};var $=D;
|
|
1
|
+
"use strict";var Q=Object.create;var f=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var Z=(t,o)=>{for(var n in o)f(t,n,{get:o[n],enumerable:!0})},B=(t,o,n,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of W(o))!Y.call(t,r)&&r!==n&&f(t,r,{get:()=>o[r],enumerable:!(u=V(o,r))||u.enumerable});return t};var g=(t,o,n)=>(n=t!=null?Q(X(t)):{},B(o||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),j=t=>B(f({},"__esModule",{value:!0}),t);var st={};Z(st,{default:()=>et});module.exports=j(st);var s=require("react/jsx-runtime"),nt=require("react"),i=require("react"),w=require("@copilotkit/react-core"),S=require("@copilotkit/react-ui"),b=g(require("./button.js")),v=g(require("./messages.js")),E=g(require("./response.js")),O=g(require("./suggestions.js")),$=require("./action.js"),C=g(require("../../helpers/fetcher.js"));const tt=t=>{const{title:o,runtimeUrl:n,popup:u,shopify_domain:r,user_id:a="",account:l="",locale:c="",query:h="",showResponseButton:_,addtocartRender:k,productRender:q,signupRender:K,style:N,className:D="",lang:R}=t,[M,U]=R?.popupTipTimeout||[3e3,6e3],[P,m]=(0,i.useState)(!1),[y,G]=(0,i.useState)(!1),[d,x]=(0,i.useState)(""),[A,T]=(0,i.useState)([]),[F,I]=(0,i.useState)([]),L=(0,i.useCallback)(async()=>{const e=await(0,C.default)({url:`${n}/copilotkit/start${h}`,method:"GET",headers:{user_id:a||"",shopify_domain:r,account:l,locale:c}});T(e?.suggested_questions?.map(p=>({message:p,title:p}))||[]),x(e?.opening_statement||""),I(e?.history||[])},[a,r,l,c]),z=(0,i.useCallback)(async()=>{const e=await(0,C.default)({url:`${n}/copilotkit/suggested_questions${h}`,method:"GET",headers:{user_id:a||"",shopify_domain:r,account:l,locale:c}});T(e?.suggested_questions?.data?.map(p=>({message:p,title:p}))||[])},[a,r,l,c]),H=()=>{P||m(!0),setTimeout(()=>{m(!1)},U)};return(0,i.useEffect)(()=>{const e=setTimeout(()=>{H()},M);return()=>{clearTimeout(e)}},[]),(0,i.useEffect)(()=>{d||L()},[]),(0,s.jsx)("div",{className:D,style:N||{},children:a&&n&&(0,s.jsx)(w.CopilotKit,{runtimeUrl:`${n}/copilotkit/chat${h}`,showDevConsole:!1,headers:{user_id:a||"",shopify_domain:r,account:l,locale:c},children:(0,s.jsx)(S.CopilotPopup,{...u,showResponseButton:_!=="follow",labels:{title:o||"DTC Live Chat",initial:d||""},instructions:d||"",onInProgress:e=>{y&&e&&T([]),y&&!e&&z()},Messages:({messages:e,inProgress:p})=>(0,s.jsx)(v.default,{messages:e,inProgress:p,ResponseButton:_==="follow"?(0,s.jsx)(E.default,{}):void 0,children:(0,s.jsx)(O.default,{currentSuggestions:A})}),Button:({open:e,setOpen:p})=>{const J=u?.Button||b.default;return(0,i.useEffect)(()=>{G(e)},[e]),(0,s.jsxs)(s.Fragment,{children:[R?.popupTip&&P&&!y&&(0,s.jsx)("div",{className:"copilotKitPopup copilotKitPopupTip",children:(0,s.jsx)("button",{onClick:()=>{p(!0),m(!1)},"aria-label":"Open Chat",className:"copilotKitPopupTipContent",children:R?.popupTip})}),(0,s.jsx)(J,{open:e,setOpen:p,setOpenTip:m})]})},children:(0,s.jsx)($.CopilotAction,{start:d,history:F,addtocartRender:k,productRender:q,signupRender:K})})})})};var et=tt;
|
|
6
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/chat/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,
|
|
6
|
-
"names": ["chat_exports", "__export", "chat_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_core", "import_react_ui", "import_action", "import_fetcher", "Chat", "props", "title", "runtimeUrl", "popup", "shopify_domain", "user_id", "query", "
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react-hooks/exhaustive-deps */\nimport React from 'react'\nimport { useCallback, useState, useEffect } from 'react'\nimport { CopilotKit } from '@copilotkit/react-core'\nimport { CopilotPopup } from '@copilotkit/react-ui'\nimport DefaultButton from './button.js'\nimport Messages from './messages.js'\nimport ResponseButton from './response.js'\nimport Suggestions from './suggestions.js'\nimport { CopilotAction } from './action.js'\nimport fetcher from '../../helpers/fetcher.js'\n\nexport interface ChatProps {\n title: string\n runtimeUrl: string\n shopify_domain: string\n /** GA \u7684 client id\n */\n user_id: string\n /** \u662F\u5426\u767B\u9646\u7528\u6237 0 or 1\n */\n account?: string\n /** \u7528\u6237\u6D4F\u89C8\u5668\u8BED\u8A00\n */\n locale?: string\n /** ?a=1&b=2\n */\n query?: string\n /** 'follow' or 'unfollow' | true or false\n */\n showResponseButton?: string | boolean\n /** \u52A0\u8D2D\u5361\u7247\uFF0C\u63A5\u53D7\u53C2\u6570\uFF1A {\"status\":\"complete\",\"args\":[{\"sku\":\"A3936031\",\"handle\":\"space-a40-a3936031\"}],\"result\":\"\"}\n * \u540E\u7AEF\u63A5\u53E3\u6587\u6863\uFF1Ahttps://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb\n */\n addtocartRender?: string | ((_props: any) => React.ReactElement)\n /** \u4EA7\u54C1\u5361\u7247\uFF0C\u63A5\u53D7\u53C2\u6570\uFF1A {\"status\":\"complete\",\"args\":[{\"sku\":\"A3936031\",\"handle\":\"space-a40-a3936031\"}],\"result\":\"\"}\n * \u540E\u7AEF\u63A5\u53E3\u6587\u6863\uFF1Ahttps://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb\n */\n productRender?: string | ((_props: any) => React.ReactElement)\n /** \u8BA2\u9605\u5361\u7247\uFF0C\u63A5\u53D7\u53C2\u6570\uFF1A\n * \u540E\u7AEF\u63A5\u53E3\u6587\u6863\uFF1Ahttps://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb\n */\n signupRender?: string | ((_props: any) => React.ReactElement)\n /** CopilotPopup \u81EA\u5B9A\u4E49\u53C2\u6570\uFF0C\u53C2\u8003\uFF1Ahttps://docs.copilotkit.ai/reference/components/CopilotPopup */\n popup?: any\n /** \u6587\u6848\uFF0C{\"popupTip\": \"Hi ! Welcome to soundcore Innovations live chat\uFF01\", \"popupTipTimeout\": [3000, 6000]} */\n lang?: any\n /** \u53C2\u8003\u6B64\u6587\u6863\uFF1Ahttps://docs.copilotkit.ai/concepts/customize-look-and-feel */\n style?: any\n className?: string\n}\n\nconst Chat = (props: ChatProps) => {\n const {\n title,\n runtimeUrl,\n popup,\n shopify_domain,\n user_id = '',\n account = '',\n locale = '',\n query = '',\n showResponseButton,\n addtocartRender,\n productRender,\n signupRender,\n style,\n className = '',\n lang,\n } = props\n const [autoTipOpen, autoTipClose] = lang?.popupTipTimeout || [3000, 6000]\n\n const [openTip, setOpenTip] = useState(false)\n const [openPopup, setOpenPopup] = useState(false)\n const [start, setstart] = useState('')\n const [currentSuggestions, setCurrentSuggestions] = useState([])\n const [history, sethistory] = useState<[{ content: string; role: string }] | []>([])\n\n const getStart = useCallback(async () => {\n const result = await fetcher({\n url: `${runtimeUrl}/copilotkit/start${query}`,\n method: 'GET',\n headers: { user_id: user_id || '', shopify_domain, account, locale },\n })\n\n setCurrentSuggestions(result?.suggested_questions?.map((item: string) => ({ message: item, title: item })) || [])\n setstart(result?.opening_statement || '')\n sethistory(result?.history || [])\n }, [user_id, shopify_domain, account, locale])\n\n const getSuggestions = useCallback(async () => {\n const result = await fetcher({\n url: `${runtimeUrl}/copilotkit/suggested_questions${query}`,\n method: 'GET',\n headers: { user_id: user_id || '', shopify_domain, account, locale },\n })\n\n setCurrentSuggestions(\n result?.suggested_questions?.data?.map((item: string) => ({ message: item, title: item })) || []\n )\n }, [user_id, shopify_domain, account, locale])\n\n const setOpenTipFn = () => {\n if (!openTip) setOpenTip(true)\n setTimeout(() => {\n setOpenTip(false)\n }, autoTipClose)\n }\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setOpenTipFn()\n }, autoTipOpen)\n\n return () => {\n clearTimeout(timer)\n }\n }, [])\n\n useEffect(() => {\n if (!start) {\n getStart()\n }\n }, [])\n\n return (\n <div className={className} style={style || {}}>\n {user_id && runtimeUrl && (\n <CopilotKit\n runtimeUrl={`${runtimeUrl}/copilotkit/chat${query}`}\n showDevConsole={false}\n headers={{ user_id: user_id || '', shopify_domain: shopify_domain, account, locale }}\n >\n <CopilotPopup\n {...popup}\n showResponseButton={showResponseButton !== 'follow'}\n labels={{\n title: title || 'DTC Live Chat',\n initial: start || '',\n }}\n instructions={start || ''}\n onInProgress={load => {\n if (openPopup && load) setCurrentSuggestions([])\n if (openPopup && !load) getSuggestions()\n }}\n Messages={({ messages, inProgress }) => (\n <Messages\n messages={messages}\n inProgress={inProgress}\n ResponseButton={showResponseButton === 'follow' ? <ResponseButton /> : undefined}\n >\n <Suggestions currentSuggestions={currentSuggestions} />\n </Messages>\n )}\n Button={({ open, setOpen }) => {\n const Button = popup?.Button || DefaultButton\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n setOpenPopup(open)\n }, [open])\n return (\n <>\n {lang?.popupTip && openTip && !openPopup && (\n <div className=\"copilotKitPopup copilotKitPopupTip\">\n <button\n onClick={() => {\n setOpen(true)\n setOpenTip(false)\n }}\n aria-label=\"Open Chat\"\n className=\"copilotKitPopupTipContent\"\n >\n {lang?.popupTip}\n </button>\n </div>\n )}\n <Button open={open} setOpen={setOpen} setOpenTip={setOpenTip} />\n </>\n )\n }}\n >\n <CopilotAction\n start={start}\n history={history}\n addtocartRender={addtocartRender}\n productRender={productRender}\n signupRender={signupRender}\n />\n </CopilotPopup>\n </CopilotKit>\n )}\n </div>\n )\n}\n\nexport default Chat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AC,CAAW,OAChC,OAAC,EAAAC,QAAA,CACC,SAAUF,EACV,WAAYC,EACZ,eAAgB5B,IAAuB,YAAW,OAAC,EAAA8B,QAAA,EAAe,EAAK,OAEvE,mBAAC,EAAAC,QAAA,CAAY,mBAAoBhB,EAAoB,EACvD,EAEF,OAAQ,CAAC,CAAE,KAAAiB,EAAM,QAAAC,CAAQ,IAAM,CAC7B,MAAMC,EAASxC,GAAO,QAAU,EAAAyC,QAEhC,sBAAU,IAAM,CACdvB,EAAaoB,CAAI,CACnB,EAAG,CAACA,CAAI,CAAC,KAEP,oBACG,UAAA1B,GAAM,UAAYG,GAAW,CAACE,MAC7B,OAAC,OAAI,UAAU,qCACb,mBAAC,UACC,QAAS,IAAM,CACbsB,EAAQ,EAAI,EACZvB,EAAW,EAAK,CAClB,EACA,aAAW,YACX,UAAU,4BAET,SAAAJ,GAAM,SACT,EACF,KAEF,OAAC4B,EAAA,CAAO,KAAMF,EAAM,QAASC,EAAS,WAAYvB,EAAY,GAChE,CAEJ,EAEA,mBAAC,iBACC,MAAOG,EACP,QAASI,EACT,gBAAiBhB,EACjB,cAAeC,EACf,aAAcC,EAChB,EACF,EACF,EAEJ,CAEJ,EAEA,IAAOzB,GAAQY",
|
|
6
|
+
"names": ["chat_exports", "__export", "chat_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_core", "import_react_ui", "import_button", "import_messages", "import_response", "import_suggestions", "import_action", "import_fetcher", "Chat", "props", "title", "runtimeUrl", "popup", "shopify_domain", "user_id", "account", "locale", "query", "showResponseButton", "addtocartRender", "productRender", "signupRender", "style", "className", "lang", "autoTipOpen", "autoTipClose", "openTip", "setOpenTip", "openPopup", "setOpenPopup", "start", "setstart", "currentSuggestions", "setCurrentSuggestions", "history", "sethistory", "getStart", "result", "fetcher", "item", "getSuggestions", "setOpenTipFn", "timer", "load", "messages", "inProgress", "Messages", "ResponseButton", "Suggestions", "open", "setOpen", "Button", "DefaultButton"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var k=Object.create;var a=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var y=(o,e)=>{for(var r in e)a(o,r,{get:e[r],enumerable:!0})},i=(o,e,r,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w(e))!u.call(o,n)&&n!==r&&a(o,n,{get:()=>e[n],enumerable:!(p=M(e,n))||p.enumerable});return o};var m=(o,e,r)=>(r=o!=null?k(f(o)):{},i(e||!o||!o.__esModule?a(r,"default",{value:o,enumerable:!0}):r,o)),C=o=>i(a({},"__esModule",{value:!0}),o);var R={};y(R,{Markdown:()=>h});module.exports=C(R);var t=require("react/jsx-runtime"),s=require("react"),c=m(require("react-markdown")),d=m(require("remark-gfm")),l=m(require("remark-math"));const g=(0,s.memo)(c.default,(o,e)=>o.children===e.children&&o.className===e.className),h=({content:o})=>(0,t.jsx)("div",{className:"copilotKitMarkdown",children:(0,t.jsx)(g,{components:N,remarkPlugins:[d.default,l.default],children:o})}),N={p({children:o}){return(0,t.jsx)("p",{children:o})},a({children:o,...e}){return(0,t.jsx)("a",{style:{color:"blue",textDecoration:"underline"},...e,target:"_blank",rel:"noopener noreferrer",children:o})}};
|
|
2
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/chat/markdown.tsx"],
|
|
4
|
+
"sourcesContent": ["import { type FC, memo } from 'react'\nimport ReactMarkdown, { type Options, type Components } from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport remarkMath from 'remark-math'\n\nconst MemoizedReactMarkdown: FC<Options> = memo(\n ReactMarkdown,\n (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className\n)\n\ntype MarkdownProps = {\n content: string\n}\n\nexport const Markdown = ({ content }: MarkdownProps) => {\n return (\n <div className=\"copilotKitMarkdown\">\n <MemoizedReactMarkdown components={components} remarkPlugins={[remarkGfm, remarkMath]}>\n {content}\n </MemoizedReactMarkdown>\n </div>\n )\n}\n\nconst components: Components = {\n p({ children }) {\n return <p>{children}</p>\n },\n a({ children, ...props }) {\n return (\n <a style={{ color: 'blue', textDecoration: 'underline' }} {...props} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </a>\n )\n },\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAiBM,IAAAI,EAAA,6BAjBNC,EAA8B,iBAC9BC,EAA6D,6BAC7DC,EAAsB,yBACtBC,EAAuB,0BAEvB,MAAMC,KAAqC,QACzC,EAAAC,QACA,CAACC,EAAWC,IAAcD,EAAU,WAAaC,EAAU,UAAYD,EAAU,YAAcC,EAAU,SAC3G,EAMaV,EAAW,CAAC,CAAE,QAAAW,CAAQ,OAE/B,OAAC,OAAI,UAAU,qBACb,mBAACJ,EAAA,CAAsB,WAAYK,EAAY,cAAe,CAAC,EAAAC,QAAW,EAAAC,OAAU,EACjF,SAAAH,EACH,EACF,EAIEC,EAAyB,CAC7B,EAAE,CAAE,SAAAG,CAAS,EAAG,CACd,SAAO,OAAC,KAAG,SAAAA,EAAS,CACtB,EACA,EAAE,CAAE,SAAAA,EAAU,GAAGC,CAAM,EAAG,CACxB,SACE,OAAC,KAAE,MAAO,CAAE,MAAO,OAAQ,eAAgB,WAAY,EAAI,GAAGA,EAAO,OAAO,SAAS,IAAI,sBACtF,SAAAD,EACH,CAEJ,CACF",
|
|
6
|
+
"names": ["markdown_exports", "__export", "Markdown", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_markdown", "import_remark_gfm", "import_remark_math", "MemoizedReactMarkdown", "ReactMarkdown", "prevProps", "nextProps", "content", "components", "remarkGfm", "remarkMath", "children", "props"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var h=Object.create;var g=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var i in e)g(t,i,{get:e[i],enumerable:!0})},R=(t,e,i,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of I(e))!b.call(t,c)&&c!==i&&g(t,c,{get:()=>e[c],enumerable:!(p=k(e,c))||p.enumerable});return t};var B=(t,e,i)=>(i=t!=null?h(E(t)):{},R(e||!t||!t.__esModule?g(i,"default",{value:t,enumerable:!0}):i,t)),S=t=>R(g({},"__esModule",{value:!0}),t);var L={};w(L,{default:()=>F});module.exports=S(L);var o=require("react/jsx-runtime"),f=B(require("react")),m=require("@copilotkit/react-ui"),K=require("./markdown.js"),A=require("@copilotkit/react-core"),n=require("@copilotkit/runtime-client-gql");const T=({messages:t,inProgress:e,ResponseButton:i,children:p})=>{const{chatComponentsCache:c}=(0,A.useCopilotContext)(),a=(0,m.useChatContext)();t=[...(0,f.useMemo)(()=>x(a.labels.initial),[a.labels.initial]),...t];const v={};for(let s=0;s<t.length;s++)if(t[s]instanceof n.ActionExecutionMessage){const r=t[s].id,l=t.find(u=>u instanceof n.ResultMessage&&u.actionExecutionId===r);l&&(v[r]=n.ResultMessage.decodeResult(l.result||""))}const y=f.default.useRef(null),C=()=>{y.current&&y.current.scrollIntoView({behavior:"auto"})};return(0,f.useEffect)(()=>{C()},[t]),(0,o.jsxs)("div",{className:"copilotKitMessages",children:[t.map((s,r)=>{const l=r===t.length-1;if(s instanceof n.TextMessage&&s.role==="user")return(0,o.jsx)("div",{className:"copilotKitMessage copilotKitUserMessage",children:s.content},r);if(s instanceof n.TextMessage&&s.role=="assistant")return(0,o.jsx)("div",{className:"copilotKitMessage copilotKitAssistantMessage",children:l&&e&&!s.content?a.icons.spinnerIcon:(0,o.jsx)(K.Markdown,{content:s.content})},r);if(s instanceof n.ActionExecutionMessage)if(c.current!==null&&c.current[s.name]){const u=c.current[s.name];if(typeof u=="string")return l&&e?(0,o.jsxs)("div",{className:"copilotKitMessage copilotKitAssistantMessage",children:[a.icons.spinnerIcon," ",(0,o.jsx)("span",{className:"inProgressLabel",children:u})]},r):null;{const N=s.arguments;let d="inProgress";v[s.id]!==void 0?d="complete":s.status.code!==n.MessageStatusCode.Pending&&(d="executing");const M=u({status:d,args:N,result:v[s.id]});return!M&&d==="complete"?null:typeof M=="string"?(0,o.jsxs)("div",{className:"copilotKitMessage copilotKitAssistantMessage",children:[l&&e&&a.icons.spinnerIcon," ",M]},r):(0,o.jsx)("div",{className:"copilotKitCustomAssistantMessage",children:M},r)}}else return!e||!l?null:(0,o.jsx)("div",{className:"copilotKitMessage copilotKitAssistantMessage",children:a.icons.spinnerIcon},r)}),(0,o.jsx)("div",{className:"responseButtonBox",children:i}),(0,o.jsx)("footer",{ref:y,children:p})]})};function x(t){let e=[];return t&&(Array.isArray(t)?e.push(...t):e.push(t)),e.map(i=>new n.TextMessage({role:n.Role.Assistant,content:i}))}var F=T;
|
|
2
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/chat/messages.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useMemo } from 'react'\nimport type { MessagesProps } from './props.js'\nimport { useChatContext } from '@copilotkit/react-ui'\nimport { Markdown } from './markdown.js'\nimport { type RenderFunctionStatus, useCopilotContext } from '@copilotkit/react-core'\nimport {\n MessageStatusCode,\n ActionExecutionMessage,\n Message,\n ResultMessage,\n TextMessage,\n Role,\n} from '@copilotkit/runtime-client-gql'\n\nconst Messages = ({ messages, inProgress, ResponseButton, children }: MessagesProps) => {\n const { chatComponentsCache } = useCopilotContext()\n\n const context = useChatContext()\n const initialMessages = useMemo(() => makeInitialMessages(context.labels.initial), [context.labels.initial])\n messages = [...initialMessages, ...messages]\n\n const functionResults: Record<string, string> = {}\n\n for (let i = 0; i < messages.length; i++) {\n if (messages[i] instanceof ActionExecutionMessage) {\n const id = messages[i].id\n const resultMessage: ResultMessage | undefined = messages.find(\n message => message instanceof ResultMessage && message.actionExecutionId === id\n ) as ResultMessage | undefined\n\n if (resultMessage) {\n functionResults[id] = ResultMessage.decodeResult(resultMessage.result || '')\n }\n }\n }\n\n const messagesEndRef = React.useRef<HTMLDivElement>(null)\n\n const scrollToBottom = () => {\n if (messagesEndRef.current) {\n messagesEndRef.current.scrollIntoView({\n behavior: 'auto',\n })\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [messages])\n\n return (\n <div className=\"copilotKitMessages\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1\n\n if (message instanceof TextMessage && message.role === 'user') {\n return (\n <div key={index} className=\"copilotKitMessage copilotKitUserMessage\">\n {message.content}\n </div>\n )\n } else if (message instanceof TextMessage && message.role == 'assistant') {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && !message.content ? (\n context.icons.spinnerIcon\n ) : (\n <Markdown content={message.content} />\n )}\n </div>\n )\n } else if (message instanceof ActionExecutionMessage) {\n if (chatComponentsCache.current !== null && chatComponentsCache.current[message.name]) {\n const render = chatComponentsCache.current[message.name]\n // render a static string\n if (typeof render === 'string') {\n // when render is static, we show it only when in progress\n if (isCurrentMessage && inProgress) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon} <span className=\"inProgressLabel\">{render}</span>\n </div>\n )\n }\n // Done - silent by default to avoid a series of \"done\" messages\n else {\n return null\n }\n }\n // render is a function\n else {\n const args = message.arguments\n\n let status: RenderFunctionStatus = 'inProgress'\n\n if (functionResults[message.id] !== undefined) {\n status = 'complete'\n } else if (message.status.code !== MessageStatusCode.Pending) {\n status = 'executing'\n }\n\n const toRender = render({\n status: status as any,\n args,\n result: functionResults[message.id],\n })\n\n // No result and complete: stay silent\n if (!toRender && status === 'complete') {\n return null\n }\n\n if (typeof toRender === 'string') {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && context.icons.spinnerIcon} {toRender}\n </div>\n )\n } else {\n return (\n <div key={index} className=\"copilotKitCustomAssistantMessage\">\n {toRender}\n </div>\n )\n }\n }\n }\n // No render function found- show the default message\n else if (!inProgress || !isCurrentMessage) {\n // Done - silent by default to avoid a series of \"done\" messages\n return null\n } else {\n // In progress\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon}\n </div>\n )\n }\n }\n })}\n <div className=\"responseButtonBox\">{ResponseButton}</div>\n <footer ref={messagesEndRef}>{children}</footer>\n </div>\n )\n}\n\nfunction makeInitialMessages(initial?: string | string[]): Message[] {\n let initialArray: string[] = []\n if (initial) {\n if (Array.isArray(initial)) {\n initialArray.push(...initial)\n } else {\n initialArray.push(initial)\n }\n }\n\n return initialArray.map(\n message =>\n new TextMessage({\n role: Role.Assistant,\n content: message,\n })\n )\n}\n\nexport default Messages\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyDY,IAAAI,EAAA,6BAzDZC,EAA0C,oBAE1CC,EAA+B,gCAC/BC,EAAyB,yBACzBC,EAA6D,kCAC7DC,EAOO,0CAEP,MAAMC,EAAW,CAAC,CAAE,SAAAC,EAAU,WAAAC,EAAY,eAAAC,EAAgB,SAAAC,CAAS,IAAqB,CACtF,KAAM,CAAE,oBAAAC,CAAoB,KAAI,qBAAkB,EAE5CC,KAAU,kBAAe,EAE/BL,EAAW,CAAC,MADY,WAAQ,IAAMM,EAAoBD,EAAQ,OAAO,OAAO,EAAG,CAACA,EAAQ,OAAO,OAAO,CAAC,EAC3E,GAAGL,CAAQ,EAE3C,MAAMO,EAA0C,CAAC,EAEjD,QAASC,EAAI,EAAGA,EAAIR,EAAS,OAAQQ,IACn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AM,OAClCQ,EAAS,WACAR,EAAQ,OAAO,OAAS,oBAAkB,UACnDQ,EAAS,aAGX,MAAMC,EAAWH,EAAO,CACtB,OAAQE,EACR,KAAAD,EACA,OAAQX,EAAgBI,EAAQ,EAAE,CACpC,CAAC,EAGD,MAAI,CAACS,GAAYD,IAAW,WACnB,KAGL,OAAOC,GAAa,YAEpB,QAAC,OAAgB,UAAW,+CACzB,UAAAJ,GAAoBf,GAAcI,EAAQ,MAAM,YAAY,IAAEe,IADvDL,CAEV,KAIA,OAAC,OAAgB,UAAU,mCACxB,SAAAK,GADOL,CAEV,CAGN,CACF,KAEK,OAAI,CAACd,GAAc,CAACe,EAEhB,QAIL,OAAC,OAAgB,UAAW,+CACzB,SAAAX,EAAQ,MAAM,aADPU,CAEV,CAIR,CAAC,KACD,OAAC,OAAI,UAAU,oBAAqB,SAAAb,EAAe,KACnD,OAAC,UAAO,IAAKU,EAAiB,SAAAT,EAAS,GACzC,CAEJ,EAEA,SAASG,EAAoBe,EAAwC,CACnE,IAAIC,EAAyB,CAAC,EAC9B,OAAID,IACE,MAAM,QAAQA,CAAO,EACvBC,EAAa,KAAK,GAAGD,CAAO,EAE5BC,EAAa,KAAKD,CAAO,GAItBC,EAAa,IAClBX,GACE,IAAI,cAAY,CACd,KAAM,OAAK,UACX,QAASA,CACX,CAAC,CACL,CACF,CAEA,IAAOpB,EAAQQ",
|
|
6
|
+
"names": ["messages_exports", "__export", "messages_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_ui", "import_markdown", "import_react_core", "import_runtime_client_gql", "Messages", "messages", "inProgress", "ResponseButton", "children", "chatComponentsCache", "context", "makeInitialMessages", "functionResults", "i", "id", "resultMessage", "message", "messagesEndRef", "React", "scrollToBottom", "index", "isCurrentMessage", "render", "args", "status", "toRender", "initial", "initialArray"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Message } from '@copilotkit/runtime-client-gql';
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
setOpen: (open: boolean) => void;
|
|
6
|
+
setOpenTip: (open: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface WindowProps {
|
|
9
|
+
open: boolean;
|
|
10
|
+
setOpen: (open: boolean) => void;
|
|
11
|
+
clickOutsideToClose: boolean;
|
|
12
|
+
hitEscapeToClose: boolean;
|
|
13
|
+
shortcut: string;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export interface HeaderProps {
|
|
17
|
+
open: boolean;
|
|
18
|
+
setOpen: (open: boolean) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ChatSuggestions {
|
|
21
|
+
currentSuggestions: SuggestionsProps[];
|
|
22
|
+
}
|
|
23
|
+
export interface SuggestionsProps {
|
|
24
|
+
title: string;
|
|
25
|
+
message: string;
|
|
26
|
+
partial?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MessagesProps {
|
|
30
|
+
messages: Message[];
|
|
31
|
+
inProgress: boolean;
|
|
32
|
+
ResponseButton?: React.ReactElement;
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
}
|
|
35
|
+
export interface InputProps {
|
|
36
|
+
inProgress: boolean;
|
|
37
|
+
onSend: (text: string) => Promise<Message>;
|
|
38
|
+
isVisible?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ResponseButtonProps {
|
|
41
|
+
onClick: () => void;
|
|
42
|
+
inProgress: boolean;
|
|
43
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!p.call(o,n)&&n!==r&&t(o,n,{get:()=>e[n],enumerable:!(s=a(e,n))||s.enumerable});return o};var c=o=>l(t({},"__esModule",{value:!0}),o);var g={};module.exports=c(g);var d=require("react"),u=require("@copilotkit/runtime-client-gql");
|
|
2
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/chat/props.ts"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { Message } from '@copilotkit/runtime-client-gql'\n\nexport interface ButtonProps {\n open: boolean\n setOpen: (open: boolean) => void\n setOpenTip: (open: boolean) => void\n}\n\nexport interface WindowProps {\n open: boolean\n setOpen: (open: boolean) => void\n clickOutsideToClose: boolean\n hitEscapeToClose: boolean\n shortcut: string\n children?: React.ReactNode\n}\n\nexport interface HeaderProps {\n open: boolean\n setOpen: (open: boolean) => void\n}\n\nexport interface ChatSuggestions {\n currentSuggestions: SuggestionsProps[]\n}\n\nexport interface SuggestionsProps {\n title: string\n message: string\n partial?: boolean\n className?: string\n}\n\nexport interface MessagesProps {\n messages: Message[]\n inProgress: boolean\n ResponseButton?: React.ReactElement\n children?: React.ReactNode\n}\n\nexport interface InputProps {\n inProgress: boolean\n onSend: (text: string) => Promise<Message>\n isVisible?: boolean\n}\n\nexport interface ResponseButtonProps {\n onClick: () => void\n inProgress: boolean\n}\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAA,IAAAE,EAAkB,iBAClBC,EAAwB",
|
|
6
|
+
"names": ["props_exports", "__toCommonJS", "import_react", "import_runtime_client_gql"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var g=(t,o)=>{for(var e in o)p(t,e,{get:o[e],enumerable:!0})},C=(t,o,e,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of l(o))!u.call(t,n)&&n!==e&&p(t,n,{get:()=>o[n],enumerable:!(s=c(o,n))||s.enumerable});return t};var b=t=>C(p({},"__esModule",{value:!0}),t);var f={};g(f,{default:()=>d});module.exports=b(f);var a=require("react/jsx-runtime"),r=require("@copilotkit/react-ui"),i=require("@copilotkit/react-core");const m=()=>{const t=(0,r.useChatContext)(),{isLoading:o,reloadMessages:e,stopGeneration:s}=(0,i.useCopilotChat)();return(0,a.jsxs)("button",{onClick:o?s:e,className:"copilotKitResponseButton",children:[o?t.labels.stopGenerating:t.labels.regenerateResponse,(0,a.jsx)("span",{children:o?t.icons.stopIcon:t.icons.regenerateIcon})]})};var d=m;
|
|
2
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/chat/response.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useChatContext } from '@copilotkit/react-ui'\nimport { useCopilotChat } from '@copilotkit/react-core'\n\nconst ResponseButton = () => {\n const context = useChatContext()\n\n const { isLoading, reloadMessages, stopGeneration } = useCopilotChat()\n\n return (\n <button onClick={isLoading ? stopGeneration : reloadMessages} className=\"copilotKitResponseButton\">\n {isLoading ? context.labels.stopGenerating : context.labels.regenerateResponse}\n <span>{isLoading ? context.icons.stopIcon : context.icons.regenerateIcon}</span>\n </button>\n )\n}\n\nexport default ResponseButton\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GASI,IAAAI,EAAA,6BATJC,EAA+B,gCAC/BC,EAA+B,kCAE/B,MAAMC,EAAiB,IAAM,CAC3B,MAAMC,KAAU,kBAAe,EAEzB,CAAE,UAAAC,EAAW,eAAAC,EAAgB,eAAAC,CAAe,KAAI,kBAAe,EAErE,SACE,QAAC,UAAO,QAASF,EAAYE,EAAiBD,EAAgB,UAAU,2BACrE,UAAAD,EAAYD,EAAQ,OAAO,eAAiBA,EAAQ,OAAO,sBAC5D,OAAC,QAAM,SAAAC,EAAYD,EAAQ,MAAM,SAAWA,EAAQ,MAAM,eAAe,GAC3E,CAEJ,EAEA,IAAON,EAAQK",
|
|
6
|
+
"names": ["response_exports", "__export", "response_default", "__toCommonJS", "import_jsx_runtime", "import_react_ui", "import_react_core", "ResponseButton", "context", "isLoading", "reloadMessages", "stopGeneration"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var C=(o,s)=>{for(var e in s)g(o,e,{get:s[e],enumerable:!0})},b=(o,s,e,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let t of c(s))!f.call(o,t)&&t!==e&&g(o,t,{get:()=>s[t],enumerable:!(n=d(s,t))||n.enumerable});return o};var h=o=>b(g({},"__esModule",{value:!0}),o);var k={};C(k,{default:()=>v});module.exports=h(k);var p=require("react/jsx-runtime"),i=require("@copilotkit/react-core"),a=require("@copilotkit/runtime-client-gql");const S=({currentSuggestions:o})=>{const{appendMessage:s}=(0,i.useCopilotChat)();return o?.length>0&&(0,p.jsx)("div",{className:"suggestions",children:o.map(({title:e,message:n,partial:t,className:r},u)=>(0,p.jsx)("button",{disabled:t,onClick:l=>{l.preventDefault();const m=new a.TextMessage({content:n,role:a.Role.User});s(m)},className:r||"suggestion",children:(0,p.jsx)("span",{children:e})},n+u))})};var v=S;
|
|
2
|
+
//# sourceMappingURL=suggestions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/chat/suggestions.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useCopilotChat } from '@copilotkit/react-core'\nimport { Role, TextMessage } from '@copilotkit/runtime-client-gql'\n\nimport type { SuggestionsProps, ChatSuggestions } from './props.js'\n\nconst Suggestions = ({ currentSuggestions }: ChatSuggestions) => {\n const { appendMessage } = useCopilotChat()\n\n return (\n currentSuggestions?.length > 0 && (\n <div className=\"suggestions\">\n {currentSuggestions.map(({ title, message, partial, className }: SuggestionsProps, index: number) => (\n <button\n key={message + index}\n disabled={partial}\n onClick={e => {\n e.preventDefault()\n const m = new TextMessage({\n content: message,\n role: Role.User,\n })\n appendMessage(m)\n }}\n className={className || 'suggestion'}\n >\n <span>{title}</span>\n </button>\n ))}\n </div>\n )\n )\n}\n\nexport default Suggestions\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyBY,IAAAI,EAAA,6BAzBZC,EAA+B,kCAC/BC,EAAkC,0CAIlC,MAAMC,EAAc,CAAC,CAAE,mBAAAC,CAAmB,IAAuB,CAC/D,KAAM,CAAE,cAAAC,CAAc,KAAI,kBAAe,EAEzC,OACED,GAAoB,OAAS,MAC3B,OAAC,OAAI,UAAU,cACZ,SAAAA,EAAmB,IAAI,CAAC,CAAE,MAAAE,EAAO,QAAAC,EAAS,QAAAC,EAAS,UAAAC,CAAU,EAAqBC,OACjF,OAAC,UAEC,SAAUF,EACV,QAASG,GAAK,CACZA,EAAE,eAAe,EACjB,MAAM,EAAI,IAAI,cAAY,CACxB,QAASJ,EACT,KAAM,OAAK,IACb,CAAC,EACDF,EAAc,CAAC,CACjB,EACA,UAAWI,GAAa,aAExB,mBAAC,QAAM,SAAAH,EAAM,GAZRC,EAAUG,CAajB,CACD,EACH,CAGN,EAEA,IAAOZ,EAAQK",
|
|
6
|
+
"names": ["suggestions_exports", "__export", "suggestions_default", "__toCommonJS", "import_jsx_runtime", "import_react_core", "import_runtime_client_gql", "Suggestions", "currentSuggestions", "appendMessage", "title", "message", "partial", "className", "index", "e"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var y=(t,o)=>{for(var a in o)i(t,a,{get:o[a],enumerable:!0})},f=(t,o,a,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of n(o))!c.call(t,e)&&e!==a&&i(t,e,{get:()=>o[e],enumerable:!(r=m(o,e))||r.enumerable});return t};var h=t=>f(i({},"__esModule",{value:!0}),t);var C={};y(C,{Default:()=>l,default:()=>d});module.exports=h(C);var p=require("react/jsx-runtime"),v=require("react"),s=require("../components/index.js"),b=require("../styles/chat.css");const u={title:"Campaign/Chat",component:s.Chat,args:{title:"DTC Live Chat",runtimeUrl:"https://beta-dtcapi.anker.com",shopify_domain:"soundcoreusa.myshopify.com"},tags:["autodocs"],decorators:[t=>(0,p.jsx)("div",{style:{marginTop:"40em"},children:(0,p.jsx)(t,{})})]};var d=u;const l={args:{title:"DTC Live Chat",runtimeUrl:"https://beta-dtcapi.anker.com",shopify_domain:"soundcoreusa.myshopify.com",user_id:"arno5",showResponseButton:"follow",lang:{popupTip:"Hi ! Welcome to soundcore Innovations live chat\uFF01",popupTipTimeout:[3e3,6e3]}}};
|
|
2
2
|
//# sourceMappingURL=chat.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/stories/chat.stories.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\nimport type { Meta, StoryObj } from '@storybook/react'\
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAwBQ,IAAAK,EAAA,6BAxBRC,EAAkB,
|
|
6
|
-
"names": ["chat_stories_exports", "__export", "Default", "chat_stories_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_components", "meta", "Story"]
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport type { Meta, StoryObj } from '@storybook/react'\nimport { Chat } from '../components/index.js'\nimport '../styles/chat.css'\n\ntype Story = StoryObj<typeof meta>\n\n// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export\nconst meta: Meta<typeof Chat> = {\n // \u540C\u65F6\u5B9A\u4E49\u4E86\u9875\u9762\u5DE6\u4FA7\u83DC\u5355\n title: 'Campaign/Chat',\n component: Chat,\n args: {\n title: 'DTC Live Chat',\n runtimeUrl: 'https://beta-dtcapi.anker.com',\n shopify_domain: 'soundcoreusa.myshopify.com',\n },\n // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs\n tags: ['autodocs'],\n // More on argTypes: https://storybook.js.org/docs/api/argtypes\n decorators: [\n Story => (\n <div style={{ marginTop: '40em' }}>\n {/* \uD83D\uDC47 Decorators in Storybook also accept a function. Replace <Story/> with Story() to enable it */}\n <Story />\n </div>\n ),\n ],\n} satisfies Meta<typeof Chat>\n\nexport default meta\n\nexport const Default: Story = {\n args: {\n title: 'DTC Live Chat',\n runtimeUrl: 'https://beta-dtcapi.anker.com',\n shopify_domain: 'soundcoreusa.myshopify.com',\n user_id: 'arno5',\n showResponseButton: 'follow',\n lang: { popupTip: 'Hi ! Welcome to soundcore Innovations live chat\uFF01', popupTipTimeout: [3000, 6000] },\n },\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAwBQ,IAAAK,EAAA,6BAxBRC,EAAkB,iBAElBC,EAAqB,kCACrBC,EAAO,8BAKP,MAAMC,EAA0B,CAE9B,MAAO,gBACP,UAAW,OACX,KAAM,CACJ,MAAO,gBACP,WAAY,gCACZ,eAAgB,4BAClB,EAEA,KAAM,CAAC,UAAU,EAEjB,WAAY,CACVC,MACE,OAAC,OAAI,MAAO,CAAE,UAAW,MAAO,EAE9B,mBAACA,EAAA,EAAM,EACT,CAEJ,CACF,EAEA,IAAOP,EAAQM,EAER,MAAMP,EAAiB,CAC5B,KAAM,CACJ,MAAO,gBACP,WAAY,gCACZ,eAAgB,6BAChB,QAAS,QACT,mBAAoB,SACpB,KAAM,CAAE,SAAU,wDAAoD,gBAAiB,CAAC,IAAM,GAAI,CAAE,CACtG,CACF",
|
|
6
|
+
"names": ["chat_stories_exports", "__export", "Default", "chat_stories_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_components", "import_chat", "meta", "Story"]
|
|
7
7
|
}
|