@servicetitan/titan-chat-ui-anvil2 3.0.1 → 3.1.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/CHANGELOG.md +12 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-messages.test.js +2 -91
- package/dist/components/chat/__tests-cy__/chat-messages.test.js.map +1 -1
- package/dist/components/chat/__tests-cy__/chat-notifications.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-notifications.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-notifications.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-notifications.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat.test.js +3 -127
- package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
- package/dist/components/chat/chat-connecting.js +1 -1
- package/dist/components/chat/chat-connecting.js.map +1 -1
- package/dist/components/chat/chat-error.d.ts +3 -1
- package/dist/components/chat/chat-error.d.ts.map +1 -1
- package/dist/components/chat/chat-error.js +3 -4
- package/dist/components/chat/chat-error.js.map +1 -1
- package/dist/components/chat/chat-input-file.d.ts.map +1 -1
- package/dist/components/chat/chat-input-file.js +19 -15
- package/dist/components/chat/chat-input-file.js.map +1 -1
- package/dist/components/chat/chat-input.d.ts.map +1 -1
- package/dist/components/chat/chat-input.js +5 -6
- package/dist/components/chat/chat-input.js.map +1 -1
- package/dist/components/chat/chat-input.module.less +4 -0
- package/dist/components/chat/chat-message-template-user.d.ts.map +1 -1
- package/dist/components/chat/chat-message-template-user.js +2 -2
- package/dist/components/chat/chat-message-template-user.js.map +1 -1
- package/dist/components/chat/chat-timer.d.ts.map +1 -1
- package/dist/components/chat/chat-timer.js +2 -3
- package/dist/components/chat/chat-timer.js.map +1 -1
- package/dist/components/chat/chat.d.ts.map +1 -1
- package/dist/components/chat/chat.js +7 -2
- package/dist/components/chat/chat.js.map +1 -1
- package/dist/components/chat/chat.module.less +9 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts +2 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts.map +1 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.js +6 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.js.map +1 -0
- package/dist/components/messages/__tests-cy__/message-agent.test.js +11 -77
- package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-system.test.js +6 -15
- package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-timeout.test.js +2 -21
- package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-typing.test.js +3 -45
- package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-user.test.js +3 -23
- package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
- package/dist/components/messages/message-timeout.d.ts.map +1 -1
- package/dist/components/messages/message-timeout.js +2 -1
- package/dist/components/messages/message-timeout.js.map +1 -1
- package/dist/components/messages/message-timeout.module.less +3 -0
- package/dist/components/messages/message-typing.js +1 -1
- package/dist/components/messages/message-typing.js.map +1 -1
- package/dist/components/messages/message-typing.module.less +4 -0
- package/package.json +4 -4
- package/src/components/chat/__tests-cy__/chat-error.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-input-file.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-input.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-log.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-messages.test.tsx +2 -107
- package/src/components/chat/__tests-cy__/chat-notifications.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-timer.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat.test.tsx +3 -161
- package/src/components/chat/chat-connecting.tsx +1 -1
- package/src/components/chat/chat-error.tsx +18 -21
- package/src/components/chat/chat-input-file.tsx +66 -31
- package/src/components/chat/chat-input.module.less +4 -0
- package/src/components/chat/chat-input.module.less.d.ts +1 -0
- package/src/components/chat/chat-input.tsx +31 -26
- package/src/components/chat/chat-message-template-user.tsx +11 -8
- package/src/components/chat/chat-timer.tsx +3 -9
- package/src/components/chat/chat.module.less +9 -0
- package/src/components/chat/chat.module.less.d.ts +4 -0
- package/src/components/chat/chat.tsx +33 -20
- package/src/components/message-content/__tests-cy__/message-content-file.test.tsx +6 -0
- package/src/components/messages/__tests-cy__/message-agent.test.tsx +15 -136
- package/src/components/messages/__tests-cy__/message-system.test.tsx +10 -28
- package/src/components/messages/__tests-cy__/message-timeout.test.tsx +2 -25
- package/src/components/messages/__tests-cy__/message-typing.test.tsx +3 -54
- package/src/components/messages/__tests-cy__/message-user.test.tsx +3 -37
- package/src/components/messages/message-timeout.module.less +3 -0
- package/src/components/messages/message-timeout.module.less.d.ts +3 -0
- package/src/components/messages/message-timeout.tsx +3 -2
- package/src/components/messages/message-typing.module.less +4 -0
- package/src/components/messages/message-typing.module.less.d.ts +1 -0
- package/src/components/messages/message-typing.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/components/chat/chat-error.module.less +0 -6
- package/dist/components/chat/chat-timer.module.less +0 -5
- package/src/components/chat/chat-error.module.less +0 -6
- package/src/components/chat/chat-error.module.less.d.ts +0 -3
- package/src/components/chat/chat-timer.module.less +0 -5
- package/src/components/chat/chat-timer.module.less.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v3.1.1 (Thu Aug 14 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- SPA-7016: [Chatbot] Add Anvil2 support for chatbot NPM packages [#41](https://github.com/servicetitan/titan-chatbot-client/pull/41) ([@AlexYarmolchuk](https://github.com/AlexYarmolchuk))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Alexandr Yarmolchuk ([@AlexYarmolchuk](https://github.com/AlexYarmolchuk))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v3.0.0 (Tue Jul 15 2025)
|
|
2
14
|
|
|
3
15
|
#### 💥 Breaking Change
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-error.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-error.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-error.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-error.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-input-file.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-input-file.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { runChatInputFileSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
2
|
+
import { ChatInputFile } from '../chat-input-file';
|
|
3
|
+
describe('ChatInputFile', () => {
|
|
4
|
+
runChatInputFileSharedTests(ChatInputFile, { isAnvil2: true });
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=chat-input-file.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-input-file.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-input-file.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,2BAA2B,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-input.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-input.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-input.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-input.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-log.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-log.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-log.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-log.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
|
|
@@ -1,95 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Provider } from '@servicetitan/react-ioc';
|
|
3
|
-
import { CHAT_UI_STORE_TOKEN, mockChatMessageModelText } from '@servicetitan/titan-chat-ui-common';
|
|
4
|
-
import { ChatUiSelectors, CypressMocks } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
5
|
-
import { mount } from 'cypress/react';
|
|
1
|
+
import { runChatMessagesSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
6
2
|
import { ChatMessages } from '../chat-messages';
|
|
7
3
|
describe('[ChatMessages]', () => {
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
cy.viewport(780, 600);
|
|
11
|
-
cy.clock(new Date('2023-10-01T10:10:00Z').getTime());
|
|
12
|
-
storeMock = new CypressMocks.ChatUiStoreMock();
|
|
13
|
-
});
|
|
14
|
-
const render = () => {
|
|
15
|
-
return mount(_jsx(Provider, { singletons: [
|
|
16
|
-
{
|
|
17
|
-
provide: CHAT_UI_STORE_TOKEN,
|
|
18
|
-
useValue: storeMock,
|
|
19
|
-
},
|
|
20
|
-
], children: _jsx(ChatMessages, { messages: storeMock.messages }) }));
|
|
21
|
-
};
|
|
22
|
-
it('should render default chat', () => {
|
|
23
|
-
render();
|
|
24
|
-
ChatUiSelectors.chatMessages.should('be.visible');
|
|
25
|
-
ChatUiSelectors.chatMessage.should('have.length', 2);
|
|
26
|
-
});
|
|
27
|
-
it('should render several consecutive agent messages without extra avatars', () => {
|
|
28
|
-
storeMock.messages = [
|
|
29
|
-
mockChatMessageModelText(true, {
|
|
30
|
-
id: 'id1',
|
|
31
|
-
timestamp: new Date('2023-01-01T10:10:00Z'),
|
|
32
|
-
message: 'Hello, this is the first message',
|
|
33
|
-
}),
|
|
34
|
-
mockChatMessageModelText(true, {
|
|
35
|
-
id: 'id2',
|
|
36
|
-
message: 'Hello, this is the second message. '.repeat(5).trim(),
|
|
37
|
-
timestamp: new Date('2023-01-01T10:10:59.999Z'),
|
|
38
|
-
}),
|
|
39
|
-
mockChatMessageModelText(true, {
|
|
40
|
-
id: 'id3',
|
|
41
|
-
message: 'Hello, this is the third message',
|
|
42
|
-
timestamp: new Date('2023-01-01T10:11:00Z'),
|
|
43
|
-
}),
|
|
44
|
-
mockChatMessageModelText(true, {
|
|
45
|
-
id: 'id4',
|
|
46
|
-
message: 'Hello, this is the forth message',
|
|
47
|
-
timestamp: new Date('2023-01-01T10:11:01Z'),
|
|
48
|
-
}),
|
|
49
|
-
mockChatMessageModelText(false, {
|
|
50
|
-
id: 'id11',
|
|
51
|
-
timestamp: new Date('2023-01-01T11:10:00Z'),
|
|
52
|
-
message: 'Hello, this is the first message',
|
|
53
|
-
}),
|
|
54
|
-
mockChatMessageModelText(false, {
|
|
55
|
-
id: 'id22',
|
|
56
|
-
message: 'Hello, this is the second message',
|
|
57
|
-
timestamp: new Date('2023-01-01T11:11:00Z'),
|
|
58
|
-
}),
|
|
59
|
-
mockChatMessageModelText(false, {
|
|
60
|
-
id: 'id33',
|
|
61
|
-
message: 'Hello, this is the third message',
|
|
62
|
-
timestamp: new Date('2023-01-01T11:12:00Z'),
|
|
63
|
-
}),
|
|
64
|
-
mockChatMessageModelText(false, {
|
|
65
|
-
id: 'id44',
|
|
66
|
-
message: 'Hello, this is the forth message',
|
|
67
|
-
timestamp: new Date('2023-01-01T11:12:01Z'),
|
|
68
|
-
}),
|
|
69
|
-
];
|
|
70
|
-
render();
|
|
71
|
-
const getTimestamp = (i) => ChatUiSelectors.chatMessage
|
|
72
|
-
.eq(i)
|
|
73
|
-
.find(`[data-cy="${ChatUiSelectors.cy.chatMessageFooter}"]`);
|
|
74
|
-
ChatUiSelectors.chatMessageAgent.should('have.length', 4);
|
|
75
|
-
ChatUiSelectors.chatMessageUser.should('have.length', 4);
|
|
76
|
-
// Agent avatar should be visible only for the first message in group
|
|
77
|
-
const getAvatar = (i) => ChatUiSelectors.chatMessageAgent
|
|
78
|
-
.find(`[data-cy="${ChatUiSelectors.cy.chatAvatar}"]`)
|
|
79
|
-
.eq(i);
|
|
80
|
-
getAvatar(0).should('be.visible');
|
|
81
|
-
getAvatar(1).should('not.exist');
|
|
82
|
-
getAvatar(2).should('not.exist');
|
|
83
|
-
getAvatar(3).should('not.exist');
|
|
84
|
-
// Footer with date should be visible only for the different formatted timestamps
|
|
85
|
-
getTimestamp(0).should('not.exist');
|
|
86
|
-
getTimestamp(1).should('be.visible').should('contain.text', 'agent • 10:10 AM');
|
|
87
|
-
getTimestamp(2).should('not.exist');
|
|
88
|
-
getTimestamp(3).should('be.visible').should('contain.text', 'agent • 10:11 AM');
|
|
89
|
-
getTimestamp(4).should('be.visible').should('contain.text', '11:10 AM');
|
|
90
|
-
getTimestamp(5).should('be.visible').should('contain.text', '11:11 AM');
|
|
91
|
-
getTimestamp(6).should('not.exist');
|
|
92
|
-
getTimestamp(7).should('be.visible').should('contain.text', '11:12 AM');
|
|
93
|
-
});
|
|
4
|
+
runChatMessagesSharedTests(ChatMessages);
|
|
94
5
|
});
|
|
95
6
|
//# sourceMappingURL=chat-messages.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-messages.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-messages.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-messages.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-messages.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-notifications.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-notifications.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { runChatNotificationsTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
2
|
+
import { ChatNotifications } from '../chat-notifications';
|
|
3
|
+
describe('ChatNotifications', () => {
|
|
4
|
+
runChatNotificationsTests(ChatNotifications);
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=chat-notifications.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-notifications.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-notifications.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-timer.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-timer.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-timer.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat-timer.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC"}
|
|
@@ -1,130 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnvilProvider } from '@servicetitan/anvil2';
|
|
3
|
-
import { Container, provide, useDependencies } from '@servicetitan/react-ioc';
|
|
4
|
-
import { CHAT_UI_BACKEND_STORE_TOKEN, CHAT_UI_STORE_TOKEN, ChatParticipantIcon, ChatUiBackendEchoStore, ChatUiStore, } from '@servicetitan/titan-chat-ui-common';
|
|
5
|
-
import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
6
|
-
import { mount as cyMount } from 'cypress/react';
|
|
7
|
-
import { useEffect } from 'react';
|
|
1
|
+
import { runChatSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
8
2
|
import { Chat } from '../chat';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
const initContainer = () => {
|
|
13
|
-
const rootContainer = new Container();
|
|
14
|
-
const container = new Container();
|
|
15
|
-
container.parent = rootContainer;
|
|
16
|
-
container.bind(CHAT_UI_STORE_TOKEN).to(ChatUiStore).inSingletonScope();
|
|
17
|
-
container
|
|
18
|
-
.bind(CHAT_UI_BACKEND_STORE_TOKEN)
|
|
19
|
-
.to(ChatUiBackendEchoStore)
|
|
20
|
-
.inSingletonScope();
|
|
21
|
-
return container;
|
|
22
|
-
};
|
|
23
|
-
describe('[Chat]', () => {
|
|
24
|
-
let container;
|
|
25
|
-
let chatUiStore;
|
|
26
|
-
let chatUiBackendStore;
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
container = initContainer();
|
|
29
|
-
chatUiStore = container.get(CHAT_UI_STORE_TOKEN);
|
|
30
|
-
chatUiBackendStore = container.get(CHAT_UI_BACKEND_STORE_TOKEN);
|
|
31
|
-
cy.viewport(780, 800);
|
|
32
|
-
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
33
|
-
});
|
|
34
|
-
const render = () => {
|
|
35
|
-
const ChatWrapper = provide({
|
|
36
|
-
singletons: [
|
|
37
|
-
{
|
|
38
|
-
provide: CHAT_UI_STORE_TOKEN,
|
|
39
|
-
useValue: chatUiStore,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
provide: CHAT_UI_BACKEND_STORE_TOKEN,
|
|
43
|
-
useValue: chatUiBackendStore,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
})(() => {
|
|
47
|
-
const [chatUiStore, chatUiBackendStore] = useDependencies(CHAT_UI_STORE_TOKEN, CHAT_UI_BACKEND_STORE_TOKEN);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
const init = async () => {
|
|
50
|
-
chatUiBackendStore.subscribe();
|
|
51
|
-
await chatUiStore.run({
|
|
52
|
-
agentName: 'EchoBot',
|
|
53
|
-
agentIcon: ChatParticipantIcon.Bot,
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
init().then(() => { });
|
|
57
|
-
return () => chatUiBackendStore.unsubscribe();
|
|
58
|
-
}, [chatUiStore, chatUiBackendStore]);
|
|
59
|
-
return _jsx(Chat, { className: "h-100vh max-h-100vh" });
|
|
60
|
-
});
|
|
61
|
-
cy.spy(chatUiStore, 'run').as('runSpy');
|
|
62
|
-
mount(_jsx(ChatWrapper, {}));
|
|
63
|
-
ChatUiSelectors.chatConnecting.should('be.visible');
|
|
64
|
-
cy.tick(1000);
|
|
65
|
-
return cy.wrap(new Promise(resolve => {
|
|
66
|
-
cy.get('@runSpy')
|
|
67
|
-
.should('have.been.calledOnce')
|
|
68
|
-
.then((invocation) => {
|
|
69
|
-
const initPromise = invocation.firstCall.returnValue;
|
|
70
|
-
initPromise.then(resolve);
|
|
71
|
-
});
|
|
72
|
-
}));
|
|
73
|
-
};
|
|
74
|
-
const ask = (message) => {
|
|
75
|
-
ChatUiSelectors.chatInput.type(`${message}{enter}`);
|
|
76
|
-
};
|
|
77
|
-
it('should render default chat', () => {
|
|
78
|
-
render().then(() => {
|
|
79
|
-
ChatUiSelectors.chatMessages.should('be.visible');
|
|
80
|
-
ChatUiSelectors.chatMessageAgent.should('have.length', 1).should('be.visible');
|
|
81
|
-
ChatUiSelectors.chatMessageContentAgent
|
|
82
|
-
.should('be.visible')
|
|
83
|
-
.should('contain.text', "Hello! I'm generic echo bot. I can echo your messages. Try it out!");
|
|
84
|
-
ChatUiSelectors.chatNotifications.should('exist');
|
|
85
|
-
ChatUiSelectors.chatSend.should('be.visible').should('be.disabled');
|
|
86
|
-
ChatUiSelectors.chatInput.should('be.visible').should('not.be.disabled');
|
|
87
|
-
ChatUiSelectors.chatInput.type('Hello');
|
|
88
|
-
ChatUiSelectors.chatSend.click();
|
|
89
|
-
ChatUiSelectors.chatMessageUser
|
|
90
|
-
.should('be.visible')
|
|
91
|
-
.should('have.length', 1)
|
|
92
|
-
.should('contain.text', 'Hello');
|
|
93
|
-
ChatUiSelectors.chatMessageTyping.should('be.visible');
|
|
94
|
-
ChatUiSelectors.chatMessageAgent.should('have.length', 1);
|
|
95
|
-
cy.tick(1000);
|
|
96
|
-
ChatUiSelectors.chatMessageTyping.should('not.exist');
|
|
97
|
-
ChatUiSelectors.chatMessageAgent.should('have.length', 2);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
it('should render chat error message', () => {
|
|
101
|
-
render().then(() => {
|
|
102
|
-
chatUiStore.setTimer({ secondsTotal: 100, secondsLeft: 10 });
|
|
103
|
-
chatUiStore.setError('error message', {
|
|
104
|
-
title: 'Custom Error',
|
|
105
|
-
recoverStrategy: {
|
|
106
|
-
recoverButtonTitle: 'Recover button title',
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
ChatUiSelectors.chatTimer.should('not.exist');
|
|
110
|
-
ChatUiSelectors.chatError.should('be.visible');
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
it('should handle send message error and retry', () => {
|
|
114
|
-
render().then(() => {
|
|
115
|
-
ask('[Error]Custom error message');
|
|
116
|
-
cy.tick(1000);
|
|
117
|
-
// Check error message
|
|
118
|
-
ChatUiSelectors.chatMessageError
|
|
119
|
-
.should('be.visible')
|
|
120
|
-
.should('contain.text', 'Message not delivered. Retry');
|
|
121
|
-
ChatUiSelectors.chatError
|
|
122
|
-
.should('be.visible')
|
|
123
|
-
.should('contain.text', ['Custom Error Title', 'Custom error message'].join(''));
|
|
124
|
-
// Retry message
|
|
125
|
-
ChatUiSelectors.chatMessageErrorRetry.should('be.visible').click();
|
|
126
|
-
cy.tick(1000);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
3
|
+
describe('Chat', () => {
|
|
4
|
+
runChatSharedTests(Chat);
|
|
129
5
|
});
|
|
130
6
|
//# sourceMappingURL=chat.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.test.js","sourceRoot":"","sources":["../../../../src/components/chat/__tests-cy__/chat.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Flex, Spinner, Text } from '@servicetitan/anvil2';
|
|
3
3
|
export const ChatConnecting = ({ className }) => {
|
|
4
|
-
return (_jsx(Flex, { direction: "column", gap: "4", alignItems: "center", className: className, "data-cy": "titan-chat-connecting", children: _jsxs(Flex, { direction: "row", gap: "4", alignItems: "center", children: [_jsx(Spinner, {}), _jsx(Text, { className: "c-
|
|
4
|
+
return (_jsx(Flex, { direction: "column", gap: "4", alignItems: "center", className: className, "data-cy": "titan-chat-connecting", children: _jsxs(Flex, { direction: "row", gap: "4", alignItems: "center", children: [_jsx(Spinner, {}), _jsx(Text, { className: "c-subdued", children: "Starting..." })] }) }));
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=chat-connecting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-connecting.js","sourceRoot":"","sources":["../../../src/components/chat/chat-connecting.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAO3D,MAAM,CAAC,MAAM,cAAc,GAA6B,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IACtE,OAAO,CACH,KAAC,IAAI,IACD,SAAS,EAAC,QAAQ,EAClB,GAAG,EAAC,GAAG,EACP,UAAU,EAAC,QAAQ,EACnB,SAAS,EAAE,SAAS,aACZ,uBAAuB,YAE/B,MAAC,IAAI,IAAC,SAAS,EAAC,KAAK,EAAC,GAAG,EAAC,GAAG,EAAC,UAAU,EAAC,QAAQ,aAC7C,KAAC,OAAO,KAAG,EACX,KAAC,IAAI,IAAC,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"chat-connecting.js","sourceRoot":"","sources":["../../../src/components/chat/chat-connecting.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAO3D,MAAM,CAAC,MAAM,cAAc,GAA6B,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IACtE,OAAO,CACH,KAAC,IAAI,IACD,SAAS,EAAC,QAAQ,EAClB,GAAG,EAAC,GAAG,EACP,UAAU,EAAC,QAAQ,EACnB,SAAS,EAAE,SAAS,aACZ,uBAAuB,YAE/B,MAAC,IAAI,IAAC,SAAS,EAAC,KAAK,EAAC,GAAG,EAAC,GAAG,EAAC,UAAU,EAAC,QAAQ,aAC7C,KAAC,OAAO,KAAG,EACX,KAAC,IAAI,IAAC,SAAS,EAAC,WAAW,4BAAmB,IAC3C,GACJ,CACV,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-error.d.ts","sourceRoot":"","sources":["../../../src/components/chat/chat-error.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-error.d.ts","sourceRoot":"","sources":["../../../src/components/chat/chat-error.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AAGxC,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CA6B/C,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Alert, Button, Flex } from '@servicetitan/anvil2';
|
|
3
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
4
4
|
import { CHAT_UI_STORE_TOKEN } from '@servicetitan/titan-chat-ui-common';
|
|
5
5
|
import { observer } from 'mobx-react';
|
|
6
6
|
import { useCallback } from 'react';
|
|
7
7
|
import { MultilineText } from '../common/multiline-text';
|
|
8
|
-
|
|
9
|
-
export const ChatError = observer(() => {
|
|
8
|
+
export const ChatError = observer(({ className }) => {
|
|
10
9
|
const [chatUiStore] = useDependencies(CHAT_UI_STORE_TOKEN);
|
|
11
10
|
const { error } = chatUiStore;
|
|
12
11
|
const handleReconnect = useCallback(async () => {
|
|
@@ -15,6 +14,6 @@ export const ChatError = observer(() => {
|
|
|
15
14
|
if (!error) {
|
|
16
15
|
return null;
|
|
17
16
|
}
|
|
18
|
-
return (
|
|
17
|
+
return (_jsx(Alert, { status: "danger", title: error.title, className: className, "data-cy": "titan-chat-error", children: _jsxs(Flex, { direction: "column", gap: "4", children: [_jsx(MultilineText, { text: error.message, "data-cy": "titan-chat-error-text" }), error.recoverStrategy && (_jsx(Button, { type: "button", appearance: "danger", size: "small", onClick: handleReconnect, "data-cy": "titan-chat-error-recover", children: error.recoverStrategy.recoverButtonTitle }))] }) }));
|
|
19
18
|
});
|
|
20
19
|
//# sourceMappingURL=chat-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-error.js","sourceRoot":"","sources":["../../../src/components/chat/chat-error.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chat-error.js","sourceRoot":"","sources":["../../../src/components/chat/chat-error.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAM,WAAW,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAA+B,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5E,MAAM,CAAC,WAAW,CAAC,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAC3D,MAAM,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC;IAE9B,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC3C,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,CACH,KAAC,KAAK,IAAC,MAAM,EAAC,QAAQ,EAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,aAAU,kBAAkB,YACvF,MAAC,IAAI,IAAC,SAAS,EAAC,QAAQ,EAAC,GAAG,EAAC,GAAG,aAC5B,KAAC,aAAa,IAAC,IAAI,EAAE,KAAK,CAAC,OAAO,aAAU,uBAAuB,GAAG,EACrE,KAAK,CAAC,eAAe,IAAI,CACtB,KAAC,MAAM,IACH,IAAI,EAAC,QAAQ,EACb,UAAU,EAAC,QAAQ,EACnB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,eAAe,aAChB,0BAA0B,YAEjC,KAAK,CAAC,eAAe,CAAC,kBAAkB,GACpC,CACZ,IACE,GACH,CACX,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input-file.d.ts","sourceRoot":"","sources":["../../../src/components/chat/chat-input-file.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-input-file.d.ts","sourceRoot":"","sources":["../../../src/components/chat/chat-input-file.tsx"],"names":[],"mappings":"AASA,OAAO,EAAe,EAAE,EAAsD,MAAM,OAAO,CAAC;AAE5F,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CA6FnD,CAAC"}
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
import { Button, Card, Flex, Icon, Text } from '@servicetitan/anvil2';
|
|
3
|
+
import IconAttachment from '@servicetitan/anvil2/assets/icons/material/round/attach_file.svg';
|
|
4
|
+
import IconDelete from '@servicetitan/anvil2/assets/icons/material/round/delete.svg';
|
|
5
|
+
import IconFile from '@servicetitan/anvil2/assets/icons/material/round/insert_drive_file.svg';
|
|
6
|
+
import IconEdit from '@servicetitan/anvil2/assets/icons/material/round/refresh.svg';
|
|
4
7
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
5
8
|
import { CHAT_UI_STORE_TOKEN } from '@servicetitan/titan-chat-ui-common';
|
|
6
9
|
import { observer } from 'mobx-react';
|
|
7
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
10
|
+
import { Fragment, useCallback, useEffect, useRef, useState } from 'react';
|
|
8
11
|
export const ChatInputFile = observer(({ className }) => {
|
|
12
|
+
const fileInputRef = useRef(null);
|
|
9
13
|
const [chatUiStore] = useDependencies(CHAT_UI_STORE_TOKEN);
|
|
10
14
|
const [fileDescriptor, setFileDescriptor] = useState(undefined);
|
|
11
|
-
const handleSelected = useCallback((
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
setFileDescriptor(fileDescriptor);
|
|
17
|
-
chatUiStore.setFile(fileDescriptor);
|
|
18
|
-
}, [chatUiStore]);
|
|
19
|
-
const handleReplace = useCallback(({ newFile }) => {
|
|
15
|
+
const handleSelected = useCallback((event) => {
|
|
16
|
+
const files = event.target.files;
|
|
17
|
+
if (!files || files.length === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
20
|
const fileDescriptor = {
|
|
21
|
-
file:
|
|
22
|
-
displayName:
|
|
21
|
+
file: files[0],
|
|
22
|
+
displayName: files[0].name,
|
|
23
23
|
};
|
|
24
24
|
setFileDescriptor(fileDescriptor);
|
|
25
25
|
chatUiStore.setFile(fileDescriptor);
|
|
26
26
|
}, [chatUiStore]);
|
|
27
|
+
const handleUpload = () => {
|
|
28
|
+
var _a;
|
|
29
|
+
(_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
30
|
+
};
|
|
27
31
|
const handleDelete = useCallback(() => {
|
|
28
32
|
setFileDescriptor(undefined);
|
|
29
33
|
chatUiStore.setFile(undefined);
|
|
@@ -36,6 +40,6 @@ export const ChatInputFile = observer(({ className }) => {
|
|
|
36
40
|
if (!chatUiStore.isFilePickerEnabled) {
|
|
37
41
|
return null;
|
|
38
42
|
}
|
|
39
|
-
return (_jsxs(Flex, { className: className, gap: "6", direction: "column", children: [_jsx(Text, { variant: "eyebrow", children: "Upload file" }), "
|
|
43
|
+
return (_jsxs(Flex, { className: className, gap: "6", direction: "column", children: [_jsx(Text, { variant: "eyebrow", children: "Upload file" }), _jsx("input", { type: "file", ref: fileInputRef, onChange: handleSelected, style: { display: 'none' }, accept: "*/*", multiple: false }), _jsx(Flex, { direction: "column", gap: "2", "data-cy": "titan-chat-upload-file", children: fileDescriptor ? (_jsx(Card, { padding: "small", children: _jsxs(Flex, { style: { width: '100%' }, direction: "row", alignItems: "center", gap: "2", children: [_jsx(Icon, { svg: IconFile, className: "m-inline-start-4" }), _jsx(Text, { variant: "body", flexGrow: 1, "data-cy": "titan-chat-upload-file-name", children: fileDescriptor.displayName }), _jsx(Button, { icon: IconEdit, "aria-label": "Replace file", appearance: "ghost", onClick: handleUpload, "data-cy": "titan-chat-upload-file-edit" }), _jsx(Button, { icon: IconDelete, "aria-label": "Delete file", appearance: "ghost", onClick: handleDelete, "data-cy": "titan-chat-upload-file-delete" })] }) })) : (_jsxs(Fragment, { children: [_jsx(Button, { type: "button", appearance: "secondary", icon: IconAttachment, onClick: handleUpload, "data-cy": "titan-chat-upload-file-btn", children: "Upload File" }), _jsx(Text, { variant: "body", size: "small", subdued: true, children: "e.g. Screenshot of issue" })] })) })] }));
|
|
40
44
|
});
|
|
41
45
|
//# sourceMappingURL=chat-input-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input-file.js","sourceRoot":"","sources":["../../../src/components/chat/chat-input-file.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"chat-input-file.js","sourceRoot":"","sources":["../../../src/components/chat/chat-input-file.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,cAAc,MAAM,kEAAkE,CAAC;AAC9F,OAAO,UAAU,MAAM,6DAA6D,CAAC;AACrF,OAAO,QAAQ,MAAM,wEAAwE,CAAC;AAC9F,OAAO,QAAQ,MAAM,8DAA8D,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAmB,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5F,MAAM,CAAC,MAAM,aAAa,GAA+B,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAChF,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,WAAW,CAAC,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAC3D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAA6B,SAAS,CAAC,CAA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1
|
-
{"version":3,"file":"chat-input.d.ts","sourceRoot":"","sources":["../../../src/components/chat/chat-input.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"chat-input.d.ts","sourceRoot":"","sources":["../../../src/components/chat/chat-input.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,EAAE,EAAsE,MAAM,OAAO,CAAC;AAM/F,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAwIhD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Textarea } from '@servicetitan/anvil2';
|
|
2
|
+
import { Button, Flex, Textarea } from '@servicetitan/anvil2';
|
|
3
3
|
import IconSend from '@servicetitan/anvil2/assets/icons/material/round/send.svg';
|
|
4
4
|
import { provide, useDependencies } from '@servicetitan/react-ioc';
|
|
5
5
|
import { CHAT_UI_STORE_TOKEN } from '@servicetitan/titan-chat-ui-common';
|
|
@@ -16,7 +16,8 @@ export const ChatInput = provide({
|
|
|
16
16
|
const [isSending, setIsSending] = useState(false);
|
|
17
17
|
const textareaRef = useRef(null);
|
|
18
18
|
const [chatUiStore, supportChatInputStore] = useDependencies(CHAT_UI_STORE_TOKEN, ChatInputStore);
|
|
19
|
-
const handleSendMessage = useCallback(async () => {
|
|
19
|
+
const handleSendMessage = useCallback(async (event) => {
|
|
20
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
20
21
|
const validateResult = await supportChatInputStore.formState.validate();
|
|
21
22
|
if (validateResult.hasError) {
|
|
22
23
|
return;
|
|
@@ -81,15 +82,13 @@ export const ChatInput = provide({
|
|
|
81
82
|
textareaRef.current.focus();
|
|
82
83
|
}
|
|
83
84
|
}, []);
|
|
84
|
-
return (_jsx("form", { className: classNames(className), onSubmit: handleSendMessage, children: _jsxs(
|
|
85
|
-
// maxRows={2}
|
|
86
|
-
autoHeight: true, onKeyDown: handleTextKeyPress, value: supportChatInputStore.formState.$.message.value, error: supportChatInputStore.formState.$.message.error, onChange: supportChatInputStore.formState.$.message.onChangeHandler, onFocus: () => {
|
|
85
|
+
return (_jsx("form", { className: classNames(className), onSubmit: handleSendMessage, children: _jsxs(Flex, { direction: "row", gap: 4, className: Styles.formContainer, children: [_jsx(Textarea, { ref: textareaRef, name: "question", placeholder: "Type your message", rows: 1, maxRows: 2, autoHeight: true, flexGrow: 1, onKeyDown: handleTextKeyPress, value: supportChatInputStore.formState.$.message.value, error: supportChatInputStore.formState.$.message.error, onChange: supportChatInputStore.formState.$.message.onChangeHandler, onFocus: () => {
|
|
87
86
|
setTimeout(() => {
|
|
88
87
|
chatUiStore.triggerScroll();
|
|
89
88
|
}, 0);
|
|
90
89
|
}, onBlur: () => {
|
|
91
90
|
supportChatInputStore.formState.$.message.enableAutoValidationAndValidate();
|
|
92
|
-
}, className: classNames('flex-grow-1', Styles.formTextarea), disabled: !chatUiStore.isStarted || isSending, "data-cy": "titan-chat-input" }), _jsx(Button, {
|
|
91
|
+
}, className: classNames('flex-grow-1', Styles.formTextarea), disabled: !chatUiStore.isStarted || isSending, "data-cy": "titan-chat-input" }), _jsx(Button, { alignSelf: "baseline", icon: IconSend, "data-pendo": "titan-chat-send", "data-cy": "titan-chat-send", type: "submit", appearance: "primary", "aria-label": "submit", disabled: !chatUiStore.isStarted ||
|
|
93
92
|
isSending ||
|
|
94
93
|
supportChatInputStore.formState.hasError ||
|
|
95
94
|
supportChatInputStore.isEmpty })] }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input.js","sourceRoot":"","sources":["../../../src/components/chat/chat-input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-input.js","sourceRoot":"","sources":["../../../src/components/chat/chat-input.tsx"],"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