@appcorp/app-corp-vista 0.3.29 → 0.3.31

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.
@@ -192,10 +192,13 @@ exports.vistaChatV2Props = {
192
192
  ],
193
193
  paymentLoading: '',
194
194
  handlePayment: function () { return void 0; },
195
+ handleLoadMore: function () { return void 0; },
195
196
  isBalanceLow: false,
196
197
  typing: 'Username is typing...',
197
198
  bannerHeading: 'Your session has started.',
198
199
  bannerDescription: 'Enjoy your conversation.',
199
200
  showBanner: true,
200
201
  showControls: true,
202
+ showLoadMore: true,
203
+ chatIsLoading: true,
201
204
  };
@@ -8,20 +8,28 @@ var react_1 = __importDefault(require("react"));
8
8
  var util_functions_1 = require("@react-pakistan/util-functions");
9
9
  var vista_vertical_divider_v1_1 = require("../../molecules/vista-vertical-divider-v1");
10
10
  var vista_chat_bubble_v1_1 = require("../../molecules/vista-chat-bubble-v1/vista-chat-bubble-v1");
11
+ var vista_button_v1_1 = require("../../molecules/vista-button-v1/vista-button-v1");
12
+ var vista_button_type_1 = require("../../type/vista-button-type");
11
13
  var VistaChatMessagesV2 = function (_a) {
12
- var messages = _a.messages, psychic = _a.psychic, user = _a.user;
14
+ var chatIsLoading = _a.chatIsLoading, handleLoadMore = _a.handleLoadMore, messages = _a.messages, psychic = _a.psychic, showLoadMore = _a.showLoadMore, user = _a.user;
13
15
  var lastDate = '';
14
- return (react_1.default.createElement("div", { className: "overflow-y-scroll" }, messages.map(function (_a, ind) {
15
- var _b, _c;
16
- var createdAt = _a.createdAt, id = _a.id, isUser = _a.isUser, message = _a.message, messageStatus = _a.messageStatus;
17
- var shouldShowDivider = ((_b = lastDate.split('T')) === null || _b === void 0 ? void 0 : _b[0]) === ((_c = createdAt.split('T')) === null || _c === void 0 ? void 0 : _c[0])
18
- ? false
19
- : true;
20
- lastDate = createdAt;
21
- return (react_1.default.createElement("div", { key: id },
22
- shouldShowDivider && (react_1.default.createElement("div", { className: "pt-8" },
23
- react_1.default.createElement(vista_vertical_divider_v1_1.VistaVerticalDividerV1, { label: (0, util_functions_1.formatDate)(createdAt, util_functions_1.DATE_FORMATS.DAY_DD_MM_YY_COMPACT) }))),
24
- react_1.default.createElement(vista_chat_bubble_v1_1.VistaChatBubbleV1, { createdAt: createdAt, isLast: ind === messages.length - 1, isUser: isUser, message: message, messageStatus: messageStatus, psychic: psychic, user: user })));
25
- })));
16
+ return (react_1.default.createElement("div", { className: "overflow-y-scroll" },
17
+ showLoadMore && (react_1.default.createElement("div", { className: "flex flex-row justify-center" },
18
+ react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { variant: chatIsLoading
19
+ ? vista_button_type_1.VISTA_BUTTON_VARIANT.ICON
20
+ : vista_button_type_1.VISTA_BUTTON_VARIANT.SECONDARY, label: chatIsLoading ? '' : 'Load Previous Chats...', handleOnClick: handleLoadMore, className: "inline-flex max-w-48 transition-all duration-1000 !bg-white", icon: react_1.default.createElement("div", { role: "status", className: "h-6 w-6 border-4 border-primary border-t-transparent rounded-full animate-spin" },
21
+ react_1.default.createElement("span", { className: "sr-only" }, "Loading...")) }))),
22
+ messages.map(function (_a, ind) {
23
+ var _b, _c;
24
+ var createdAt = _a.createdAt, id = _a.id, isUser = _a.isUser, message = _a.message, messageStatus = _a.messageStatus;
25
+ var shouldShowDivider = ((_b = lastDate.split('T')) === null || _b === void 0 ? void 0 : _b[0]) === ((_c = createdAt.split('T')) === null || _c === void 0 ? void 0 : _c[0])
26
+ ? false
27
+ : true;
28
+ lastDate = createdAt;
29
+ return (react_1.default.createElement("div", { key: id },
30
+ shouldShowDivider && (react_1.default.createElement("div", { className: "pt-8" },
31
+ react_1.default.createElement(vista_vertical_divider_v1_1.VistaVerticalDividerV1, { label: (0, util_functions_1.formatDate)(createdAt, util_functions_1.DATE_FORMATS.DAY_DD_MM_YY_COMPACT) }))),
32
+ react_1.default.createElement(vista_chat_bubble_v1_1.VistaChatBubbleV1, { createdAt: createdAt, isLast: ind === messages.length - 1, isUser: isUser, message: message, messageStatus: messageStatus, psychic: psychic, user: user })));
33
+ })));
26
34
  };
27
35
  exports.VistaChatMessagesV2 = VistaChatMessagesV2;
@@ -13,7 +13,7 @@ var vista_button_type_1 = require("../../type/vista-button-type");
13
13
  var vista_banner_v1_1 = require("../../atoms/vista-banner-v1/vista-banner-v1");
14
14
  var vista_chat_messages_v2_1 = require("./vista-chat-messages-v2");
15
15
  var VistaChatV2 = function (_a) {
16
- var actionItems = _a.actionItems, bannerDescription = _a.bannerDescription, bannerHeading = _a.bannerHeading, buttonDenominations = _a.buttonDenominations, chatId = _a.chatId, chatValue = _a.chatValue, _b = _a.containerClassName, containerClassName = _b === void 0 ? '' : _b, _c = _a.estimatedBalance, estimatedBalance = _c === void 0 ? '' : _c, handleChatOnChange = _a.handleChatOnChange, handleOnBlur = _a.handleOnBlur, handleOnFocus = _a.handleOnFocus, handlePayment = _a.handlePayment, isBalanceLow = _a.isBalanceLow, messages = _a.messages, name = _a.name, paymentLoading = _a.paymentLoading, psychic = _a.psychic, _d = _a.showBanner, showBanner = _d === void 0 ? false : _d, _e = _a.showControls, showControls = _e === void 0 ? true : _e, timer = _a.timer, typing = _a.typing, user = _a.user;
16
+ var actionItems = _a.actionItems, bannerDescription = _a.bannerDescription, bannerHeading = _a.bannerHeading, buttonDenominations = _a.buttonDenominations, chatId = _a.chatId, _b = _a.chatIsLoading, chatIsLoading = _b === void 0 ? false : _b, chatValue = _a.chatValue, _c = _a.containerClassName, containerClassName = _c === void 0 ? '' : _c, _d = _a.estimatedBalance, estimatedBalance = _d === void 0 ? '' : _d, handleChatOnChange = _a.handleChatOnChange, handleLoadMore = _a.handleLoadMore, handleOnBlur = _a.handleOnBlur, handleOnFocus = _a.handleOnFocus, handlePayment = _a.handlePayment, isBalanceLow = _a.isBalanceLow, messages = _a.messages, name = _a.name, paymentLoading = _a.paymentLoading, psychic = _a.psychic, _e = _a.showBanner, showBanner = _e === void 0 ? false : _e, _f = _a.showControls, showControls = _f === void 0 ? true : _f, showLoadMore = _a.showLoadMore, timer = _a.timer, typing = _a.typing, user = _a.user;
17
17
  var handleOnKeyDown = function (e) {
18
18
  if (e.key === 'Enter') {
19
19
  actionItems[0].handleOnClick();
@@ -24,7 +24,7 @@ var VistaChatV2 = function (_a) {
24
24
  react_1.default.createElement(vista_chat_heading_v1_1.VistaChatHeadingV1, { estimatedBalance: estimatedBalance, heading: name, timer: timer }),
25
25
  showBanner && (react_1.default.createElement(vista_banner_v1_1.VistaBannerV1, { description: bannerDescription, heading: bannerHeading })),
26
26
  react_1.default.createElement("div", { className: "overflow-y-auto h-full flex flex-col justify-end p-4" },
27
- react_1.default.createElement(vista_chat_messages_v2_1.VistaChatMessagesV2, { messages: messages, user: user, psychic: psychic })),
27
+ react_1.default.createElement(vista_chat_messages_v2_1.VistaChatMessagesV2, { messages: messages, psychic: psychic, showLoadMore: showLoadMore, user: user, handleLoadMore: handleLoadMore, chatIsLoading: chatIsLoading })),
28
28
  isBalanceLow && (react_1.default.createElement("div", { className: "grid grid-cols-5 m-4 p-4 border-2 border-primary border-dashed rounded-md justify-between items-center bg-cyan-200" },
29
29
  react_1.default.createElement("div", { className: "col-span-2" },
30
30
  react_1.default.createElement("p", { className: "text-md font-semibold" }, "You are running out of your Kismaa credits, click one of the buttons to top up your account.")),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/app-corp-vista",
3
- "version": "0.3.29",
3
+ "version": "0.3.31",
4
4
  "scripts": {
5
5
  "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib && cp yarn.lock lib",
6
6
  "build:next": "next build",
@@ -45,10 +45,12 @@ export interface VistaChatV2Props {
45
45
  bannerHeading: string;
46
46
  buttonDenominations: ButtonDenomination[];
47
47
  chatId: string;
48
+ chatIsLoading?: boolean;
48
49
  chatValue: string;
49
50
  containerClassName?: string;
50
51
  estimatedBalance?: string;
51
52
  handleChatOnChange: (k: string, v: string) => void;
53
+ handleLoadMore: () => void;
52
54
  handleOnBlur?: () => void;
53
55
  handleOnFocus?: () => void;
54
56
  handlePayment: (l: string, v: string) => void;
@@ -59,12 +61,16 @@ export interface VistaChatV2Props {
59
61
  psychic: VistaChatV2Psychic;
60
62
  showBanner?: boolean;
61
63
  showControls?: boolean;
64
+ showLoadMore: boolean;
62
65
  timer: string;
63
66
  typing?: string;
64
67
  user: VistaChatV2User;
65
68
  }
66
69
  export interface VistaChatMessageV2 {
70
+ chatIsLoading: boolean;
71
+ handleLoadMore: () => void;
67
72
  messages: VistaChatV2Message[];
68
73
  psychic: VistaChatV2Psychic;
74
+ showLoadMore: boolean;
69
75
  user: VistaChatV2User;
70
76
  }