@botonic/react 0.26.1 → 0.27.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/assets/url-icon.png +0 -0
- package/lib/cjs/components/button.d.ts +1 -0
- package/lib/cjs/components/button.js +11 -2
- package/lib/cjs/components/button.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +1 -0
- package/lib/cjs/components/index-types.js.map +1 -1
- package/lib/cjs/components/message/styles.d.ts +30 -8
- package/lib/cjs/components/multichannel/multichannel-button.js +2 -1
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +2 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-reply.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.d.ts +0 -2
- package/lib/cjs/components/multichannel/multichannel-utils.js +1 -10
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +4 -2
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/constants.d.ts +3 -0
- package/lib/cjs/constants.js +4 -0
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/webchat/components/styled-scrollbar.d.ts +2 -1
- package/lib/cjs/webchat/header.d.ts +1 -1
- package/lib/cjs/webchat/message-list/styles.d.ts +4 -4
- package/lib/cjs/webchat/trigger-button/styles.d.ts +3 -3
- package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
- package/lib/cjs/webview-app.js +6 -2
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/assets/url-icon.png +0 -0
- package/lib/esm/components/button.d.ts +1 -0
- package/lib/esm/components/button.js +11 -2
- package/lib/esm/components/button.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +1 -0
- package/lib/esm/components/index-types.js.map +1 -1
- package/lib/esm/components/message/styles.d.ts +30 -8
- package/lib/esm/components/multichannel/multichannel-button.js +3 -2
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +3 -2
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-reply.js +2 -2
- package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +4 -4
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.d.ts +0 -2
- package/lib/esm/components/multichannel/multichannel-utils.js +0 -7
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +5 -3
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/constants.d.ts +3 -0
- package/lib/esm/constants.js +4 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/webchat/components/styled-scrollbar.d.ts +2 -1
- package/lib/esm/webchat/header.d.ts +1 -1
- package/lib/esm/webchat/message-list/styles.d.ts +4 -4
- package/lib/esm/webchat/trigger-button/styles.d.ts +3 -3
- package/lib/esm/webchat/webchat-dev.d.ts +1 -1
- package/lib/esm/webview-app.js +6 -2
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +4 -2
- package/src/assets/url-icon.png +0 -0
- package/src/components/button.jsx +25 -0
- package/src/components/index-types.ts +1 -0
- package/src/components/multichannel/multichannel-button.jsx +3 -2
- package/src/components/multichannel/multichannel-carousel.jsx +2 -2
- package/src/components/multichannel/multichannel-reply.jsx +2 -2
- package/src/components/multichannel/multichannel-text.jsx +3 -5
- package/src/components/multichannel/multichannel-utils.js +0 -12
- package/src/components/multichannel/multichannel.jsx +7 -7
- package/src/constants.js +4 -0
- package/src/webview-app.tsx +7 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INPUT } from '@botonic/core'
|
|
1
|
+
import { INPUT, isFacebook, isWhatsapp } from '@botonic/core'
|
|
2
2
|
import React, { useContext } from 'react'
|
|
3
3
|
|
|
4
4
|
import { RequestContext } from '../../contexts'
|
|
@@ -16,8 +16,6 @@ import {
|
|
|
16
16
|
getButtonType,
|
|
17
17
|
getMultichannelButtons,
|
|
18
18
|
getMultichannelReplies,
|
|
19
|
-
isFacebook,
|
|
20
|
-
isWhatsapp,
|
|
21
19
|
MENU_BUTTON_WHATSAPP_BUTTON_LIST,
|
|
22
20
|
MULTICHANNEL_WHATSAPP_PROPS,
|
|
23
21
|
WHATSAPP_LIST_MAX_BUTTONS,
|
|
@@ -113,7 +111,7 @@ export const MultichannelText = props => {
|
|
|
113
111
|
return messages
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
if (isWhatsapp(requestContext)) {
|
|
114
|
+
if (isWhatsapp(requestContext.session)) {
|
|
117
115
|
const texts = getText(props.children)
|
|
118
116
|
const { postbackButtons, urlButtons, webviewButtons } = getWhatsappButtons()
|
|
119
117
|
|
|
@@ -280,7 +278,7 @@ export const MultichannelText = props => {
|
|
|
280
278
|
return <>{messages}</>
|
|
281
279
|
}
|
|
282
280
|
|
|
283
|
-
if (isFacebook(requestContext)) {
|
|
281
|
+
if (isFacebook(requestContext.session)) {
|
|
284
282
|
const text = getText(props.children)
|
|
285
283
|
const multichannelFacebook = new MultichannelFacebook()
|
|
286
284
|
const { texts, propsLastText, propsWithoutChildren } =
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Providers } from '@botonic/core'
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* Whatsapp does not support Markdown
|
|
@@ -73,13 +71,3 @@ export function getMultichannelButtons(node) {
|
|
|
73
71
|
export function getMultichannelReplies(node) {
|
|
74
72
|
return getFilteredElements(node, isMultichannelReply)
|
|
75
73
|
}
|
|
76
|
-
|
|
77
|
-
export const isWhatsapp = context =>
|
|
78
|
-
context.session &&
|
|
79
|
-
context.session.user &&
|
|
80
|
-
context.session.user.provider == Providers.Messaging.WHATSAPP
|
|
81
|
-
|
|
82
|
-
export const isFacebook = context =>
|
|
83
|
-
context.session &&
|
|
84
|
-
context.session.user &&
|
|
85
|
-
context.session.user.provider == Providers.Messaging.FACEBOOK
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFacebook, isWhatsapp } from '@botonic/core'
|
|
1
2
|
import React, { useContext } from 'react'
|
|
2
3
|
|
|
3
4
|
import { COMPONENT_TYPE } from '../../constants'
|
|
@@ -9,18 +10,17 @@ import { MultichannelCarousel } from './multichannel-carousel'
|
|
|
9
10
|
import { MultichannelContext } from './multichannel-context'
|
|
10
11
|
import { MultichannelReply } from './multichannel-reply'
|
|
11
12
|
import { MultichannelText } from './multichannel-text'
|
|
12
|
-
import {
|
|
13
|
-
isFacebook,
|
|
14
|
-
isWhatsapp,
|
|
15
|
-
MULTICHANNEL_WHATSAPP_PROPS,
|
|
16
|
-
} from './multichannel-utils'
|
|
13
|
+
import { MULTICHANNEL_WHATSAPP_PROPS } from './multichannel-utils'
|
|
17
14
|
|
|
18
15
|
export const Multichannel = props => {
|
|
19
16
|
const requestContext = useContext(RequestContext)
|
|
20
|
-
if (
|
|
17
|
+
if (
|
|
18
|
+
!isWhatsapp(requestContext.session) &&
|
|
19
|
+
!isFacebook(requestContext.session)
|
|
20
|
+
) {
|
|
21
21
|
return props.children
|
|
22
22
|
}
|
|
23
|
-
if (isFacebook(requestContext)) {
|
|
23
|
+
if (isFacebook(requestContext.session)) {
|
|
24
24
|
const newChildren = deepMapWithIndex(props.children, child => {
|
|
25
25
|
if (child && child.type && child.type.name === COMPONENT_TYPE.TEXT) {
|
|
26
26
|
return (
|
package/src/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BotonicLogo from './assets/botonic_react_logo100x100.png'
|
|
2
|
+
import UrlIcon from './assets/url-icon.png'
|
|
2
3
|
|
|
3
4
|
export const COLORS = {
|
|
4
5
|
// http://chir.ag/projects/name-that-color
|
|
@@ -36,6 +37,7 @@ export const WEBCHAT = {
|
|
|
36
37
|
HEIGHT: 450,
|
|
37
38
|
TITLE: 'Botonic',
|
|
38
39
|
LOGO: BotonicLogo,
|
|
40
|
+
URL_ICON: UrlIcon,
|
|
39
41
|
PLACEHOLDER: 'Ask me something...',
|
|
40
42
|
FONT_FAMILY: "'Noto Sans JP', sans-serif",
|
|
41
43
|
BORDER_RADIUS_TOP_CORNERS: '6px 6px 0px 0px',
|
|
@@ -115,6 +117,8 @@ export const WEBCHAT = {
|
|
|
115
117
|
buttonStyleBackground: 'button.style.background',
|
|
116
118
|
buttonStyleColor: 'button.style.color',
|
|
117
119
|
customButton: 'button.custom',
|
|
120
|
+
urlIconImage: 'button.urlIcon.image',
|
|
121
|
+
urlIconEnabled: 'button.urlIcon.enable',
|
|
118
122
|
// Replies
|
|
119
123
|
alignReplies: 'replies.align',
|
|
120
124
|
customReply: 'reply.custom',
|
package/src/webview-app.tsx
CHANGED
|
@@ -63,10 +63,14 @@ class App extends React.Component {
|
|
|
63
63
|
if (provider === PROVIDER.FACEBOOK) {
|
|
64
64
|
try {
|
|
65
65
|
window.MessengerExtensions.requestCloseBrowser(
|
|
66
|
-
()
|
|
67
|
-
|
|
66
|
+
function success() {},
|
|
67
|
+
function error(err) {
|
|
68
|
+
window.close()
|
|
69
|
+
}
|
|
68
70
|
)
|
|
69
|
-
} catch (e) {
|
|
71
|
+
} catch (e) {
|
|
72
|
+
window.close()
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
if (provider === PROVIDER.WEBCHAT) {
|
|
72
76
|
try {
|