@anker-in/campaign-ui 0.1.6 → 0.1.8

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 (74) hide show
  1. package/dist/cjs/components/animation/CodeEditor.d.ts +7 -0
  2. package/dist/cjs/components/animation/CodeEditor.js +2 -0
  3. package/dist/cjs/components/animation/CodeEditor.js.map +7 -0
  4. package/dist/cjs/components/animation/Preview.d.ts +5 -0
  5. package/dist/cjs/components/animation/Preview.js +2 -0
  6. package/dist/cjs/components/animation/Preview.js.map +7 -0
  7. package/dist/cjs/components/animation/bannerAni.d.ts +16 -0
  8. package/dist/cjs/components/animation/bannerAni.js +59 -0
  9. package/dist/cjs/components/animation/bannerAni.js.map +7 -0
  10. package/dist/cjs/components/animation/libs.d.js +2 -0
  11. package/dist/cjs/components/animation/libs.d.js.map +7 -0
  12. package/dist/cjs/components/animation/textAni.d.ts +9 -0
  13. package/dist/cjs/components/animation/textAni.js +2 -0
  14. package/dist/cjs/components/animation/textAni.js.map +7 -0
  15. package/dist/cjs/components/chat/Messages.d.ts +1 -1
  16. package/dist/cjs/components/chat/action.d.ts +1 -3
  17. package/dist/cjs/components/chat/action.js +1 -1
  18. package/dist/cjs/components/chat/action.js.map +3 -3
  19. package/dist/cjs/components/chat/index.d.ts +0 -10
  20. package/dist/cjs/components/chat/index.js +1 -1
  21. package/dist/cjs/components/chat/index.js.map +3 -3
  22. package/dist/cjs/components/chat/messages.js +1 -1
  23. package/dist/cjs/components/chat/messages.js.map +3 -3
  24. package/dist/cjs/components/chat/props.d.ts +0 -1
  25. package/dist/cjs/components/chat/props.js +1 -1
  26. package/dist/cjs/components/chat/props.js.map +1 -1
  27. package/dist/cjs/components/chat/utils.d.ts +2 -1
  28. package/dist/cjs/components/chat/utils.js +1 -1
  29. package/dist/cjs/components/chat/utils.js.map +3 -3
  30. package/dist/cjs/components/index.d.ts +0 -1
  31. package/dist/cjs/components/index.js +1 -1
  32. package/dist/cjs/components/index.js.map +3 -3
  33. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  34. package/dist/esm/components/animation/CodeEditor.d.ts +7 -0
  35. package/dist/esm/components/animation/CodeEditor.js +2 -0
  36. package/dist/esm/components/animation/CodeEditor.js.map +7 -0
  37. package/dist/esm/components/animation/Preview.d.ts +5 -0
  38. package/dist/esm/components/animation/Preview.js +2 -0
  39. package/dist/esm/components/animation/Preview.js.map +7 -0
  40. package/dist/esm/components/animation/bannerAni.d.ts +16 -0
  41. package/dist/esm/components/animation/bannerAni.js +59 -0
  42. package/dist/esm/components/animation/bannerAni.js.map +7 -0
  43. package/dist/esm/components/animation/libs.d.js +2 -0
  44. package/dist/esm/components/animation/libs.d.js.map +7 -0
  45. package/dist/esm/components/animation/textAni.d.ts +9 -0
  46. package/dist/esm/components/animation/textAni.js +2 -0
  47. package/dist/esm/components/animation/textAni.js.map +7 -0
  48. package/dist/esm/components/chat/Messages.d.ts +1 -1
  49. package/dist/esm/components/chat/action.d.ts +1 -3
  50. package/dist/esm/components/chat/action.js +1 -1
  51. package/dist/esm/components/chat/action.js.map +3 -3
  52. package/dist/esm/components/chat/index.d.ts +0 -10
  53. package/dist/esm/components/chat/index.js +1 -1
  54. package/dist/esm/components/chat/index.js.map +3 -3
  55. package/dist/esm/components/chat/messages.js +1 -1
  56. package/dist/esm/components/chat/messages.js.map +3 -3
  57. package/dist/esm/components/chat/props.d.ts +0 -1
  58. package/dist/esm/components/chat/props.js.map +1 -1
  59. package/dist/esm/components/chat/utils.d.ts +2 -1
  60. package/dist/esm/components/chat/utils.js +1 -1
  61. package/dist/esm/components/chat/utils.js.map +3 -3
  62. package/dist/esm/components/index.d.ts +0 -1
  63. package/dist/esm/components/index.js +1 -1
  64. package/dist/esm/components/index.js.map +3 -3
  65. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +11 -7
  67. package/src/components/chat/action.tsx +0 -24
  68. package/src/components/chat/index.tsx +2 -18
  69. package/src/components/chat/messages.tsx +1 -5
  70. package/src/components/chat/props.ts +0 -1
  71. package/src/components/index.ts +0 -3
  72. package/src/helpers/index.ts +2 -0
  73. package/src/helpers/utils.ts +8 -0
  74. package/src/components/chat/utils.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "commonjs",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  "build:js:esm:types": "tsc --outdir dist/esm",
48
48
  "build:css": "postcss src/styles/chat.css -o style.css",
49
49
  "lint": "eslint \"src/**/*.ts*\"",
50
- "test": "eslint \"src/**/*.ts*\"",
50
+ "test": "echo run @anker-in/campaign-ui tests",
51
51
  "clean": "rm -rf .turbo node_modules dist style.css"
52
52
  },
53
53
  "keywords": [],
@@ -73,10 +73,11 @@
73
73
  "stylelint": "^16.6.0"
74
74
  },
75
75
  "dependencies": {
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",
76
+ "@copilotkit/react-core": "1.8.13",
77
+ "@copilotkit/react-ui": "1.8.13",
78
+ "@copilotkit/runtime-client-gql": "1.8.13",
79
+ "@copilotkit/shared": "1.8.13",
80
+ "@monaco-editor/react": "^4.6.0",
80
81
  "@radix-ui/react-checkbox": "^1.0.4",
81
82
  "@radix-ui/react-dialog": "^1.0.5",
82
83
  "@radix-ui/react-icons": "^1.3.0",
@@ -87,10 +88,13 @@
87
88
  "autoprefixer": "^10.4.19",
88
89
  "class-variance-authority": "^0.7.0",
89
90
  "clsx": "^2.1.1",
91
+ "gsap": "^3.12.5",
92
+ "monaco-editor": "^0.52.0",
90
93
  "postcss": "^8.4.38",
91
94
  "react": "^18.3.1",
95
+ "react-codepen-embed": "^1.1.0",
92
96
  "react-dom": "^18.3.1",
93
97
  "tailwind-merge": "^2.3.0",
94
98
  "tailwindcss": "^3.4.3"
95
99
  }
96
- }
100
+ }
@@ -15,8 +15,6 @@ export interface ActionProps {
15
15
  start?: string
16
16
  history: Message[]
17
17
  addtocartHandler?: (_args: any) => Promise<any>
18
- commonRender?: string | ((_props: any) => React.ReactElement)
19
- pointsExchangeCouponRender?: string | ((_props: any) => React.ReactElement)
20
18
  gotocheckoutRender?: string | ((_props: any) => React.ReactElement)
21
19
  gotocartRender?: string | ((_props: any) => React.ReactElement)
22
20
  addtocartRender?: string | ((_props: any) => React.ReactElement)
@@ -30,8 +28,6 @@ export const CopilotAction = ({
30
28
  start,
31
29
  history,
32
30
  addtocartHandler,
33
- commonRender,
34
- pointsExchangeCouponRender,
35
31
  gotocheckoutRender,
36
32
  gotocartRender,
37
33
  addtocartRender,
@@ -72,26 +68,6 @@ export const CopilotAction = ({
72
68
  },
73
69
  })
74
70
 
75
- useCopilotAction({
76
- name: 'common_action',
77
- description: 'common action',
78
- parameters: [{ act: '' }] as any,
79
- render: commonRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
80
- handler: function () {
81
- // console.log('common_action', props)
82
- },
83
- })
84
-
85
- useCopilotAction({
86
- name: 'points_exchange_coupon',
87
- description: 'points exchange coupon',
88
- parameters: [{ act: '' }] as any,
89
- render: pointsExchangeCouponRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
90
- handler: function () {
91
- // console.log('points_exchange_coupon', props)
92
- },
93
- })
94
-
95
71
  useCopilotAction({
96
72
  name: 'go_to_cart',
97
73
  description: 'go to cart',
@@ -34,16 +34,6 @@ export interface ChatProps {
34
34
  * unfollow: ResponseButton 在聊天框底部
35
35
  */
36
36
  showResponseButton?: string | boolean
37
- /** messages 的回调事件
38
- * 每次生成/接受新的messages,会将 整个 messages list 传递给外部
39
- */
40
- messagesCallback?: (_messages: any) => void
41
- /** 通用 action 的触发事件
42
- */
43
- commonRender?: string | ((_props: any) => React.ReactElement)
44
- /** 通用 积分 换 Coupon 的触发事件
45
- */
46
- pointsExchangeCouponRender?: string | ((_props: any) => React.ReactElement)
47
37
  /** 跳转 checkout action 卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
48
38
  * 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
49
39
  */
@@ -87,11 +77,8 @@ const Chat = (props: ChatProps) => {
87
77
  prologue = '',
88
78
  locale = '',
89
79
  query = '',
90
- messagesCallback,
91
80
  showResponseButton,
92
81
  gotocheckoutRender,
93
- commonRender,
94
- pointsExchangeCouponRender,
95
82
  gotocartRender,
96
83
  addtocartRender,
97
84
  productRender,
@@ -129,7 +116,7 @@ const Chat = (props: ChatProps) => {
129
116
  setCurrentSuggestions(result?.suggested_questions?.map((item: string) => ({ message: item, title: item })) || [])
130
117
  setstart(result?.opening_statement || '')
131
118
  sethistory(result?.history || [])
132
- }, [userId, shopifyDomain, account, locale, query])
119
+ }, [userId, shopifyDomain, account, locale])
133
120
 
134
121
  const getSuggestions = useCallback(async () => {
135
122
  const result = await fetcher({
@@ -141,7 +128,7 @@ const Chat = (props: ChatProps) => {
141
128
  setCurrentSuggestions(
142
129
  result?.suggested_questions?.data?.map((item: string) => ({ message: item, title: item })) || []
143
130
  )
144
- }, [userId, shopifyDomain, account, locale, query])
131
+ }, [userId, shopifyDomain, account, locale])
145
132
 
146
133
  const setOpenTipFn = () => {
147
134
  if (!openTip) setOpenTip(true)
@@ -180,7 +167,6 @@ const Chat = (props: ChatProps) => {
180
167
  <Messages
181
168
  messages={messages}
182
169
  inProgress={inProgress}
183
- messagesCallback={messagesCallback}
184
170
  ResponseButton={showResponseButton === 'follow' ? <ResponseButton /> : undefined}
185
171
  >
186
172
  <Suggestions currentSuggestions={currentSuggestions} />
@@ -217,8 +203,6 @@ const Chat = (props: ChatProps) => {
217
203
  <CopilotAction
218
204
  start={start}
219
205
  history={history}
220
- commonRender={commonRender}
221
- pointsExchangeCouponRender={pointsExchangeCouponRender}
222
206
  gotocartRender={gotocartRender}
223
207
  gotocheckoutRender={gotocheckoutRender}
224
208
  addtocartRender={addtocartRender}
@@ -12,7 +12,7 @@ import {
12
12
  Role,
13
13
  } from '@copilotkit/runtime-client-gql'
14
14
 
15
- const Messages = ({ messages, inProgress, ResponseButton, messagesCallback, children }: MessagesProps) => {
15
+ const Messages = ({ messages, inProgress, ResponseButton, children }: MessagesProps) => {
16
16
  const [isExpanded, setIsExpanded] = useState(true)
17
17
 
18
18
  const { chatComponentsCache } = useCopilotContext()
@@ -51,10 +51,6 @@ const Messages = ({ messages, inProgress, ResponseButton, messagesCallback, chil
51
51
  scrollToBottom()
52
52
  }, [messages])
53
53
 
54
- useEffect(() => {
55
- if (messagesCallback) messagesCallback(messages)
56
- }, [messages])
57
-
58
54
  useEffect(() => {
59
55
  const textarea = document.querySelector('.copilotKitInput textarea') as HTMLTextAreaElement
60
56
 
@@ -36,7 +36,6 @@ export interface MessagesProps {
36
36
  inProgress: boolean
37
37
  ResponseButton?: React.ReactElement
38
38
  children?: React.ReactNode
39
- messagesCallback?: (messages: any) => void
40
39
  }
41
40
 
42
41
  export interface InputProps {
@@ -1,5 +1,2 @@
1
1
  // eslint-disable-next-line import/extensions
2
-
3
2
  export { default as Chat } from './chat/index.js'
4
-
5
- export { useCopilotChat, useCopilotAction, useCopilotReadable } from './chat/utils.js'
@@ -0,0 +1,2 @@
1
+ export { cn } from './utils.js'
2
+ export { noop } from './utils.js'
@@ -0,0 +1,8 @@
1
+ import { clsx, type ClassValue } from 'clsx'
2
+ import { twMerge } from 'tailwind-merge'
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
7
+
8
+ export function noop(): any {}
@@ -1,3 +0,0 @@
1
- import { useCopilotChat, useCopilotAction, useCopilotReadable } from '@copilotkit/react-core'
2
-
3
- export { useCopilotChat, useCopilotAction, useCopilotReadable }