@botonic/react 0.30.5 → 0.30.6-alpha.1
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/element.js +3 -2
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +4 -4
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +12 -11
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.d.ts +3 -12
- package/lib/cjs/components/multichannel/multichannel-utils.js +30 -25
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +10 -8
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/components/multichannel/whatsapp/constants.d.ts +11 -0
- package/lib/cjs/components/multichannel/whatsapp/constants.js +13 -0
- package/lib/cjs/components/multichannel/whatsapp/constants.js.map +1 -0
- package/lib/cjs/components/whatsapp-button-list.js +2 -2
- package/lib/cjs/components/whatsapp-button-list.js.map +1 -1
- package/lib/cjs/components/whatsapp-cta-url-button.js +5 -5
- package/lib/cjs/components/whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/constants.d.ts +0 -6
- package/lib/cjs/constants.js +2 -7
- package/lib/cjs/constants.js.map +1 -1
- package/lib/esm/components/element.js +3 -2
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +5 -5
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +2 -1
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.d.ts +3 -12
- package/lib/esm/components/multichannel/multichannel-utils.js +26 -23
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +9 -7
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/components/multichannel/whatsapp/constants.d.ts +11 -0
- package/lib/esm/components/multichannel/whatsapp/constants.js +10 -0
- package/lib/esm/components/multichannel/whatsapp/constants.js.map +1 -0
- package/lib/esm/components/whatsapp-button-list.js +1 -1
- package/lib/esm/components/whatsapp-cta-url-button.js +1 -1
- package/lib/esm/constants.d.ts +0 -6
- package/lib/esm/constants.js +1 -6
- package/lib/esm/constants.js.map +1 -1
- package/package.json +1 -1
- package/src/components/element.jsx +3 -2
- package/src/components/multichannel/multichannel-button.jsx +1 -1
- package/src/components/multichannel/multichannel-carousel.jsx +7 -5
- package/src/components/multichannel/multichannel-text.jsx +4 -2
- package/src/components/multichannel/multichannel-utils.js +29 -26
- package/src/components/multichannel/multichannel.jsx +9 -7
- package/src/components/multichannel/whatsapp/constants.ts +10 -0
- package/src/components/whatsapp-button-list.tsx +1 -1
- package/src/components/whatsapp-cta-url-button.tsx +1 -1
- package/src/constants.js +1 -7
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { isFacebook, isWhatsapp } from '@botonic/core'
|
|
2
2
|
import React, { useContext } from 'react'
|
|
3
3
|
|
|
4
|
-
import { COMPONENT_TYPE } from '../../constants'
|
|
5
4
|
import { RequestContext } from '../../contexts'
|
|
6
5
|
import { deepMapWithIndex } from '../../util/react'
|
|
6
|
+
import { Button } from '../button'
|
|
7
|
+
import { Carousel } from '../carousel'
|
|
8
|
+
import { Reply } from '../reply'
|
|
7
9
|
import { Text } from '../text'
|
|
8
10
|
import { MultichannelButton } from './multichannel-button'
|
|
9
11
|
import { MultichannelCarousel } from './multichannel-carousel'
|
|
10
12
|
import { MultichannelContext } from './multichannel-context'
|
|
11
13
|
import { MultichannelReply } from './multichannel-reply'
|
|
12
14
|
import { MultichannelText } from './multichannel-text'
|
|
13
|
-
import { MULTICHANNEL_WHATSAPP_PROPS } from './
|
|
15
|
+
import { MULTICHANNEL_WHATSAPP_PROPS } from './whatsapp/constants'
|
|
14
16
|
|
|
15
17
|
export const Multichannel = props => {
|
|
16
18
|
const requestContext = useContext(RequestContext)
|
|
@@ -22,7 +24,7 @@ export const Multichannel = props => {
|
|
|
22
24
|
}
|
|
23
25
|
if (isFacebook(requestContext.session)) {
|
|
24
26
|
const newChildren = deepMapWithIndex(props.children, child => {
|
|
25
|
-
if (child && child.type && child.type.name ===
|
|
27
|
+
if (child && child.type && child.type.name === Text.name) {
|
|
26
28
|
return (
|
|
27
29
|
<MultichannelText {...child.props} key={child.key}>
|
|
28
30
|
{child.props.children}
|
|
@@ -35,21 +37,21 @@ export const Multichannel = props => {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
let newChildren = deepMapWithIndex(props.children, (child, index) => {
|
|
38
|
-
if (child && child.type && child.type.name ===
|
|
40
|
+
if (child && child.type && child.type.name === Button.name) {
|
|
39
41
|
return (
|
|
40
42
|
<MultichannelButton {...child.props} key={child.key}>
|
|
41
43
|
{child.props.children}
|
|
42
44
|
</MultichannelButton>
|
|
43
45
|
)
|
|
44
46
|
}
|
|
45
|
-
if (child && child.type && child.type.name ===
|
|
47
|
+
if (child && child.type && child.type.name === Reply.name) {
|
|
46
48
|
return (
|
|
47
49
|
<MultichannelReply {...child.props} key={child.key}>
|
|
48
50
|
{child.props.children}
|
|
49
51
|
</MultichannelReply>
|
|
50
52
|
)
|
|
51
53
|
}
|
|
52
|
-
if (child && child.type && child.type.name ===
|
|
54
|
+
if (child && child.type && child.type.name === Text.name) {
|
|
53
55
|
return (
|
|
54
56
|
<MultichannelText
|
|
55
57
|
{...child.props}
|
|
@@ -62,7 +64,7 @@ export const Multichannel = props => {
|
|
|
62
64
|
</MultichannelText>
|
|
63
65
|
)
|
|
64
66
|
}
|
|
65
|
-
if (child && child.type && child.type.name ===
|
|
67
|
+
if (child && child.type && child.type.name === Carousel.name) {
|
|
66
68
|
return (
|
|
67
69
|
<MultichannelCarousel
|
|
68
70
|
{...child.props}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const MULTICHANNEL_WHATSAPP_PROPS = { markdown: false }
|
|
2
|
+
|
|
3
|
+
export const WHATSAPP_MAX_BUTTONS = 3
|
|
4
|
+
export const WHATSAPP_LIST_MAX_BUTTONS = 10
|
|
5
|
+
export const WHATSAPP_MAX_BUTTON_CHARS = 20
|
|
6
|
+
export const WHATSAPP_MAX_HEADER_CHARS = 60
|
|
7
|
+
export const WHATSAPP_MAX_BODY_CHARS = 1024
|
|
8
|
+
export const WHATSAPP_MAX_FOOTER_CHARS = 60
|
|
9
|
+
export const DEFAULT_WHATSAPP_MAX_BUTTON_SEPARATOR = 'More options:'
|
|
10
|
+
export const MENU_BUTTON_WHATSAPP_BUTTON_LIST = 'Show options'
|
|
@@ -4,7 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import { truncateText } from '../util'
|
|
5
5
|
import { renderComponent } from '../util/react'
|
|
6
6
|
import { Message } from './message'
|
|
7
|
-
import { WHATSAPP_MAX_BUTTON_CHARS } from './multichannel/
|
|
7
|
+
import { WHATSAPP_MAX_BUTTON_CHARS } from './multichannel/whatsapp/constants'
|
|
8
8
|
import { convertToMarkdownMeta } from './multichannel/whatsapp/markdown-meta'
|
|
9
9
|
|
|
10
10
|
// TODO: Add validation in component
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
WHATSAPP_MAX_BUTTON_CHARS,
|
|
11
11
|
WHATSAPP_MAX_FOOTER_CHARS,
|
|
12
12
|
WHATSAPP_MAX_HEADER_CHARS,
|
|
13
|
-
} from './multichannel/
|
|
13
|
+
} from './multichannel/whatsapp/constants'
|
|
14
14
|
import { convertToMarkdownMeta } from './multichannel/whatsapp/markdown-meta'
|
|
15
15
|
|
|
16
16
|
export interface WhatsappCTAUrlButtonCommonProps {
|
package/src/constants.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BotonicLogo from './assets/botonic_react_logo100x100.png'
|
|
2
2
|
import UrlIcon from './assets/url-icon.png'
|
|
3
|
+
import { Button, Carousel, Reply, Text } from './components'
|
|
3
4
|
|
|
4
5
|
export const COLORS = {
|
|
5
6
|
// http://chir.ag/projects/name-that-color
|
|
@@ -189,10 +190,3 @@ export const ROLES = {
|
|
|
189
190
|
DOCUMENT_MESSAGE: 'document-message',
|
|
190
191
|
RAW_MESSAGE: 'raw-message',
|
|
191
192
|
}
|
|
192
|
-
|
|
193
|
-
export const COMPONENT_TYPE = {
|
|
194
|
-
TEXT: 'Text',
|
|
195
|
-
BUTTON: 'Button',
|
|
196
|
-
REPLY: 'Reply',
|
|
197
|
-
CAROUSEL: 'Carousel',
|
|
198
|
-
}
|