@botonic/react 0.36.4 → 0.37.0-alpha.0
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/lib/cjs/components/button/index.js +1 -1
- package/lib/cjs/components/button/index.js.map +1 -1
- package/lib/cjs/components/custom-message.d.ts +1 -1
- package/lib/cjs/components/custom-message.js +4 -1
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +2 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/webchat/context/messages-reducer.js +6 -0
- package/lib/cjs/webchat/context/messages-reducer.js.map +1 -1
- package/lib/cjs/webchat/context/types.d.ts +1 -1
- package/lib/cjs/webchat/custom-messages/index.d.ts +1 -0
- package/lib/cjs/webchat/custom-messages/index.js +9 -0
- package/lib/cjs/webchat/custom-messages/index.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-angry.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-angry.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-angry.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-frown.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-frown.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-frown.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-grin-beam.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-grin-beam.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-grin-beam.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-meh.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-meh.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-meh.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-smile.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-smile.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-smile.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/index.d.ts +6 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/index.js +10 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/index.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/star.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/star.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/star.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/index.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/index.js +51 -0
- package/lib/cjs/webchat/custom-messages/rating/index.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/rating-selector.d.ts +11 -0
- package/lib/cjs/webchat/custom-messages/rating/rating-selector.js +23 -0
- package/lib/cjs/webchat/custom-messages/rating/rating-selector.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/smileys.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/smileys.js +19 -0
- package/lib/cjs/webchat/custom-messages/rating/smileys.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/stars.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/stars.js +11 -0
- package/lib/cjs/webchat/custom-messages/rating/stars.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/styles.d.ts +6 -0
- package/lib/cjs/webchat/custom-messages/rating/styles.js +25 -0
- package/lib/cjs/webchat/custom-messages/rating/styles.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/types.d.ts +13 -0
- package/lib/cjs/webchat/custom-messages/rating/types.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/types.js.map +1 -0
- package/lib/cjs/webchat/index.d.ts +1 -0
- package/lib/cjs/webchat/index.js +1 -0
- package/lib/cjs/webchat/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/cjs/webchat/session-view.js +1 -3
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/esm/components/button/index.js +1 -1
- package/lib/esm/components/button/index.js.map +1 -1
- package/lib/esm/components/custom-message.d.ts +1 -1
- package/lib/esm/components/custom-message.js +4 -1
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/webchat/context/messages-reducer.js +6 -0
- package/lib/esm/webchat/context/messages-reducer.js.map +1 -1
- package/lib/esm/webchat/context/types.d.ts +1 -1
- package/lib/esm/webchat/custom-messages/index.d.ts +1 -0
- package/lib/esm/webchat/custom-messages/index.js +2 -0
- package/lib/esm/webchat/custom-messages/index.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-angry.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-angry.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-angry.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-frown.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-frown.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-frown.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-grin-beam.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-grin-beam.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-grin-beam.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-meh.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-meh.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-meh.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-smile.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-smile.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-smile.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/index.d.ts +6 -0
- package/lib/esm/webchat/custom-messages/rating/icons/index.js +7 -0
- package/lib/esm/webchat/custom-messages/rating/icons/index.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/star.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/star.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/star.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/index.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/index.js +49 -0
- package/lib/esm/webchat/custom-messages/rating/index.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/rating-selector.d.ts +11 -0
- package/lib/esm/webchat/custom-messages/rating/rating-selector.js +19 -0
- package/lib/esm/webchat/custom-messages/rating/rating-selector.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/smileys.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/smileys.js +15 -0
- package/lib/esm/webchat/custom-messages/rating/smileys.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/stars.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/stars.js +7 -0
- package/lib/esm/webchat/custom-messages/rating/stars.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/styles.d.ts +6 -0
- package/lib/esm/webchat/custom-messages/rating/styles.js +21 -0
- package/lib/esm/webchat/custom-messages/rating/styles.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/types.d.ts +13 -0
- package/lib/esm/webchat/custom-messages/rating/types.js +6 -0
- package/lib/esm/webchat/custom-messages/rating/types.js.map +1 -0
- package/lib/esm/webchat/index.d.ts +1 -0
- package/lib/esm/webchat/index.js +1 -0
- package/lib/esm/webchat/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/webchat/session-view.js +1 -3
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/package.json +1 -1
- package/src/components/button/index.tsx +2 -1
- package/src/components/custom-message.tsx +14 -11
- package/src/index.ts +1 -1
- package/src/webchat/context/messages-reducer.ts +8 -0
- package/src/webchat/context/types.ts +1 -1
- package/src/webchat/custom-messages/index.ts +1 -0
- package/src/webchat/custom-messages/rating/icons/face-angry.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-frown.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-grin-beam.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-meh.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-smile.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/index.ts +6 -0
- package/src/webchat/custom-messages/rating/icons/star.tsx +21 -0
- package/src/webchat/custom-messages/rating/index.tsx +91 -0
- package/src/webchat/custom-messages/rating/rating-selector.tsx +59 -0
- package/src/webchat/custom-messages/rating/smileys.tsx +27 -0
- package/src/webchat/custom-messages/rating/stars.tsx +9 -0
- package/src/webchat/custom-messages/rating/styles.ts +26 -0
- package/src/webchat/custom-messages/rating/types.ts +15 -0
- package/src/webchat/index.ts +1 -0
- package/src/webchat/input-panel/send-button.tsx +1 -1
- package/src/webchat/session-view.jsx +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-view.js","sourceRoot":"","sources":["../../../src/webchat/session-view.jsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;WAO1B,MAAM,CAAC,WAAW;;CAE5B,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEvB,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;WAMb,MAAM,CAAC,YAAY;;CAE7B,CAAA;AAED,MAAM,oB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AI,EAAC,2BAA2B,EAChC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAC9D,QAAQ,EAAE,yBAAyB,GACnC,8BAEI,GACa,IACN,KACA,CACtB,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -13,7 +13,8 @@ export const Button = (props: ButtonProps) => {
|
|
|
13
13
|
const { webchatState, openWebview, sendPayload, sendInput, updateMessage } =
|
|
14
14
|
useContext(WebchatContext)
|
|
15
15
|
|
|
16
|
-
const autoDisable =
|
|
16
|
+
const autoDisable =
|
|
17
|
+
webchatState.theme?.button?.autodisable || props.autodisable
|
|
17
18
|
|
|
18
19
|
const handleClick = event => {
|
|
19
20
|
event.preventDefault()
|
|
@@ -20,7 +20,7 @@ import { Reply } from './reply'
|
|
|
20
20
|
|
|
21
21
|
export interface CustomMessageArgs {
|
|
22
22
|
name: string
|
|
23
|
-
component: React.
|
|
23
|
+
component: React.FC<any>
|
|
24
24
|
defaultProps?: Record<string, any>
|
|
25
25
|
errorBoundary?: any
|
|
26
26
|
}
|
|
@@ -92,15 +92,18 @@ export const customMessage = ({
|
|
|
92
92
|
}
|
|
93
93
|
WrappedComponent.customTypeName = name
|
|
94
94
|
// eslint-disable-next-line react/display-name
|
|
95
|
-
WrappedComponent.deserialize = (msg: any) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
WrappedComponent.deserialize = (msg: any) => {
|
|
96
|
+
const json = { ...msg.data, messageId: msg.id }
|
|
97
|
+
return (
|
|
98
|
+
<WrappedComponent
|
|
99
|
+
id={msg.id}
|
|
100
|
+
key={msg.key}
|
|
101
|
+
json={json}
|
|
102
|
+
{...msg.data}
|
|
103
|
+
sentBy={msg.sentBy || SENDERS.bot}
|
|
104
|
+
isUnread={msg.isUnread}
|
|
105
|
+
/>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
105
108
|
return WrappedComponent
|
|
106
109
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
|
|
2
2
|
export * from './components'
|
|
3
|
-
export
|
|
3
|
+
export * from './contexts'
|
|
4
4
|
export { DevApp } from './dev-app'
|
|
5
5
|
export * from './index-types'
|
|
6
6
|
export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SENDERS } from '../../index-types'
|
|
2
|
+
import { isCustom } from '../../message-utils'
|
|
2
3
|
import { WebchatAction } from './actions'
|
|
3
4
|
import { WebchatState } from './types'
|
|
4
5
|
|
|
@@ -100,6 +101,13 @@ function updateMessageReducer(
|
|
|
100
101
|
props: { ...msgComponent.props, ack: action.payload.ack },
|
|
101
102
|
},
|
|
102
103
|
}
|
|
104
|
+
|
|
105
|
+
if (isCustom(action.payload)) {
|
|
106
|
+
// If the message is a custom message, update the json property to update props.
|
|
107
|
+
// If user close and open the chat the message will render again with the new props.
|
|
108
|
+
updatedMsgComponent.props.json = action.payload.data.json
|
|
109
|
+
}
|
|
110
|
+
|
|
103
111
|
updatedMessageComponents = {
|
|
104
112
|
messagesComponents: [
|
|
105
113
|
...state.messagesComponents.slice(0, msgIndex),
|
|
@@ -78,7 +78,7 @@ export interface WebchatContextProps {
|
|
|
78
78
|
updateLatestInput: (input: ClientInput) => void
|
|
79
79
|
updateMessage: (message: WebchatMessage) => void
|
|
80
80
|
updateReplies: (replies: (typeof Reply)[]) => void
|
|
81
|
-
updateUser: (user: ClientUser) => void
|
|
81
|
+
updateUser: (user: Partial<ClientUser>) => void
|
|
82
82
|
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
83
83
|
trackEvent?: TrackEventFunction
|
|
84
84
|
webchatState: WebchatState
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CustomRatingMessage } from './rating'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceAngrySvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zM338.7 395.9c6.6-5.9 7.1-16 1.2-22.6C323.8 355.4 295.7 336 256 336s-67.8 19.4-83.9 37.3c-5.9 6.6-5.4 16.7 1.2 22.6s16.7 5.4 22.6-1.2c11.7-13 31.6-26.7 60.1-26.7s48.4 13.7 60.1 26.7c5.9 6.6 16 7.1 22.6 1.2zM176.4 272c17.7 0 32-14.3 32-32c0-1.5-.1-3-.3-4.4l10.9 3.6c8.4 2.8 17.4-1.7 20.2-10.1s-1.7-17.4-10.1-20.2l-96-32c-8.4-2.8-17.4 1.7-20.2 10.1s1.7 17.4 10.1 20.2l30.7 10.2c-5.8 5.8-9.3 13.8-9.3 22.6c0 17.7 14.3 32 32 32zm192-32c0-8.9-3.6-17-9.5-22.8l30.2-10.1c8.4-2.8 12.9-11.9 10.1-20.2s-11.9-12.9-20.2-10.1l-96 32c-8.4 2.8-12.9 11.9-10.1 20.2s11.9 12.9 20.2 10.1l11.7-3.9c-.2 1.5-.3 3.1-.3 4.7c0 17.7 14.3 32 32 32s32-14.3 32-32z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm72.4-118.5c9.7-9 10.2-24.2 1.2-33.9C315.3 344.3 290.6 328 256 328s-59.3 16.3-73.5 31.6c-9 9.7-8.5 24.9 1.2 33.9s24.9 8.5 33.9-1.2c7.4-7.9 20-16.4 38.5-16.4s31.1 8.5 38.5 16.4c9 9.7 24.2 10.2 33.9 1.2zM176.4 272c17.7 0 32-14.3 32-32c0-1.5-.1-3-.3-4.4l10.9 3.6c8.4 2.8 17.4-1.7 20.2-10.1s-1.7-17.4-10.1-20.2l-96-32c-8.4-2.8-17.4 1.7-20.2 10.1s1.7 17.4 10.1 20.2l30.7 10.2c-5.8 5.8-9.3 13.8-9.3 22.6c0 17.7 14.3 32 32 32zm192-32c0-8.9-3.6-17-9.5-22.8l30.2-10.1c8.4-2.8 12.9-11.9 10.1-20.2s-11.9-12.9-20.2-10.1l-96 32c-8.4 2.8-12.9 11.9-10.1 20.2s11.9 12.9 20.2 10.1l11.7-3.9c-.2 1.5-.3 3.1-.3 4.7c0 17.7 14.3 32 32 32s32-14.3 32-32z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceFrownSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM159.3 388.7c-2.6 8.4-11.6 13.2-20 10.5s-13.2-11.6-10.5-20C145.2 326.1 196.3 288 256 288s110.8 38.1 127.3 91.3c2.6 8.4-2.1 17.4-10.5 20s-17.4-2.1-20-10.5C340.5 349.4 302.1 320 256 320s-84.5 29.4-96.7 68.7zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zM174.6 384.1c-4.5 12.5-18.2 18.9-30.7 14.4s-18.9-18.2-14.4-30.7C146.9 319.4 198.9 288 256 288s109.1 31.4 126.6 79.9c4.5 12.5-2 26.2-14.4 30.7s-26.2-2-30.7-14.4C328.2 358.5 297.2 336 256 336s-72.2 22.5-81.4 48.1zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceGrinBeamSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM388.1 312.8c12.3-3.8 24.3 6.9 19.3 18.7C382.4 390.6 324.2 432 256.3 432s-126.2-41.4-151.1-100.5c-5-11.8 7-22.5 19.3-18.7c39.7 12.2 84.5 19 131.8 19s92.1-6.8 131.8-19zm-170.5-84s0 0 0 0c0 0 0 0 0 0l-.2-.2c-.2-.2-.4-.5-.7-.9c-.6-.8-1.6-2-2.8-3.4c-2.5-2.8-6-6.6-10.2-10.3c-8.8-7.8-18.8-14-27.7-14s-18.9 6.2-27.7 14c-4.2 3.7-7.7 7.5-10.2 10.3c-1.2 1.4-2.2 2.6-2.8 3.4c-.3 .4-.6 .7-.7 .9l-.2 .2c0 0 0 0 0 0c0 0 0 0 0 0s0 0 0 0c-2.1 2.8-5.7 3.9-8.9 2.8s-5.5-4.1-5.5-7.6c0-17.9 6.7-35.6 16.6-48.8c9.8-13 23.9-23.2 39.4-23.2s29.6 10.2 39.4 23.2c9.9 13.2 16.6 30.9 16.6 48.8c0 3.4-2.2 6.5-5.5 7.6s-6.9 0-8.9-2.8c0 0 0 0 0 0s0 0 0 0zm160 0c0 0 0 0 0 0l-.2-.2c-.2-.2-.4-.5-.7-.9c-.6-.8-1.6-2-2.8-3.4c-2.5-2.8-6-6.6-10.2-10.3c-8.8-7.8-18.8-14-27.7-14s-18.9 6.2-27.7 14c-4.2 3.7-7.7 7.5-10.2 10.3c-1.2 1.4-2.2 2.6-2.8 3.4c-.3 .4-.6 .7-.7 .9l-.2 .2c0 0 0 0 0 0c0 0 0 0 0 0s0 0 0 0c-2.1 2.8-5.7 3.9-8.9 2.8s-5.5-4.1-5.5-7.6c0-17.9 6.7-35.6 16.6-48.8c9.8-13 23.9-23.2 39.4-23.2s29.6 10.2 39.4 23.2c9.9 13.2 16.6 30.9 16.6 48.8c0 3.4-2.2 6.5-5.5 7.6s-6.9 0-8.9-2.8c0 0 0 0 0 0s0 0 0 0s0 0 0 0z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm349.5 52.4c18.7-4.4 35.9 12 25.5 28.1C350.4 374.6 306.3 400 255.9 400s-94.5-25.4-119.1-63.5c-10.4-16.1 6.8-32.5 25.5-28.1c28.9 6.8 60.5 10.5 93.6 10.5s64.7-3.7 93.6-10.5zM217.6 228.8s0 0 0 0c0 0 0 0 0 0l-.2-.2c-.2-.2-.4-.5-.7-.9c-.6-.8-1.6-2-2.8-3.4c-2.5-2.8-6-6.6-10.2-10.3c-8.8-7.8-18.8-14-27.7-14s-18.9 6.2-27.7 14c-4.2 3.7-7.7 7.5-10.2 10.3c-1.2 1.4-2.2 2.6-2.8 3.4c-.3 .4-.6 .7-.7 .9l-.2 .2c0 0 0 0 0 0c0 0 0 0 0 0s0 0 0 0c-2.1 2.8-5.7 3.9-8.9 2.8s-5.5-4.1-5.5-7.6c0-17.9 6.7-35.6 16.6-48.8c9.8-13 23.9-23.2 39.4-23.2s29.6 10.2 39.4 23.2c9.9 13.2 16.6 30.9 16.6 48.8c0 3.4-2.2 6.5-5.5 7.6s-6.9 0-8.9-2.8c0 0 0 0 0 0s0 0 0 0zm160 0c0 0 0 0 0 0l-.2-.2c-.2-.2-.4-.5-.7-.9c-.6-.8-1.6-2-2.8-3.4c-2.5-2.8-6-6.6-10.2-10.3c-8.8-7.8-18.8-14-27.7-14s-18.9 6.2-27.7 14c-4.2 3.7-7.7 7.5-10.2 10.3c-1.2 1.4-2.2 2.6-2.8 3.4c-.3 .4-.6 .7-.7 .9l-.2 .2c0 0 0 0 0 0c0 0 0 0 0 0s0 0 0 0c-2.1 2.8-5.7 3.9-8.9 2.8s-5.5-4.1-5.5-7.6c0-17.9 6.7-35.6 16.6-48.8c9.8-13 23.9-23.2 39.4-23.2s29.6 10.2 39.4 23.2c9.9 13.2 16.6 30.9 16.6 48.8c0 3.4-2.2 6.5-5.5 7.6s-6.9 0-8.9-2.8c0 0 0 0 0 0s0 0 0 0s0 0 0 0z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceMehSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM176.4 176a32 32 0 1 1 0 64 32 32 0 1 1 0-64zm128 32a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zM160 336l192 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-192 0c-8.8 0-16-7.2-16-16s7.2-16 16-16z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M464 256A208 208 0 1 1 48 256a208 208 0 1 1 416 0zM256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM176.4 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm192-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM184 328c-13.3 0-24 10.7-24 24s10.7 24 24 24l144 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-144 0z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceSmileSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM164.1 325.5C182 346.2 212.6 368 256 368s74-21.8 91.9-42.5c5.8-6.7 15.9-7.4 22.6-1.6s7.4 15.9 1.6 22.6C349.8 372.1 311.1 400 256 400s-93.8-27.9-116.1-53.5c-5.8-6.7-5.1-16.8 1.6-22.6s16.8-5.1 22.6 1.6zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm177.6 62.1C192.8 334.5 218.8 352 256 352s63.2-17.5 78.4-33.9c9-9.7 24.2-10.4 33.9-1.4s10.4 24.2 1.4 33.9c-22 23.8-60 49.4-113.6 49.4s-91.7-25.5-113.6-49.4c-9-9.7-8.4-24.9 1.4-33.9s24.9-8.4 33.9 1.4zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const StarSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.7 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0zm0 79L235.4 187.2c-3.5 7.1-10.2 12.1-18.1 13.3L99 217.9 184.9 303c5.5 5.5 8.1 13.3 6.8 21L171.4 443.7l105.2-56.2c7.1-3.8 15.6-3.8 22.6 0l105.2 56.2L384.2 324.1c-1.3-7.7 1.2-15.5 6.8-21l85.9-85.1L358.6 200.5c-7.8-1.2-14.6-6.1-18.1-13.3L287.9 79z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { INPUT, InputType } from '@botonic/core'
|
|
2
|
+
import React, { useContext, useState } from 'react'
|
|
3
|
+
import { ThemeContext } from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import { Button, customMessage } from '../../../components'
|
|
6
|
+
import { WebchatContext } from '../../context'
|
|
7
|
+
import { RatingSelector } from './rating-selector'
|
|
8
|
+
import { MessageBubble } from './styles'
|
|
9
|
+
import { RatingType } from './types'
|
|
10
|
+
|
|
11
|
+
interface CustomRatingMessageProps {
|
|
12
|
+
payloads: string[]
|
|
13
|
+
messageText: string
|
|
14
|
+
buttonText: string
|
|
15
|
+
ratingType: RatingType
|
|
16
|
+
json: { messageId?: string; valueSent?: number }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CustomRatingMessage: React.FC<CustomRatingMessageProps> = props => {
|
|
20
|
+
const { payloads, messageText, buttonText, ratingType } = props
|
|
21
|
+
const { webchatState, updateMessage, sendInput } = useContext(WebchatContext)
|
|
22
|
+
|
|
23
|
+
const theme = useContext(ThemeContext)
|
|
24
|
+
const color = theme?.brand?.color ?? ''
|
|
25
|
+
|
|
26
|
+
const [ratingValue, setRatingValue] = useState(
|
|
27
|
+
props.json?.valueSent ? props.json.valueSent : -1
|
|
28
|
+
)
|
|
29
|
+
const [showRating, setShowRating] = useState(true)
|
|
30
|
+
|
|
31
|
+
const ratingChanged = (newRating: number) => {
|
|
32
|
+
setRatingValue(newRating)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const updateMessageJSON = (messageId?: string) => {
|
|
36
|
+
if (messageId) {
|
|
37
|
+
const messageToUpdate = webchatState.messagesJSON.filter(m => {
|
|
38
|
+
return m.id === messageId
|
|
39
|
+
})[0]
|
|
40
|
+
messageToUpdate.data.json.valueSent = ratingValue
|
|
41
|
+
updateMessage(messageToUpdate)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleButtonSend = () => {
|
|
46
|
+
if (ratingValue !== -1) {
|
|
47
|
+
setShowRating(false)
|
|
48
|
+
|
|
49
|
+
const payload = payloads[ratingValue - 1]
|
|
50
|
+
|
|
51
|
+
updateMessageJSON(props.json?.messageId)
|
|
52
|
+
|
|
53
|
+
const input = {
|
|
54
|
+
type: INPUT.POSTBACK as InputType,
|
|
55
|
+
payload,
|
|
56
|
+
}
|
|
57
|
+
void sendInput(input)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const disabled = ratingValue === -1
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className='rating-message-container'>
|
|
65
|
+
<MessageBubble className='rating-message-bubble'>
|
|
66
|
+
{messageText}
|
|
67
|
+
<RatingSelector
|
|
68
|
+
color={color}
|
|
69
|
+
onRatingChange={ratingChanged}
|
|
70
|
+
ratingValue={ratingValue}
|
|
71
|
+
ratingType={ratingType}
|
|
72
|
+
valueSent={props.json?.valueSent}
|
|
73
|
+
/>
|
|
74
|
+
</MessageBubble>
|
|
75
|
+
{!props.json?.valueSent && showRating && (
|
|
76
|
+
<Button
|
|
77
|
+
autodisable={true}
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
onClick={handleButtonSend}
|
|
80
|
+
>
|
|
81
|
+
{buttonText}
|
|
82
|
+
</Button>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default customMessage({
|
|
89
|
+
name: 'custom-rating',
|
|
90
|
+
component: CustomRatingMessage,
|
|
91
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Smileys } from './smileys'
|
|
4
|
+
import { Stars } from './stars'
|
|
5
|
+
import { RatingSelectorContainer } from './styles'
|
|
6
|
+
import { RatingType } from './types'
|
|
7
|
+
|
|
8
|
+
const NUMBER_OF_RATING_BUTTONS = 5
|
|
9
|
+
interface RatingSelectorProps {
|
|
10
|
+
color: string
|
|
11
|
+
isSent?: boolean
|
|
12
|
+
onRatingChange: (newRating: number) => void
|
|
13
|
+
ratingValue: number
|
|
14
|
+
ratingType: RatingType
|
|
15
|
+
valueSent?: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const RatingSelector = ({
|
|
19
|
+
color,
|
|
20
|
+
isSent,
|
|
21
|
+
onRatingChange,
|
|
22
|
+
ratingValue,
|
|
23
|
+
ratingType,
|
|
24
|
+
valueSent,
|
|
25
|
+
}: RatingSelectorProps) => {
|
|
26
|
+
const [hover, setHover] = useState<number>(valueSent ? valueSent : -1)
|
|
27
|
+
|
|
28
|
+
const onHover = (ratingNumber: number) => {
|
|
29
|
+
if (!valueSent) setHover(ratingNumber)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<RatingSelectorContainer isSent={isSent}>
|
|
34
|
+
{Array.from({ length: NUMBER_OF_RATING_BUTTONS }, (_star, i) => {
|
|
35
|
+
const ratingNumber = i + 1
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
key={i}
|
|
40
|
+
onMouseEnter={() => onHover(ratingNumber)}
|
|
41
|
+
onMouseLeave={() => onHover(ratingValue)}
|
|
42
|
+
onClick={() => onRatingChange(ratingNumber)}
|
|
43
|
+
>
|
|
44
|
+
{ratingType === RatingType.Stars && (
|
|
45
|
+
<Stars color={color} ratingNumber={ratingNumber} hover={hover} />
|
|
46
|
+
)}
|
|
47
|
+
{ratingType === RatingType.Smileys && (
|
|
48
|
+
<Smileys
|
|
49
|
+
color={color}
|
|
50
|
+
ratingNumber={ratingNumber}
|
|
51
|
+
hover={hover}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
})}
|
|
57
|
+
</RatingSelectorContainer>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
FaceAngrySvg,
|
|
5
|
+
FaceFrownSvg,
|
|
6
|
+
FaceGrinBeamSvg,
|
|
7
|
+
FaceMehSvg,
|
|
8
|
+
FaceSmileSvg,
|
|
9
|
+
} from './icons'
|
|
10
|
+
import { RatingItemProps } from './types'
|
|
11
|
+
|
|
12
|
+
const SMILEY_MAP = {
|
|
13
|
+
1: FaceFrownSvg,
|
|
14
|
+
2: FaceAngrySvg,
|
|
15
|
+
3: FaceMehSvg,
|
|
16
|
+
4: FaceSmileSvg,
|
|
17
|
+
5: FaceGrinBeamSvg,
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
export const Smileys = ({ color, ratingNumber, hover }: RatingItemProps) => {
|
|
21
|
+
const isSelected = hover === ratingNumber
|
|
22
|
+
const SmileyComponent = SMILEY_MAP[ratingNumber as keyof typeof SMILEY_MAP]
|
|
23
|
+
|
|
24
|
+
return SmileyComponent ? (
|
|
25
|
+
<SmileyComponent color={color} selected={isSelected} />
|
|
26
|
+
) : null
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { StarSvg } from './icons/index'
|
|
4
|
+
import { RatingItemProps } from './types'
|
|
5
|
+
|
|
6
|
+
export const Stars = ({ color, ratingNumber, hover }: RatingItemProps) => {
|
|
7
|
+
const isSelected = hover >= ratingNumber
|
|
8
|
+
return <StarSvg color={color} selected={isSelected} />
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
// TODO: Review how define all this styles
|
|
4
|
+
export const MessageBubble = styled.div`
|
|
5
|
+
margin: 0px 0px 5px 0px;
|
|
6
|
+
`
|
|
7
|
+
|
|
8
|
+
interface RatingSelectorContainerProps {
|
|
9
|
+
isSent?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const RatingSelectorContainer = styled.div<RatingSelectorContainerProps>`
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
margin-top: 16px;
|
|
17
|
+
|
|
18
|
+
& > div {
|
|
19
|
+
cursor: ${props => (props.isSent ? 'default' : 'pointer')};
|
|
20
|
+
|
|
21
|
+
svg {
|
|
22
|
+
height: 27px;
|
|
23
|
+
width: 27px;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export enum RatingType {
|
|
2
|
+
Stars = 'stars',
|
|
3
|
+
Smileys = 'smileys',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface RatingItemProps {
|
|
7
|
+
color: string
|
|
8
|
+
ratingNumber: number
|
|
9
|
+
hover: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface RatingIconProps {
|
|
13
|
+
color: string
|
|
14
|
+
selected?: boolean
|
|
15
|
+
}
|
package/src/webchat/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import SendButtonIcon from '../../assets/send-button.svg'
|
|
4
|
-
import { ROLES
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
5
|
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
@@ -127,14 +127,6 @@ export const SessionView = props => {
|
|
|
127
127
|
}
|
|
128
128
|
/>
|
|
129
129
|
<SessionViewAttribute label='PAYLOAD:' value={input.payload} />
|
|
130
|
-
<SessionViewAttribute
|
|
131
|
-
label='INTENT:'
|
|
132
|
-
value={
|
|
133
|
-
input.intent
|
|
134
|
-
? `${input.intent} (${(input.confidence * 100).toFixed(1)}%)`
|
|
135
|
-
: ''
|
|
136
|
-
}
|
|
137
|
-
/>
|
|
138
130
|
<SessionViewAttribute
|
|
139
131
|
label='PATH:'
|
|
140
132
|
value={lastRoutePath ? `/${lastRoutePath}` : '/'}
|