@anker-in/campaign-ui 0.1.7 → 0.1.9

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 (68) 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 -4
  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 -13
  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/index.d.ts +0 -1
  28. package/dist/cjs/components/index.js +1 -1
  29. package/dist/cjs/components/index.js.map +3 -3
  30. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  31. package/dist/esm/components/animation/CodeEditor.d.ts +7 -0
  32. package/dist/esm/components/animation/CodeEditor.js +2 -0
  33. package/dist/esm/components/animation/CodeEditor.js.map +7 -0
  34. package/dist/esm/components/animation/Preview.d.ts +5 -0
  35. package/dist/esm/components/animation/Preview.js +2 -0
  36. package/dist/esm/components/animation/Preview.js.map +7 -0
  37. package/dist/esm/components/animation/bannerAni.d.ts +16 -0
  38. package/dist/esm/components/animation/bannerAni.js +59 -0
  39. package/dist/esm/components/animation/bannerAni.js.map +7 -0
  40. package/dist/esm/components/animation/libs.d.js +2 -0
  41. package/dist/esm/components/animation/libs.d.js.map +7 -0
  42. package/dist/esm/components/animation/textAni.d.ts +9 -0
  43. package/dist/esm/components/animation/textAni.js +2 -0
  44. package/dist/esm/components/animation/textAni.js.map +7 -0
  45. package/dist/esm/components/chat/Messages.d.ts +1 -1
  46. package/dist/esm/components/chat/action.d.ts +1 -4
  47. package/dist/esm/components/chat/action.js +1 -1
  48. package/dist/esm/components/chat/action.js.map +3 -3
  49. package/dist/esm/components/chat/index.d.ts +0 -13
  50. package/dist/esm/components/chat/index.js +1 -1
  51. package/dist/esm/components/chat/index.js.map +3 -3
  52. package/dist/esm/components/chat/messages.js +1 -1
  53. package/dist/esm/components/chat/messages.js.map +3 -3
  54. package/dist/esm/components/chat/props.d.ts +0 -1
  55. package/dist/esm/components/chat/props.js.map +1 -1
  56. package/dist/esm/components/index.d.ts +0 -1
  57. package/dist/esm/components/index.js +1 -1
  58. package/dist/esm/components/index.js.map +3 -3
  59. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +11 -7
  61. package/src/components/chat/action.tsx +1 -41
  62. package/src/components/chat/index.tsx +4 -24
  63. package/src/components/chat/messages.tsx +1 -5
  64. package/src/components/chat/props.ts +0 -1
  65. package/src/components/index.ts +0 -10
  66. package/src/helpers/index.ts +2 -0
  67. package/src/helpers/utils.ts +8 -0
  68. package/src/components/chat/utils.ts +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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,13 +15,10 @@ 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)
23
21
  signupRender?: string | ((_props: any) => React.ReactElement)
24
- shulexRender?: string | ((_props: any) => React.ReactElement)
25
22
  productRender?: string | ((_props: any) => React.ReactElement)
26
23
  productRenderTipMessage?: string
27
24
  children?: React.ReactNode
@@ -31,14 +28,11 @@ export const CopilotAction = ({
31
28
  start,
32
29
  history,
33
30
  addtocartHandler,
34
- commonRender,
35
- pointsExchangeCouponRender,
36
31
  gotocheckoutRender,
37
32
  gotocartRender,
38
33
  addtocartRender,
39
34
  productRender,
40
35
  signupRender,
41
- shulexRender,
42
36
  children,
43
37
  }: ActionProps) => {
44
38
  const { setMessages, appendMessage, isLoading } = useCopilotChat()
@@ -74,26 +68,6 @@ export const CopilotAction = ({
74
68
  },
75
69
  })
76
70
 
77
- useCopilotAction({
78
- name: 'common_action',
79
- description: 'common action',
80
- parameters: [{ act: '' }] as any,
81
- render: commonRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
82
- handler: function () {
83
- // console.log('common_action', props)
84
- },
85
- })
86
-
87
- useCopilotAction({
88
- name: 'points_exchange_coupon',
89
- description: 'points exchange coupon',
90
- parameters: [{ act: '' }] as any,
91
- render: pointsExchangeCouponRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
92
- handler: function () {
93
- // console.log('points_exchange_coupon', props)
94
- },
95
- })
96
-
97
71
  useCopilotAction({
98
72
  name: 'go_to_cart',
99
73
  description: 'go to cart',
@@ -120,7 +94,7 @@ export const CopilotAction = ({
120
94
  parameters: [{ sku: '', handle: '' }] as any,
121
95
  render: productRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
122
96
  handler: function (props) {
123
- // console.log('show_product_card-props', props)
97
+ console.log('show_product_card-props', props)
124
98
  // const ishistory = props?.find((item: { ishistory: any }) => item?.ishistory)
125
99
  // if (!ishistory) {
126
100
  // const content = new TextMessage({
@@ -146,20 +120,6 @@ export const CopilotAction = ({
146
120
  },
147
121
  })
148
122
 
149
- useCopilotAction({
150
- name: 'shulex',
151
- description: 'shulex',
152
- parameters: [
153
- {
154
- name: 'shulex',
155
- },
156
- ] as any,
157
- render: shulexRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
158
- handler: function () {
159
- // console.log('shulex-props', props)
160
- },
161
- })
162
-
163
123
  useCopilotReadable({
164
124
  description: "Today's date",
165
125
  value: new Date().toLocaleDateString(),
@@ -34,19 +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
- /** shulex的 action 的触发事件
45
- */
46
- shulexRender?: string | ((_props: any) => React.ReactElement)
47
- /** 通用 积分 换 Coupon 的触发事件
48
- */
49
- pointsExchangeCouponRender?: string | ((_props: any) => React.ReactElement)
50
37
  /** 跳转 checkout action 卡片,接受参数: {"status":"complete","args":[{"sku":["A3936031"],"handle":"space-a40-a3936031"}],"result":""}
51
38
  * 后端接口文档:https://anker-in.feishu.cn/wiki/DOYJwE9oxipWmYk072ncnJNznBb
52
39
  */
@@ -90,12 +77,8 @@ const Chat = (props: ChatProps) => {
90
77
  prologue = '',
91
78
  locale = '',
92
79
  query = '',
93
- messagesCallback,
94
80
  showResponseButton,
95
81
  gotocheckoutRender,
96
- commonRender,
97
- shulexRender,
98
- pointsExchangeCouponRender,
99
82
  gotocartRender,
100
83
  addtocartRender,
101
84
  productRender,
@@ -133,7 +116,7 @@ const Chat = (props: ChatProps) => {
133
116
  setCurrentSuggestions(result?.suggested_questions?.map((item: string) => ({ message: item, title: item })) || [])
134
117
  setstart(result?.opening_statement || '')
135
118
  sethistory(result?.history || [])
136
- }, [userId, shopifyDomain, account, locale, query])
119
+ }, [userId, shopifyDomain, account, locale])
137
120
 
138
121
  const getSuggestions = useCallback(async () => {
139
122
  const result = await fetcher({
@@ -145,7 +128,7 @@ const Chat = (props: ChatProps) => {
145
128
  setCurrentSuggestions(
146
129
  result?.suggested_questions?.data?.map((item: string) => ({ message: item, title: item })) || []
147
130
  )
148
- }, [userId, shopifyDomain, account, locale, query])
131
+ }, [userId, shopifyDomain, account, locale])
149
132
 
150
133
  const setOpenTipFn = () => {
151
134
  if (!openTip) setOpenTip(true)
@@ -184,13 +167,13 @@ const Chat = (props: ChatProps) => {
184
167
  <Messages
185
168
  messages={messages}
186
169
  inProgress={inProgress}
187
- messagesCallback={messagesCallback}
188
170
  ResponseButton={showResponseButton === 'follow' ? <ResponseButton /> : undefined}
189
171
  >
190
172
  <Suggestions currentSuggestions={currentSuggestions} />
191
173
  </Messages>
192
174
  )}
193
- Button={({ open, setOpen: setOpenDefault }) => {
175
+ Button={props => {
176
+ const { open, setOpen: setOpenDefault } = props as any
194
177
  const Button = popup?.Button || DefaultButton
195
178
  // eslint-disable-next-line react-hooks/rules-of-hooks
196
179
  useEffect(() => {
@@ -221,9 +204,6 @@ const Chat = (props: ChatProps) => {
221
204
  <CopilotAction
222
205
  start={start}
223
206
  history={history}
224
- commonRender={commonRender}
225
- shulexRender={shulexRender}
226
- pointsExchangeCouponRender={pointsExchangeCouponRender}
227
207
  gotocartRender={gotocartRender}
228
208
  gotocheckoutRender={gotocheckoutRender}
229
209
  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,12 +1,2 @@
1
1
  // eslint-disable-next-line import/extensions
2
-
3
2
  export { default as Chat } from './chat/index.js'
4
-
5
- export {
6
- Role,
7
- ActionExecutionMessage,
8
- TextMessage,
9
- useCopilotChat,
10
- useCopilotAction,
11
- useCopilotReadable,
12
- } 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,4 +0,0 @@
1
- import { useCopilotChat, useCopilotAction, useCopilotReadable } from '@copilotkit/react-core'
2
- import { Role, ActionExecutionMessage, TextMessage } from '@copilotkit/runtime-client-gql'
3
-
4
- export { useCopilotChat, useCopilotAction, useCopilotReadable, Role, ActionExecutionMessage, TextMessage }