UNPKG

@botonic/react

Version:

Build Chatbots using React

15 lines 1.14 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { truncateText } from '../util'; import { Button } from './button'; import { Carousel } from './carousel'; import { Element } from './element'; import { WHATSAPP_MAX_BODY_CHARS, WHATSAPP_MAX_BUTTON_CHARS, WHATSAPP_MAX_CAROUSEL_CARD_TEXT_CHARS, } from './multichannel/whatsapp/constants'; import { Pic } from './pic'; import { Title } from './title'; /* Reference: https://developers.facebook.com/docs/whatsapp/cloud-api/messages/interactive-media-carousel-messages/ */ export const WhatsappInteractiveMediaCarousel = (props) => { return (_jsx(Carousel, Object.assign({ text: truncateText(props.textMessage, WHATSAPP_MAX_BODY_CHARS) }, { children: props.cards.map((card, index) => (_jsxs(Element, { children: [_jsx(Pic, { src: card.action.imageLink }), _jsx(Title, { children: truncateText(card.text, WHATSAPP_MAX_CAROUSEL_CARD_TEXT_CHARS) }), _jsx(Button, Object.assign({ url: card.action.buttonUrl }, { children: truncateText(card.action.buttonText, WHATSAPP_MAX_BUTTON_CHARS) }))] }, index))) }))); }; //# sourceMappingURL=whatsapp-interactive-media-carousel.js.map