@appcorp/app-corp-vista 0.0.40 → 0.0.41

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.
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ type Props = {
3
+ fill: string;
4
+ };
5
+ export declare const ChatTriangle: FC<Props>;
6
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ChatTriangle = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var ChatTriangle = function (_a) {
9
+ var fill = _a.fill;
10
+ return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", x: "0px", y: "0px", viewBox: "0 0 100 100", xmlSpace: "preserve", fill: fill },
11
+ react_1.default.createElement("polygon", { points: "0,100 100,100 0,0" })));
12
+ };
13
+ exports.ChatTriangle = ChatTriangle;
@@ -113,7 +113,44 @@ exports.vistaChatV2Props = {
113
113
  chatValue: '',
114
114
  handleChatOnChange: function () { return void 0; },
115
115
  sectionHeading: 'Psychic Tools',
116
- messages: [],
116
+ user: {
117
+ avatarUrl: '',
118
+ avatarAlt: '',
119
+ },
120
+ psychic: {
121
+ avatarUrl: '',
122
+ avatarAlt: '',
123
+ },
124
+ messages: [
125
+ {
126
+ message: 'Hello from User',
127
+ id: 'item-1',
128
+ createdAt: '2025-01-11 10:09:49.891',
129
+ status: 'DELIVERED',
130
+ isUser: true,
131
+ },
132
+ {
133
+ message: 'Hello from Psychic',
134
+ id: 'item-2',
135
+ createdAt: '2025-01-11 10:15:49.891',
136
+ status: 'DELIVERED',
137
+ isUser: false,
138
+ },
139
+ {
140
+ message: 'Hello from User',
141
+ id: 'item-3',
142
+ createdAt: '2025-01-11 10:19:49.891',
143
+ status: 'DELIVERED',
144
+ isUser: true,
145
+ },
146
+ {
147
+ message: 'Hello from User',
148
+ id: 'item-4',
149
+ createdAt: '2025-01-11 10:29:49.891',
150
+ status: 'DELIVERED',
151
+ isUser: true,
152
+ },
153
+ ],
117
154
  actionItems: [
118
155
  {
119
156
  enabled: true,
@@ -1,2 +1,3 @@
1
1
  import { FC } from 'react';
2
- export declare const VistaChatBubbleV1: FC<any>;
2
+ import { VistaChatBubbleV1Props } from '../../type/vista-chat-bubble-type';
3
+ export declare const VistaChatBubbleV1: FC<VistaChatBubbleV1Props>;
@@ -7,53 +7,24 @@ exports.VistaChatBubbleV1 = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var vista_avatar_v1_1 = require("../vista-avatar-v1/vista-avatar-v1");
9
9
  var format_timestamp_1 = require("../../utils/format-timestamp");
10
+ var chat_triangle_1 = require("../../atoms/chat-triangle/chat-triangle");
10
11
  var VistaChatBubbleV1 = function (_a) {
11
- var message = _a.message, timestamp = _a.timestamp, type = _a.type, showAvatar = _a.showAvatar, currentUser = _a.currentUser, status = _a.status;
12
- var isRecipient = currentUser && type !== currentUser;
13
- var getContainerClasses = function () {
14
- return "flex items-start gap-6 ".concat(isRecipient ? 'justify-start' : 'justify-end');
15
- };
16
- var getAvatar = function () {
17
- return showAvatar ? react_1.default.createElement(vista_avatar_v1_1.VistaAvatarV1, { alt: "" }) : null;
18
- };
19
- var getBubbleClasses = function () {
20
- return "relative ".concat(isRecipient ? 'bg-gray-200 text-black' : 'bg-primary text-white');
21
- };
12
+ var message = _a.message, createdAt = _a.createdAt, isUser = _a.isUser, user = _a.user, psychic = _a.psychic;
22
13
  var getBubbleStyles = function () { return ({
23
- borderTopLeftRadius: isRecipient ? '0px' : '8px',
24
- borderTopRightRadius: isRecipient ? '8px' : '0px',
14
+ borderTopLeftRadius: isUser ? '8px' : '0px',
15
+ borderTopRightRadius: isUser ? '0px' : '8px',
25
16
  borderBottomLeftRadius: '8px',
26
17
  borderBottomRightRadius: '8px',
27
18
  }); };
28
- // const getTriangle = (): JSX.Element | null =>
29
- // showAvatar ? (
30
- // <ChatTriangle fill={isRecipient ? '#E5E7EB' : '#9153D0'} />
31
- // ) : null;
32
- // const getStatusIndicator = (): JSX.Element | null => {
33
- // if (isRecipient || !status) return null;
34
- // const isViewed = status === VISTA_CHAT_BUBBLE_STATUS.VIEWED;
35
- // const fillPercentage = isViewed ? '100' : '50';
36
- // const fillColor = '#7e22ce';
37
- // const emptyColor = '#D1D5DB';
38
- // return (
39
- // <ChatCircle
40
- // fillColor={fillColor}
41
- // fillPercentage={fillPercentage}
42
- // emptyColor={emptyColor}
43
- // />
44
- // );
45
- // };
46
- var getTextAlignmentClasses = function () {
47
- return "flex items-center px-4 py-2 text-xs justify-between ".concat(isRecipient ? 'text-left' : 'text-right');
48
- };
49
- return (react_1.default.createElement("div", { className: getContainerClasses() },
50
- react_1.default.createElement("div", { className: "order-1 min-w-10" }, isRecipient && getAvatar()),
51
- react_1.default.createElement("div", { className: isRecipient ? 'order-2' : 'order-1' },
52
- react_1.default.createElement("div", { className: getBubbleClasses(), style: getBubbleStyles() },
53
- react_1.default.createElement("div", { className: "absolute top-0 size-4 ".concat(isRecipient ? '-left-4 rotate-180' : '-right-4 rotate-90') }),
19
+ return (react_1.default.createElement("div", { className: "flex items-start gap-6 my-2 ".concat(isUser ? 'justify-end' : 'justify-start') },
20
+ react_1.default.createElement("div", { className: isUser ? 'order-1' : 'order-2' },
21
+ react_1.default.createElement("div", { className: "relative ".concat(isUser ? 'bg-primary text-white' : 'bg-gray-200 text-black'), style: getBubbleStyles() },
22
+ react_1.default.createElement("div", { className: "absolute top-0 size-4 ".concat(isUser ? '-right-4 rotate-90' : '-left-4 rotate-180') },
23
+ react_1.default.createElement(chat_triangle_1.ChatTriangle, { fill: isUser ? '#9153D0' : '#E5E7EB' })),
54
24
  react_1.default.createElement("p", { className: "px-4 pt-2" }, message),
55
- react_1.default.createElement("div", { className: getTextAlignmentClasses() },
56
- react_1.default.createElement("span", { className: "mr-2" }, (0, format_timestamp_1.formatTimestamp)(timestamp))))),
57
- react_1.default.createElement("div", { className: "order-2 min-w-10" }, !isRecipient && getAvatar())));
25
+ react_1.default.createElement("div", { className: "flex items-center px-4 py-2 text-xs justify-between ".concat(isUser ? 'text-right' : 'text-left') },
26
+ react_1.default.createElement("span", { className: "mr-2" }, (0, format_timestamp_1.formatTimestamp)(createdAt))))),
27
+ react_1.default.createElement("div", { className: "order-1 min-w-10" },
28
+ react_1.default.createElement(vista_avatar_v1_1.VistaAvatarV1, { alt: isUser ? user.avatarAlt : psychic.avatarAlt, src: isUser ? user.avatarUrl : psychic.avatarUrl }))));
58
29
  };
59
30
  exports.VistaChatBubbleV1 = VistaChatBubbleV1;
@@ -38,13 +38,15 @@ exports.VistaChatV1 = void 0;
38
38
  var react_1 = __importStar(require("react"));
39
39
  var sort_messages_by_timestamp_1 = require("../../utils/sort-messages-by-timestamp");
40
40
  var get_divider_label_1 = require("../../utils/get-divider-label");
41
- var should_show_avatar_1 = require("../../utils/should-show-avatar");
42
- var vista_chat_type_1 = require("../../type/vista-chat-type");
43
- var vista_chat_bubble_v1_1 = require("../../molecules/vista-chat-bubble-v1/vista-chat-bubble-v1");
41
+ // import { shouldShowAvatar } from '../../utils/should-show-avatar';
42
+ // import { VISTA_CHAT_BUBBLE_STATUS } from '../../type/vista-chat-type';
43
+ // import { VistaChatBubbleV1 } from '../../molecules/vista-chat-bubble-v1/vista-chat-bubble-v1';
44
44
  var vista_chat_heading_v1_1 = require("../../molecules/vista-chat-heading-v1/vista-chat-heading-v1");
45
45
  var vista_chat_side_bar_v1_1 = require("../../molecules/vista-chat-side-bar-v1/vista-chat-side-bar-v1");
46
46
  var VistaChatV1 = function (_a) {
47
- var currentUser = _a.currentUser, messages = _a.messages, chats = _a.chats;
47
+ var
48
+ // currentUser,
49
+ messages = _a.messages, chats = _a.chats;
48
50
  var chatContainerRef = (0, react_1.useRef)(null);
49
51
  var getMessageSpacing = function (index) {
50
52
  var isFirstMessage = index === 0;
@@ -60,8 +62,7 @@ var VistaChatV1 = function (_a) {
60
62
  var dividerLabel = (0, get_divider_label_1.getDividerLabel)(message.timestamp, index > 0 ? sortedMessages[index - 1].timestamp : undefined);
61
63
  return (react_1.default.createElement("div", { key: index },
62
64
  dividerLabel && (react_1.default.createElement("div", { className: "my-4 text-center text-sm text-gray-500" }, dividerLabel)),
63
- react_1.default.createElement("div", { className: getMessageSpacing(index) },
64
- react_1.default.createElement(vista_chat_bubble_v1_1.VistaChatBubbleV1, { message: message.message, timestamp: message.timestamp, type: message.type, currentUser: currentUser, showAvatar: (0, should_show_avatar_1.shouldShowAvatar)(index), status: vista_chat_type_1.VISTA_CHAT_BUBBLE_STATUS.DELIVERED }))));
65
+ react_1.default.createElement("div", { className: getMessageSpacing(index) })));
65
66
  });
66
67
  };
67
68
  var scrollToBottom = function () {
@@ -13,11 +13,11 @@ var vista_button_v1_1 = require("../../molecules/vista-button-v1/vista-button-v1
13
13
  var vista_button_type_1 = require("../../type/vista-button-type");
14
14
  var vista_chat_bubble_v1_1 = require("../../molecules/vista-chat-bubble-v1/vista-chat-bubble-v1");
15
15
  var VistaChatV2 = function (_a) {
16
- var actionItems = _a.actionItems, chatId = _a.chatId, chatValue = _a.chatValue, handleChatOnChange = _a.handleChatOnChange, sectionHeading = _a.sectionHeading, messages = _a.messages;
16
+ var actionItems = _a.actionItems, chatId = _a.chatId, chatValue = _a.chatValue, handleChatOnChange = _a.handleChatOnChange, sectionHeading = _a.sectionHeading, messages = _a.messages, user = _a.user, psychic = _a.psychic;
17
17
  var renderChatMessages = function () {
18
- return (react_1.default.createElement(react_1.default.Fragment, null, messages.map((function (_a, idx) {
19
- var message = _a.message, timestamp = _a.timestamp, currentUser = _a.currentUser, type = _a.type, status = _a.status;
20
- return (react_1.default.createElement(vista_chat_bubble_v1_1.VistaChatBubbleV1, { key: idx, message: message, timestamp: timestamp, type: type, currentUser: currentUser, status: status }));
18
+ return (react_1.default.createElement(react_1.default.Fragment, null, messages.map((function (_a) {
19
+ var createdAt = _a.createdAt, id = _a.id, isUser = _a.isUser, message = _a.message;
20
+ return (react_1.default.createElement(vista_chat_bubble_v1_1.VistaChatBubbleV1, { createdAt: createdAt, isUser: isUser, key: id, message: message, psychic: psychic, user: user }));
21
21
  }))));
22
22
  };
23
23
  return (react_1.default.createElement("div", { className: "relative h-screen grid grid-cols-12 grid-rows-1 overflow-hidden" },
@@ -25,7 +25,7 @@ var VistaChatV2 = function (_a) {
25
25
  react_1.default.createElement("section", { className: "col-span-9 flex flex-col" },
26
26
  react_1.default.createElement(vista_chat_heading_v1_1.VistaChatHeadingV1, { heading: "Doris Brown" }),
27
27
  react_1.default.createElement("div", { className: "overflow-hidden h-full" },
28
- react_1.default.createElement("div", { className: "h-full overflow-y-auto p-4" }, renderChatMessages())),
28
+ react_1.default.createElement("div", { className: "h-full flex flex-col justify-end overflow-y-auto p-4" }, renderChatMessages())),
29
29
  react_1.default.createElement("div", { className: "flex flex-row items-center gap-4 border-t border-gray-200 p-4" },
30
30
  react_1.default.createElement("div", { className: 'w-full' },
31
31
  react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: handleChatOnChange, id: chatId, placeholder: 'Enter message...', value: chatValue })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/app-corp-vista",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "scripts": {
5
5
  "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib",
6
6
  "build:next": "next build",
@@ -0,0 +1,8 @@
1
+ import { VistaChatV2Psychic, VistaChatV2User } from "./vista-chat-type";
2
+ export interface VistaChatBubbleV1Props {
3
+ createdAt: string;
4
+ isUser: boolean;
5
+ message: string;
6
+ psychic: VistaChatV2Psychic;
7
+ user: VistaChatV2User;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -19,6 +19,14 @@ export interface VistaChatV2ActionItem {
19
19
  order: number;
20
20
  variant: VISTA_BUTTON_VARIANT;
21
21
  }
22
+ export interface VistaChatV2User {
23
+ avatarUrl: string;
24
+ avatarAlt: string;
25
+ }
26
+ export interface VistaChatV2Psychic {
27
+ avatarUrl: string;
28
+ avatarAlt: string;
29
+ }
22
30
  export interface VistaChatV2Props {
23
31
  actionItems: VistaChatV2ActionItem[];
24
32
  chatId: string;
@@ -26,4 +34,6 @@ export interface VistaChatV2Props {
26
34
  handleChatOnChange: (k: string, v: string) => void;
27
35
  sectionHeading: string;
28
36
  messages: any[];
37
+ user: VistaChatV2User;
38
+ psychic: VistaChatV2Psychic;
29
39
  }