@botonic/react 0.31.0 → 0.31.1-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/index.d.ts +5 -0
- package/lib/cjs/components/index.js +11 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/whatsapp-catalog.d.ts +6 -0
- package/lib/cjs/components/whatsapp-catalog.js +25 -0
- package/lib/cjs/components/whatsapp-catalog.js.map +1 -0
- package/lib/cjs/components/whatsapp-media-carousel.d.ts +46 -0
- package/lib/cjs/components/whatsapp-media-carousel.js +40 -0
- package/lib/cjs/components/whatsapp-media-carousel.js.map +1 -0
- package/lib/cjs/components/whatsapp-product-carousel.d.ts +32 -0
- package/lib/cjs/components/whatsapp-product-carousel.js +34 -0
- package/lib/cjs/components/whatsapp-product-carousel.js.map +1 -0
- package/lib/cjs/components/whatsapp-product-list.d.ts +15 -0
- package/lib/cjs/components/whatsapp-product-list.js +26 -0
- package/lib/cjs/components/whatsapp-product-list.js.map +1 -0
- package/lib/cjs/components/whatsapp-product.d.ts +7 -0
- package/lib/cjs/components/whatsapp-product.js +25 -0
- package/lib/cjs/components/whatsapp-product.js.map +1 -0
- package/lib/cjs/util/functional.d.ts +3 -0
- package/lib/cjs/util/functional.js +30 -0
- package/lib/cjs/util/functional.js.map +1 -0
- package/lib/esm/components/index.d.ts +5 -0
- package/lib/esm/components/index.js +5 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/whatsapp-catalog.d.ts +6 -0
- package/lib/esm/components/whatsapp-catalog.js +21 -0
- package/lib/esm/components/whatsapp-catalog.js.map +1 -0
- package/lib/esm/components/whatsapp-media-carousel.d.ts +46 -0
- package/lib/esm/components/whatsapp-media-carousel.js +36 -0
- package/lib/esm/components/whatsapp-media-carousel.js.map +1 -0
- package/lib/esm/components/whatsapp-product-carousel.d.ts +32 -0
- package/lib/esm/components/whatsapp-product-carousel.js +30 -0
- package/lib/esm/components/whatsapp-product-carousel.js.map +1 -0
- package/lib/esm/components/whatsapp-product-list.d.ts +15 -0
- package/lib/esm/components/whatsapp-product-list.js +22 -0
- package/lib/esm/components/whatsapp-product-list.js.map +1 -0
- package/lib/esm/components/whatsapp-product.d.ts +7 -0
- package/lib/esm/components/whatsapp-product.js +21 -0
- package/lib/esm/components/whatsapp-product.js.map +1 -0
- package/lib/esm/util/functional.d.ts +3 -0
- package/lib/esm/util/functional.js +26 -0
- package/lib/esm/util/functional.js.map +1 -0
- package/package.json +2 -2
- package/src/components/index.ts +16 -0
- package/src/components/whatsapp-catalog.tsx +42 -0
- package/src/components/whatsapp-media-carousel.tsx +104 -0
- package/src/components/whatsapp-product-carousel.tsx +83 -0
- package/src/components/whatsapp-product-list.tsx +56 -0
- package/src/components/whatsapp-product.tsx +44 -0
- package/src/util/functional.ts +31 -0
|
@@ -21,5 +21,10 @@ export { Title } from './title';
|
|
|
21
21
|
export { Video } from './video';
|
|
22
22
|
export { normalizeWebchatSettings, WebchatSettings, WebchatSettingsProps, } from './webchat-settings';
|
|
23
23
|
export { WhatsappButtonList, WhatsappButtonListProps, WhatsappButtonListRowProps, WhatsappButtonListSectionProps, } from './whatsapp-button-list';
|
|
24
|
+
export { WhatsappCatalog, WhatsappCatalogProps } from './whatsapp-catalog';
|
|
24
25
|
export { WhatsappCTAUrlButton, WhatsappCTAUrlButtonProps, } from './whatsapp-cta-url-button';
|
|
26
|
+
export { WhatsappMediaCarousel, WhatsappMediaCarouselProps, } from './whatsapp-media-carousel';
|
|
27
|
+
export { WhatsappProduct } from './whatsapp-product';
|
|
28
|
+
export { WhatsappProductCarousel, WhatsappProductCarouselProps, } from './whatsapp-product-carousel';
|
|
29
|
+
export { ProductItem, WhatsappProductList, WhatsappProductListProps, WhatsappProductListSection, } from './whatsapp-product-list';
|
|
25
30
|
export { WhatsappTemplate } from './whatsapp-template';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WhatsappTemplate = exports.WhatsappCTAUrlButton = exports.WhatsappButtonList = exports.WebchatSettings = exports.normalizeWebchatSettings = exports.Video = exports.Title = exports.Text = exports.Subtitle = exports.ShareButton = exports.Reply = exports.Raw = exports.Pic = exports.MessageTemplate = exports.Message = exports.Location = exports.Image = exports.Handoff = exports.Element = exports.Document = exports.customMessage = exports.Carousel = exports.Button = exports.Audio = void 0;
|
|
3
|
+
exports.WhatsappTemplate = exports.WhatsappProductList = exports.WhatsappProductCarousel = exports.WhatsappProduct = exports.WhatsappMediaCarousel = exports.WhatsappCTAUrlButton = exports.WhatsappCatalog = exports.WhatsappButtonList = exports.WebchatSettings = exports.normalizeWebchatSettings = exports.Video = exports.Title = exports.Text = exports.Subtitle = exports.ShareButton = exports.Reply = exports.Raw = exports.Pic = exports.MessageTemplate = exports.Message = exports.Location = exports.Image = exports.Handoff = exports.Element = exports.Document = exports.customMessage = exports.Carousel = exports.Button = exports.Audio = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var audio_1 = require("./audio");
|
|
6
6
|
Object.defineProperty(exports, "Audio", { enumerable: true, get: function () { return audio_1.Audio; } });
|
|
@@ -47,8 +47,18 @@ Object.defineProperty(exports, "normalizeWebchatSettings", { enumerable: true, g
|
|
|
47
47
|
Object.defineProperty(exports, "WebchatSettings", { enumerable: true, get: function () { return webchat_settings_1.WebchatSettings; } });
|
|
48
48
|
var whatsapp_button_list_1 = require("./whatsapp-button-list");
|
|
49
49
|
Object.defineProperty(exports, "WhatsappButtonList", { enumerable: true, get: function () { return whatsapp_button_list_1.WhatsappButtonList; } });
|
|
50
|
+
var whatsapp_catalog_1 = require("./whatsapp-catalog");
|
|
51
|
+
Object.defineProperty(exports, "WhatsappCatalog", { enumerable: true, get: function () { return whatsapp_catalog_1.WhatsappCatalog; } });
|
|
50
52
|
var whatsapp_cta_url_button_1 = require("./whatsapp-cta-url-button");
|
|
51
53
|
Object.defineProperty(exports, "WhatsappCTAUrlButton", { enumerable: true, get: function () { return whatsapp_cta_url_button_1.WhatsappCTAUrlButton; } });
|
|
54
|
+
var whatsapp_media_carousel_1 = require("./whatsapp-media-carousel");
|
|
55
|
+
Object.defineProperty(exports, "WhatsappMediaCarousel", { enumerable: true, get: function () { return whatsapp_media_carousel_1.WhatsappMediaCarousel; } });
|
|
56
|
+
var whatsapp_product_1 = require("./whatsapp-product");
|
|
57
|
+
Object.defineProperty(exports, "WhatsappProduct", { enumerable: true, get: function () { return whatsapp_product_1.WhatsappProduct; } });
|
|
58
|
+
var whatsapp_product_carousel_1 = require("./whatsapp-product-carousel");
|
|
59
|
+
Object.defineProperty(exports, "WhatsappProductCarousel", { enumerable: true, get: function () { return whatsapp_product_carousel_1.WhatsappProductCarousel; } });
|
|
60
|
+
var whatsapp_product_list_1 = require("./whatsapp-product-list");
|
|
61
|
+
Object.defineProperty(exports, "WhatsappProductList", { enumerable: true, get: function () { return whatsapp_product_list_1.WhatsappProductList; } });
|
|
52
62
|
var whatsapp_template_1 = require("./whatsapp-template");
|
|
53
63
|
Object.defineProperty(exports, "WhatsappTemplate", { enumerable: true, get: function () { return whatsapp_template_1.WhatsappTemplate; } });
|
|
54
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;;AAAA,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,wDAA6B;AAC7B,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,uDAAoD;AAA3C,mHAAA,eAAe,OAAA;AACxB,yDAA8B;AAC9B,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AACpB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,uDAI2B;AAHzB,4HAAA,wBAAwB,OAAA;AACxB,mHAAA,eAAe,OAAA;AAGjB,+DAK+B;AAJ7B,0HAAA,kBAAkB,OAAA;AAKpB,qEAGkC;AAFhC,+HAAA,oBAAoB,OAAA;AAGtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;;AAAA,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,wDAA6B;AAC7B,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,uDAAoD;AAA3C,mHAAA,eAAe,OAAA;AACxB,yDAA8B;AAC9B,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AACpB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,+BAA6B;AAApB,4FAAA,IAAI,OAAA;AACb,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,uDAI2B;AAHzB,4HAAA,wBAAwB,OAAA;AACxB,mHAAA,eAAe,OAAA;AAGjB,+DAK+B;AAJ7B,0HAAA,kBAAkB,OAAA;AAKpB,uDAA0E;AAAjE,mHAAA,eAAe,OAAA;AACxB,qEAGkC;AAFhC,+HAAA,oBAAoB,OAAA;AAGtB,qEAGkC;AAFhC,gIAAA,qBAAqB,OAAA;AAGvB,uDAAoD;AAA3C,mHAAA,eAAe,OAAA;AACxB,yEAGoC;AAFlC,oIAAA,uBAAuB,OAAA;AAGzB,iEAKgC;AAH9B,4HAAA,mBAAmB,OAAA;AAIrB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsappCatalog = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const react_1 = require("../util/react");
|
|
7
|
+
const message_1 = require("./message");
|
|
8
|
+
const serialize = (message) => {
|
|
9
|
+
return { text: message };
|
|
10
|
+
};
|
|
11
|
+
const WhatsappCatalog = (props) => {
|
|
12
|
+
const renderBrowser = () => {
|
|
13
|
+
// Return a dummy message for browser
|
|
14
|
+
const message = `WhatsApp Catalog would be sent to the user.`;
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(message) }, props, { type: core_1.INPUT.TEXT }, { children: message })));
|
|
16
|
+
};
|
|
17
|
+
const renderNode = () => {
|
|
18
|
+
return (
|
|
19
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
20
|
+
(0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { body: props.body, footer: props.footer, thumbnailProductId: props.thumbnailProductId, type: core_1.INPUT.WHATSAPP_CATALOG })));
|
|
21
|
+
};
|
|
22
|
+
return (0, react_1.renderComponent)({ renderBrowser, renderNode });
|
|
23
|
+
};
|
|
24
|
+
exports.WhatsappCatalog = WhatsappCatalog;
|
|
25
|
+
//# sourceMappingURL=whatsapp-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-catalog.js","sourceRoot":"","sources":["../../../src/components/whatsapp-catalog.tsx"],"names":[],"mappings":";;;;AAAA,wCAAqC;AAGrC,yCAA+C;AAC/C,uCAAmC;AAQnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAEM,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,6CAA6C,CAAA;QAC7D,OAAO,CACL,uBAAC,iBAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,YAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,oDACM,KAAK,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,IAAI,EAAE,YAAK,CAAC,gBAAgB,IAC5B,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AAzBY,QAAA,eAAe,mBAyB3B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type Parameters = TextParameter | CurrencyParameter | DateTimeParameter;
|
|
2
|
+
interface TextParameter {
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
interface CurrencyParameter {
|
|
7
|
+
type: 'currency';
|
|
8
|
+
currency: {
|
|
9
|
+
fallbackValue: string;
|
|
10
|
+
code: string;
|
|
11
|
+
amount1000: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface DateTimeParameter {
|
|
15
|
+
type: 'date_time';
|
|
16
|
+
dateTime: {
|
|
17
|
+
fallbackValue: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
type CardButton = QuickReplyButton | UrlButton;
|
|
21
|
+
interface Button {
|
|
22
|
+
type: 'quick_reply' | 'url';
|
|
23
|
+
buttonIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
interface QuickReplyButton extends Button {
|
|
26
|
+
payload: string;
|
|
27
|
+
}
|
|
28
|
+
interface UrlButton extends Button {
|
|
29
|
+
urlVariable: string;
|
|
30
|
+
}
|
|
31
|
+
interface Card {
|
|
32
|
+
fileType: 'image' | 'video';
|
|
33
|
+
fileId: string;
|
|
34
|
+
cardIndex?: number;
|
|
35
|
+
bodyParameters?: Parameters[];
|
|
36
|
+
buttons?: CardButton[];
|
|
37
|
+
extraComponents?: Record<string, any>[];
|
|
38
|
+
}
|
|
39
|
+
export interface WhatsappMediaCarouselProps {
|
|
40
|
+
templateName: string;
|
|
41
|
+
templateLanguage: string;
|
|
42
|
+
cards: Card[];
|
|
43
|
+
bodyParameters?: Parameters[];
|
|
44
|
+
}
|
|
45
|
+
export declare const WhatsappMediaCarousel: (props: WhatsappMediaCarouselProps) => any;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsappMediaCarousel = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const functional_1 = require("../util/functional");
|
|
7
|
+
const react_1 = require("../util/react");
|
|
8
|
+
const message_1 = require("./message");
|
|
9
|
+
const serialize = (message) => {
|
|
10
|
+
return { text: message };
|
|
11
|
+
};
|
|
12
|
+
const WhatsappMediaCarousel = (props) => {
|
|
13
|
+
const renderBrowser = () => {
|
|
14
|
+
// Return a dummy message for browser
|
|
15
|
+
const message = `WhatsApp Media Carousel would be sent to the user.`;
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(message) }, props, { type: core_1.INPUT.TEXT }, { children: message })));
|
|
17
|
+
};
|
|
18
|
+
const getCards = (cards) => {
|
|
19
|
+
cards.forEach((card, index) => {
|
|
20
|
+
var _a;
|
|
21
|
+
if (!card.cardIndex) {
|
|
22
|
+
card.cardIndex = index;
|
|
23
|
+
}
|
|
24
|
+
(_a = card.buttons) === null || _a === void 0 ? void 0 : _a.forEach((button, index) => {
|
|
25
|
+
if (!button.buttonIndex) {
|
|
26
|
+
button.buttonIndex = index;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return (0, functional_1.toSnakeCaseKeys)(cards);
|
|
31
|
+
};
|
|
32
|
+
const renderNode = () => {
|
|
33
|
+
return (
|
|
34
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
35
|
+
(0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { bodyParameters: JSON.stringify((0, functional_1.toSnakeCaseKeys)(props.bodyParameters)), cards: JSON.stringify(getCards(props.cards)), templateName: props.templateName, templateLanguage: props.templateLanguage, type: core_1.INPUT.WHATSAPP_MEDIA_CAROUSEL })));
|
|
36
|
+
};
|
|
37
|
+
return (0, react_1.renderComponent)({ renderBrowser, renderNode });
|
|
38
|
+
};
|
|
39
|
+
exports.WhatsappMediaCarousel = WhatsappMediaCarousel;
|
|
40
|
+
//# sourceMappingURL=whatsapp-media-carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-media-carousel.js","sourceRoot":"","sources":["../../../src/components/whatsapp-media-carousel.tsx"],"names":[],"mappings":";;;;AAAA,wCAAqC;AAGrC,mDAAoD;AACpD,yCAA+C;AAC/C,uCAAmC;AAsDnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAEM,MAAM,qBAAqB,GAAG,CAAC,KAAiC,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,oDAAoD,CAAA;QACpE,OAAO,CACL,uBAAC,iBAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,YAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;;YAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;aACvB;YACD,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBACtC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;oBACvB,MAAM,CAAC,WAAW,GAAG,KAAK,CAAA;iBAC3B;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,OAAO,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;IAC/B,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,oDACM,KAAK,IACT,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAA,4BAAe,EAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EACrE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,IAAI,EAAE,YAAK,CAAC,uBAAuB,IACnC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AAxCY,QAAA,qBAAqB,yBAwCjC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type Parameters = TextParameter | CurrencyParameter | DateTimeParameter;
|
|
2
|
+
interface TextParameter {
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
interface CurrencyParameter {
|
|
7
|
+
type: 'currency';
|
|
8
|
+
currency: {
|
|
9
|
+
fallbackValue: string;
|
|
10
|
+
code: string;
|
|
11
|
+
amount1000: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface DateTimeParameter {
|
|
15
|
+
type: 'date_time';
|
|
16
|
+
dateTime: {
|
|
17
|
+
fallbackValue: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface Card {
|
|
21
|
+
productRetailerId: string;
|
|
22
|
+
catalogId: string;
|
|
23
|
+
cardIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface WhatsappProductCarouselProps {
|
|
26
|
+
templateName: string;
|
|
27
|
+
templateLanguage: string;
|
|
28
|
+
cards: Card[];
|
|
29
|
+
bodyParameters?: Parameters[];
|
|
30
|
+
}
|
|
31
|
+
export declare const WhatsappProductCarousel: (props: WhatsappProductCarouselProps) => any;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsappProductCarousel = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const functional_1 = require("../util/functional");
|
|
7
|
+
const react_1 = require("../util/react");
|
|
8
|
+
const message_1 = require("./message");
|
|
9
|
+
const serialize = (message) => {
|
|
10
|
+
return { text: message };
|
|
11
|
+
};
|
|
12
|
+
const WhatsappProductCarousel = (props) => {
|
|
13
|
+
const renderBrowser = () => {
|
|
14
|
+
// Return a dummy message for browser
|
|
15
|
+
const message = `WhatsApp Product Carousel would be sent to the user.`;
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(message) }, props, { type: core_1.INPUT.TEXT }, { children: message })));
|
|
17
|
+
};
|
|
18
|
+
const getCards = (cards) => {
|
|
19
|
+
cards.forEach((card, index) => {
|
|
20
|
+
if (!card.cardIndex) {
|
|
21
|
+
card.cardIndex = index;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return (0, functional_1.toSnakeCaseKeys)(cards);
|
|
25
|
+
};
|
|
26
|
+
const renderNode = () => {
|
|
27
|
+
return (
|
|
28
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
29
|
+
(0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { bodyParameters: JSON.stringify((0, functional_1.toSnakeCaseKeys)(props.bodyParameters)), cards: JSON.stringify(getCards(props.cards)), templateName: props.templateName, templateLanguage: props.templateLanguage, type: core_1.INPUT.WHATSAPP_PRODUCT_CAROUSEL })));
|
|
30
|
+
};
|
|
31
|
+
return (0, react_1.renderComponent)({ renderBrowser, renderNode });
|
|
32
|
+
};
|
|
33
|
+
exports.WhatsappProductCarousel = WhatsappProductCarousel;
|
|
34
|
+
//# sourceMappingURL=whatsapp-product-carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-product-carousel.js","sourceRoot":"","sources":["../../../src/components/whatsapp-product-carousel.tsx"],"names":[],"mappings":";;;;AAAA,wCAAqC;AAGrC,mDAAoD;AACpD,yCAA+C;AAC/C,uCAAmC;AAoCnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAEM,MAAM,uBAAuB,GAAG,CACrC,KAAmC,EACnC,EAAE;IACF,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,sDAAsD,CAAA;QACtE,OAAO,CACL,uBAAC,iBAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,YAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;aACvB;QACH,CAAC,CAAC,CAAA;QACF,OAAO,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;IAC/B,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,oDACM,KAAK,IACT,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAA,4BAAe,EAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EACrE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,IAAI,EAAE,YAAK,CAAC,yBAAyB,IACrC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AArCY,QAAA,uBAAuB,2BAqCnC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ProductItem {
|
|
2
|
+
productRetailerId: string;
|
|
3
|
+
}
|
|
4
|
+
export interface WhatsappProductListSection {
|
|
5
|
+
title: string;
|
|
6
|
+
productItems: ProductItem[];
|
|
7
|
+
}
|
|
8
|
+
export interface WhatsappProductListProps {
|
|
9
|
+
body: string;
|
|
10
|
+
header: string;
|
|
11
|
+
catalogId: string;
|
|
12
|
+
sections: WhatsappProductListSection[];
|
|
13
|
+
footer?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const WhatsappProductList: (props: WhatsappProductListProps) => any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsappProductList = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const functional_1 = require("../util/functional");
|
|
7
|
+
const react_1 = require("../util/react");
|
|
8
|
+
const message_1 = require("./message");
|
|
9
|
+
const serialize = (message) => {
|
|
10
|
+
return { text: message };
|
|
11
|
+
};
|
|
12
|
+
const WhatsappProductList = (props) => {
|
|
13
|
+
const renderBrowser = () => {
|
|
14
|
+
// Return a dummy message for browser
|
|
15
|
+
const message = `WhatsApp Product List would be sent to the user.`;
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(message) }, props, { type: core_1.INPUT.TEXT }, { children: message })));
|
|
17
|
+
};
|
|
18
|
+
const renderNode = () => {
|
|
19
|
+
return (
|
|
20
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
21
|
+
(0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { body: props.body, footer: props.footer, header: props.header, sections: JSON.stringify((0, functional_1.toSnakeCaseKeys)(props.sections)), catalogId: props.catalogId, type: core_1.INPUT.WHATSAPP_PRODUCT_LIST })));
|
|
22
|
+
};
|
|
23
|
+
return (0, react_1.renderComponent)({ renderBrowser, renderNode });
|
|
24
|
+
};
|
|
25
|
+
exports.WhatsappProductList = WhatsappProductList;
|
|
26
|
+
//# sourceMappingURL=whatsapp-product-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-product-list.js","sourceRoot":"","sources":["../../../src/components/whatsapp-product-list.tsx"],"names":[],"mappings":";;;;AAAA,wCAAqC;AAGrC,mDAAoD;AACpD,yCAA+C;AAC/C,uCAAmC;AAmBnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAEM,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,kDAAkD,CAAA;QAClE,OAAO,CACL,uBAAC,iBAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,YAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,oDACM,KAAK,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAA,4BAAe,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EACzD,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,IAAI,EAAE,YAAK,CAAC,qBAAqB,IACjC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AA3BY,QAAA,mBAAmB,uBA2B/B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsappProduct = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const react_1 = require("../util/react");
|
|
7
|
+
const message_1 = require("./message");
|
|
8
|
+
const serialize = (message) => {
|
|
9
|
+
return { text: message };
|
|
10
|
+
};
|
|
11
|
+
const WhatsappProduct = (props) => {
|
|
12
|
+
const renderBrowser = () => {
|
|
13
|
+
// Return a dummy message for browser
|
|
14
|
+
const message = `WhatsApp Product would be sent to the user.`;
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(message) }, props, { type: core_1.INPUT.TEXT }, { children: message })));
|
|
16
|
+
};
|
|
17
|
+
const renderNode = () => {
|
|
18
|
+
return (
|
|
19
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
20
|
+
(0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { body: props.body, footer: props.footer, catalogId: props.catalogId, productId: props.productId, type: core_1.INPUT.WHATSAPP_PRODUCT })));
|
|
21
|
+
};
|
|
22
|
+
return (0, react_1.renderComponent)({ renderBrowser, renderNode });
|
|
23
|
+
};
|
|
24
|
+
exports.WhatsappProduct = WhatsappProduct;
|
|
25
|
+
//# sourceMappingURL=whatsapp-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-product.js","sourceRoot":"","sources":["../../../src/components/whatsapp-product.tsx"],"names":[],"mappings":";;;;AAAA,wCAAqC;AAGrC,yCAA+C;AAC/C,uCAAmC;AASnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAEM,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,6CAA6C,CAAA;QAC7D,OAAO,CACL,uBAAC,iBAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,YAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,oDACM,KAAK,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,IAAI,EAAE,YAAK,CAAC,gBAAgB,IAC5B,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,IAAA,uBAAe,EAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AA1BY,QAAA,eAAe,mBA0B3B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toSnakeCaseKeys = void 0;
|
|
4
|
+
function camelCaseToSnake(str) {
|
|
5
|
+
return str
|
|
6
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
7
|
+
.replace(/([A-Za-z])(\d)/g, '$1_$2')
|
|
8
|
+
.replace(/(\d)([A-Za-z])/g, '$1_$2')
|
|
9
|
+
.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function toSnakeCaseKeys(input) {
|
|
12
|
+
if (Array.isArray(input)) {
|
|
13
|
+
return input.map(item => toSnakeCaseKeys(item));
|
|
14
|
+
}
|
|
15
|
+
if (typeof input === 'object' && input !== null) {
|
|
16
|
+
const result = Object.keys(input).reduce((acc, key) => {
|
|
17
|
+
const snakeKey = camelCaseToSnake(key);
|
|
18
|
+
const value = input[key];
|
|
19
|
+
acc[snakeKey] =
|
|
20
|
+
typeof value === 'object' && value !== null
|
|
21
|
+
? toSnakeCaseKeys(value)
|
|
22
|
+
: value;
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
return input;
|
|
28
|
+
}
|
|
29
|
+
exports.toSnakeCaseKeys = toSnakeCaseKeys;
|
|
30
|
+
//# sourceMappingURL=functional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functional.js","sourceRoot":"","sources":["../../../src/util/functional.ts"],"names":[],"mappings":";;;AAAA,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,GAAG;SACP,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,WAAW,EAAE,CAAA;AAClB,CAAC;AAGD,SAAgB,eAAe,CAAC,KAAY;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAA;KAChD;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACpD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;YACtC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;YACxB,GAAG,CAAC,QAAQ,CAAC;gBACX,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;oBACzC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC;oBACxB,CAAC,CAAC,KAAK,CAAA;YAEX,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,OAAO,MAAM,CAAA;KACd;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AArBD,0CAqBC"}
|
|
@@ -21,5 +21,10 @@ export { Title } from './title';
|
|
|
21
21
|
export { Video } from './video';
|
|
22
22
|
export { normalizeWebchatSettings, WebchatSettings, WebchatSettingsProps, } from './webchat-settings';
|
|
23
23
|
export { WhatsappButtonList, WhatsappButtonListProps, WhatsappButtonListRowProps, WhatsappButtonListSectionProps, } from './whatsapp-button-list';
|
|
24
|
+
export { WhatsappCatalog, WhatsappCatalogProps } from './whatsapp-catalog';
|
|
24
25
|
export { WhatsappCTAUrlButton, WhatsappCTAUrlButtonProps, } from './whatsapp-cta-url-button';
|
|
26
|
+
export { WhatsappMediaCarousel, WhatsappMediaCarouselProps, } from './whatsapp-media-carousel';
|
|
27
|
+
export { WhatsappProduct } from './whatsapp-product';
|
|
28
|
+
export { WhatsappProductCarousel, WhatsappProductCarouselProps, } from './whatsapp-product-carousel';
|
|
29
|
+
export { ProductItem, WhatsappProductList, WhatsappProductListProps, WhatsappProductListSection, } from './whatsapp-product-list';
|
|
25
30
|
export { WhatsappTemplate } from './whatsapp-template';
|
|
@@ -21,6 +21,11 @@ export { Title } from './title';
|
|
|
21
21
|
export { Video } from './video';
|
|
22
22
|
export { normalizeWebchatSettings, WebchatSettings, } from './webchat-settings';
|
|
23
23
|
export { WhatsappButtonList, } from './whatsapp-button-list';
|
|
24
|
+
export { WhatsappCatalog } from './whatsapp-catalog';
|
|
24
25
|
export { WhatsappCTAUrlButton, } from './whatsapp-cta-url-button';
|
|
26
|
+
export { WhatsappMediaCarousel, } from './whatsapp-media-carousel';
|
|
27
|
+
export { WhatsappProduct } from './whatsapp-product';
|
|
28
|
+
export { WhatsappProductCarousel, } from './whatsapp-product-carousel';
|
|
29
|
+
export { WhatsappProductList, } from './whatsapp-product-list';
|
|
25
30
|
export { WhatsappTemplate } from './whatsapp-template';
|
|
26
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EACL,wBAAwB,EACxB,eAAe,GAEhB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,kBAAkB,GAInB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,oBAAoB,GAErB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EACL,wBAAwB,EACxB,eAAe,GAEhB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,kBAAkB,GAInB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAwB,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EACL,oBAAoB,GAErB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,uBAAuB,GAExB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAEL,mBAAmB,GAGpB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT } from '@botonic/core';
|
|
3
|
+
import { renderComponent } from '../util/react';
|
|
4
|
+
import { Message } from './message';
|
|
5
|
+
const serialize = (message) => {
|
|
6
|
+
return { text: message };
|
|
7
|
+
};
|
|
8
|
+
export const WhatsappCatalog = (props) => {
|
|
9
|
+
const renderBrowser = () => {
|
|
10
|
+
// Return a dummy message for browser
|
|
11
|
+
const message = `WhatsApp Catalog would be sent to the user.`;
|
|
12
|
+
return (_jsx(Message, Object.assign({ json: serialize(message) }, props, { type: INPUT.TEXT }, { children: message })));
|
|
13
|
+
};
|
|
14
|
+
const renderNode = () => {
|
|
15
|
+
return (
|
|
16
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
17
|
+
_jsx("message", Object.assign({}, props, { body: props.body, footer: props.footer, thumbnailProductId: props.thumbnailProductId, type: INPUT.WHATSAPP_CATALOG })));
|
|
18
|
+
};
|
|
19
|
+
return renderComponent({ renderBrowser, renderNode });
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=whatsapp-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-catalog.js","sourceRoot":"","sources":["../../../src/components/whatsapp-catalog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,6CAA6C,CAAA;QAC7D,OAAO,CACL,KAAC,OAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,KAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,kCACM,KAAK,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,IAAI,EAAE,KAAK,CAAC,gBAAgB,IAC5B,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type Parameters = TextParameter | CurrencyParameter | DateTimeParameter;
|
|
2
|
+
interface TextParameter {
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
interface CurrencyParameter {
|
|
7
|
+
type: 'currency';
|
|
8
|
+
currency: {
|
|
9
|
+
fallbackValue: string;
|
|
10
|
+
code: string;
|
|
11
|
+
amount1000: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface DateTimeParameter {
|
|
15
|
+
type: 'date_time';
|
|
16
|
+
dateTime: {
|
|
17
|
+
fallbackValue: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
type CardButton = QuickReplyButton | UrlButton;
|
|
21
|
+
interface Button {
|
|
22
|
+
type: 'quick_reply' | 'url';
|
|
23
|
+
buttonIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
interface QuickReplyButton extends Button {
|
|
26
|
+
payload: string;
|
|
27
|
+
}
|
|
28
|
+
interface UrlButton extends Button {
|
|
29
|
+
urlVariable: string;
|
|
30
|
+
}
|
|
31
|
+
interface Card {
|
|
32
|
+
fileType: 'image' | 'video';
|
|
33
|
+
fileId: string;
|
|
34
|
+
cardIndex?: number;
|
|
35
|
+
bodyParameters?: Parameters[];
|
|
36
|
+
buttons?: CardButton[];
|
|
37
|
+
extraComponents?: Record<string, any>[];
|
|
38
|
+
}
|
|
39
|
+
export interface WhatsappMediaCarouselProps {
|
|
40
|
+
templateName: string;
|
|
41
|
+
templateLanguage: string;
|
|
42
|
+
cards: Card[];
|
|
43
|
+
bodyParameters?: Parameters[];
|
|
44
|
+
}
|
|
45
|
+
export declare const WhatsappMediaCarousel: (props: WhatsappMediaCarouselProps) => any;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT } from '@botonic/core';
|
|
3
|
+
import { toSnakeCaseKeys } from '../util/functional';
|
|
4
|
+
import { renderComponent } from '../util/react';
|
|
5
|
+
import { Message } from './message';
|
|
6
|
+
const serialize = (message) => {
|
|
7
|
+
return { text: message };
|
|
8
|
+
};
|
|
9
|
+
export const WhatsappMediaCarousel = (props) => {
|
|
10
|
+
const renderBrowser = () => {
|
|
11
|
+
// Return a dummy message for browser
|
|
12
|
+
const message = `WhatsApp Media Carousel would be sent to the user.`;
|
|
13
|
+
return (_jsx(Message, Object.assign({ json: serialize(message) }, props, { type: INPUT.TEXT }, { children: message })));
|
|
14
|
+
};
|
|
15
|
+
const getCards = (cards) => {
|
|
16
|
+
cards.forEach((card, index) => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (!card.cardIndex) {
|
|
19
|
+
card.cardIndex = index;
|
|
20
|
+
}
|
|
21
|
+
(_a = card.buttons) === null || _a === void 0 ? void 0 : _a.forEach((button, index) => {
|
|
22
|
+
if (!button.buttonIndex) {
|
|
23
|
+
button.buttonIndex = index;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return toSnakeCaseKeys(cards);
|
|
28
|
+
};
|
|
29
|
+
const renderNode = () => {
|
|
30
|
+
return (
|
|
31
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
32
|
+
_jsx("message", Object.assign({}, props, { bodyParameters: JSON.stringify(toSnakeCaseKeys(props.bodyParameters)), cards: JSON.stringify(getCards(props.cards)), templateName: props.templateName, templateLanguage: props.templateLanguage, type: INPUT.WHATSAPP_MEDIA_CAROUSEL })));
|
|
33
|
+
};
|
|
34
|
+
return renderComponent({ renderBrowser, renderNode });
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=whatsapp-media-carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-media-carousel.js","sourceRoot":"","sources":["../../../src/components/whatsapp-media-carousel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsDnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAiC,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,oDAAoD,CAAA;QACpE,OAAO,CACL,KAAC,OAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,KAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;;YAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;aACvB;YACD,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBACtC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;oBACvB,MAAM,CAAC,WAAW,GAAG,KAAK,CAAA;iBAC3B;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,OAAO,eAAe,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,kCACM,KAAK,IACT,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EACrE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,IAAI,EAAE,KAAK,CAAC,uBAAuB,IACnC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type Parameters = TextParameter | CurrencyParameter | DateTimeParameter;
|
|
2
|
+
interface TextParameter {
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
interface CurrencyParameter {
|
|
7
|
+
type: 'currency';
|
|
8
|
+
currency: {
|
|
9
|
+
fallbackValue: string;
|
|
10
|
+
code: string;
|
|
11
|
+
amount1000: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface DateTimeParameter {
|
|
15
|
+
type: 'date_time';
|
|
16
|
+
dateTime: {
|
|
17
|
+
fallbackValue: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface Card {
|
|
21
|
+
productRetailerId: string;
|
|
22
|
+
catalogId: string;
|
|
23
|
+
cardIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface WhatsappProductCarouselProps {
|
|
26
|
+
templateName: string;
|
|
27
|
+
templateLanguage: string;
|
|
28
|
+
cards: Card[];
|
|
29
|
+
bodyParameters?: Parameters[];
|
|
30
|
+
}
|
|
31
|
+
export declare const WhatsappProductCarousel: (props: WhatsappProductCarouselProps) => any;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT } from '@botonic/core';
|
|
3
|
+
import { toSnakeCaseKeys } from '../util/functional';
|
|
4
|
+
import { renderComponent } from '../util/react';
|
|
5
|
+
import { Message } from './message';
|
|
6
|
+
const serialize = (message) => {
|
|
7
|
+
return { text: message };
|
|
8
|
+
};
|
|
9
|
+
export const WhatsappProductCarousel = (props) => {
|
|
10
|
+
const renderBrowser = () => {
|
|
11
|
+
// Return a dummy message for browser
|
|
12
|
+
const message = `WhatsApp Product Carousel would be sent to the user.`;
|
|
13
|
+
return (_jsx(Message, Object.assign({ json: serialize(message) }, props, { type: INPUT.TEXT }, { children: message })));
|
|
14
|
+
};
|
|
15
|
+
const getCards = (cards) => {
|
|
16
|
+
cards.forEach((card, index) => {
|
|
17
|
+
if (!card.cardIndex) {
|
|
18
|
+
card.cardIndex = index;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return toSnakeCaseKeys(cards);
|
|
22
|
+
};
|
|
23
|
+
const renderNode = () => {
|
|
24
|
+
return (
|
|
25
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
26
|
+
_jsx("message", Object.assign({}, props, { bodyParameters: JSON.stringify(toSnakeCaseKeys(props.bodyParameters)), cards: JSON.stringify(getCards(props.cards)), templateName: props.templateName, templateLanguage: props.templateLanguage, type: INPUT.WHATSAPP_PRODUCT_CAROUSEL })));
|
|
27
|
+
};
|
|
28
|
+
return renderComponent({ renderBrowser, renderNode });
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=whatsapp-product-carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-product-carousel.js","sourceRoot":"","sources":["../../../src/components/whatsapp-product-carousel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAoCnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,KAAmC,EACnC,EAAE;IACF,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,sDAAsD,CAAA;QACtE,OAAO,CACL,KAAC,OAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,KAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;aACvB;QACH,CAAC,CAAC,CAAA;QACF,OAAO,eAAe,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,kCACM,KAAK,IACT,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EACrE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,IAAI,EAAE,KAAK,CAAC,yBAAyB,IACrC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ProductItem {
|
|
2
|
+
productRetailerId: string;
|
|
3
|
+
}
|
|
4
|
+
export interface WhatsappProductListSection {
|
|
5
|
+
title: string;
|
|
6
|
+
productItems: ProductItem[];
|
|
7
|
+
}
|
|
8
|
+
export interface WhatsappProductListProps {
|
|
9
|
+
body: string;
|
|
10
|
+
header: string;
|
|
11
|
+
catalogId: string;
|
|
12
|
+
sections: WhatsappProductListSection[];
|
|
13
|
+
footer?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const WhatsappProductList: (props: WhatsappProductListProps) => any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT } from '@botonic/core';
|
|
3
|
+
import { toSnakeCaseKeys } from '../util/functional';
|
|
4
|
+
import { renderComponent } from '../util/react';
|
|
5
|
+
import { Message } from './message';
|
|
6
|
+
const serialize = (message) => {
|
|
7
|
+
return { text: message };
|
|
8
|
+
};
|
|
9
|
+
export const WhatsappProductList = (props) => {
|
|
10
|
+
const renderBrowser = () => {
|
|
11
|
+
// Return a dummy message for browser
|
|
12
|
+
const message = `WhatsApp Product List would be sent to the user.`;
|
|
13
|
+
return (_jsx(Message, Object.assign({ json: serialize(message) }, props, { type: INPUT.TEXT }, { children: message })));
|
|
14
|
+
};
|
|
15
|
+
const renderNode = () => {
|
|
16
|
+
return (
|
|
17
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
18
|
+
_jsx("message", Object.assign({}, props, { body: props.body, footer: props.footer, header: props.header, sections: JSON.stringify(toSnakeCaseKeys(props.sections)), catalogId: props.catalogId, type: INPUT.WHATSAPP_PRODUCT_LIST })));
|
|
19
|
+
};
|
|
20
|
+
return renderComponent({ renderBrowser, renderNode });
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=whatsapp-product-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-product-list.js","sourceRoot":"","sources":["../../../src/components/whatsapp-product-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAmBnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,kDAAkD,CAAA;QAClE,OAAO,CACL,KAAC,OAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,KAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,kCACM,KAAK,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EACzD,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,IAAI,EAAE,KAAK,CAAC,qBAAqB,IACjC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { INPUT } from '@botonic/core';
|
|
3
|
+
import { renderComponent } from '../util/react';
|
|
4
|
+
import { Message } from './message';
|
|
5
|
+
const serialize = (message) => {
|
|
6
|
+
return { text: message };
|
|
7
|
+
};
|
|
8
|
+
export const WhatsappProduct = (props) => {
|
|
9
|
+
const renderBrowser = () => {
|
|
10
|
+
// Return a dummy message for browser
|
|
11
|
+
const message = `WhatsApp Product would be sent to the user.`;
|
|
12
|
+
return (_jsx(Message, Object.assign({ json: serialize(message) }, props, { type: INPUT.TEXT }, { children: message })));
|
|
13
|
+
};
|
|
14
|
+
const renderNode = () => {
|
|
15
|
+
return (
|
|
16
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
17
|
+
_jsx("message", Object.assign({}, props, { body: props.body, footer: props.footer, catalogId: props.catalogId, productId: props.productId, type: INPUT.WHATSAPP_PRODUCT })));
|
|
18
|
+
};
|
|
19
|
+
return renderComponent({ renderBrowser, renderNode });
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=whatsapp-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-product.js","sourceRoot":"","sources":["../../../src/components/whatsapp-product.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,qCAAqC;QACrC,MAAM,OAAO,GAAG,6CAA6C,CAAA;QAC7D,OAAO,CACL,KAAC,OAAO,kBAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAM,KAAK,IAAE,IAAI,EAAE,KAAK,CAAC,IAAI,gBAC3D,OAAO,IACA,CACX,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO;QACL,gFAAgF;QAChF,kCACM,KAAK,IACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,IAAI,EAAE,KAAK,CAAC,gBAAgB,IAC5B,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,eAAe,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function camelCaseToSnake(str) {
|
|
2
|
+
return str
|
|
3
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
4
|
+
.replace(/([A-Za-z])(\d)/g, '$1_$2')
|
|
5
|
+
.replace(/(\d)([A-Za-z])/g, '$1_$2')
|
|
6
|
+
.toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
export function toSnakeCaseKeys(input) {
|
|
9
|
+
if (Array.isArray(input)) {
|
|
10
|
+
return input.map(item => toSnakeCaseKeys(item));
|
|
11
|
+
}
|
|
12
|
+
if (typeof input === 'object' && input !== null) {
|
|
13
|
+
const result = Object.keys(input).reduce((acc, key) => {
|
|
14
|
+
const snakeKey = camelCaseToSnake(key);
|
|
15
|
+
const value = input[key];
|
|
16
|
+
acc[snakeKey] =
|
|
17
|
+
typeof value === 'object' && value !== null
|
|
18
|
+
? toSnakeCaseKeys(value)
|
|
19
|
+
: value;
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
return input;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=functional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functional.js","sourceRoot":"","sources":["../../../src/util/functional.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,GAAG;SACP,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,WAAW,EAAE,CAAA;AAClB,CAAC;AAGD,MAAM,UAAU,eAAe,CAAC,KAAY;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAA;KAChD;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACpD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;YACtC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;YACxB,GAAG,CAAC,QAAQ,CAAC;gBACX,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;oBACzC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC;oBACxB,CAAC,CAAC,KAAK,CAAA;YAEX,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,OAAO,MAAM,CAAA;KACd;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/react",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.1-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Build Chatbots using React",
|
|
6
6
|
"main": "./lib/cjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet '.*.js' '*.js' 'src/**/*.js*' --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@botonic/core": "
|
|
23
|
+
"@botonic/core": "0.31.1-alpha.0",
|
|
24
24
|
"axios": "^1.7.9",
|
|
25
25
|
"emoji-picker-react": "^4.12.0",
|
|
26
26
|
"lodash.merge": "^4.6.2",
|
package/src/components/index.ts
CHANGED
|
@@ -30,8 +30,24 @@ export {
|
|
|
30
30
|
WhatsappButtonListRowProps,
|
|
31
31
|
WhatsappButtonListSectionProps,
|
|
32
32
|
} from './whatsapp-button-list'
|
|
33
|
+
export { WhatsappCatalog, WhatsappCatalogProps } from './whatsapp-catalog'
|
|
33
34
|
export {
|
|
34
35
|
WhatsappCTAUrlButton,
|
|
35
36
|
WhatsappCTAUrlButtonProps,
|
|
36
37
|
} from './whatsapp-cta-url-button'
|
|
38
|
+
export {
|
|
39
|
+
WhatsappMediaCarousel,
|
|
40
|
+
WhatsappMediaCarouselProps,
|
|
41
|
+
} from './whatsapp-media-carousel'
|
|
42
|
+
export { WhatsappProduct } from './whatsapp-product'
|
|
43
|
+
export {
|
|
44
|
+
WhatsappProductCarousel,
|
|
45
|
+
WhatsappProductCarouselProps,
|
|
46
|
+
} from './whatsapp-product-carousel'
|
|
47
|
+
export {
|
|
48
|
+
ProductItem,
|
|
49
|
+
WhatsappProductList,
|
|
50
|
+
WhatsappProductListProps,
|
|
51
|
+
WhatsappProductListSection,
|
|
52
|
+
} from './whatsapp-product-list'
|
|
37
53
|
export { WhatsappTemplate } from './whatsapp-template'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { INPUT } from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { renderComponent } from '../util/react'
|
|
5
|
+
import { Message } from './message'
|
|
6
|
+
|
|
7
|
+
export interface WhatsappCatalogProps {
|
|
8
|
+
body: string
|
|
9
|
+
footer?: string
|
|
10
|
+
thumbnailProductId?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const serialize = (message: string) => {
|
|
14
|
+
return { text: message }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const WhatsappCatalog = (props: WhatsappCatalogProps) => {
|
|
18
|
+
const renderBrowser = () => {
|
|
19
|
+
// Return a dummy message for browser
|
|
20
|
+
const message = `WhatsApp Catalog would be sent to the user.`
|
|
21
|
+
return (
|
|
22
|
+
<Message json={serialize(message)} {...props} type={INPUT.TEXT}>
|
|
23
|
+
{message}
|
|
24
|
+
</Message>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const renderNode = () => {
|
|
29
|
+
return (
|
|
30
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
31
|
+
<message
|
|
32
|
+
{...props}
|
|
33
|
+
body={props.body}
|
|
34
|
+
footer={props.footer}
|
|
35
|
+
thumbnailProductId={props.thumbnailProductId}
|
|
36
|
+
type={INPUT.WHATSAPP_CATALOG}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return renderComponent({ renderBrowser, renderNode })
|
|
42
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { INPUT } from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { toSnakeCaseKeys } from '../util/functional'
|
|
5
|
+
import { renderComponent } from '../util/react'
|
|
6
|
+
import { Message } from './message'
|
|
7
|
+
|
|
8
|
+
type Parameters = TextParameter | CurrencyParameter | DateTimeParameter
|
|
9
|
+
|
|
10
|
+
interface TextParameter {
|
|
11
|
+
type: 'text'
|
|
12
|
+
text: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface CurrencyParameter {
|
|
16
|
+
type: 'currency'
|
|
17
|
+
currency: {
|
|
18
|
+
fallbackValue: string
|
|
19
|
+
code: string
|
|
20
|
+
amount1000: number
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface DateTimeParameter {
|
|
25
|
+
type: 'date_time'
|
|
26
|
+
dateTime: { fallbackValue: string }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type CardButton = QuickReplyButton | UrlButton
|
|
30
|
+
|
|
31
|
+
interface Button {
|
|
32
|
+
type: 'quick_reply' | 'url'
|
|
33
|
+
buttonIndex?: number
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface QuickReplyButton extends Button {
|
|
37
|
+
payload: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface UrlButton extends Button {
|
|
41
|
+
urlVariable: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface Card {
|
|
45
|
+
fileType: 'image' | 'video'
|
|
46
|
+
fileId: string
|
|
47
|
+
cardIndex?: number
|
|
48
|
+
bodyParameters?: Parameters[]
|
|
49
|
+
buttons?: CardButton[]
|
|
50
|
+
extraComponents?: Record<string, any>[]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface WhatsappMediaCarouselProps {
|
|
54
|
+
templateName: string
|
|
55
|
+
templateLanguage: string
|
|
56
|
+
cards: Card[]
|
|
57
|
+
bodyParameters?: Parameters[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const serialize = (message: string) => {
|
|
61
|
+
return { text: message }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const WhatsappMediaCarousel = (props: WhatsappMediaCarouselProps) => {
|
|
65
|
+
const renderBrowser = () => {
|
|
66
|
+
// Return a dummy message for browser
|
|
67
|
+
const message = `WhatsApp Media Carousel would be sent to the user.`
|
|
68
|
+
return (
|
|
69
|
+
<Message json={serialize(message)} {...props} type={INPUT.TEXT}>
|
|
70
|
+
{message}
|
|
71
|
+
</Message>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const getCards = (cards: Card[]) => {
|
|
76
|
+
cards.forEach((card, index) => {
|
|
77
|
+
if (!card.cardIndex) {
|
|
78
|
+
card.cardIndex = index
|
|
79
|
+
}
|
|
80
|
+
card.buttons?.forEach((button, index) => {
|
|
81
|
+
if (!button.buttonIndex) {
|
|
82
|
+
button.buttonIndex = index
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
return toSnakeCaseKeys(cards)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const renderNode = () => {
|
|
90
|
+
return (
|
|
91
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
92
|
+
<message
|
|
93
|
+
{...props}
|
|
94
|
+
bodyParameters={JSON.stringify(toSnakeCaseKeys(props.bodyParameters))}
|
|
95
|
+
cards={JSON.stringify(getCards(props.cards))}
|
|
96
|
+
templateName={props.templateName}
|
|
97
|
+
templateLanguage={props.templateLanguage}
|
|
98
|
+
type={INPUT.WHATSAPP_MEDIA_CAROUSEL}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return renderComponent({ renderBrowser, renderNode })
|
|
104
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { INPUT } from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { toSnakeCaseKeys } from '../util/functional'
|
|
5
|
+
import { renderComponent } from '../util/react'
|
|
6
|
+
import { Message } from './message'
|
|
7
|
+
|
|
8
|
+
type Parameters = TextParameter | CurrencyParameter | DateTimeParameter
|
|
9
|
+
|
|
10
|
+
interface TextParameter {
|
|
11
|
+
type: 'text'
|
|
12
|
+
text: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface CurrencyParameter {
|
|
16
|
+
type: 'currency'
|
|
17
|
+
currency: {
|
|
18
|
+
fallbackValue: string
|
|
19
|
+
code: string
|
|
20
|
+
amount1000: number
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface DateTimeParameter {
|
|
25
|
+
type: 'date_time'
|
|
26
|
+
dateTime: { fallbackValue: string }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Card {
|
|
30
|
+
productRetailerId: string
|
|
31
|
+
catalogId: string
|
|
32
|
+
cardIndex?: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface WhatsappProductCarouselProps {
|
|
36
|
+
templateName: string
|
|
37
|
+
templateLanguage: string
|
|
38
|
+
cards: Card[]
|
|
39
|
+
bodyParameters?: Parameters[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const serialize = (message: string) => {
|
|
43
|
+
return { text: message }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const WhatsappProductCarousel = (
|
|
47
|
+
props: WhatsappProductCarouselProps
|
|
48
|
+
) => {
|
|
49
|
+
const renderBrowser = () => {
|
|
50
|
+
// Return a dummy message for browser
|
|
51
|
+
const message = `WhatsApp Product Carousel would be sent to the user.`
|
|
52
|
+
return (
|
|
53
|
+
<Message json={serialize(message)} {...props} type={INPUT.TEXT}>
|
|
54
|
+
{message}
|
|
55
|
+
</Message>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const getCards = (cards: Card[]) => {
|
|
60
|
+
cards.forEach((card, index) => {
|
|
61
|
+
if (!card.cardIndex) {
|
|
62
|
+
card.cardIndex = index
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
return toSnakeCaseKeys(cards)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const renderNode = () => {
|
|
69
|
+
return (
|
|
70
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
71
|
+
<message
|
|
72
|
+
{...props}
|
|
73
|
+
bodyParameters={JSON.stringify(toSnakeCaseKeys(props.bodyParameters))}
|
|
74
|
+
cards={JSON.stringify(getCards(props.cards))}
|
|
75
|
+
templateName={props.templateName}
|
|
76
|
+
templateLanguage={props.templateLanguage}
|
|
77
|
+
type={INPUT.WHATSAPP_PRODUCT_CAROUSEL}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return renderComponent({ renderBrowser, renderNode })
|
|
83
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { INPUT } from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { toSnakeCaseKeys } from '../util/functional'
|
|
5
|
+
import { renderComponent } from '../util/react'
|
|
6
|
+
import { Message } from './message'
|
|
7
|
+
|
|
8
|
+
export interface ProductItem {
|
|
9
|
+
productRetailerId: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface WhatsappProductListSection {
|
|
13
|
+
title: string
|
|
14
|
+
productItems: ProductItem[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface WhatsappProductListProps {
|
|
18
|
+
body: string
|
|
19
|
+
header: string
|
|
20
|
+
catalogId: string
|
|
21
|
+
sections: WhatsappProductListSection[]
|
|
22
|
+
footer?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const serialize = (message: string) => {
|
|
26
|
+
return { text: message }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const WhatsappProductList = (props: WhatsappProductListProps) => {
|
|
30
|
+
const renderBrowser = () => {
|
|
31
|
+
// Return a dummy message for browser
|
|
32
|
+
const message = `WhatsApp Product List would be sent to the user.`
|
|
33
|
+
return (
|
|
34
|
+
<Message json={serialize(message)} {...props} type={INPUT.TEXT}>
|
|
35
|
+
{message}
|
|
36
|
+
</Message>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const renderNode = () => {
|
|
41
|
+
return (
|
|
42
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
43
|
+
<message
|
|
44
|
+
{...props}
|
|
45
|
+
body={props.body}
|
|
46
|
+
footer={props.footer}
|
|
47
|
+
header={props.header}
|
|
48
|
+
sections={JSON.stringify(toSnakeCaseKeys(props.sections))}
|
|
49
|
+
catalogId={props.catalogId}
|
|
50
|
+
type={INPUT.WHATSAPP_PRODUCT_LIST}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return renderComponent({ renderBrowser, renderNode })
|
|
56
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { INPUT } from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { renderComponent } from '../util/react'
|
|
5
|
+
import { Message } from './message'
|
|
6
|
+
|
|
7
|
+
export interface WhatsappProductProps {
|
|
8
|
+
body: string
|
|
9
|
+
catalogId: string
|
|
10
|
+
productId: string
|
|
11
|
+
footer?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const serialize = (message: string) => {
|
|
15
|
+
return { text: message }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const WhatsappProduct = (props: WhatsappProductProps) => {
|
|
19
|
+
const renderBrowser = () => {
|
|
20
|
+
// Return a dummy message for browser
|
|
21
|
+
const message = `WhatsApp Product would be sent to the user.`
|
|
22
|
+
return (
|
|
23
|
+
<Message json={serialize(message)} {...props} type={INPUT.TEXT}>
|
|
24
|
+
{message}
|
|
25
|
+
</Message>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const renderNode = () => {
|
|
30
|
+
return (
|
|
31
|
+
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
|
|
32
|
+
<message
|
|
33
|
+
{...props}
|
|
34
|
+
body={props.body}
|
|
35
|
+
footer={props.footer}
|
|
36
|
+
catalogId={props.catalogId}
|
|
37
|
+
productId={props.productId}
|
|
38
|
+
type={INPUT.WHATSAPP_PRODUCT}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return renderComponent({ renderBrowser, renderNode })
|
|
44
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function camelCaseToSnake(str: string): string {
|
|
2
|
+
return str
|
|
3
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
4
|
+
.replace(/([A-Za-z])(\d)/g, '$1_$2')
|
|
5
|
+
.replace(/(\d)([A-Za-z])/g, '$1_$2')
|
|
6
|
+
.toLowerCase()
|
|
7
|
+
}
|
|
8
|
+
type Input = Record<string, any> | Record<string, any>[] | undefined
|
|
9
|
+
|
|
10
|
+
export function toSnakeCaseKeys(input: Input): Input {
|
|
11
|
+
if (Array.isArray(input)) {
|
|
12
|
+
return input.map(item => toSnakeCaseKeys(item))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof input === 'object' && input !== null) {
|
|
16
|
+
const result = Object.keys(input).reduce((acc, key) => {
|
|
17
|
+
const snakeKey = camelCaseToSnake(key)
|
|
18
|
+
const value = input[key]
|
|
19
|
+
acc[snakeKey] =
|
|
20
|
+
typeof value === 'object' && value !== null
|
|
21
|
+
? toSnakeCaseKeys(value)
|
|
22
|
+
: value
|
|
23
|
+
|
|
24
|
+
return acc
|
|
25
|
+
}, {})
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return input
|
|
31
|
+
}
|