@anker-in/campaign-ui 0.0.33-alpha → 0.0.33-alpha2

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/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.0.33-alpha",
3
+ "version": "0.0.33-alpha2",
4
4
  "type": "commonjs",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",
7
7
  "module": "./dist/esm/index.js",
8
- "style": "./style.css",
9
8
  "exports": {
10
9
  ".": {
11
10
  "require": {
@@ -46,7 +45,7 @@
46
45
  "build:js:cjs:types": "tsc --outdir dist/cjs",
47
46
  "build:js:esm": "node esbuild-esm.mjs",
48
47
  "build:js:esm:types": "tsc --outdir dist/esm",
49
- "build:css": "postcss src/styles/global.css -o style.css",
48
+ "build:css": "postcss src/styles/chat.css -o style.css",
50
49
  "lint": "eslint \"src/**/*.ts*\"",
51
50
  "test": "eslint \"src/**/*.ts*\"",
52
51
  "clean": "rm -rf .turbo node_modules dist style.css"
@@ -74,9 +73,10 @@
74
73
  "stylelint": "^16.6.0"
75
74
  },
76
75
  "dependencies": {
77
- "@copilotkit/react-core": "^1.1.2",
78
- "@copilotkit/react-ui": "^1.1.2",
79
- "@copilotkit/runtime-client-gql": "^1.1.2",
76
+ "@copilotkit/react-core": "1.1.2",
77
+ "@copilotkit/react-ui": "1.1.2",
78
+ "@copilotkit/runtime-client-gql": "1.1.2",
79
+ "@copilotkit/shared": "1.1.2",
80
80
  "@radix-ui/react-checkbox": "^1.0.4",
81
81
  "@radix-ui/react-dialog": "^1.0.5",
82
82
  "@radix-ui/react-icons": "^1.3.0",
@@ -12,8 +12,8 @@ interface Message {
12
12
  export interface ActionProps {
13
13
  start?: string
14
14
  history: Message[]
15
- buynowRender?: string | ((_props: any) => string)
16
- signupRender?: string | ((_props: any) => string)
15
+ buynowRender?: string | ((_props: any) => React.ReactElement)
16
+ signupRender?: string | ((_props: any) => React.ReactElement)
17
17
  children?: React.ReactNode
18
18
  }
19
19
 
@@ -5,6 +5,8 @@ import { CopilotPopup } from '@copilotkit/react-ui'
5
5
  import { CopilotAction } from './action.js'
6
6
  import fetcher from '../../helpers/fetcher.js'
7
7
 
8
+ // import '../../styles/chat.css'
9
+
8
10
  export interface ChatProps {
9
11
  title: string
10
12
  runtimeUrl: string
@@ -18,11 +20,11 @@ export interface ChatProps {
18
20
  /** 产品卡片,接受参数: {"status":"complete","args":[{"sku":"A3936031","handle":"space-a40-a3936031"}],"result":""}
19
21
  * 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
20
22
  */
21
- buynowRender?: string | ((_props: any) => string)
23
+ buynowRender?: string | ((_props: any) => React.ReactElement)
22
24
  /** 订阅卡片,接受参数:
23
25
  * 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
24
26
  */
25
- signupRender?: string | ((_props: any) => string)
27
+ signupRender?: string | ((_props: any) => React.ReactElement)
26
28
  /** CopilotPopup 自定义参数,参考:https://docs.copilotkit.ai/reference/components/CopilotPopup */
27
29
  popup?: any
28
30
  /** 文案,{"popupTip": "Hi ! Welcome to soundcore Innovations live chat!"} */
@@ -48,6 +50,7 @@ const Chat = (props: ChatProps) => {
48
50
  } = props
49
51
 
50
52
  const [openTip, setOpenTip] = useState(false)
53
+ const [openPopup, setOpenPopup] = useState(false)
51
54
  const [start, setstart] = useState('')
52
55
  const [history, sethistory] = useState<[{ content: string; role: string }] | []>([])
53
56
 
@@ -62,9 +65,13 @@ const Chat = (props: ChatProps) => {
62
65
  sethistory(result?.history || [])
63
66
  }, [user_id])
64
67
 
68
+ const setOpenTipFn = () => {
69
+ if (!openTip) setOpenTip(true)
70
+ }
71
+
65
72
  useEffect(() => {
66
73
  const timer = setTimeout(() => {
67
- if (!openTip) setOpenTip(true)
74
+ setOpenTipFn()
68
75
  }, 3000)
69
76
 
70
77
  return () => {
@@ -104,9 +111,11 @@ const Chat = (props: ChatProps) => {
104
111
  }}
105
112
  Button={({ open, setOpen }) => {
106
113
  const Button = popup?.Button
114
+ useEffect(() => setOpenPopup(open), [open])
115
+
107
116
  return (
108
117
  <>
109
- {lang?.popupTip && openTip && (
118
+ {lang?.popupTip && openTip && !openPopup && (
110
119
  <div className="copilotKitPopup copilotKitPopupTip">
111
120
  <button
112
121
  onClick={() => {
@@ -35,7 +35,7 @@ export const Default: Story = {
35
35
  title: 'DTC Live Chat',
36
36
  runtimeUrl: 'https://beta-dtcapi.anker.com',
37
37
  shopify_domain: 'soundcoreusa.myshopify.com',
38
- user_id: 'ar_4',
38
+ user_id: 'ar_411',
39
39
  query: '',
40
40
  lang: { popupTip: 'Hi ! Welcome to soundcore Innovations live chat!' },
41
41
  },