@anker-in/campaign-ui 0.1.5 → 0.1.7

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.
@@ -21,6 +21,7 @@ export interface ActionProps {
21
21
  gotocartRender?: string | ((_props: any) => React.ReactElement)
22
22
  addtocartRender?: string | ((_props: any) => React.ReactElement)
23
23
  signupRender?: string | ((_props: any) => React.ReactElement)
24
+ shulexRender?: string | ((_props: any) => React.ReactElement)
24
25
  productRender?: string | ((_props: any) => React.ReactElement)
25
26
  productRenderTipMessage?: string
26
27
  children?: React.ReactNode
@@ -37,6 +38,7 @@ export const CopilotAction = ({
37
38
  addtocartRender,
38
39
  productRender,
39
40
  signupRender,
41
+ shulexRender,
40
42
  children,
41
43
  }: ActionProps) => {
42
44
  const { setMessages, appendMessage, isLoading } = useCopilotChat()
@@ -118,7 +120,7 @@ export const CopilotAction = ({
118
120
  parameters: [{ sku: '', handle: '' }] as any,
119
121
  render: productRender || (props => <div className="hidden">{JSON.stringify(props)}</div>),
120
122
  handler: function (props) {
121
- console.log('show_product_card-props', props)
123
+ // console.log('show_product_card-props', props)
122
124
  // const ishistory = props?.find((item: { ishistory: any }) => item?.ishistory)
123
125
  // if (!ishistory) {
124
126
  // const content = new TextMessage({
@@ -144,6 +146,20 @@ export const CopilotAction = ({
144
146
  },
145
147
  })
146
148
 
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
+
147
163
  useCopilotReadable({
148
164
  description: "Today's date",
149
165
  value: new Date().toLocaleDateString(),
@@ -37,10 +37,13 @@ export interface ChatProps {
37
37
  /** messages 的回调事件
38
38
  * 每次生成/接受新的messages,会将 整个 messages list 传递给外部
39
39
  */
40
- messagesCallback?: (messages: any) => void
40
+ messagesCallback?: (_messages: any) => void
41
41
  /** 通用 action 的触发事件
42
42
  */
43
43
  commonRender?: string | ((_props: any) => React.ReactElement)
44
+ /** shulex的 action 的触发事件
45
+ */
46
+ shulexRender?: string | ((_props: any) => React.ReactElement)
44
47
  /** 通用 积分 换 Coupon 的触发事件
45
48
  */
46
49
  pointsExchangeCouponRender?: string | ((_props: any) => React.ReactElement)
@@ -91,6 +94,7 @@ const Chat = (props: ChatProps) => {
91
94
  showResponseButton,
92
95
  gotocheckoutRender,
93
96
  commonRender,
97
+ shulexRender,
94
98
  pointsExchangeCouponRender,
95
99
  gotocartRender,
96
100
  addtocartRender,
@@ -218,6 +222,7 @@ const Chat = (props: ChatProps) => {
218
222
  start={start}
219
223
  history={history}
220
224
  commonRender={commonRender}
225
+ shulexRender={shulexRender}
221
226
  pointsExchangeCouponRender={pointsExchangeCouponRender}
222
227
  gotocartRender={gotocartRender}
223
228
  gotocheckoutRender={gotocheckoutRender}
@@ -0,0 +1,4 @@
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 }
@@ -1,2 +1,12 @@
1
1
  // eslint-disable-next-line import/extensions
2
+
2
3
  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'