beem-component 2.1.21 → 2.1.23
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.
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BmCardv2 = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
const _excluded = ["className", "children", "borderColor", "borderWidth"];
|
|
9
|
+
const _excluded = ["className", "children", "borderColor", "borderWidth", "contentHeight"];
|
|
10
10
|
/* eslint-disable func-style */
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
13
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
14
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
14
15
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
@@ -23,10 +24,11 @@ const hexToRgba = function (hex) {
|
|
|
23
24
|
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
24
25
|
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
25
26
|
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
26
|
-
} catch (
|
|
27
|
+
} catch (_unused) {
|
|
27
28
|
return "rgba(0, 0, 0, ".concat(opacity, ")");
|
|
28
29
|
}
|
|
29
30
|
};
|
|
31
|
+
const CardContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
30
32
|
const StyledCard = _styledComponents.default.div.withConfig({
|
|
31
33
|
displayName: "Card__StyledCard"
|
|
32
34
|
})(["background-color:var(--card,#fff);color:var(--card-foreground,#000);display:flex;flex-direction:column;gap:1.5rem;border-radius:0.75rem;border-style:solid;border-color:", ";border-width:", ";width:100%;"], _ref => {
|
|
@@ -49,25 +51,49 @@ const Title = _styledComponents.default.h4.withConfig({
|
|
|
49
51
|
const Description = _styledComponents.default.p.withConfig({
|
|
50
52
|
displayName: "Card__Description"
|
|
51
53
|
})(["color:var(--muted-foreground,#666);margin:0;"]);
|
|
52
|
-
const
|
|
53
|
-
displayName: "
|
|
54
|
-
})(["min-height:
|
|
54
|
+
const ContentWrapper = _styledComponents.default.div.withConfig({
|
|
55
|
+
displayName: "Card__ContentWrapper"
|
|
56
|
+
})(["min-height:", ";padding:0 1.5rem;max-height:calc(100vh - 28.5714rem);overflow-y:auto;scrollbar-width:thin;scrollbar-color:", " transparent;&::-webkit-scrollbar-thumb{background:", ";border-radius:0.6429rem;transition:background 0.2s ease;}&::-webkit-scrollbar-thumb:hover{background:", ";}&:last-child{padding-bottom:1.5rem;}@media (max-width:54.8571rem){max-height:calc(100vh - 17.8572rem);}"], _ref3 => {
|
|
57
|
+
let {
|
|
58
|
+
$contentHeight
|
|
59
|
+
} = _ref3;
|
|
60
|
+
return $contentHeight || '14.2857rem';
|
|
61
|
+
}, () => hexToRgba('#33b1ba', 0.2), () => hexToRgba('#33b1ba', 0.3), () => hexToRgba('#33b1ba', 0.4));
|
|
62
|
+
function Content(_ref4) {
|
|
63
|
+
let {
|
|
64
|
+
children,
|
|
65
|
+
style
|
|
66
|
+
} = _ref4;
|
|
67
|
+
const {
|
|
68
|
+
contentHeight
|
|
69
|
+
} = (0, _react.useContext)(CardContext);
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(ContentWrapper, {
|
|
71
|
+
$contentHeight: contentHeight,
|
|
72
|
+
style: style
|
|
73
|
+
}, children);
|
|
74
|
+
}
|
|
55
75
|
const Footer = _styledComponents.default.div.withConfig({
|
|
56
76
|
displayName: "Card__Footer"
|
|
57
77
|
})(["display:flex;justify-content:space-between;align-items:center;padding:0 1.5rem 1.5rem 1.5rem;gap:1rem;@media (max-width:42.8571rem){flex-direction:column;align-items:stretch;& > *{width:100%;}}"]);
|
|
58
|
-
function CardComponent(
|
|
78
|
+
function CardComponent(_ref5) {
|
|
59
79
|
let {
|
|
60
80
|
className,
|
|
61
81
|
children,
|
|
62
82
|
borderColor,
|
|
63
|
-
borderWidth
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
borderWidth,
|
|
84
|
+
contentHeight
|
|
85
|
+
} = _ref5,
|
|
86
|
+
props = _objectWithoutProperties(_ref5, _excluded);
|
|
87
|
+
const contextValue = {
|
|
88
|
+
contentHeight
|
|
89
|
+
};
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(CardContext.Provider, {
|
|
91
|
+
value: contextValue
|
|
92
|
+
}, /*#__PURE__*/_react.default.createElement(StyledCard, _extends({
|
|
67
93
|
className: className,
|
|
68
94
|
borderColor: borderColor,
|
|
69
95
|
borderWidth: borderWidth
|
|
70
|
-
}, props), children);
|
|
96
|
+
}, props), children));
|
|
71
97
|
}
|
|
72
98
|
const BmCardv2 = exports.BmCardv2 = Object.assign(CardComponent, {
|
|
73
99
|
Header,
|
|
@@ -446,14 +446,49 @@ const QuickReplyRender = _ref24 => {
|
|
|
446
446
|
isImg: true
|
|
447
447
|
}, /*#__PURE__*/_react.default.createElement(ConnectorRenderer, null));
|
|
448
448
|
};
|
|
449
|
-
const
|
|
449
|
+
const ImageRender = _ref25 => {
|
|
450
|
+
let {
|
|
451
|
+
type,
|
|
452
|
+
state,
|
|
453
|
+
rest,
|
|
454
|
+
isInteractive,
|
|
455
|
+
connector,
|
|
456
|
+
caption,
|
|
457
|
+
originalUrl
|
|
458
|
+
} = _ref25;
|
|
459
|
+
const renderers = {
|
|
460
|
+
dotgo_v3: () => {
|
|
461
|
+
var _caption$text;
|
|
462
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, originalUrl && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(BmImageChat, _extends({
|
|
463
|
+
state: state,
|
|
464
|
+
src: originalUrl
|
|
465
|
+
}, rest))), caption && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, caption === null || caption === void 0 || (_caption$text = caption.text) === null || _caption$text === void 0 ? void 0 : _caption$text.split('\n').map((line, idx) => /*#__PURE__*/_react.default.createElement("p", {
|
|
466
|
+
key: "body-line-".concat(idx)
|
|
467
|
+
}, line, /*#__PURE__*/_react.default.createElement("br", null)))));
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
const FallbackRenderer = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, originalUrl && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(BmImageChat, _extends({
|
|
471
|
+
state: state,
|
|
472
|
+
src: originalUrl
|
|
473
|
+
}, rest))), caption && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, caption === null || caption === void 0 ? void 0 : caption.split('\n').map((line, idx) => /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", {
|
|
474
|
+
key: "content-line-".concat(idx)
|
|
475
|
+
}, line, /*#__PURE__*/_react.default.createElement("br", null))))));
|
|
476
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
477
|
+
return /*#__PURE__*/_react.default.createElement(Messages, {
|
|
478
|
+
type: type,
|
|
479
|
+
state: state,
|
|
480
|
+
isInteractive: isInteractive,
|
|
481
|
+
isImg: true
|
|
482
|
+
}, /*#__PURE__*/_react.default.createElement(ConnectorRenderer, null));
|
|
483
|
+
};
|
|
484
|
+
const ProductDetailRender = _ref26 => {
|
|
450
485
|
let {
|
|
451
486
|
type,
|
|
452
487
|
state,
|
|
453
488
|
header,
|
|
454
489
|
body,
|
|
455
490
|
isInteractive
|
|
456
|
-
} =
|
|
491
|
+
} = _ref26;
|
|
457
492
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Messages, {
|
|
458
493
|
type: type,
|
|
459
494
|
state: state,
|
|
@@ -462,7 +497,7 @@ const ProductDetailRender = _ref25 => {
|
|
|
462
497
|
state: state
|
|
463
498
|
}, /*#__PURE__*/_react.default.createElement(_ShoppingCartOutlined.default, null), "Catalog")));
|
|
464
499
|
};
|
|
465
|
-
const ListReplyRender =
|
|
500
|
+
const ListReplyRender = _ref27 => {
|
|
466
501
|
let {
|
|
467
502
|
title,
|
|
468
503
|
body,
|
|
@@ -474,7 +509,7 @@ const ListReplyRender = _ref26 => {
|
|
|
474
509
|
header,
|
|
475
510
|
action,
|
|
476
511
|
footer
|
|
477
|
-
} =
|
|
512
|
+
} = _ref27;
|
|
478
513
|
const renderers = {
|
|
479
514
|
dotgo_v3: () => {
|
|
480
515
|
var _header$header$type3, _body$text2;
|
|
@@ -498,7 +533,7 @@ const ListReplyRender = _ref26 => {
|
|
|
498
533
|
isInteractive: isInteractive
|
|
499
534
|
}, /*#__PURE__*/_react.default.createElement(ConnectorRenderer, null)));
|
|
500
535
|
};
|
|
501
|
-
const OrderRender =
|
|
536
|
+
const OrderRender = _ref28 => {
|
|
502
537
|
let {
|
|
503
538
|
amount,
|
|
504
539
|
type,
|
|
@@ -507,14 +542,14 @@ const OrderRender = _ref27 => {
|
|
|
507
542
|
product_items,
|
|
508
543
|
connector,
|
|
509
544
|
isInteractive
|
|
510
|
-
} =
|
|
545
|
+
} = _ref28;
|
|
511
546
|
const renderers = {
|
|
512
|
-
dotgo_v3:
|
|
547
|
+
dotgo_v3: _ref29 => {
|
|
513
548
|
let {
|
|
514
549
|
displayItems,
|
|
515
550
|
sumQuantities,
|
|
516
551
|
setDisplayItems
|
|
517
|
-
} =
|
|
552
|
+
} = _ref29;
|
|
518
553
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(OrderBody, {
|
|
519
554
|
state: state
|
|
520
555
|
}, /*#__PURE__*/_react.default.createElement(CartContent, {
|
|
@@ -544,12 +579,12 @@ const OrderRender = _ref27 => {
|
|
|
544
579
|
}, /*#__PURE__*/_react.default.createElement("p", null, displayItems ? 'HIDE' : 'SHOW', " CART ITEMS")));
|
|
545
580
|
}
|
|
546
581
|
};
|
|
547
|
-
const FallbackRenderer =
|
|
582
|
+
const FallbackRenderer = _ref30 => {
|
|
548
583
|
let {
|
|
549
584
|
sumQuantities,
|
|
550
585
|
displayItems,
|
|
551
586
|
setDisplayItems
|
|
552
|
-
} =
|
|
587
|
+
} = _ref30;
|
|
553
588
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(OrderBody, {
|
|
554
589
|
state: state
|
|
555
590
|
}, /*#__PURE__*/_react.default.createElement(CartContent, {
|
|
@@ -596,7 +631,7 @@ const OrderRender = _ref27 => {
|
|
|
596
631
|
items: items
|
|
597
632
|
})));
|
|
598
633
|
};
|
|
599
|
-
BmChat.Details =
|
|
634
|
+
BmChat.Details = _ref31 => {
|
|
600
635
|
var _children$message, _children$message2;
|
|
601
636
|
let {
|
|
602
637
|
children,
|
|
@@ -615,8 +650,8 @@ BmChat.Details = _ref30 => {
|
|
|
615
650
|
isInteractive,
|
|
616
651
|
type,
|
|
617
652
|
extension
|
|
618
|
-
} =
|
|
619
|
-
rest = _objectWithoutProperties(
|
|
653
|
+
} = _ref31,
|
|
654
|
+
rest = _objectWithoutProperties(_ref31, _excluded3);
|
|
620
655
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Details, _extends({
|
|
621
656
|
state: state
|
|
622
657
|
}, rest), /*#__PURE__*/_react.default.createElement(MessageState, null, state === 'inbound' && session && handleState({
|
|
@@ -655,6 +690,12 @@ BmChat.Details = _ref30 => {
|
|
|
655
690
|
type: type,
|
|
656
691
|
state: state,
|
|
657
692
|
connector: metadata.connector
|
|
693
|
+
})) : metadata.message.type === 'image' ? /*#__PURE__*/_react.default.createElement(ImageRender, _extends({
|
|
694
|
+
isInteractive: true
|
|
695
|
+
}, metadata.message, {
|
|
696
|
+
type: type,
|
|
697
|
+
state: state,
|
|
698
|
+
connector: metadata === null || metadata === void 0 ? void 0 : metadata.connector
|
|
658
699
|
})) : /*#__PURE__*/_react.default.createElement(Messages, {
|
|
659
700
|
metadata: metadata,
|
|
660
701
|
state: state
|
|
@@ -675,6 +716,10 @@ BmChat.Details = _ref30 => {
|
|
|
675
716
|
type: type,
|
|
676
717
|
state: state,
|
|
677
718
|
connector: children === null || children === void 0 ? void 0 : children.connector
|
|
719
|
+
})), children.message.type === 'image' && /*#__PURE__*/_react.default.createElement(ImageRender, _extends({}, children.message, {
|
|
720
|
+
type: type,
|
|
721
|
+
state: state,
|
|
722
|
+
connector: children === null || children === void 0 ? void 0 : children.connector
|
|
678
723
|
}))) : type === 'pdf' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactPdf.Document, {
|
|
679
724
|
file: {
|
|
680
725
|
url: "".concat(file)
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -17,7 +17,7 @@ import React from 'react';
|
|
|
17
17
|
// import PeopleIcon from '@mui/icons-material/People';
|
|
18
18
|
// import BusinessIcon from '@mui/icons-material/Business';
|
|
19
19
|
|
|
20
|
-
import { BmChat, GlobalStyle } from './lib/components';
|
|
20
|
+
import { BmChat, GlobalStyle, BmCardv2, BmButton } from './lib/components';
|
|
21
21
|
// import AlertBox from './lib/components/Alert/Alert';
|
|
22
22
|
|
|
23
23
|
// import ProgressIndicator from './lib/components/newProgress';
|
|
@@ -600,6 +600,72 @@ const Chat = () => {
|
|
|
600
600
|
statusCode: 3,
|
|
601
601
|
},
|
|
602
602
|
},
|
|
603
|
+
{
|
|
604
|
+
id: 109370,
|
|
605
|
+
message:
|
|
606
|
+
'{ "dotgoV2": { "type": "image", "caption": "To register for AzamTV MAX, you need to download the AzamTV MAX App from Google Play Store or Apple App Store. \\n\\nOnce you have downloaded the App, follow these steps to register: \\n1. Open the App and click on REGISTER. \\n2. Enter your mobile number. \\n3. Enter the OTP sent to your mobile number. \\n4. Enter your details (Name, Surname, Email, Password) \\n5. Click on REGISTER. \\n\\nDo you need any further assistance?", "originalUrl": "https://imgur.com/JyXrxLv.png", "previewUrl": "https://imgur.com/JyXrxLv.png" }}',
|
|
607
|
+
time: '2025-10-06T10:53:38.000Z',
|
|
608
|
+
direction: 'outbound',
|
|
609
|
+
message_type: 'interactive',
|
|
610
|
+
messageId: '121302f4-50ca-48c3-a32a-2d570064a000',
|
|
611
|
+
is_live_agent: 0,
|
|
612
|
+
is_deleted: 0,
|
|
613
|
+
is_comment: 0,
|
|
614
|
+
channel: 'whatsapp',
|
|
615
|
+
sent_to_vendor: 1,
|
|
616
|
+
replyMessageId: null,
|
|
617
|
+
agent_name: null,
|
|
618
|
+
df_agent_name: null,
|
|
619
|
+
resolve_time: null,
|
|
620
|
+
metadata: null,
|
|
621
|
+
statusDetails: {
|
|
622
|
+
statusCode: 3,
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
id: 109414,
|
|
627
|
+
message: 'Reply',
|
|
628
|
+
time: '2025-10-06T11:31:15.000Z',
|
|
629
|
+
direction: 'inbound',
|
|
630
|
+
message_type: 'text',
|
|
631
|
+
messageId: null,
|
|
632
|
+
is_live_agent: 0,
|
|
633
|
+
is_deleted: 0,
|
|
634
|
+
is_comment: 0,
|
|
635
|
+
channel: 'whatsapp',
|
|
636
|
+
sent_to_vendor: 1,
|
|
637
|
+
replyMessageId: '121302f4-50ca-48c3-a32a-2d570064a000',
|
|
638
|
+
agent_name: null,
|
|
639
|
+
df_agent_name: null,
|
|
640
|
+
resolve_time: null,
|
|
641
|
+
metadata: {
|
|
642
|
+
id: '121302f4-50ca-48c3-a32a-2d570064a000',
|
|
643
|
+
prev_message:
|
|
644
|
+
'{ "dotgoV2": { "type": "image", "caption": "To register for AzamTV MAX, you need to download the AzamTV MAX App from Google Play Store or Apple App Store. \\n\\nOnce you have downloaded the App, follow these steps to register: \\n1. Open the App and click on REGISTER. \\n2. Enter your mobile number. \\n3. Enter the OTP sent to your mobile number. \\n4. Enter your details (Name, Surname, Email, Password) \\n5. Click on REGISTER. \\n\\nDo you need any further assistance?", "originalUrl": "https://imgur.com/JyXrxLv.png", "previewUrl": "https://imgur.com/JyXrxLv.png" }}',
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
id: 109469,
|
|
649
|
+
message: 'Image reply',
|
|
650
|
+
time: '2025-10-06T11:38:34.000Z',
|
|
651
|
+
direction: 'inbound',
|
|
652
|
+
message_type: 'text',
|
|
653
|
+
messageId: null,
|
|
654
|
+
is_live_agent: 1,
|
|
655
|
+
is_deleted: 0,
|
|
656
|
+
is_comment: 0,
|
|
657
|
+
channel: 'whatsapp',
|
|
658
|
+
sent_to_vendor: 1,
|
|
659
|
+
replyMessageId: null,
|
|
660
|
+
agent_name: null,
|
|
661
|
+
df_agent_name: null,
|
|
662
|
+
resolve_time: null,
|
|
663
|
+
metadata: {
|
|
664
|
+
id: 'wamid.HBgMMjU1Njg3MzQ5NTgxFQIAEhgUM0E1NTVGOThBMzk0NTM1OTgyQTMA',
|
|
665
|
+
prev_message:
|
|
666
|
+
'https://bm-chatbot-images.s3.eu-west-1.amazonaws.com/081c00de-cc02-44f2-bd91-5cf3a5a73d09.jpeg',
|
|
667
|
+
},
|
|
668
|
+
},
|
|
603
669
|
];
|
|
604
670
|
const isJson = (itemOg) => {
|
|
605
671
|
let item = itemOg;
|
|
@@ -776,6 +842,39 @@ const Chat = () => {
|
|
|
776
842
|
</BmChat.Details>
|
|
777
843
|
)
|
|
778
844
|
)}
|
|
845
|
+
<BmCardv2 borderColor="#d62a2af" borderWidth="1.5px" contentHeight="0">
|
|
846
|
+
<BmCardv2.Header>
|
|
847
|
+
<BmCardv2.Title>Appointment Summary</BmCardv2.Title>
|
|
848
|
+
<BmCardv2.Description>
|
|
849
|
+
This BmCardv2 shows a quick overview of your booking.
|
|
850
|
+
</BmCardv2.Description>
|
|
851
|
+
</BmCardv2.Header>
|
|
852
|
+
<BmCardv2.Content>
|
|
853
|
+
<p>
|
|
854
|
+
<strong>Type:</strong> Consultation
|
|
855
|
+
</p>
|
|
856
|
+
<p>
|
|
857
|
+
<strong>Date:</strong> June 24, 2025
|
|
858
|
+
</p>
|
|
859
|
+
<p>
|
|
860
|
+
<strong>Doctor:</strong> Dr. Smith
|
|
861
|
+
</p>
|
|
862
|
+
</BmCardv2.Content>
|
|
863
|
+
<BmCardv2.Footer>
|
|
864
|
+
<BmButton width="100%" size="medium" variant="primary">
|
|
865
|
+
Edit
|
|
866
|
+
</BmButton>
|
|
867
|
+
<BmButton
|
|
868
|
+
borderColor="#000000"
|
|
869
|
+
width="100%"
|
|
870
|
+
size="medium"
|
|
871
|
+
variant="secondary"
|
|
872
|
+
color="#000000"
|
|
873
|
+
>
|
|
874
|
+
Cancel
|
|
875
|
+
</BmButton>
|
|
876
|
+
</BmCardv2.Footer>
|
|
877
|
+
</BmCardv2>
|
|
779
878
|
</>
|
|
780
879
|
);
|
|
781
880
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable func-style */
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
5
|
const hexToRgba = (hex, opacity = 0.6) => {
|
|
@@ -12,16 +12,17 @@ const hexToRgba = (hex, opacity = 0.6) => {
|
|
|
12
12
|
) {
|
|
13
13
|
throw new Error('Invalid hex');
|
|
14
14
|
}
|
|
15
|
-
|
|
16
15
|
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
17
16
|
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
18
17
|
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
19
18
|
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
20
|
-
} catch
|
|
19
|
+
} catch {
|
|
21
20
|
return `rgba(0, 0, 0, ${opacity})`;
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
|
|
24
|
+
const CardContext = createContext({});
|
|
25
|
+
|
|
25
26
|
const StyledCard = styled.div`
|
|
26
27
|
background-color: var(--card, #fff);
|
|
27
28
|
color: var(--card-foreground, #000);
|
|
@@ -53,12 +54,11 @@ const Description = styled.p`
|
|
|
53
54
|
margin: 0;
|
|
54
55
|
`;
|
|
55
56
|
|
|
56
|
-
const
|
|
57
|
-
min-height:
|
|
57
|
+
const ContentWrapper = styled.div`
|
|
58
|
+
min-height: ${({ $contentHeight }) => $contentHeight || '14.2857rem'};
|
|
58
59
|
padding: 0 1.5rem;
|
|
59
60
|
max-height: calc(100vh - 28.5714rem);
|
|
60
61
|
overflow-y: auto;
|
|
61
|
-
|
|
62
62
|
scrollbar-width: thin;
|
|
63
63
|
scrollbar-color: ${() => hexToRgba('#33b1ba', 0.2)} transparent;
|
|
64
64
|
|
|
@@ -69,7 +69,7 @@ const Content = styled.div`
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
&::-webkit-scrollbar-thumb:hover {
|
|
72
|
-
background: ${() => hexToRgba('#33b1ba', 0.
|
|
72
|
+
background: ${() => hexToRgba('#33b1ba', 0.4)};
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
&:last-child {
|
|
@@ -81,6 +81,15 @@ const Content = styled.div`
|
|
|
81
81
|
}
|
|
82
82
|
`;
|
|
83
83
|
|
|
84
|
+
function Content({ children, style }) {
|
|
85
|
+
const { contentHeight } = useContext(CardContext);
|
|
86
|
+
return (
|
|
87
|
+
<ContentWrapper $contentHeight={contentHeight} style={style}>
|
|
88
|
+
{children}
|
|
89
|
+
</ContentWrapper>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
84
93
|
const Footer = styled.div`
|
|
85
94
|
display: flex;
|
|
86
95
|
justify-content: space-between;
|
|
@@ -91,7 +100,6 @@ const Footer = styled.div`
|
|
|
91
100
|
@media (max-width: 42.8571rem) {
|
|
92
101
|
flex-direction: column;
|
|
93
102
|
align-items: stretch;
|
|
94
|
-
|
|
95
103
|
& > * {
|
|
96
104
|
width: 100%;
|
|
97
105
|
}
|
|
@@ -103,17 +111,22 @@ function CardComponent({
|
|
|
103
111
|
children,
|
|
104
112
|
borderColor,
|
|
105
113
|
borderWidth,
|
|
114
|
+
contentHeight,
|
|
106
115
|
...props
|
|
107
116
|
}) {
|
|
117
|
+
const contextValue = { contentHeight };
|
|
118
|
+
|
|
108
119
|
return (
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
<CardContext.Provider value={contextValue}>
|
|
121
|
+
<StyledCard
|
|
122
|
+
className={className}
|
|
123
|
+
borderColor={borderColor}
|
|
124
|
+
borderWidth={borderWidth}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</StyledCard>
|
|
129
|
+
</CardContext.Provider>
|
|
117
130
|
);
|
|
118
131
|
}
|
|
119
132
|
|
|
@@ -517,6 +517,68 @@ const QuickReplyRender = ({
|
|
|
517
517
|
</Messages>
|
|
518
518
|
);
|
|
519
519
|
};
|
|
520
|
+
const ImageRender = ({
|
|
521
|
+
type,
|
|
522
|
+
state,
|
|
523
|
+
rest,
|
|
524
|
+
isInteractive,
|
|
525
|
+
connector,
|
|
526
|
+
caption,
|
|
527
|
+
originalUrl,
|
|
528
|
+
}) => {
|
|
529
|
+
const renderers = {
|
|
530
|
+
dotgo_v3: () => (
|
|
531
|
+
<>
|
|
532
|
+
{originalUrl && (
|
|
533
|
+
<>
|
|
534
|
+
<BmImageChat state={state} src={originalUrl} {...rest} />
|
|
535
|
+
</>
|
|
536
|
+
)}
|
|
537
|
+
|
|
538
|
+
{caption && (
|
|
539
|
+
<>
|
|
540
|
+
{caption?.text?.split('\n').map((line, idx) => (
|
|
541
|
+
<p key={`body-line-${idx}`}>
|
|
542
|
+
{line}
|
|
543
|
+
<br />
|
|
544
|
+
</p>
|
|
545
|
+
))}
|
|
546
|
+
</>
|
|
547
|
+
)}
|
|
548
|
+
</>
|
|
549
|
+
),
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
const FallbackRenderer = () => (
|
|
553
|
+
<>
|
|
554
|
+
{originalUrl && (
|
|
555
|
+
<div>
|
|
556
|
+
<BmImageChat state={state} src={originalUrl} {...rest} />
|
|
557
|
+
</div>
|
|
558
|
+
)}
|
|
559
|
+
|
|
560
|
+
{caption && (
|
|
561
|
+
<>
|
|
562
|
+
{caption?.split('\n').map((line, idx) => (
|
|
563
|
+
<div>
|
|
564
|
+
<p key={`content-line-${idx}`}>
|
|
565
|
+
{line}
|
|
566
|
+
<br />
|
|
567
|
+
</p>
|
|
568
|
+
</div>
|
|
569
|
+
))}
|
|
570
|
+
</>
|
|
571
|
+
)}
|
|
572
|
+
</>
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
const ConnectorRenderer = renderers[connector] || FallbackRenderer;
|
|
576
|
+
return (
|
|
577
|
+
<Messages type={type} state={state} isInteractive={isInteractive} isImg>
|
|
578
|
+
<ConnectorRenderer />
|
|
579
|
+
</Messages>
|
|
580
|
+
);
|
|
581
|
+
};
|
|
520
582
|
const ProductDetailRender = ({ type, state, header, body, isInteractive }) => {
|
|
521
583
|
return (
|
|
522
584
|
<>
|
|
@@ -820,6 +882,14 @@ BmChat.Details = ({
|
|
|
820
882
|
state={state}
|
|
821
883
|
connector={metadata.connector}
|
|
822
884
|
/>
|
|
885
|
+
) : metadata.message.type === 'image' ? (
|
|
886
|
+
<ImageRender
|
|
887
|
+
isInteractive
|
|
888
|
+
{...metadata.message}
|
|
889
|
+
type={type}
|
|
890
|
+
state={state}
|
|
891
|
+
connector={metadata?.connector}
|
|
892
|
+
/>
|
|
823
893
|
) : (
|
|
824
894
|
<Messages metadata={metadata} state={state}>
|
|
825
895
|
{metadata.message.text}
|
|
@@ -865,6 +935,14 @@ BmChat.Details = ({
|
|
|
865
935
|
connector={children?.connector}
|
|
866
936
|
/>
|
|
867
937
|
)}
|
|
938
|
+
{children.message.type === 'image' && (
|
|
939
|
+
<ImageRender
|
|
940
|
+
{...children.message}
|
|
941
|
+
type={type}
|
|
942
|
+
state={state}
|
|
943
|
+
connector={children?.connector}
|
|
944
|
+
/>
|
|
945
|
+
)}
|
|
868
946
|
</>
|
|
869
947
|
) : type === 'pdf' ? (
|
|
870
948
|
<>
|