@yext/chat-ui-react 0.1.0
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/LICENSE +33 -0
- package/README.md +44 -0
- package/THIRD-PARTY-NOTICES +2106 -0
- package/lib/bundle.css +1 -0
- package/lib/commonjs/components/ChatHeader.d.ts +51 -0
- package/lib/commonjs/components/ChatHeader.d.ts.map +1 -0
- package/lib/commonjs/components/ChatHeader.js +42 -0
- package/lib/commonjs/components/ChatHeader.js.map +1 -0
- package/lib/commonjs/components/ChatInput.d.ts +48 -0
- package/lib/commonjs/components/ChatInput.d.ts.map +1 -0
- package/lib/commonjs/components/ChatInput.js +50 -0
- package/lib/commonjs/components/ChatInput.js.map +1 -0
- package/lib/commonjs/components/ChatPanel.d.ts +39 -0
- package/lib/commonjs/components/ChatPanel.d.ts.map +1 -0
- package/lib/commonjs/components/ChatPanel.js +54 -0
- package/lib/commonjs/components/ChatPanel.js.map +1 -0
- package/lib/commonjs/components/ChatPopUp.d.ts +42 -0
- package/lib/commonjs/components/ChatPopUp.d.ts.map +1 -0
- package/lib/commonjs/components/ChatPopUp.js +45 -0
- package/lib/commonjs/components/ChatPopUp.js.map +1 -0
- package/lib/commonjs/components/LoadingDots.d.ts +9 -0
- package/lib/commonjs/components/LoadingDots.d.ts.map +1 -0
- package/lib/commonjs/components/LoadingDots.js +15 -0
- package/lib/commonjs/components/LoadingDots.js.map +1 -0
- package/lib/commonjs/components/Markdown.d.ts +13 -0
- package/lib/commonjs/components/Markdown.d.ts.map +1 -0
- package/lib/commonjs/components/Markdown.js +32 -0
- package/lib/commonjs/components/Markdown.js.map +1 -0
- package/lib/commonjs/components/MessageBubble.d.ts +49 -0
- package/lib/commonjs/components/MessageBubble.d.ts.map +1 -0
- package/lib/commonjs/components/MessageBubble.js +54 -0
- package/lib/commonjs/components/MessageBubble.js.map +1 -0
- package/lib/commonjs/components/index.d.ts +11 -0
- package/lib/commonjs/components/index.d.ts.map +1 -0
- package/lib/commonjs/components/index.js +14 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/hooks/index.d.ts +2 -0
- package/lib/commonjs/hooks/index.d.ts.map +1 -0
- package/lib/commonjs/hooks/index.js +6 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useComposedCssClasses.d.ts +30 -0
- package/lib/commonjs/hooks/useComposedCssClasses.d.ts.map +1 -0
- package/lib/commonjs/hooks/useComposedCssClasses.js +60 -0
- package/lib/commonjs/hooks/useComposedCssClasses.js.map +1 -0
- package/lib/commonjs/icons/Arrow.d.ts +3 -0
- package/lib/commonjs/icons/Arrow.d.ts.map +1 -0
- package/lib/commonjs/icons/Arrow.js +9 -0
- package/lib/commonjs/icons/Arrow.js.map +1 -0
- package/lib/commonjs/icons/Cross.d.ts +3 -0
- package/lib/commonjs/icons/Cross.d.ts.map +1 -0
- package/lib/commonjs/icons/Cross.js +9 -0
- package/lib/commonjs/icons/Cross.js.map +1 -0
- package/lib/commonjs/icons/DualSync.d.ts +3 -0
- package/lib/commonjs/icons/DualSync.d.ts.map +1 -0
- package/lib/commonjs/icons/DualSync.js +9 -0
- package/lib/commonjs/icons/DualSync.js.map +1 -0
- package/lib/commonjs/icons/Message.d.ts +3 -0
- package/lib/commonjs/icons/Message.d.ts.map +1 -0
- package/lib/commonjs/icons/Message.js +9 -0
- package/lib/commonjs/icons/Message.js.map +1 -0
- package/lib/commonjs/index.d.ts +3 -0
- package/lib/commonjs/index.d.ts.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/utils/defaultHandleError.d.ts +9 -0
- package/lib/commonjs/utils/defaultHandleError.d.ts.map +1 -0
- package/lib/commonjs/utils/defaultHandleError.js +15 -0
- package/lib/commonjs/utils/defaultHandleError.js.map +1 -0
- package/lib/esm/components/ChatHeader.d.ts +51 -0
- package/lib/esm/components/ChatHeader.d.ts.map +1 -0
- package/lib/esm/components/ChatHeader.js +38 -0
- package/lib/esm/components/ChatHeader.js.map +1 -0
- package/lib/esm/components/ChatInput.d.ts +48 -0
- package/lib/esm/components/ChatInput.d.ts.map +1 -0
- package/lib/esm/components/ChatInput.js +43 -0
- package/lib/esm/components/ChatInput.js.map +1 -0
- package/lib/esm/components/ChatPanel.d.ts +39 -0
- package/lib/esm/components/ChatPanel.d.ts.map +1 -0
- package/lib/esm/components/ChatPanel.js +50 -0
- package/lib/esm/components/ChatPanel.js.map +1 -0
- package/lib/esm/components/ChatPopUp.d.ts +42 -0
- package/lib/esm/components/ChatPopUp.d.ts.map +1 -0
- package/lib/esm/components/ChatPopUp.js +41 -0
- package/lib/esm/components/ChatPopUp.js.map +1 -0
- package/lib/esm/components/LoadingDots.d.ts +9 -0
- package/lib/esm/components/LoadingDots.d.ts.map +1 -0
- package/lib/esm/components/LoadingDots.js +11 -0
- package/lib/esm/components/LoadingDots.js.map +1 -0
- package/lib/esm/components/Markdown.d.ts +13 -0
- package/lib/esm/components/Markdown.d.ts.map +1 -0
- package/lib/esm/components/Markdown.js +25 -0
- package/lib/esm/components/Markdown.js.map +1 -0
- package/lib/esm/components/MessageBubble.d.ts +49 -0
- package/lib/esm/components/MessageBubble.d.ts.map +1 -0
- package/lib/esm/components/MessageBubble.js +50 -0
- package/lib/esm/components/MessageBubble.js.map +1 -0
- package/lib/esm/components/index.d.ts +11 -0
- package/lib/esm/components/index.d.ts.map +1 -0
- package/lib/esm/components/index.js +6 -0
- package/lib/esm/components/index.js.map +1 -0
- package/lib/esm/hooks/index.d.ts +2 -0
- package/lib/esm/hooks/index.d.ts.map +1 -0
- package/lib/esm/hooks/index.js +2 -0
- package/lib/esm/hooks/index.js.map +1 -0
- package/lib/esm/hooks/useComposedCssClasses.d.ts +30 -0
- package/lib/esm/hooks/useComposedCssClasses.d.ts.map +1 -0
- package/lib/esm/hooks/useComposedCssClasses.js +56 -0
- package/lib/esm/hooks/useComposedCssClasses.js.map +1 -0
- package/lib/esm/icons/Arrow.d.ts +3 -0
- package/lib/esm/icons/Arrow.d.ts.map +1 -0
- package/lib/esm/icons/Arrow.js +5 -0
- package/lib/esm/icons/Arrow.js.map +1 -0
- package/lib/esm/icons/Cross.d.ts +3 -0
- package/lib/esm/icons/Cross.d.ts.map +1 -0
- package/lib/esm/icons/Cross.js +5 -0
- package/lib/esm/icons/Cross.js.map +1 -0
- package/lib/esm/icons/DualSync.d.ts +3 -0
- package/lib/esm/icons/DualSync.d.ts.map +1 -0
- package/lib/esm/icons/DualSync.js +5 -0
- package/lib/esm/icons/DualSync.js.map +1 -0
- package/lib/esm/icons/Message.d.ts +3 -0
- package/lib/esm/icons/Message.d.ts.map +1 -0
- package/lib/esm/icons/Message.js +5 -0
- package/lib/esm/icons/Message.js.map +1 -0
- package/lib/esm/index.d.ts +266 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/tsdoc-metadata.json +11 -0
- package/lib/esm/utils/defaultHandleError.d.ts +9 -0
- package/lib/esm/utils/defaultHandleError.d.ts.map +1 -0
- package/lib/esm/utils/defaultHandleError.js +11 -0
- package/lib/esm/utils/defaultHandleError.js.map +1 -0
- package/package.json +95 -0
- package/src/components/ChatHeader.tsx +118 -0
- package/src/components/ChatInput.tsx +129 -0
- package/src/components/ChatPanel.tsx +108 -0
- package/src/components/ChatPopUp.tsx +112 -0
- package/src/components/LoadingDots.tsx +22 -0
- package/src/components/Markdown.tsx +36 -0
- package/src/components/MessageBubble.tsx +125 -0
- package/src/components/index.ts +17 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useComposedCssClasses.ts +62 -0
- package/src/icons/Arrow.tsx +8 -0
- package/src/icons/Cross.tsx +8 -0
- package/src/icons/DualSync.tsx +8 -0
- package/src/icons/Message.tsx +10 -0
- package/src/index.ts +2 -0
- package/src/utils/defaultHandleError.ts +10 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageBubble = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const chat_headless_react_1 = require("@yext/chat-headless-react");
|
|
6
|
+
const hooks_1 = require("../hooks");
|
|
7
|
+
const tailwind_merge_1 = require("tailwind-merge");
|
|
8
|
+
const Markdown_1 = require("./Markdown");
|
|
9
|
+
const builtInCssClasses = {
|
|
10
|
+
topContainer: "w-full animate-fade-in @container",
|
|
11
|
+
subContainer: "flex flex-col @lg:flex-row @lg:items-center @lg:gap-x-2 @lg:m-1",
|
|
12
|
+
subContainer__user: "@lg:flex-row-reverse",
|
|
13
|
+
message: "peer rounded-2xl text-[13px] @[480px]:text-base p-4 w-fit max-w-[80%] prose overflow-x-auto",
|
|
14
|
+
message__bot: "text-slate-900 bg-gradient-to-tr from-slate-50 to-slate-100",
|
|
15
|
+
message__user: "ml-auto @lg:ml-0 text-white bg-gradient-to-tr from-blue-600 to-blue-700",
|
|
16
|
+
timestamp: "w-fit my-0.5 text-slate-400 text-[13px] opacity-0 peer-hover:opacity-100 duration-200 whitespace-pre-wrap",
|
|
17
|
+
timestamp__user: "ml-auto",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A component that displays the provided message.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*
|
|
24
|
+
* @param props - {@link MessageBubbleProps}
|
|
25
|
+
*/
|
|
26
|
+
function MessageBubble({ message, showTimestamp = true, customCssClasses, formatTimestamp = defaultFormatTimestamp, }) {
|
|
27
|
+
const cssClasses = (0, hooks_1.useComposedCssClasses)(builtInCssClasses, customCssClasses);
|
|
28
|
+
const messageCssClasses = (0, tailwind_merge_1.twMerge)(cssClasses.message, message.source === chat_headless_react_1.MessageSource.USER
|
|
29
|
+
? cssClasses.message__user
|
|
30
|
+
: cssClasses.message__bot);
|
|
31
|
+
const subContainerCssClasses = (0, tailwind_merge_1.twMerge)(cssClasses.subContainer, message.source === chat_headless_react_1.MessageSource.USER
|
|
32
|
+
? cssClasses.subContainer__user
|
|
33
|
+
: cssClasses.subContainer__bot);
|
|
34
|
+
const timestampCssClasses = (0, tailwind_merge_1.twMerge)(cssClasses.timestamp, message.source === chat_headless_react_1.MessageSource.USER
|
|
35
|
+
? cssClasses.timestamp__user
|
|
36
|
+
: cssClasses.timestamp__bot);
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: cssClasses.topContainer, children: (0, jsx_runtime_1.jsxs)("div", { className: subContainerCssClasses, children: [(0, jsx_runtime_1.jsx)("div", { className: messageCssClasses, children: (0, jsx_runtime_1.jsx)(Markdown_1.Markdown, { content: message.text }) }), showTimestamp && ((0, jsx_runtime_1.jsx)("div", { className: timestampCssClasses, children: message.timestamp ? formatTimestamp(message.timestamp) : " " }))] }) }));
|
|
38
|
+
}
|
|
39
|
+
exports.MessageBubble = MessageBubble;
|
|
40
|
+
/**
|
|
41
|
+
* Formats message's timestamp from "2023-05-18T19:33:34.553Z" to "7:33:34 PM"
|
|
42
|
+
*
|
|
43
|
+
* @param timestamp - the timestamp to convert from
|
|
44
|
+
* @returns formatted timestamp
|
|
45
|
+
*/
|
|
46
|
+
function defaultFormatTimestamp(timestamp) {
|
|
47
|
+
return new Date(timestamp).toLocaleString(undefined, {
|
|
48
|
+
hour: "numeric",
|
|
49
|
+
minute: "numeric",
|
|
50
|
+
second: "numeric",
|
|
51
|
+
hour12: true,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=MessageBubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBubble.js","sourceRoot":"","sources":["../../../src/components/MessageBubble.tsx"],"names":[],"mappings":";;;;AAAA,mEAAmE;AACnE,oCAAiD;AACjD,mDAAyC;AACzC,yCAAsC;AAoBtC,MAAM,iBAAiB,GAA4B;IACjD,YAAY,EAAE,mCAAmC;IACjD,YAAY,EACV,iEAAiE;IACnE,kBAAkB,EAAE,sBAAsB;IAC1C,OAAO,EACL,6FAA6F;IAC/F,YAAY,EAAE,6DAA6D;IAC3E,aAAa,EACX,yEAAyE;IAC3E,SAAS,EACP,2GAA2G;IAC7G,eAAe,EAAE,SAAS;CAC3B,CAAC;AAyBF;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,aAAa,GAAG,IAAI,EACpB,gBAAgB,EAChB,eAAe,GAAG,sBAAsB,GACrB;IACnB,MAAM,UAAU,GAAG,IAAA,6BAAqB,EAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;IAC9E,MAAM,iBAAiB,GAAG,IAAA,wBAAO,EAC/B,UAAU,CAAC,OAAO,EAClB,OAAO,CAAC,MAAM,KAAK,mCAAa,CAAC,IAAI;QACnC,CAAC,CAAC,UAAU,CAAC,aAAa;QAC1B,CAAC,CAAC,UAAU,CAAC,YAAY,CAC5B,CAAC;IACF,MAAM,sBAAsB,GAAG,IAAA,wBAAO,EACpC,UAAU,CAAC,YAAY,EACvB,OAAO,CAAC,MAAM,KAAK,mCAAa,CAAC,IAAI;QACnC,CAAC,CAAC,UAAU,CAAC,kBAAkB;QAC/B,CAAC,CAAC,UAAU,CAAC,iBAAiB,CACjC,CAAC;IACF,MAAM,mBAAmB,GAAG,IAAA,wBAAO,EACjC,UAAU,CAAC,SAAS,EACpB,OAAO,CAAC,MAAM,KAAK,mCAAa,CAAC,IAAI;QACnC,CAAC,CAAC,UAAU,CAAC,eAAe;QAC5B,CAAC,CAAC,UAAU,CAAC,cAAc,CAC9B,CAAC;IAEF,OAAO,CACL,gCAAK,SAAS,EAAE,UAAU,CAAC,YAAY,YACrC,iCAAK,SAAS,EAAE,sBAAsB,aACpC,gCAAK,SAAS,EAAE,iBAAiB,YAC/B,uBAAC,mBAAQ,IAAC,OAAO,EAAE,OAAO,CAAC,IAAI,GAAI,GAC/B,EAEL,aAAa,IAAI,CAChB,gCAAK,SAAS,EAAE,mBAAmB,YAChC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,GACzD,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC;AAzCD,sCAyCC;AAED;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,SAAiB;IAC/C,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE;QACnD,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ChatInput } from "./ChatInput";
|
|
2
|
+
export type { ChatInputCssClasses, ChatInputProps } from "./ChatInput";
|
|
3
|
+
export { ChatHeader } from "./ChatHeader";
|
|
4
|
+
export type { ChatHeaderCssClasses, ChatHeaderProps } from "./ChatHeader";
|
|
5
|
+
export { MessageBubble } from "./MessageBubble";
|
|
6
|
+
export type { MessageBubbleCssClasses, MessageBubbleProps, } from "./MessageBubble";
|
|
7
|
+
export { ChatPanel } from "./ChatPanel";
|
|
8
|
+
export type { ChatPanelCssClasses, ChatPanelProps } from "./ChatPanel";
|
|
9
|
+
export { ChatPopUp } from "./ChatPopUp";
|
|
10
|
+
export type { ChatPopUpCssClasses, ChatPopUpProps } from "./ChatPopUp";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatPopUp = exports.ChatPanel = exports.MessageBubble = exports.ChatHeader = exports.ChatInput = void 0;
|
|
4
|
+
var ChatInput_1 = require("./ChatInput");
|
|
5
|
+
Object.defineProperty(exports, "ChatInput", { enumerable: true, get: function () { return ChatInput_1.ChatInput; } });
|
|
6
|
+
var ChatHeader_1 = require("./ChatHeader");
|
|
7
|
+
Object.defineProperty(exports, "ChatHeader", { enumerable: true, get: function () { return ChatHeader_1.ChatHeader; } });
|
|
8
|
+
var MessageBubble_1 = require("./MessageBubble");
|
|
9
|
+
Object.defineProperty(exports, "MessageBubble", { enumerable: true, get: function () { return MessageBubble_1.MessageBubble; } });
|
|
10
|
+
var ChatPanel_1 = require("./ChatPanel");
|
|
11
|
+
Object.defineProperty(exports, "ChatPanel", { enumerable: true, get: function () { return ChatPanel_1.ChatPanel; } });
|
|
12
|
+
var ChatPopUp_1 = require("./ChatPopUp");
|
|
13
|
+
Object.defineProperty(exports, "ChatPopUp", { enumerable: true, get: function () { return ChatPopUp_1.ChatPopUp; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAGlB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAGnB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AAMtB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAGlB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useComposedCssClasses = void 0;
|
|
4
|
+
var useComposedCssClasses_1 = require("./useComposedCssClasses");
|
|
5
|
+
Object.defineProperty(exports, "useComposedCssClasses", { enumerable: true, get: function () { return useComposedCssClasses_1.useComposedCssClasses; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useComposedCssClasses merges a component's built-in tailwind classes with custom tailwind classes.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Tailwind classes will be merged without conflict, with custom classes having higher priority
|
|
6
|
+
* than built-in ones.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* Suppose a component has built-in classes of `{ container: 'px-4 text-slate-700' }`.
|
|
10
|
+
*
|
|
11
|
+
* Passing in the custom classes:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* { container: 'text-red-200 mb-3' }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* results in the merged classes of:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* { container: 'px-4 text-red-200 mb-3' }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*
|
|
25
|
+
* @param builtInClasses - The component's built-in tailwind classes
|
|
26
|
+
* @param customClasses - The custom tailwind classes to merge with the built-in ones
|
|
27
|
+
* @returns The composed CSS classes
|
|
28
|
+
*/
|
|
29
|
+
export declare function useComposedCssClasses<ClassInterface extends Partial<Record<keyof ClassInterface, string | object>>>(builtInClasses: Readonly<ClassInterface>, customClasses?: Partial<ClassInterface>): ClassInterface;
|
|
30
|
+
//# sourceMappingURL=useComposedCssClasses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposedCssClasses.d.ts","sourceRoot":"","sources":["../../../src/hooks/useComposedCssClasses.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,SAAS,OAAO,CAAC,MAAM,CAAC,MAAM,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAE7E,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,EACxC,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACtC,cAAc,CAyBhB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useComposedCssClasses = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const tailwind_merge_1 = require("tailwind-merge");
|
|
6
|
+
/**
|
|
7
|
+
* useComposedCssClasses merges a component's built-in tailwind classes with custom tailwind classes.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Tailwind classes will be merged without conflict, with custom classes having higher priority
|
|
11
|
+
* than built-in ones.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* Suppose a component has built-in classes of `{ container: 'px-4 text-slate-700' }`.
|
|
15
|
+
*
|
|
16
|
+
* Passing in the custom classes:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* { container: 'text-red-200 mb-3' }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* results in the merged classes of:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* { container: 'px-4 text-red-200 mb-3' }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*
|
|
30
|
+
* @param builtInClasses - The component's built-in tailwind classes
|
|
31
|
+
* @param customClasses - The custom tailwind classes to merge with the built-in ones
|
|
32
|
+
* @returns The composed CSS classes
|
|
33
|
+
*/
|
|
34
|
+
function useComposedCssClasses(builtInClasses, customClasses) {
|
|
35
|
+
return (0, react_1.useMemo)(() => {
|
|
36
|
+
const mergeCssClasses = (builtInClasses, customClasses) => {
|
|
37
|
+
const mergedCssClasses = { ...builtInClasses };
|
|
38
|
+
if (!customClasses) {
|
|
39
|
+
return mergedCssClasses;
|
|
40
|
+
}
|
|
41
|
+
Object.keys(customClasses).forEach((key) => {
|
|
42
|
+
const builtIn = builtInClasses[key];
|
|
43
|
+
const custom = customClasses[key];
|
|
44
|
+
if (!builtIn || !custom) {
|
|
45
|
+
mergedCssClasses[key] = custom || builtIn;
|
|
46
|
+
}
|
|
47
|
+
else if (typeof builtIn === "object" && typeof custom === "object") {
|
|
48
|
+
mergedCssClasses[key] = mergeCssClasses(builtIn, custom);
|
|
49
|
+
}
|
|
50
|
+
else if (typeof builtIn === "string" && typeof custom === "string") {
|
|
51
|
+
mergedCssClasses[key] = (0, tailwind_merge_1.twMerge)(builtIn, custom);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return mergedCssClasses;
|
|
55
|
+
};
|
|
56
|
+
return mergeCssClasses(builtInClasses, customClasses);
|
|
57
|
+
}, [builtInClasses, customClasses]);
|
|
58
|
+
}
|
|
59
|
+
exports.useComposedCssClasses = useComposedCssClasses;
|
|
60
|
+
//# sourceMappingURL=useComposedCssClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComposedCssClasses.js","sourceRoot":"","sources":["../../../src/hooks/useComposedCssClasses.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,mDAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,qBAAqB,CAGnC,cAAwC,EACxC,aAAuC;IAEvC,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,MAAM,eAAe,GAAG,CACtB,cAAwC,EACxC,aAAuC,EACvC,EAAE;YACF,MAAM,gBAAgB,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC;YAC/C,IAAI,CAAC,aAAa,EAAE;gBAClB,OAAO,gBAAgB,CAAC;aACzB;YACD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACzC,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;gBACpC,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;gBAClC,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE;oBACvB,gBAAgB,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC;iBAC3C;qBAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;oBACpE,gBAAgB,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;iBAC1D;qBAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;oBACpE,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAA,wBAAO,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;iBAClD;YACH,CAAC,CAAC,CAAC;YACH,OAAO,gBAAgB,CAAC;QAC1B,CAAC,CAAC;QACF,OAAO,eAAe,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;AACtC,CAAC;AA9BD,sDA8BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Arrow.d.ts","sourceRoot":"","sources":["../../../src/icons/Arrow.tsx"],"names":[],"mappings":";AAAA,wBAAgB,SAAS,IAAI,GAAG,CAAC,OAAO,CAOvC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrowIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function ArrowIcon() {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: "100%", height: "100%", viewBox: "0 0 20 20", fill: 'none', stroke: "currentColor", strokeLinecap: "square", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M10 5V15" }), (0, jsx_runtime_1.jsx)("path", { d: "M15 8.84615L10 4L5 8.84615" })] }));
|
|
7
|
+
}
|
|
8
|
+
exports.ArrowIcon = ArrowIcon;
|
|
9
|
+
//# sourceMappingURL=Arrow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Arrow.js","sourceRoot":"","sources":["../../../src/icons/Arrow.tsx"],"names":[],"mappings":";;;;AAAA,SAAgB,SAAS;IACvB,OAAO,CACL,iCAAK,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAC,4BAA4B,aAC9I,iCAAM,CAAC,EAAC,UAAU,GAAE,EACpB,iCAAM,CAAC,EAAC,4BAA4B,GAAE,IAClC,CACP,CAAC;AACJ,CAAC;AAPD,8BAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cross.d.ts","sourceRoot":"","sources":["../../../src/icons/Cross.tsx"],"names":[],"mappings":";AAAA,wBAAgB,SAAS,IAAI,GAAG,CAAC,OAAO,CAOvC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrossIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function CrossIcon() {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: "100%", height: "100%", viewBox: "0 0 20 20", stroke: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M14 14L6 6", strokeLinecap: "square", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M14 6L6 14", strokeLinecap: "square", strokeLinejoin: "round" })] }));
|
|
7
|
+
}
|
|
8
|
+
exports.CrossIcon = CrossIcon;
|
|
9
|
+
//# sourceMappingURL=Cross.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cross.js","sourceRoot":"","sources":["../../../src/icons/Cross.tsx"],"names":[],"mappings":";;;;AAAA,SAAgB,SAAS;IACvB,OAAO,CACL,iCAAK,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,MAAM,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,aAC1G,iCAAM,CAAC,EAAC,YAAY,EAAC,aAAa,EAAC,QAAQ,EAAC,cAAc,EAAC,OAAO,GAAE,EACpE,iCAAM,CAAC,EAAC,YAAY,EAAC,aAAa,EAAC,QAAQ,EAAC,cAAc,EAAC,OAAO,GAAE,IAChE,CACP,CAAC;AACJ,CAAC;AAPD,8BAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualSync.d.ts","sourceRoot":"","sources":["../../../src/icons/DualSync.tsx"],"names":[],"mappings":";AAAA,wBAAgB,YAAY,IAAI,GAAG,CAAC,OAAO,CAO1C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DualSyncIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function DualSyncIcon() {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: "100%", height: "100%", viewBox: "0 0 20 20", fill: 'currentColor', stroke: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M14.3148 6.47397C14.9074 7.36266 15.2593 8.46858 15.2593 9.63375C15.2593 12.675 12.9259 15.1634 10.0741 15.1634C9.11111 15.1634 8.2037 14.8671 7.42593 14.3734L9.05556 13.8995L8.87037 13.1293L6 13.939L6.75926 17L7.48148 16.8025L7.03704 15.0449C7.92593 15.6176 8.96296 15.9336 10.0741 15.9336C13.3519 15.9336 16 13.1095 16 9.614C16 8.2711 15.6111 7.02693 14.9259 6L14.3148 6.47397Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M9.92593 4.68459C10.8889 4.68459 11.7963 4.95341 12.5741 5.40143L10.9444 5.81362L11.1296 6.51254L14 5.77778L13.2407 3L12.5185 3.17921L12.963 4.77419C12.0741 4.25448 11.037 3.96774 9.92593 3.96774C6.64815 3.96774 4 6.53047 4 9.70251C4 10.9211 4.40741 12.0681 5.07407 13L5.68518 12.5878C5.09259 11.7634 4.74074 10.7778 4.74074 9.70251C4.74074 6.94265 7.07407 4.68459 9.92593 4.68459Z" })] }));
|
|
7
|
+
}
|
|
8
|
+
exports.DualSyncIcon = DualSyncIcon;
|
|
9
|
+
//# sourceMappingURL=DualSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualSync.js","sourceRoot":"","sources":["../../../src/icons/DualSync.tsx"],"names":[],"mappings":";;;;AAAA,SAAgB,YAAY;IAC1B,OAAO,CACL,iCAAK,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,cAAc,EAAC,MAAM,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,aAChI,iCAAM,CAAC,EAAC,6XAA6X,GAAE,EACvY,iCAAM,CAAC,EAAC,+XAA+X,GAAE,IACnY,CACP,CAAC;AACJ,CAAC;AAPD,oCAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/icons/Message.tsx"],"names":[],"mappings":";AAAA,wBAAgB,WAAW,IAAI,GAAG,CAAC,OAAO,CASzC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function MessageIcon() {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: "100%", height: "100%", viewBox: "0 0 20 20", fill: 'currentColor', xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M3.37424 17.1166L6.31902 14.1718H16.6258V4.84663H3.37424V17.1166ZM3.86503 5.33742H16.135V13.681H6.31902H6.11043L5.96319 13.8282L3.85276 15.9386V5.33742H3.86503Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M14.4172 9.2638H6.07362V9.7546H14.4172V9.2638Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M13.9264 10.7362H6.07362V11.227H13.9264V10.7362Z" }), (0, jsx_runtime_1.jsx)("path", { d: "M13.4356 7.79141H6.07362V8.28221H13.4356V7.79141Z" })] }));
|
|
7
|
+
}
|
|
8
|
+
exports.MessageIcon = MessageIcon;
|
|
9
|
+
//# sourceMappingURL=Message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/icons/Message.tsx"],"names":[],"mappings":";;;;AAAA,SAAgB,WAAW;IACzB,OAAO,CACL,iCAAK,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,cAAc,EAAC,KAAK,EAAC,4BAA4B,aACxG,iCAAM,CAAC,EAAC,kKAAkK,GAAE,EAC5K,iCAAM,CAAC,EAAC,gDAAgD,GAAG,EAC3D,iCAAM,CAAC,EAAC,kDAAkD,GAAG,EAC7D,iCAAM,CAAC,EAAC,mDAAmD,GAAG,IAC1D,CACP,CAAC;AACJ,CAAC;AATD,kCASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
|
18
|
+
__exportStar(require("./hooks"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultHandleError.d.ts","sourceRoot":"","sources":["../../../src/utils/defaultHandleError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,QAE/C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultHandleApiError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default handler function for API errors.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*
|
|
9
|
+
* @param e - error returned from api request
|
|
10
|
+
*/
|
|
11
|
+
function defaultHandleApiError(e) {
|
|
12
|
+
console.error(e);
|
|
13
|
+
}
|
|
14
|
+
exports.defaultHandleApiError = defaultHandleApiError;
|
|
15
|
+
//# sourceMappingURL=defaultHandleError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultHandleError.js","sourceRoot":"","sources":["../../../src/utils/defaultHandleError.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,CAAU;IAC9C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAFD,sDAEC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* The CSS class interface for the {@link ChatHeader} component.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ChatHeaderCssClasses {
|
|
8
|
+
header?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
restartButton?: string;
|
|
11
|
+
closeButton?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The props for the {@link ChatHeader} component.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export interface ChatHeaderProps {
|
|
19
|
+
/**
|
|
20
|
+
* The headers's title text, essentially how the chat window identifies itself to the user.
|
|
21
|
+
*/
|
|
22
|
+
title: string;
|
|
23
|
+
/**
|
|
24
|
+
* Displays a restart button which allows the user to restart the conversation.
|
|
25
|
+
* Defaults to false.
|
|
26
|
+
*/
|
|
27
|
+
showRestartButton?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Displays a close button which will invoke {@link ChatHeaderProps.onClose} on click.
|
|
30
|
+
* Default to false.
|
|
31
|
+
*/
|
|
32
|
+
showCloseButton?: boolean;
|
|
33
|
+
/** A function which is called when the close button is clicked. */
|
|
34
|
+
onClose?: () => void;
|
|
35
|
+
/** Custom icon for for restart button. */
|
|
36
|
+
restartButtonIcon?: JSX.Element;
|
|
37
|
+
/** Custom icon for for close button. */
|
|
38
|
+
closeButtonIcon?: JSX.Element;
|
|
39
|
+
/** CSS classes for customizing the component styling. */
|
|
40
|
+
customCssClasses?: ChatHeaderCssClasses;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A component that renders the header of a chat bot panel,
|
|
44
|
+
* including the title and a button to reset the conversation.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*
|
|
48
|
+
* @param props - {@link ChatHeaderProps}
|
|
49
|
+
*/
|
|
50
|
+
export declare function ChatHeader({ title, showRestartButton, restartButtonIcon, showCloseButton, closeButtonIcon, onClose, customCssClasses, }: ChatHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
//# sourceMappingURL=ChatHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatHeader.d.ts","sourceRoot":"","sources":["../../../src/components/ChatHeader.tsx"],"names":[],"mappings":";AAOA;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,2CAA2C;IAC3C,iBAAiB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC,yCAAyC;IACzC,eAAe,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC9B,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,iBAAiB,EACjB,iBAAoC,EACpC,eAAe,EACf,eAA+B,EAC/B,OAAO,EACP,gBAAgB,GACjB,EAAE,eAAe,2CA4CjB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useChatActions } from "@yext/chat-headless-react";
|
|
3
|
+
import { DualSyncIcon } from "../icons/DualSync";
|
|
4
|
+
import { useComposedCssClasses } from "../hooks/useComposedCssClasses";
|
|
5
|
+
import { useCallback, useRef, useState } from "react";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import { CrossIcon } from "../icons/Cross";
|
|
8
|
+
const builtInCssClasses = {
|
|
9
|
+
header: "w-full px-4 py-3 flex justify-between bg-gradient-to-tr from-blue-600 to-blue-800 rounded-t-3xl",
|
|
10
|
+
title: "text-white text-xl font-medium",
|
|
11
|
+
restartButton: "w-8 text-white stroke-[0.2] ml-auto",
|
|
12
|
+
closeButton: "w-8 text-white hover:scale-110"
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A component that renders the header of a chat bot panel,
|
|
16
|
+
* including the title and a button to reset the conversation.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*
|
|
20
|
+
* @param props - {@link ChatHeaderProps}
|
|
21
|
+
*/
|
|
22
|
+
export function ChatHeader({ title, showRestartButton, restartButtonIcon = _jsx(DualSyncIcon, {}), showCloseButton, closeButtonIcon = _jsx(CrossIcon, {}), onClose, customCssClasses, }) {
|
|
23
|
+
const chat = useChatActions();
|
|
24
|
+
const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);
|
|
25
|
+
const [isSpinning, setIsSpinning] = useState(false);
|
|
26
|
+
const restartButtonCssClasses = twMerge(cssClasses.restartButton, isSpinning ? "animate-[spin_0.3s_linear_infinite]" : "hover:scale-110");
|
|
27
|
+
const clearTimerRef = useRef();
|
|
28
|
+
const onRestart = useCallback(async () => {
|
|
29
|
+
clearTimeout(clearTimerRef.current);
|
|
30
|
+
setIsSpinning(true);
|
|
31
|
+
clearTimerRef.current = setTimeout(() => {
|
|
32
|
+
setIsSpinning(false);
|
|
33
|
+
}, 1000);
|
|
34
|
+
chat.restartConversation();
|
|
35
|
+
}, [chat]);
|
|
36
|
+
return (_jsxs("div", { className: cssClasses.header, children: [_jsx("h1", { className: cssClasses.title, children: title }), showRestartButton && (_jsx("button", { "aria-label": "Restart Conversation", onClick: onRestart, className: restartButtonCssClasses, children: restartButtonIcon })), showCloseButton && (_jsx("button", { "aria-label": "Close Chat", onClick: onClose, className: cssClasses.closeButton, children: closeButtonIcon }))] }));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ChatHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatHeader.js","sourceRoot":"","sources":["../../../src/components/ChatHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAc3C,MAAM,iBAAiB,GAAmC;IACxD,MAAM,EACJ,iGAAiG;IACnG,KAAK,EAAE,gCAAgC;IACvC,aAAa,EAAE,qCAAqC;IACpD,WAAW,EAAE,gCAAgC;CAC9C,CAAC;AAgCF;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,iBAAiB,EACjB,iBAAiB,GAAG,KAAC,YAAY,KAAG,EACpC,eAAe,EACf,eAAe,GAAG,KAAC,SAAS,KAAG,EAC/B,OAAO,EACP,gBAAgB,GACA;IAChB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAE9B,MAAM,UAAU,GAAG,qBAAqB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;IAE9E,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,uBAAuB,GAAG,OAAO,CACrC,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,iBAAiB,CACvE,CAAC;IAEF,MAAM,aAAa,GAAG,MAAM,EAAiC,CAAC;IAC9D,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACvC,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACpC,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACtC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,eAAK,SAAS,EAAE,UAAU,CAAC,MAAM,aAC/B,aAAI,SAAS,EAAE,UAAU,CAAC,KAAK,YAAG,KAAK,GAAM,EAC5C,iBAAiB,IAAI,CACpB,+BACa,sBAAsB,EACjC,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,uBAAuB,YAEjC,iBAAiB,GACX,CACV,EACA,eAAe,IAAI,CAClB,+BACW,YAAY,EACvB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,UAAU,CAAC,WAAW,YAEhC,eAAe,GACT,CACR,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* The CSS class interface for the {@link ChatInput} component.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ChatInputCssClasses {
|
|
8
|
+
container?: string;
|
|
9
|
+
textArea?: string;
|
|
10
|
+
sendButton?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The props for the {@link ChatInput} component.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface ChatInputProps {
|
|
18
|
+
/**
|
|
19
|
+
* The input's placeholder text when no text has been entered by the user.
|
|
20
|
+
* Defaults to "Type a message...".
|
|
21
|
+
*/
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Enable streaming behavior by making a request to Chat Streaming API.
|
|
25
|
+
* Defaults to true.
|
|
26
|
+
*/
|
|
27
|
+
stream?: boolean;
|
|
28
|
+
/** Enable auto focus for the input box. Defaults to false. */
|
|
29
|
+
inputAutoFocus?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A function which is called when an error occurs from
|
|
32
|
+
* Chat API while processing the user's message.
|
|
33
|
+
* By default, the error is logged to the console.
|
|
34
|
+
*/
|
|
35
|
+
handleError?: (e: unknown) => void;
|
|
36
|
+
/** Custom icon for the send button. */
|
|
37
|
+
sendButtonIcon?: JSX.Element;
|
|
38
|
+
/** CSS classes for customizing the component styling. */
|
|
39
|
+
customCssClasses?: ChatInputCssClasses;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A component that allows user to input message and send to Chat API.
|
|
43
|
+
* @public
|
|
44
|
+
*
|
|
45
|
+
* @param props - {@link ChatInputProps}
|
|
46
|
+
*/
|
|
47
|
+
export declare function ChatInput({ placeholder, stream, inputAutoFocus, handleError, sendButtonIcon, customCssClasses, }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
//# sourceMappingURL=ChatInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../src/components/ChatInput.tsx"],"names":[],"mappings":";AAQA;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAUD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,uCAAuC;IACvC,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC7B,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,WAAiC,EACjC,MAAa,EACb,cAAsB,EACtB,WAAW,EACX,cAA8B,EAC9B,gBAAgB,GACjB,EAAE,cAAc,2CA0DhB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { useChatActions, useChatState } from "@yext/chat-headless-react";
|
|
4
|
+
import { ArrowIcon } from "../icons/Arrow";
|
|
5
|
+
import { useComposedCssClasses } from "../hooks";
|
|
6
|
+
import Textarea from "react-expanding-textarea";
|
|
7
|
+
import { twMerge } from "tailwind-merge";
|
|
8
|
+
import { defaultHandleApiError } from "../utils/defaultHandleError";
|
|
9
|
+
const builtInCssClasses = {
|
|
10
|
+
container: "w-full h-fit flex flex-row relative @container",
|
|
11
|
+
textArea: "w-full p-4 pr-10 border border-slate-300 disabled:bg-slate-50 rounded-3xl resize-none text-[13px] @[480px]:text-base",
|
|
12
|
+
sendButton: "rounded-full p-1.5 w-8 stroke-2 text-white bg-blue-600 disabled:bg-slate-100 hover:bg-blue-800 active:scale-90 transition-all absolute right-7 bottom-2.5 @[480px]:bottom-3.5",
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A component that allows user to input message and send to Chat API.
|
|
16
|
+
* @public
|
|
17
|
+
*
|
|
18
|
+
* @param props - {@link ChatInputProps}
|
|
19
|
+
*/
|
|
20
|
+
export function ChatInput({ placeholder = "Type a message...", stream = true, inputAutoFocus = false, handleError, sendButtonIcon = _jsx(ArrowIcon, {}), customCssClasses, }) {
|
|
21
|
+
const chat = useChatActions();
|
|
22
|
+
const [input, setInput] = useState("");
|
|
23
|
+
const canSendMessage = useChatState((state) => state.conversation.canSendMessage);
|
|
24
|
+
const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);
|
|
25
|
+
const sendButtonClassNames = twMerge(cssClasses.sendButton, input.length === 0 && "opacity-0 invisible");
|
|
26
|
+
const sendMessage = useCallback(async () => {
|
|
27
|
+
const res = stream
|
|
28
|
+
? chat.streamNextMessage(input)
|
|
29
|
+
: chat.getNextMessage(input);
|
|
30
|
+
setInput("");
|
|
31
|
+
res.catch((e) => (handleError ? handleError(e) : defaultHandleApiError(e)));
|
|
32
|
+
}, [chat, input, handleError, stream]);
|
|
33
|
+
const handleKeyDown = useCallback((e) => {
|
|
34
|
+
if (e.key === "Enter") {
|
|
35
|
+
sendMessage();
|
|
36
|
+
}
|
|
37
|
+
}, [sendMessage]);
|
|
38
|
+
const onInputChange = useCallback((e) => {
|
|
39
|
+
setInput(e.target.value);
|
|
40
|
+
}, []);
|
|
41
|
+
return (_jsxs("div", { className: cssClasses.container, children: [_jsx(Textarea, { autoFocus: inputAutoFocus, disabled: !canSendMessage, onKeyDown: handleKeyDown, value: input, onChange: onInputChange, className: cssClasses.textArea, placeholder: placeholder }), _jsx("button", { "aria-label": "Send Message", disabled: !canSendMessage, onClick: sendMessage, className: sendButtonClassNames, children: sendButtonIcon })] }));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=ChatInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatInput.js","sourceRoot":"","sources":["../../../src/components/ChatInput.tsx"],"names":[],"mappings":"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"}
|