@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.
Files changed (72) hide show
  1. package/lib/cjs/assets/url-icon.png +0 -0
  2. package/lib/cjs/components/button.d.ts +1 -0
  3. package/lib/cjs/components/button.js +11 -2
  4. package/lib/cjs/components/button.js.map +1 -1
  5. package/lib/cjs/components/index-types.d.ts +1 -0
  6. package/lib/cjs/components/index-types.js.map +1 -1
  7. package/lib/cjs/components/message/styles.d.ts +30 -8
  8. package/lib/cjs/components/multichannel/multichannel-button.js +2 -1
  9. package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
  10. package/lib/cjs/components/multichannel/multichannel-carousel.js +2 -1
  11. package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
  12. package/lib/cjs/components/multichannel/multichannel-reply.js +2 -2
  13. package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -1
  14. package/lib/cjs/components/multichannel/multichannel-text.js +2 -2
  15. package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
  16. package/lib/cjs/components/multichannel/multichannel-utils.d.ts +0 -2
  17. package/lib/cjs/components/multichannel/multichannel-utils.js +1 -10
  18. package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
  19. package/lib/cjs/components/multichannel/multichannel.js +4 -2
  20. package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
  21. package/lib/cjs/constants.d.ts +3 -0
  22. package/lib/cjs/constants.js +4 -0
  23. package/lib/cjs/constants.js.map +1 -1
  24. package/lib/cjs/webchat/components/styled-scrollbar.d.ts +2 -1
  25. package/lib/cjs/webchat/header.d.ts +1 -1
  26. package/lib/cjs/webchat/message-list/styles.d.ts +4 -4
  27. package/lib/cjs/webchat/trigger-button/styles.d.ts +3 -3
  28. package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
  29. package/lib/cjs/webview-app.js +6 -2
  30. package/lib/cjs/webview-app.js.map +1 -1
  31. package/lib/esm/assets/url-icon.png +0 -0
  32. package/lib/esm/components/button.d.ts +1 -0
  33. package/lib/esm/components/button.js +11 -2
  34. package/lib/esm/components/button.js.map +1 -1
  35. package/lib/esm/components/index-types.d.ts +1 -0
  36. package/lib/esm/components/index-types.js.map +1 -1
  37. package/lib/esm/components/message/styles.d.ts +30 -8
  38. package/lib/esm/components/multichannel/multichannel-button.js +3 -2
  39. package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
  40. package/lib/esm/components/multichannel/multichannel-carousel.js +3 -2
  41. package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
  42. package/lib/esm/components/multichannel/multichannel-reply.js +2 -2
  43. package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -1
  44. package/lib/esm/components/multichannel/multichannel-text.js +4 -4
  45. package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
  46. package/lib/esm/components/multichannel/multichannel-utils.d.ts +0 -2
  47. package/lib/esm/components/multichannel/multichannel-utils.js +0 -7
  48. package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
  49. package/lib/esm/components/multichannel/multichannel.js +5 -3
  50. package/lib/esm/components/multichannel/multichannel.js.map +1 -1
  51. package/lib/esm/constants.d.ts +3 -0
  52. package/lib/esm/constants.js +4 -0
  53. package/lib/esm/constants.js.map +1 -1
  54. package/lib/esm/webchat/components/styled-scrollbar.d.ts +2 -1
  55. package/lib/esm/webchat/header.d.ts +1 -1
  56. package/lib/esm/webchat/message-list/styles.d.ts +4 -4
  57. package/lib/esm/webchat/trigger-button/styles.d.ts +3 -3
  58. package/lib/esm/webchat/webchat-dev.d.ts +1 -1
  59. package/lib/esm/webview-app.js +6 -2
  60. package/lib/esm/webview-app.js.map +1 -1
  61. package/package.json +4 -2
  62. package/src/assets/url-icon.png +0 -0
  63. package/src/components/button.jsx +25 -0
  64. package/src/components/index-types.ts +1 -0
  65. package/src/components/multichannel/multichannel-button.jsx +3 -2
  66. package/src/components/multichannel/multichannel-carousel.jsx +2 -2
  67. package/src/components/multichannel/multichannel-reply.jsx +2 -2
  68. package/src/components/multichannel/multichannel-text.jsx +3 -5
  69. package/src/components/multichannel/multichannel-utils.js +0 -12
  70. package/src/components/multichannel/multichannel.jsx +7 -7
  71. package/src/constants.js +4 -0
  72. 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 (!isWhatsapp(requestContext) && !isFacebook(requestContext)) {
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',
@@ -63,10 +63,14 @@ class App extends React.Component {
63
63
  if (provider === PROVIDER.FACEBOOK) {
64
64
  try {
65
65
  window.MessengerExtensions.requestCloseBrowser(
66
- () => undefined,
67
- err => console.log(err)
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 {