@appcorp/app-corp-vista 0.0.14 → 0.0.16
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/atoms/chat-circle.d.ts +7 -0
- package/atoms/chat-circle.js +16 -0
- package/atoms/chat-triangle.d.ts +6 -0
- package/atoms/chat-triangle.js +43 -0
- package/data/vista-chat-props.d.ts +30 -0
- package/data/vista-chat-props.js +109 -0
- package/molecules/vista-chat-bubble-v1.d.ts +2 -0
- package/molecules/vista-chat-bubble-v1.js +57 -0
- package/molecules/vista-chat-heading-v1.d.ts +6 -0
- package/molecules/vista-chat-heading-v1.js +13 -0
- package/molecules/vista-chat-list-item-v1.d.ts +9 -0
- package/molecules/vista-chat-list-item-v1.js +23 -0
- package/molecules/vista-chat-search-bar-v1.d.ts +2 -0
- package/molecules/vista-chat-search-bar-v1.js +12 -0
- package/molecules/vista-chat-side-bar-v1.d.ts +11 -0
- package/molecules/vista-chat-side-bar-v1.js +29 -0
- package/organisms/vista-chat-v1/vista-chat-v1.d.ts +3 -0
- package/organisms/vista-chat-v1/vista-chat-v1.js +89 -0
- package/package.json +2 -1
- package/templates/vista-auth-v1/vista-auth-v1.d.ts +3 -0
- package/templates/vista-auth-v1/vista-auth-v1.js +50 -0
- package/type/vista-auth-type.d.ts +26 -0
- package/type/vista-auth-type.js +2 -0
- package/type/vista-chat-type.d.ts +13 -0
- package/type/vista-chat-type.js +13 -0
- package/utils/format-timestamp.d.ts +1 -0
- package/utils/format-timestamp.js +12 -0
- package/utils/get-divider-label.d.ts +1 -0
- package/utils/get-divider-label.js +19 -0
- package/utils/should-show-avatar.d.ts +1 -0
- package/utils/should-show-avatar.js +16 -0
- package/utils/sort-messages-by-timestamp.d.ts +6 -0
- package/utils/sort-messages-by-timestamp.js +7 -0
|
@@ -0,0 +1,16 @@
|
|
|
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.ChatCircle = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var ChatCircle = function (_a) {
|
|
9
|
+
var fillColor = _a.fillColor, fillPercentage = _a.fillPercentage, emptyColor = _a.emptyColor;
|
|
10
|
+
return (react_1.default.createElement("svg", { viewBox: "0 0 32 32", width: 12, height: 12, xmlns: "http://www.w3.org/2000/svg" },
|
|
11
|
+
react_1.default.createElement("mask", { id: "circle-mask-".concat(fillPercentage) },
|
|
12
|
+
react_1.default.createElement("rect", { x: "0", y: "0", width: "".concat(fillPercentage, "%"), height: "100%", fill: "white" })),
|
|
13
|
+
react_1.default.createElement("circle", { cx: "16", cy: "16", r: "15", fill: emptyColor }),
|
|
14
|
+
react_1.default.createElement("circle", { cx: "16", cy: "16", r: "15", fill: fillColor, mask: "url(#circle-mask-".concat(fillPercentage, ")") })));
|
|
15
|
+
};
|
|
16
|
+
exports.ChatCircle = ChatCircle;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ChatTriangle = void 0;
|
|
37
|
+
var React = __importStar(require("react"));
|
|
38
|
+
var ChatTriangle = function (_a) {
|
|
39
|
+
var fill = _a.fill;
|
|
40
|
+
return (React.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 },
|
|
41
|
+
React.createElement("polygon", { points: "0,100 100,100 0,0" })));
|
|
42
|
+
};
|
|
43
|
+
exports.ChatTriangle = ChatTriangle;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VISTA_CHAT_BUBBLE_TYPES } from "../type/vista-chat-type";
|
|
2
|
+
export declare const chats: {
|
|
3
|
+
avatarUrl: string;
|
|
4
|
+
avatarAlt: string;
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
|
+
lastMessage: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const messages: {
|
|
11
|
+
message: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
type: VISTA_CHAT_BUBBLE_TYPES;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const vistaChatV1Props: {
|
|
16
|
+
currentUser: VISTA_CHAT_BUBBLE_TYPES;
|
|
17
|
+
messages: {
|
|
18
|
+
message: string;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
type: VISTA_CHAT_BUBBLE_TYPES;
|
|
21
|
+
}[];
|
|
22
|
+
chats: {
|
|
23
|
+
avatarUrl: string;
|
|
24
|
+
avatarAlt: string;
|
|
25
|
+
firstName: string;
|
|
26
|
+
lastName: string;
|
|
27
|
+
lastMessage: string;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vistaChatV1Props = exports.messages = exports.chats = void 0;
|
|
4
|
+
var vista_chat_type_1 = require("../type/vista-chat-type");
|
|
5
|
+
exports.chats = [
|
|
6
|
+
{
|
|
7
|
+
avatarUrl: '',
|
|
8
|
+
avatarAlt: '',
|
|
9
|
+
firstName: 'Doris',
|
|
10
|
+
lastName: 'Brown',
|
|
11
|
+
lastMessage: 'Hello Sir, how are you?',
|
|
12
|
+
timestamp: '14:22 PM',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
avatarUrl: '',
|
|
16
|
+
avatarAlt: '',
|
|
17
|
+
firstName: 'Linda',
|
|
18
|
+
lastName: 'Taylor',
|
|
19
|
+
lastMessage: 'Hello Miss, how are you?',
|
|
20
|
+
timestamp: '12:10 PM',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
exports.messages = [
|
|
24
|
+
{
|
|
25
|
+
message: 'Good Morning',
|
|
26
|
+
timestamp: '2024-12-23T10:00:00Z',
|
|
27
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
message: 'I am well thank you for asking',
|
|
31
|
+
timestamp: '2024-12-23T10:20:00Z',
|
|
32
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
message: "That's great to hear! How can I assist you today?",
|
|
36
|
+
timestamp: '2024-12-23T10:25:00Z',
|
|
37
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
message: 'I have a question about my recent order',
|
|
41
|
+
timestamp: '2024-12-23T10:30:00Z',
|
|
42
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
message: "Of course, I'd be happy to help. Can you please provide me with your order number?",
|
|
46
|
+
timestamp: '2024-12-23T10:32:00Z',
|
|
47
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
message: "Certainly, it's ORD-12345",
|
|
51
|
+
timestamp: '2024-12-23T10:35:00Z',
|
|
52
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
message: "Certainly, it's ORD-12345",
|
|
56
|
+
timestamp: '2024-12-23T10:36:00Z',
|
|
57
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
message: "Certainly, it's ORD-12345",
|
|
61
|
+
timestamp: '2024-12-23T10:37:00Z',
|
|
62
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
message: "Certainly, it's ORD-12345",
|
|
66
|
+
timestamp: '2024-12-23T10:38:00Z',
|
|
67
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
message: "Thank you. I've located your order. What specific information do you need about it?",
|
|
71
|
+
timestamp: '2024-12-23T10:37:00Z',
|
|
72
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
message: 'I was wondering about the estimated delivery date',
|
|
76
|
+
timestamp: '2024-12-23T10:40:00Z',
|
|
77
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
message: 'According to our system, your order is scheduled to be delivered on Friday, June 25th.',
|
|
81
|
+
timestamp: '2024-12-23T10:42:00Z',
|
|
82
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
message: "That's perfect, thank you so much for your help!",
|
|
86
|
+
timestamp: '2024-12-23T10:45:00Z',
|
|
87
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
message: "You're welcome! I'm glad I could assist you. If you have any more questions in the future, please don't hesitate to ask.",
|
|
91
|
+
timestamp: '2024-12-19T10:47:00Z',
|
|
92
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
message: "You're welcome! I'm glad I could assist you. If you have any more questions in the future, please don't hesitate to ask.",
|
|
96
|
+
timestamp: '2024-12-20T10:47:00Z',
|
|
97
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
message: "You're welcome! I'm glad I could assist you. If you have any more questions in the future, please don't hesitate to ask.",
|
|
101
|
+
timestamp: '2021-12-23T10:47:00Z',
|
|
102
|
+
type: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.PSYCHIC,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
exports.vistaChatV1Props = {
|
|
106
|
+
currentUser: vista_chat_type_1.VISTA_CHAT_BUBBLE_TYPES.USER,
|
|
107
|
+
messages: exports.messages,
|
|
108
|
+
chats: exports.chats,
|
|
109
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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.VistaChatBubbleV1 = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var vista_avatar_v1_1 = require("./vista-avatar-v1/vista-avatar-v1");
|
|
9
|
+
var format_timestamp_1 = require("../utils/format-timestamp");
|
|
10
|
+
var vista_chat_type_1 = require("../type/vista-chat-type");
|
|
11
|
+
var chat_triangle_1 = require("../atoms/chat-triangle");
|
|
12
|
+
var chat_circle_1 = require("../atoms/chat-circle");
|
|
13
|
+
var VistaChatBubbleV1 = function (_a) {
|
|
14
|
+
var message = _a.message, timestamp = _a.timestamp, type = _a.type, showAvatar = _a.showAvatar, currentUser = _a.currentUser, status = _a.status;
|
|
15
|
+
var isRecipient = currentUser && type !== currentUser;
|
|
16
|
+
var getContainerClasses = function () {
|
|
17
|
+
return "flex items-start gap-6 ".concat(isRecipient ? 'justify-start' : 'justify-end');
|
|
18
|
+
};
|
|
19
|
+
var getAvatar = function () {
|
|
20
|
+
return showAvatar ? react_1.default.createElement(vista_avatar_v1_1.VistaAvatarV1, { alt: "" }) : null;
|
|
21
|
+
};
|
|
22
|
+
var getBubbleClasses = function () {
|
|
23
|
+
return "relative ".concat(isRecipient ? 'bg-gray-200 text-black' : 'bg-primary text-white');
|
|
24
|
+
};
|
|
25
|
+
var getBubbleStyles = function () { return ({
|
|
26
|
+
borderTopLeftRadius: isRecipient ? '0px' : '8px',
|
|
27
|
+
borderTopRightRadius: isRecipient ? '8px' : '0px',
|
|
28
|
+
borderBottomLeftRadius: '8px',
|
|
29
|
+
borderBottomRightRadius: '8px',
|
|
30
|
+
}); };
|
|
31
|
+
var getTriangle = function () {
|
|
32
|
+
return showAvatar ? (react_1.default.createElement(chat_triangle_1.ChatTriangle, { fill: isRecipient ? '#E5E7EB' : '#9153D0' })) : null;
|
|
33
|
+
};
|
|
34
|
+
var getStatusIndicator = function () {
|
|
35
|
+
if (isRecipient || !status)
|
|
36
|
+
return null;
|
|
37
|
+
var isViewed = status === vista_chat_type_1.VISTA_CHAT_BUBBLE_STATUS.VIEWED;
|
|
38
|
+
var fillPercentage = isViewed ? '100' : '50';
|
|
39
|
+
var fillColor = '#7e22ce';
|
|
40
|
+
var emptyColor = '#D1D5DB';
|
|
41
|
+
return (react_1.default.createElement(chat_circle_1.ChatCircle, { fillColor: fillColor, fillPercentage: fillPercentage, emptyColor: emptyColor }));
|
|
42
|
+
};
|
|
43
|
+
var getTextAlignmentClasses = function () {
|
|
44
|
+
return "flex items-center px-4 py-2 text-xs justify-between ".concat(isRecipient ? 'text-left' : 'text-right');
|
|
45
|
+
};
|
|
46
|
+
return (react_1.default.createElement("div", { className: getContainerClasses() },
|
|
47
|
+
react_1.default.createElement("div", { className: "order-1 min-w-10" }, isRecipient && getAvatar()),
|
|
48
|
+
react_1.default.createElement("div", { className: isRecipient ? 'order-2' : 'order-1' },
|
|
49
|
+
react_1.default.createElement("div", { className: getBubbleClasses(), style: getBubbleStyles() },
|
|
50
|
+
react_1.default.createElement("div", { className: "absolute top-0 size-4 ".concat(isRecipient ? '-left-4 rotate-180' : '-right-4 rotate-90') }, getTriangle()),
|
|
51
|
+
react_1.default.createElement("p", { className: "px-4 pt-2" }, message),
|
|
52
|
+
react_1.default.createElement("div", { className: getTextAlignmentClasses() },
|
|
53
|
+
react_1.default.createElement("span", { className: "mr-2" }, (0, format_timestamp_1.formatTimestamp)(timestamp)),
|
|
54
|
+
getStatusIndicator()))),
|
|
55
|
+
react_1.default.createElement("div", { className: "order-2 min-w-10" }, !isRecipient && getAvatar())));
|
|
56
|
+
};
|
|
57
|
+
exports.VistaChatBubbleV1 = VistaChatBubbleV1;
|
|
@@ -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.VistaChatHeadingV1 = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var VistaChatHeadingV1 = function (_a) {
|
|
9
|
+
var heading = _a.heading;
|
|
10
|
+
return (react_1.default.createElement("div", { className: "border-b border-gray-600 p-4 text-black dark:text-white" },
|
|
11
|
+
react_1.default.createElement("p", { className: "text-lg font-semibold" }, heading)));
|
|
12
|
+
};
|
|
13
|
+
exports.VistaChatHeadingV1 = VistaChatHeadingV1;
|
|
@@ -0,0 +1,23 @@
|
|
|
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.VistaChatListItemV1 = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var vista_avatar_type_1 = require("@appcorp/app-corp-designs/type/vista-avatar-type");
|
|
9
|
+
var vista_avatar_v1_1 = require("@appcorp/app-corp-designs/molecules/vista-avatar-v1");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var VistaChatListItemV1 = function (_a) {
|
|
12
|
+
var firstName = _a.firstName, lastName = _a.lastName, timestamp = _a.timestamp, lastMessage = _a.lastMessage;
|
|
13
|
+
return (react_1.default.createElement("div", { className: "flex cursor-pointer items-center justify-between gap-3 p-3 hover:bg-gray-100 dark:hover:bg-gray-600" },
|
|
14
|
+
react_1.default.createElement(vista_avatar_v1_1.VistaAvatarV1, { alt: "avatar", size: vista_avatar_type_1.VISTA_AVATAR_SIZES.SM, status: vista_avatar_type_1.VISTA_AVATAR_STATUS.ONLINE, statusPosition: vista_avatar_type_1.VISTA_STATUS_POSITION.TOP_RIGHT }),
|
|
15
|
+
react_1.default.createElement("div", { className: "flex-1" },
|
|
16
|
+
react_1.default.createElement("p", { className: "font-medium dark:text-gray-300" },
|
|
17
|
+
firstName,
|
|
18
|
+
" ",
|
|
19
|
+
lastName),
|
|
20
|
+
react_1.default.createElement("p", { className: "truncate text-sm text-gray-500" }, (0, util_functions_1.truncateText)(lastMessage, 18))),
|
|
21
|
+
react_1.default.createElement("span", { className: "text-xs text-gray-400" }, timestamp)));
|
|
22
|
+
};
|
|
23
|
+
exports.VistaChatListItemV1 = VistaChatListItemV1;
|
|
@@ -0,0 +1,12 @@
|
|
|
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.VistaChatSearchBarV1 = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var VistaChatSearchBarV1 = function () {
|
|
9
|
+
return (react_1.default.createElement("div", { className: "border-b border-gray-600 p-4" },
|
|
10
|
+
react_1.default.createElement("input", { className: "w-full rounded-lg bg-gray-100 px-4 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-400", placeholder: "Search messages or users", type: "text" })));
|
|
11
|
+
};
|
|
12
|
+
exports.VistaChatSearchBarV1 = VistaChatSearchBarV1;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.VistaChatSideBarV1 = void 0;
|
|
18
|
+
var react_1 = __importDefault(require("react"));
|
|
19
|
+
var vista_chat_heading_v1_1 = require("./vista-chat-heading-v1");
|
|
20
|
+
var vista_chat_search_bar_v1_1 = require("./vista-chat-search-bar-v1");
|
|
21
|
+
var vista_chat_list_item_v1_1 = require("./vista-chat-list-item-v1");
|
|
22
|
+
var VistaChatSideBarV1 = function (_a) {
|
|
23
|
+
var chats = _a.chats;
|
|
24
|
+
return (react_1.default.createElement("div", { className: "col-span-3 flex flex-col border-r border-gray-600 shadow-md" },
|
|
25
|
+
react_1.default.createElement(vista_chat_heading_v1_1.VistaChatHeadingV1, { heading: "Chats" }),
|
|
26
|
+
react_1.default.createElement(vista_chat_search_bar_v1_1.VistaChatSearchBarV1, null),
|
|
27
|
+
react_1.default.createElement("div", { className: "divide flex-1 divide-y divide-gray-600 overflow-y-auto" }, chats.map(function (item) { return (react_1.default.createElement(vista_chat_list_item_v1_1.VistaChatListItemV1, __assign({ key: item.firstName }, item))); }))));
|
|
28
|
+
};
|
|
29
|
+
exports.VistaChatSideBarV1 = VistaChatSideBarV1;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.VistaChatV1 = void 0;
|
|
38
|
+
var react_1 = __importStar(require("react"));
|
|
39
|
+
var sort_messages_by_timestamp_1 = require("../../utils/sort-messages-by-timestamp");
|
|
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");
|
|
44
|
+
var vista_chat_heading_v1_1 = require("../../molecules/vista-chat-heading-v1");
|
|
45
|
+
var vista_chat_side_bar_v1_1 = require("../../molecules/vista-chat-side-bar-v1");
|
|
46
|
+
var VistaChatV1 = function (_a) {
|
|
47
|
+
var currentUser = _a.currentUser, messages = _a.messages, chats = _a.chats;
|
|
48
|
+
var chatContainerRef = (0, react_1.useRef)(null);
|
|
49
|
+
var getMessageSpacing = function (index) {
|
|
50
|
+
var isFirstMessage = index === 0;
|
|
51
|
+
var isDifferentSender = index > 0 && messages[index - 1].type !== messages[index].type;
|
|
52
|
+
if (isFirstMessage || isDifferentSender) {
|
|
53
|
+
return 'mt-6';
|
|
54
|
+
}
|
|
55
|
+
return 'mt-1';
|
|
56
|
+
};
|
|
57
|
+
var sortedMessages = (0, sort_messages_by_timestamp_1.sortMessagesByTimestamp)(messages);
|
|
58
|
+
var renderChatMessages = function () {
|
|
59
|
+
return sortedMessages.map(function (message, index) {
|
|
60
|
+
var dividerLabel = (0, get_divider_label_1.getDividerLabel)(message.timestamp, index > 0 ? sortedMessages[index - 1].timestamp : undefined);
|
|
61
|
+
return (react_1.default.createElement("div", { key: index },
|
|
62
|
+
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
|
+
});
|
|
66
|
+
};
|
|
67
|
+
var scrollToBottom = function () {
|
|
68
|
+
if (chatContainerRef === null || chatContainerRef === void 0 ? void 0 : chatContainerRef.current) {
|
|
69
|
+
chatContainerRef === null || chatContainerRef === void 0 ? void 0 : chatContainerRef.current.scrollTo({
|
|
70
|
+
top: chatContainerRef === null || chatContainerRef === void 0 ? void 0 : chatContainerRef.current.scrollHeight,
|
|
71
|
+
behavior: 'smooth',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
(0, react_1.useEffect)(function () {
|
|
76
|
+
scrollToBottom();
|
|
77
|
+
}, [sortedMessages]);
|
|
78
|
+
return (react_1.default.createElement("div", { className: "relative h-screen grid grid-cols-12 grid-rows-1 overflow-hidden" },
|
|
79
|
+
react_1.default.createElement(vista_chat_side_bar_v1_1.VistaChatSideBarV1, { chats: chats }),
|
|
80
|
+
react_1.default.createElement("section", { className: "col-span-9 flex flex-col" },
|
|
81
|
+
react_1.default.createElement(vista_chat_heading_v1_1.VistaChatHeadingV1, { heading: "Doris Brown" }),
|
|
82
|
+
react_1.default.createElement("div", { className: "overflow-hidden" },
|
|
83
|
+
react_1.default.createElement("div", { className: "h-full overflow-y-auto p-4", ref: chatContainerRef }, renderChatMessages())),
|
|
84
|
+
react_1.default.createElement("div", { className: "bg-background border-t border-gray-600 p-4" },
|
|
85
|
+
react_1.default.createElement("form", { className: "flex items-center gap-3" },
|
|
86
|
+
react_1.default.createElement("input", { type: "text", placeholder: "Enter Message...", className: "flex-1 rounded-full border px-4 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-400" }),
|
|
87
|
+
react_1.default.createElement("button", { className: "rounded-full bg-indigo-500 px-4 py-2 text-white" }, "Send"))))));
|
|
88
|
+
};
|
|
89
|
+
exports.VistaChatV1 = VistaChatV1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appcorp/app-corp-vista",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
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",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"autoprefixer": "^10.4.20",
|
|
62
62
|
"clsx": "^2.1.1",
|
|
63
63
|
"concurrently": "^9.1.1",
|
|
64
|
+
"date-fns": "^4.1.0",
|
|
64
65
|
"eslint": "^9",
|
|
65
66
|
"eslint-config-next": "15.1.3",
|
|
66
67
|
"eslint-plugin-storybook": "^0.11.1",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.VistaAuthV1 = void 0;
|
|
8
|
+
var react_1 = __importDefault(require("react"));
|
|
9
|
+
var link_1 = __importDefault(require("next/link"));
|
|
10
|
+
var image_1 = __importDefault(require("next/image"));
|
|
11
|
+
var vista_text_input_v1_1 = require("../../molecules/vista-text-input-v1");
|
|
12
|
+
var VistaAuthV1 = function (_a) {
|
|
13
|
+
var actionLabel = _a.actionLabel, actionRoute = _a.actionRoute, banner = _a.banner, bannerAlt = _a.bannerAlt, description = _a.description, emailSignInButtonLabel = _a.emailSignInButtonLabel, forgotPassword = _a.forgotPassword, forgotPasswordRoute = _a.forgotPasswordRoute, handleSignIn = _a.handleSignIn, heading = _a.heading, inputElements = _a.inputElements, _b = _a.label, label = _b === void 0 ? false : _b, logo = _a.logo, logoAlt = _a.logoAlt, _c = _a.reverted, reverted = _c === void 0 ? false : _c;
|
|
14
|
+
return (react_1.default.createElement("section", { className: 'h-screen' },
|
|
15
|
+
react_1.default.createElement("div", { className: "flex min-h-full flex-1" },
|
|
16
|
+
react_1.default.createElement("div", { className: "flex flex-1 flex-col justify-center px-4 py-12 sm:px-6 lg:flex-none lg:px-20 xl:px-24 ".concat(reverted ? 'order-2' : 'order-1') },
|
|
17
|
+
react_1.default.createElement("div", { className: "mx-auto w-full max-w-sm lg:w-96" },
|
|
18
|
+
react_1.default.createElement("div", null,
|
|
19
|
+
react_1.default.createElement("img", { alt: logoAlt, src: logo, className: "h-10 w-auto" }),
|
|
20
|
+
react_1.default.createElement("h2", { className: "mt-8 text-2xl/9 font-bold tracking-tight text-gray-900 dark:text-white" }, heading),
|
|
21
|
+
react_1.default.createElement("p", { className: "mt-2 text-sm/6 text-gray-500 dark:text-gray-300" },
|
|
22
|
+
description,
|
|
23
|
+
' ',
|
|
24
|
+
react_1.default.createElement(link_1.default, { href: actionRoute, className: "font-semibold text-primary" }, actionLabel))),
|
|
25
|
+
react_1.default.createElement("div", { className: "mt-10" },
|
|
26
|
+
react_1.default.createElement("div", null,
|
|
27
|
+
react_1.default.createElement("div", { className: "space-y-6" },
|
|
28
|
+
inputElements
|
|
29
|
+
.filter(function (_a) {
|
|
30
|
+
var enabled = _a.enabled;
|
|
31
|
+
return enabled;
|
|
32
|
+
})
|
|
33
|
+
.map(function (_a) {
|
|
34
|
+
var handleOnChange = _a.handleOnChange, id = _a.id, inputLabel = _a.inputLabel, inputType = _a.inputType, placeholder = _a.placeholder, value = _a.value;
|
|
35
|
+
return (react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: handleOnChange, id: id, key: id, label: inputLabel, placeholder: placeholder, type: inputType, value: value }));
|
|
36
|
+
}),
|
|
37
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between" },
|
|
38
|
+
react_1.default.createElement("div", { className: "flex items-center" },
|
|
39
|
+
react_1.default.createElement("input", { id: "remember-me", name: "remember-me", type: "checkbox", className: "size-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600" }),
|
|
40
|
+
react_1.default.createElement("label", { htmlFor: "remember-me", className: "ml-3 block text-sm/6 text-gray-700 dark:text-gray-300" }, "Remember me")),
|
|
41
|
+
forgotPassword && forgotPasswordRoute && (react_1.default.createElement("div", { className: "text-sm/6" },
|
|
42
|
+
react_1.default.createElement("a", { href: forgotPasswordRoute, className: "font-semibold text-primary" }, forgotPassword)))),
|
|
43
|
+
react_1.default.createElement("div", null,
|
|
44
|
+
react_1.default.createElement("button", { className: "flex w-full justify-center rounded-md bg-primary px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-primary/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/80", onClick: handleSignIn, type: "submit" }, emailSignInButtonLabel))))))),
|
|
45
|
+
react_1.default.createElement("div", { className: "relative hidden w-0 flex-1 lg:block ".concat(reverted ? 'order-1' : 'order-2') },
|
|
46
|
+
react_1.default.createElement(image_1.default, { alt: bannerAlt, className: "absolute inset-0 size-full object-cover ".concat(reverted ? '' : 'scale-x-[-1]'), fill: true, height: 0, loading: "lazy", sizes: "60vw", src: banner, width: 0 }),
|
|
47
|
+
label && (react_1.default.createElement("div", { className: "absolute top-14 bg-primary px-6 py-2 ".concat(reverted ? 'right-0' : 'left-0') },
|
|
48
|
+
react_1.default.createElement("p", { className: "text-xl font-semibold text-white" }, label)))))));
|
|
49
|
+
};
|
|
50
|
+
exports.VistaAuthV1 = VistaAuthV1;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface VistaAuthInputElements {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
handleOnChange: (k: string, v: string) => void;
|
|
4
|
+
id: string;
|
|
5
|
+
inputLabel: string;
|
|
6
|
+
inputType: string;
|
|
7
|
+
placeholder: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
export interface VistaAuthV1Props {
|
|
11
|
+
actionLabel: string;
|
|
12
|
+
actionRoute: string;
|
|
13
|
+
banner: string;
|
|
14
|
+
bannerAlt: string;
|
|
15
|
+
description: string;
|
|
16
|
+
emailSignInButtonLabel: string;
|
|
17
|
+
forgotPassword: string;
|
|
18
|
+
forgotPasswordRoute?: string;
|
|
19
|
+
handleSignIn: () => void;
|
|
20
|
+
heading: string;
|
|
21
|
+
inputElements: VistaAuthInputElements[];
|
|
22
|
+
label?: string;
|
|
23
|
+
logo: string;
|
|
24
|
+
logoAlt: string;
|
|
25
|
+
reverted?: boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum VISTA_CHAT_BUBBLE_TYPES {
|
|
2
|
+
PSYCHIC = "PSYCHIC",
|
|
3
|
+
USER = "USER"
|
|
4
|
+
}
|
|
5
|
+
export declare enum VISTA_CHAT_BUBBLE_STATUS {
|
|
6
|
+
DELIVERED = "DELIVERED",
|
|
7
|
+
VIEWED = "VIEWED"
|
|
8
|
+
}
|
|
9
|
+
export interface VistaChatV1Props {
|
|
10
|
+
currentUser: VISTA_CHAT_BUBBLE_TYPES;
|
|
11
|
+
messages: any[];
|
|
12
|
+
chats: any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VISTA_CHAT_BUBBLE_STATUS = exports.VISTA_CHAT_BUBBLE_TYPES = void 0;
|
|
4
|
+
var VISTA_CHAT_BUBBLE_TYPES;
|
|
5
|
+
(function (VISTA_CHAT_BUBBLE_TYPES) {
|
|
6
|
+
VISTA_CHAT_BUBBLE_TYPES["PSYCHIC"] = "PSYCHIC";
|
|
7
|
+
VISTA_CHAT_BUBBLE_TYPES["USER"] = "USER";
|
|
8
|
+
})(VISTA_CHAT_BUBBLE_TYPES || (exports.VISTA_CHAT_BUBBLE_TYPES = VISTA_CHAT_BUBBLE_TYPES = {}));
|
|
9
|
+
var VISTA_CHAT_BUBBLE_STATUS;
|
|
10
|
+
(function (VISTA_CHAT_BUBBLE_STATUS) {
|
|
11
|
+
VISTA_CHAT_BUBBLE_STATUS["DELIVERED"] = "DELIVERED";
|
|
12
|
+
VISTA_CHAT_BUBBLE_STATUS["VIEWED"] = "VIEWED";
|
|
13
|
+
})(VISTA_CHAT_BUBBLE_STATUS || (exports.VISTA_CHAT_BUBBLE_STATUS = VISTA_CHAT_BUBBLE_STATUS = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatTimestamp: (isoString: string) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatTimestamp = void 0;
|
|
4
|
+
var formatTimestamp = function (isoString) {
|
|
5
|
+
var date = new Date(isoString);
|
|
6
|
+
return date.toLocaleTimeString([], {
|
|
7
|
+
hour: '2-digit',
|
|
8
|
+
minute: '2-digit',
|
|
9
|
+
hour12: true,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
exports.formatTimestamp = formatTimestamp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDividerLabel: (timestamp: string, previousTimestamp?: string) => string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDividerLabel = void 0;
|
|
4
|
+
var date_fns_1 = require("date-fns");
|
|
5
|
+
var getDividerLabel = function (timestamp, previousTimestamp) {
|
|
6
|
+
var currentDate = (0, date_fns_1.parseISO)(timestamp);
|
|
7
|
+
var previousDate = previousTimestamp ? (0, date_fns_1.parseISO)(previousTimestamp) : null;
|
|
8
|
+
if (!previousDate || currentDate.getDate() !== previousDate.getDate()) {
|
|
9
|
+
if ((0, date_fns_1.isToday)(currentDate))
|
|
10
|
+
return 'Today';
|
|
11
|
+
if ((0, date_fns_1.isYesterday)(currentDate))
|
|
12
|
+
return 'Yesterday';
|
|
13
|
+
if ((0, date_fns_1.isThisWeek)(currentDate))
|
|
14
|
+
return 'This Week';
|
|
15
|
+
return (0, date_fns_1.format)(currentDate, 'MMMM dd, yyyy');
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
exports.getDividerLabel = getDividerLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shouldShowAvatar: (index: number) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldShowAvatar = void 0;
|
|
4
|
+
var vista_chat_props_1 = require("../data/vista-chat-props");
|
|
5
|
+
var shouldShowAvatar = function (index) {
|
|
6
|
+
if (index === 0)
|
|
7
|
+
return true;
|
|
8
|
+
var currentMessage = vista_chat_props_1.messages[index];
|
|
9
|
+
var previousMessage = vista_chat_props_1.messages[index - 1];
|
|
10
|
+
var isDifferentSender = currentMessage.type !== previousMessage.type;
|
|
11
|
+
var currentDate = new Date(currentMessage.timestamp).toDateString();
|
|
12
|
+
var previousDate = new Date(previousMessage.timestamp).toDateString();
|
|
13
|
+
var isDifferentDay = currentDate !== previousDate;
|
|
14
|
+
return isDifferentSender || isDifferentDay;
|
|
15
|
+
};
|
|
16
|
+
exports.shouldShowAvatar = shouldShowAvatar;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortMessagesByTimestamp = void 0;
|
|
4
|
+
var sortMessagesByTimestamp = function (message) {
|
|
5
|
+
return message.sort(function (a, b) { return new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(); });
|
|
6
|
+
};
|
|
7
|
+
exports.sortMessagesByTimestamp = sortMessagesByTimestamp;
|