@anker-in/campaign-ui 0.1.7 → 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.
- package/dist/cjs/components/animation/CodeEditor.d.ts +7 -0
- package/dist/cjs/components/animation/CodeEditor.js +2 -0
- package/dist/cjs/components/animation/CodeEditor.js.map +7 -0
- package/dist/cjs/components/animation/Preview.d.ts +5 -0
- package/dist/cjs/components/animation/Preview.js +2 -0
- package/dist/cjs/components/animation/Preview.js.map +7 -0
- package/dist/cjs/components/animation/bannerAni.d.ts +16 -0
- package/dist/cjs/components/animation/bannerAni.js +59 -0
- package/dist/cjs/components/animation/bannerAni.js.map +7 -0
- package/dist/cjs/components/animation/libs.d.js +2 -0
- package/dist/cjs/components/animation/libs.d.js.map +7 -0
- package/dist/cjs/components/animation/textAni.d.ts +9 -0
- package/dist/cjs/components/animation/textAni.js +2 -0
- package/dist/cjs/components/animation/textAni.js.map +7 -0
- package/dist/cjs/components/chat/Messages.d.ts +1 -1
- package/dist/cjs/components/chat/action.d.ts +1 -4
- package/dist/cjs/components/chat/action.js +1 -1
- package/dist/cjs/components/chat/action.js.map +3 -3
- package/dist/cjs/components/chat/index.d.ts +0 -13
- package/dist/cjs/components/chat/index.js +1 -1
- package/dist/cjs/components/chat/index.js.map +3 -3
- package/dist/cjs/components/chat/messages.js +1 -1
- package/dist/cjs/components/chat/messages.js.map +3 -3
- package/dist/cjs/components/chat/props.d.ts +0 -1
- package/dist/cjs/components/chat/props.js +1 -1
- package/dist/cjs/components/chat/props.js.map +1 -1
- package/dist/cjs/components/index.d.ts +0 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/index.js.map +3 -3
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/animation/CodeEditor.d.ts +7 -0
- package/dist/esm/components/animation/CodeEditor.js +2 -0
- package/dist/esm/components/animation/CodeEditor.js.map +7 -0
- package/dist/esm/components/animation/Preview.d.ts +5 -0
- package/dist/esm/components/animation/Preview.js +2 -0
- package/dist/esm/components/animation/Preview.js.map +7 -0
- package/dist/esm/components/animation/bannerAni.d.ts +16 -0
- package/dist/esm/components/animation/bannerAni.js +59 -0
- package/dist/esm/components/animation/bannerAni.js.map +7 -0
- package/dist/esm/components/animation/libs.d.js +2 -0
- package/dist/esm/components/animation/libs.d.js.map +7 -0
- package/dist/esm/components/animation/textAni.d.ts +9 -0
- package/dist/esm/components/animation/textAni.js +2 -0
- package/dist/esm/components/animation/textAni.js.map +7 -0
- package/dist/esm/components/chat/Messages.d.ts +1 -1
- package/dist/esm/components/chat/action.d.ts +1 -4
- package/dist/esm/components/chat/action.js +1 -1
- package/dist/esm/components/chat/action.js.map +3 -3
- package/dist/esm/components/chat/index.d.ts +0 -13
- package/dist/esm/components/chat/index.js +1 -1
- package/dist/esm/components/chat/index.js.map +3 -3
- package/dist/esm/components/chat/messages.js +1 -1
- package/dist/esm/components/chat/messages.js.map +3 -3
- package/dist/esm/components/chat/props.d.ts +0 -1
- package/dist/esm/components/chat/props.js.map +1 -1
- package/dist/esm/components/index.d.ts +0 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +3 -3
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -7
- package/src/components/chat/action.tsx +1 -41
- package/src/components/chat/index.tsx +2 -23
- package/src/components/chat/messages.tsx +1 -5
- package/src/components/chat/props.ts +0 -1
- package/src/components/index.ts +0 -10
- package/src/helpers/index.ts +2 -0
- package/src/helpers/utils.ts +8 -0
- 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.
|
|
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": "
|
|
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.
|
|
77
|
-
"@copilotkit/react-ui": "1.
|
|
78
|
-
"@copilotkit/runtime-client-gql": "1.
|
|
79
|
-
"@copilotkit/shared": "1.
|
|
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
|
-
|
|
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
|
|
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
|
|
131
|
+
}, [userId, shopifyDomain, account, locale])
|
|
149
132
|
|
|
150
133
|
const setOpenTipFn = () => {
|
|
151
134
|
if (!openTip) setOpenTip(true)
|
|
@@ -184,7 +167,6 @@ 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} />
|
|
@@ -221,9 +203,6 @@ const Chat = (props: ChatProps) => {
|
|
|
221
203
|
<CopilotAction
|
|
222
204
|
start={start}
|
|
223
205
|
history={history}
|
|
224
|
-
commonRender={commonRender}
|
|
225
|
-
shulexRender={shulexRender}
|
|
226
|
-
pointsExchangeCouponRender={pointsExchangeCouponRender}
|
|
227
206
|
gotocartRender={gotocartRender}
|
|
228
207
|
gotocheckoutRender={gotocheckoutRender}
|
|
229
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,
|
|
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
|
|
package/src/components/index.ts
CHANGED
|
@@ -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 }
|