@yext/chat-ui-react 0.8.1-alpha.53.2 → 0.8.2
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/lib/bundle.css +1 -1
- package/lib/commonjs/package.json.js +1 -1
- package/lib/commonjs/src/components/ChatInput.js +1 -1
- package/lib/commonjs/src/components/ChatPanel.d.ts +10 -5
- package/lib/commonjs/src/components/ChatPanel.d.ts.map +1 -1
- package/lib/commonjs/src/components/ChatPanel.js +41 -8
- package/lib/commonjs/src/components/ChatPanel.js.map +1 -1
- package/lib/commonjs/src/components/ChatPopUp.d.ts +1 -1
- package/lib/commonjs/src/components/ChatPopUp.d.ts.map +1 -1
- package/lib/commonjs/src/components/ChatPopUp.js +2 -2
- package/lib/commonjs/src/components/ChatPopUp.js.map +1 -1
- package/lib/commonjs/src/components/FeedbackButtons.d.ts +4 -3
- package/lib/commonjs/src/components/FeedbackButtons.d.ts.map +1 -1
- package/lib/commonjs/src/components/FeedbackButtons.js +1 -2
- package/lib/commonjs/src/components/FeedbackButtons.js.map +1 -1
- package/lib/commonjs/src/components/Markdown.d.ts +3 -7
- package/lib/commonjs/src/components/Markdown.d.ts.map +1 -1
- package/lib/commonjs/src/components/Markdown.js +1 -1
- package/lib/commonjs/src/components/Markdown.js.map +1 -1
- package/lib/commonjs/src/components/MessageSuggestions.d.ts +27 -0
- package/lib/commonjs/src/components/MessageSuggestions.d.ts.map +1 -0
- package/lib/commonjs/src/components/MessageSuggestions.js +35 -0
- package/lib/commonjs/src/components/MessageSuggestions.js.map +1 -0
- package/lib/commonjs/src/components/index.d.ts +2 -4
- package/lib/commonjs/src/components/index.d.ts.map +1 -1
- package/lib/commonjs/src/hooks/index.d.ts +0 -3
- package/lib/commonjs/src/hooks/index.d.ts.map +1 -1
- package/lib/commonjs/src/hooks/useDefaultHandleApiError.d.ts +1 -1
- package/lib/commonjs/src/hooks/useDefaultHandleApiError.js +1 -1
- package/lib/commonjs/src/hooks/useDefaultHandleApiError.js.map +1 -1
- package/lib/commonjs/src/hooks/useFetchInitialMessage.d.ts +1 -1
- package/lib/commonjs/src/hooks/useFetchInitialMessage.js +1 -1
- package/lib/commonjs/src/hooks/useFetchInitialMessage.js.map +1 -1
- package/lib/commonjs/src/hooks/useReportAnalyticsEvent.d.ts +0 -2
- package/lib/commonjs/src/hooks/useReportAnalyticsEvent.d.ts.map +1 -1
- package/lib/commonjs/src/hooks/useReportAnalyticsEvent.js +0 -2
- package/lib/commonjs/src/hooks/useReportAnalyticsEvent.js.map +1 -1
- package/lib/commonjs/src/index.js +0 -10
- package/lib/commonjs/src/index.js.map +1 -1
- package/lib/esm/index.d.ts +30 -87
- package/lib/esm/package.json.mjs +1 -1
- package/lib/esm/src/components/ChatInput.mjs +1 -1
- package/lib/esm/src/components/ChatPanel.d.ts +10 -5
- package/lib/esm/src/components/ChatPanel.d.ts.map +1 -1
- package/lib/esm/src/components/ChatPanel.mjs +42 -9
- package/lib/esm/src/components/ChatPanel.mjs.map +1 -1
- package/lib/esm/src/components/ChatPopUp.d.ts +1 -1
- package/lib/esm/src/components/ChatPopUp.d.ts.map +1 -1
- package/lib/esm/src/components/ChatPopUp.mjs +2 -2
- package/lib/esm/src/components/ChatPopUp.mjs.map +1 -1
- package/lib/esm/src/components/FeedbackButtons.d.ts +4 -3
- package/lib/esm/src/components/FeedbackButtons.d.ts.map +1 -1
- package/lib/esm/src/components/FeedbackButtons.mjs +1 -2
- package/lib/esm/src/components/FeedbackButtons.mjs.map +1 -1
- package/lib/esm/src/components/Markdown.d.ts +3 -7
- package/lib/esm/src/components/Markdown.d.ts.map +1 -1
- package/lib/esm/src/components/Markdown.mjs +1 -1
- package/lib/esm/src/components/Markdown.mjs.map +1 -1
- package/lib/esm/src/components/MessageSuggestions.d.ts +27 -0
- package/lib/esm/src/components/MessageSuggestions.d.ts.map +1 -0
- package/lib/esm/src/components/MessageSuggestions.mjs +29 -0
- package/lib/esm/src/components/MessageSuggestions.mjs.map +1 -0
- package/lib/esm/src/components/index.d.ts +2 -4
- package/lib/esm/src/components/index.d.ts.map +1 -1
- package/lib/esm/src/hooks/index.d.ts +0 -3
- package/lib/esm/src/hooks/index.d.ts.map +1 -1
- package/lib/esm/src/hooks/useDefaultHandleApiError.d.ts +1 -1
- package/lib/esm/src/hooks/useDefaultHandleApiError.mjs +1 -1
- package/lib/esm/src/hooks/useDefaultHandleApiError.mjs.map +1 -1
- package/lib/esm/src/hooks/useFetchInitialMessage.d.ts +1 -1
- package/lib/esm/src/hooks/useFetchInitialMessage.mjs +1 -1
- package/lib/esm/src/hooks/useFetchInitialMessage.mjs.map +1 -1
- package/lib/esm/src/hooks/useReportAnalyticsEvent.d.ts +0 -2
- package/lib/esm/src/hooks/useReportAnalyticsEvent.d.ts.map +1 -1
- package/lib/esm/src/hooks/useReportAnalyticsEvent.mjs +0 -2
- package/lib/esm/src/hooks/useReportAnalyticsEvent.mjs.map +1 -1
- package/lib/esm/src/index.mjs +0 -5
- package/lib/esm/src/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatPanel.tsx +72 -16
- package/src/components/ChatPopUp.tsx +1 -1
- package/src/components/FeedbackButtons.tsx +3 -3
- package/src/components/Markdown.tsx +2 -7
- package/src/components/MessageSuggestions.tsx +71 -0
- package/src/components/index.ts +6 -6
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useDefaultHandleApiError.ts +1 -1
- package/src/hooks/useFetchInitialMessage.ts +1 -1
- package/src/hooks/useReportAnalyticsEvent.ts +0 -2
- package/lib/commonjs/src/hooks/useScrollToLastMessage.d.ts +0 -15
- package/lib/commonjs/src/hooks/useScrollToLastMessage.d.ts.map +0 -1
- package/lib/commonjs/src/hooks/useScrollToLastMessage.js +0 -45
- package/lib/commonjs/src/hooks/useScrollToLastMessage.js.map +0 -1
- package/lib/esm/src/hooks/useScrollToLastMessage.d.ts +0 -15
- package/lib/esm/src/hooks/useScrollToLastMessage.d.ts.map +0 -1
- package/lib/esm/src/hooks/useScrollToLastMessage.mjs +0 -43
- package/lib/esm/src/hooks/useScrollToLastMessage.mjs.map +0 -1
- package/src/hooks/useScrollToLastMessage.ts +0 -47
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var chatHeadlessReact = require('@yext/chat-headless-react');
|
|
5
|
+
var useDefaultHandleApiError = require('../hooks/useDefaultHandleApiError.js');
|
|
6
|
+
var withStylelessCssClasses = require('../utils/withStylelessCssClasses.js');
|
|
7
|
+
var useComposedCssClasses = require('../hooks/useComposedCssClasses.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
12
|
+
|
|
13
|
+
const defaultClassnames = withStylelessCssClasses.withStylelessCssClasses("Suggestions", {
|
|
14
|
+
container: "flex gap-2 mt-4 w-full overflow-x-auto flex-wrap",
|
|
15
|
+
suggestion: "hover:cursor-pointer px-2 py-1 bg-white hover:bg-slate-300 rounded-full text-sm text-blue-700 border border-blue-700 hover:underline",
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* A component that displays a list of suggested messages
|
|
19
|
+
* to the user, which they can click to send the message to the bot.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
const MessageSuggestions = ({ suggestions, customCssClasses, }) => {
|
|
24
|
+
const actions = chatHeadlessReact.useChatActions();
|
|
25
|
+
const defaultHandleApiError = useDefaultHandleApiError.useDefaultHandleApiError();
|
|
26
|
+
const sendMsg = React.useCallback((msg) => {
|
|
27
|
+
const res = actions.getNextMessage(msg);
|
|
28
|
+
res.catch(defaultHandleApiError);
|
|
29
|
+
}, [defaultHandleApiError, actions]);
|
|
30
|
+
const classes = useComposedCssClasses.useComposedCssClasses(defaultClassnames, customCssClasses);
|
|
31
|
+
return (React__default.default.createElement("div", { className: classes.container }, suggestions.map((suggestion, index) => (React__default.default.createElement("button", { key: index, className: classes.suggestion, onClick: () => sendMsg(suggestion) }, suggestion)))));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.MessageSuggestions = MessageSuggestions;
|
|
35
|
+
//# sourceMappingURL=MessageSuggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageSuggestions.js","sources":["../../../../src/components/MessageSuggestions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useChatActions } from \"@yext/chat-headless-react\";\nimport { useDefaultHandleApiError } from \"../hooks/useDefaultHandleApiError\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { useComposedCssClasses } from \"../hooks\";\n\n/**\n * The CSS class interface for the MessageSuggestion component.\n *\n * @public\n */\nexport interface MessageSuggestionCssClasses {\n container?: string;\n suggestion?: string;\n}\n\n/**\n * The props for the MessageSuggestions component.\n *\n * @public\n */\nexport interface MessageSuggestionsProps {\n suggestions: string[];\n customCssClasses?: MessageSuggestionCssClasses;\n}\n\nconst defaultClassnames: MessageSuggestionCssClasses = withStylelessCssClasses(\n \"Suggestions\",\n {\n container: \"flex gap-2 mt-4 w-full overflow-x-auto flex-wrap\",\n suggestion:\n \"hover:cursor-pointer px-2 py-1 bg-white hover:bg-slate-300 rounded-full text-sm text-blue-700 border border-blue-700 hover:underline\",\n }\n);\n\n/**\n * A component that displays a list of suggested messages\n * to the user, which they can click to send the message to the bot.\n *\n * @internal\n */\nexport const MessageSuggestions: React.FC<MessageSuggestionsProps> = ({\n suggestions,\n customCssClasses,\n}) => {\n const actions = useChatActions();\n const defaultHandleApiError = useDefaultHandleApiError();\n const sendMsg = useCallback(\n (msg: string) => {\n const res = actions.getNextMessage(msg);\n res.catch(defaultHandleApiError);\n },\n [defaultHandleApiError, actions]\n );\n\n const classes = useComposedCssClasses(defaultClassnames, customCssClasses);\n\n return (\n <div className={classes.container}>\n {suggestions.map((suggestion, index) => (\n <button\n key={index}\n className={classes.suggestion}\n onClick={() => sendMsg(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n );\n};\n"],"names":["withStylelessCssClasses","useChatActions","useDefaultHandleApiError","useCallback","useComposedCssClasses","React"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,iBAAiB,GAAgCA,+CAAuB,CAC5E,aAAa,EACb;AACE,IAAA,SAAS,EAAE,kDAAkD;AAC7D,IAAA,UAAU,EACR,sIAAsI;AACzI,CAAA,CACF,CAAC;AAEF;;;;;AAKG;AACU,MAAA,kBAAkB,GAAsC,CAAC,EACpE,WAAW,EACX,gBAAgB,GACjB,KAAI;AACH,IAAA,MAAM,OAAO,GAAGC,gCAAc,EAAE,CAAC;AACjC,IAAA,MAAM,qBAAqB,GAAGC,iDAAwB,EAAE,CAAC;AACzD,IAAA,MAAM,OAAO,GAAGC,iBAAW,CACzB,CAAC,GAAW,KAAI;QACd,MAAM,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AACxC,QAAA,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACnC,KAAC,EACD,CAAC,qBAAqB,EAAE,OAAO,CAAC,CACjC,CAAC;IAEF,MAAM,OAAO,GAAGC,2CAAqB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;IAE3E,QACEC,8CAAK,SAAS,EAAE,OAAO,CAAC,SAAS,IAC9B,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,MACjCA,sBAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EACE,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,OAAO,CAAC,UAAU,EAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,EAEjC,EAAA,UAAU,CACJ,CACV,CAAC,CACE,EACN;AACJ;;;;"}
|
|
@@ -8,9 +8,7 @@ export { ChatPanel } from "./ChatPanel";
|
|
|
8
8
|
export type { ChatPanelCssClasses, ChatPanelProps } from "./ChatPanel";
|
|
9
9
|
export { ChatPopUp } from "./ChatPopUp";
|
|
10
10
|
export type { ChatPopUpCssClasses, ChatPopUpProps } from "./ChatPopUp";
|
|
11
|
-
export {
|
|
12
|
-
export type { FeedbackButtonsCssClasses, FeedbackButtonsProps } from "./FeedbackButtons";
|
|
13
|
-
export { Markdown } from "./Markdown";
|
|
14
|
-
export { MarkdownProps } from "./Markdown";
|
|
11
|
+
export type { FeedbackButtonsCssClasses } from "./FeedbackButtons";
|
|
15
12
|
export type { InitialMessagePopUpCssClasses } from "./InitialMessagePopUp";
|
|
13
|
+
export type { MessageSuggestionCssClasses, MessageSuggestionsProps, } from "./MessageSuggestions";
|
|
16
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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;AAEvE,
|
|
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;AAEvE,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,YAAY,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAE3E,YAAY,EACV,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { useComposedCssClasses } from "./useComposedCssClasses";
|
|
2
|
-
export { useDefaultHandleApiError } from "./useDefaultHandleApiError";
|
|
3
|
-
export { useFetchInitialMessage } from "./useFetchInitialMessage";
|
|
4
2
|
export { useReportAnalyticsEvent } from "./useReportAnalyticsEvent";
|
|
5
|
-
export { useScrollToLastMessage } from "./useScrollToLastMessage";
|
|
6
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Returns a default handler function for API errors. It will log the error and
|
|
3
3
|
* add a default error message to state.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export declare function useDefaultHandleApiError(): (e: unknown) => void;
|
|
8
8
|
//# sourceMappingURL=useDefaultHandleApiError.d.ts.map
|
|
@@ -7,7 +7,7 @@ var React = require('react');
|
|
|
7
7
|
* Returns a default handler function for API errors. It will log the error and
|
|
8
8
|
* add a default error message to state.
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
10
|
+
* @internal
|
|
11
11
|
*/
|
|
12
12
|
function useDefaultHandleApiError() {
|
|
13
13
|
const chat = chatHeadlessReact.useChatActions();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDefaultHandleApiError.js","sources":["../../../../src/hooks/useDefaultHandleApiError.ts"],"sourcesContent":["import { MessageSource, useChatActions } from \"@yext/chat-headless-react\";\nimport { useCallback } from \"react\";\n\n/**\n * Returns a default handler function for API errors. It will log the error and\n * add a default error message to state.\n *\n * @
|
|
1
|
+
{"version":3,"file":"useDefaultHandleApiError.js","sources":["../../../../src/hooks/useDefaultHandleApiError.ts"],"sourcesContent":["import { MessageSource, useChatActions } from \"@yext/chat-headless-react\";\nimport { useCallback } from \"react\";\n\n/**\n * Returns a default handler function for API errors. It will log the error and\n * add a default error message to state.\n *\n * @internal\n */\nexport function useDefaultHandleApiError() {\n const chat = useChatActions();\n\n return useCallback(\n (e: unknown) => {\n console.error(e);\n chat.addMessage({\n text: \"Sorry, I'm unable to respond at the moment. Please try again later!\",\n source: MessageSource.BOT,\n timestamp: new Date().toISOString(),\n });\n },\n [chat]\n );\n}\n"],"names":["useChatActions","useCallback","MessageSource"],"mappings":";;;;;AAGA;;;;;AAKG;SACa,wBAAwB,GAAA;AACtC,IAAA,MAAM,IAAI,GAAGA,gCAAc,EAAE,CAAC;AAE9B,IAAA,OAAOC,iBAAW,CAChB,CAAC,CAAU,KAAI;AACb,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,UAAU,CAAC;AACd,YAAA,IAAI,EAAE,qEAAqE;YAC3E,MAAM,EAAEC,+BAAa,CAAC,GAAG;AACzB,YAAA,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AACpC,SAAA,CAAC,CAAC;AACL,KAAC,EACD,CAAC,IAAI,CAAC,CACP,CAAC;AACJ;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Sends a request to Chat API to fetch the initial message when the
|
|
3
3
|
* conversation first start or when the message history is reset.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @internal
|
|
6
6
|
*
|
|
7
7
|
* @param handleError - A function which is called when an error occurs while fetching for initial message.
|
|
8
8
|
* By default, the error is logged to the console and an error message is added to state.
|
|
@@ -8,7 +8,7 @@ var useDefaultHandleApiError = require('./useDefaultHandleApiError.js');
|
|
|
8
8
|
* Sends a request to Chat API to fetch the initial message when the
|
|
9
9
|
* conversation first start or when the message history is reset.
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
11
|
+
* @internal
|
|
12
12
|
*
|
|
13
13
|
* @param handleError - A function which is called when an error occurs while fetching for initial message.
|
|
14
14
|
* By default, the error is logged to the console and an error message is added to state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchInitialMessage.js","sources":["../../../../src/hooks/useFetchInitialMessage.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { useChatState, useChatActions } from \"@yext/chat-headless-react\";\nimport { useDefaultHandleApiError } from \"../hooks/useDefaultHandleApiError\";\n\n/**\n * Sends a request to Chat API to fetch the initial message when the\n * conversation first start or when the message history is reset.\n *\n * @
|
|
1
|
+
{"version":3,"file":"useFetchInitialMessage.js","sources":["../../../../src/hooks/useFetchInitialMessage.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { useChatState, useChatActions } from \"@yext/chat-headless-react\";\nimport { useDefaultHandleApiError } from \"../hooks/useDefaultHandleApiError\";\n\n/**\n * Sends a request to Chat API to fetch the initial message when the\n * conversation first start or when the message history is reset.\n *\n * @internal\n *\n * @param handleError - A function which is called when an error occurs while fetching for initial message.\n * By default, the error is logged to the console and an error message is added to state.\n * @param stream - Enable streaming behavior by making a request to Chat Streaming API. Defaults to false.\n * @param customCondition - additional condition for when to fetch initial message\n */\nexport function useFetchInitialMessage(\n handleError?: (e: unknown) => void,\n stream = false,\n customCondition = true\n) {\n const chat = useChatActions();\n const defaultHandleApiError = useDefaultHandleApiError();\n const messages = useChatState((state) => state.conversation.messages);\n const [fetchInitialMessage, setFetchInitialMessage] = useState(\n messages.length === 0\n );\n const [messagesLength, setMessagesLength] = useState(messages.length);\n const canSendMessage = useChatState(\n (state) => state.conversation.canSendMessage\n );\n\n //handle message history resets\n useEffect(() => {\n const newMessagesLength = messages.length;\n // Fetch data only when the conversation messages changes from non-zero to zero\n if (messagesLength > 0 && newMessagesLength === 0) {\n setFetchInitialMessage(true);\n }\n setMessagesLength(newMessagesLength);\n }, [messages.length, messagesLength]);\n\n useEffect(() => {\n if (!fetchInitialMessage || !canSendMessage || !customCondition) {\n return;\n }\n setFetchInitialMessage(false);\n const res = stream ? chat.streamNextMessage() : chat.getNextMessage();\n res.catch((e) => (handleError ? handleError(e) : defaultHandleApiError(e)));\n }, [\n chat,\n stream,\n handleError,\n defaultHandleApiError,\n fetchInitialMessage,\n canSendMessage,\n customCondition,\n ]);\n}\n"],"names":["useChatActions","useDefaultHandleApiError","useChatState","useState","useEffect"],"mappings":";;;;;;AAIA;;;;;;;;;;AAUG;AACG,SAAU,sBAAsB,CACpC,WAAkC,EAClC,MAAM,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CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,KAAC,EAAE;QACD,IAAI;QACJ,MAAM;QACN,WAAW;QACX,qBAAqB;QACrB,mBAAmB;QACnB,cAAc;QACd,eAAe;AAChB,KAAA,CAAC,CAAC;AACL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReportAnalyticsEvent.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useReportAnalyticsEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,2BAA2B,CAAC;AAIzE
|
|
1
|
+
{"version":3,"file":"useReportAnalyticsEvent.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useReportAnalyticsEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,2BAA2B,CAAC;AAIzE;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,YAAY,CAAC,QAAQ,CAAC,CAMhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReportAnalyticsEvent.js","sources":["../../../../src/hooks/useReportAnalyticsEvent.ts"],"sourcesContent":["import { ChatHeadless, useChatActions } from \"@yext/chat-headless-react\";\nimport { version } from \"../../package.json\";\nimport { useCallback } from \"react\";\n\n/**\n * Returns a function to send requests to Yext Analytics API.\n
|
|
1
|
+
{"version":3,"file":"useReportAnalyticsEvent.js","sources":["../../../../src/hooks/useReportAnalyticsEvent.ts"],"sourcesContent":["import { ChatHeadless, useChatActions } from \"@yext/chat-headless-react\";\nimport { version } from \"../../package.json\";\nimport { useCallback } from \"react\";\n\n/**\n * Returns a function to send requests to Yext Analytics API.\n *\n * @public\n */\nexport function useReportAnalyticsEvent(): ChatHeadless[\"report\"] {\n const chat = useChatActions();\n chat.addClientSdk({\n CHAT_UI_REACT: version,\n });\n return useCallback((payload) => chat.report(payload), [chat]);\n}\n"],"names":["useChatActions","version","useCallback"],"mappings":";;;;;;AAIA;;;;AAIG;SACa,uBAAuB,GAAA;AACrC,IAAA,MAAM,IAAI,GAAGA,gCAAc,EAAE,CAAC;IAC9B,IAAI,CAAC,YAAY,CAAC;AAChB,QAAA,aAAa,EAAEC,gBAAO;AACvB,KAAA,CAAC,CAAC;AACH,IAAA,OAAOC,iBAAW,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE;;;;"}
|
|
@@ -5,13 +5,8 @@ var ChatHeader = require('./components/ChatHeader.js');
|
|
|
5
5
|
var MessageBubble = require('./components/MessageBubble.js');
|
|
6
6
|
var ChatPanel = require('./components/ChatPanel.js');
|
|
7
7
|
var ChatPopUp = require('./components/ChatPopUp.js');
|
|
8
|
-
var FeedbackButtons = require('./components/FeedbackButtons.js');
|
|
9
|
-
var Markdown = require('./components/Markdown.js');
|
|
10
8
|
var useComposedCssClasses = require('./hooks/useComposedCssClasses.js');
|
|
11
|
-
var useDefaultHandleApiError = require('./hooks/useDefaultHandleApiError.js');
|
|
12
|
-
var useFetchInitialMessage = require('./hooks/useFetchInitialMessage.js');
|
|
13
9
|
var useReportAnalyticsEvent = require('./hooks/useReportAnalyticsEvent.js');
|
|
14
|
-
var useScrollToLastMessage = require('./hooks/useScrollToLastMessage.js');
|
|
15
10
|
|
|
16
11
|
|
|
17
12
|
|
|
@@ -20,11 +15,6 @@ exports.ChatHeader = ChatHeader.ChatHeader;
|
|
|
20
15
|
exports.MessageBubble = MessageBubble.MessageBubble;
|
|
21
16
|
exports.ChatPanel = ChatPanel.ChatPanel;
|
|
22
17
|
exports.ChatPopUp = ChatPopUp.ChatPopUp;
|
|
23
|
-
exports.FeedbackButtons = FeedbackButtons.FeedbackButtons;
|
|
24
|
-
exports.Markdown = Markdown.Markdown;
|
|
25
18
|
exports.useComposedCssClasses = useComposedCssClasses.useComposedCssClasses;
|
|
26
|
-
exports.useDefaultHandleApiError = useDefaultHandleApiError.useDefaultHandleApiError;
|
|
27
|
-
exports.useFetchInitialMessage = useFetchInitialMessage.useFetchInitialMessage;
|
|
28
19
|
exports.useReportAnalyticsEvent = useReportAnalyticsEvent.useReportAnalyticsEvent;
|
|
29
|
-
exports.useScrollToLastMessage = useScrollToLastMessage.useScrollToLastMessage;
|
|
30
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatHeadless } from '@yext/chat-headless-react';
|
|
2
2
|
import { Message } from '@yext/chat-headless-react';
|
|
3
3
|
import { default as React_2 } from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A component that renders the header of a chat bot panel,
|
|
@@ -133,6 +134,7 @@ export declare interface ChatPanelCssClasses {
|
|
|
133
134
|
inputContainer?: string;
|
|
134
135
|
inputCssClasses?: ChatInputCssClasses;
|
|
135
136
|
messageBubbleCssClasses?: MessageBubbleCssClasses;
|
|
137
|
+
messageSuggestionClasses?: MessageSuggestionCssClasses;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
/**
|
|
@@ -141,14 +143,17 @@ export declare interface ChatPanelCssClasses {
|
|
|
141
143
|
* @public
|
|
142
144
|
*/
|
|
143
145
|
export declare interface ChatPanelProps extends Omit<MessageBubbleProps, "customCssClasses" | "message">, Omit<ChatInputProps, "customCssClasses"> {
|
|
144
|
-
/** A
|
|
145
|
-
header?:
|
|
146
|
-
/** A custom input component to render at the bottom of the panel. */
|
|
147
|
-
input?: JSX.Element;
|
|
146
|
+
/** A header to render at the top of the panel. */
|
|
147
|
+
header?: ReactNode;
|
|
148
148
|
/**
|
|
149
149
|
* CSS classes for customizing the component styling.
|
|
150
150
|
*/
|
|
151
151
|
customCssClasses?: ChatPanelCssClasses;
|
|
152
|
+
/**
|
|
153
|
+
* A set of pre-written initial messages that the user
|
|
154
|
+
* can click on instead of typing their own.
|
|
155
|
+
*/
|
|
156
|
+
messageSuggestions?: string[];
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
/**
|
|
@@ -189,7 +194,7 @@ export declare interface ChatPopUpCssClasses {
|
|
|
189
194
|
*
|
|
190
195
|
* @public
|
|
191
196
|
*/
|
|
192
|
-
export declare interface ChatPopUpProps extends Omit<ChatHeaderProps, "showCloseButton" | "customCssClasses">, Omit<ChatPanelProps, "header" | "
|
|
197
|
+
export declare interface ChatPopUpProps extends Omit<ChatHeaderProps, "showCloseButton" | "customCssClasses">, Omit<ChatPanelProps, "header" | "customCssClasses"> {
|
|
193
198
|
/** Custom icon for the popup button to open the panel. */
|
|
194
199
|
openPanelButtonIcon?: JSX.Element;
|
|
195
200
|
/** CSS classes for customizing the component styling. */
|
|
@@ -219,14 +224,6 @@ export declare interface ChatPopUpProps extends Omit<ChatHeaderProps, "showClose
|
|
|
219
224
|
ctaLabel?: string;
|
|
220
225
|
}
|
|
221
226
|
|
|
222
|
-
/**
|
|
223
|
-
* Displays feedback buttons (e.g. thumbs up and thumbs down) that will
|
|
224
|
-
* report analytic events on click.
|
|
225
|
-
*
|
|
226
|
-
* @public
|
|
227
|
-
*/
|
|
228
|
-
export declare function FeedbackButtons({ customCssClasses, responseId, }: FeedbackButtonsProps): React_2.JSX.Element;
|
|
229
|
-
|
|
230
227
|
/**
|
|
231
228
|
* The CSS class interface for the FeedbackButtons component.
|
|
232
229
|
*
|
|
@@ -242,18 +239,6 @@ export declare interface FeedbackButtonsCssClasses {
|
|
|
242
239
|
thumbsDownFillIcon?: string;
|
|
243
240
|
}
|
|
244
241
|
|
|
245
|
-
/**
|
|
246
|
-
* The props for the FeedbackButtons component.
|
|
247
|
-
*
|
|
248
|
-
* @public
|
|
249
|
-
*/
|
|
250
|
-
export declare interface FeedbackButtonsProps {
|
|
251
|
-
/** The response ID correlates to the current message to give feedback on. */
|
|
252
|
-
responseId?: string;
|
|
253
|
-
/** CSS classes for customizing the component styling. */
|
|
254
|
-
customCssClasses?: FeedbackButtonsCssClasses;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
242
|
/**
|
|
258
243
|
* The CSS class interface for the InitialMessagePopUp component.
|
|
259
244
|
*
|
|
@@ -266,31 +251,6 @@ export declare interface InitialMessagePopUpCssClasses {
|
|
|
266
251
|
message?: string;
|
|
267
252
|
}
|
|
268
253
|
|
|
269
|
-
/**
|
|
270
|
-
* Renders Github-Flavored Markdown from the Knowledge Graph. This Markdown can include
|
|
271
|
-
* arbitrary HTML. Any HTML will be sanitized according to Rehype's default Schema.
|
|
272
|
-
*
|
|
273
|
-
* @remarks
|
|
274
|
-
* A link click will send a CHAT_LINK_CLICK analytics event
|
|
275
|
-
*
|
|
276
|
-
* @public
|
|
277
|
-
*/
|
|
278
|
-
export declare function Markdown({ content, responseId, className }: MarkdownProps): React_2.JSX.Element;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* The props for the {@link Markdown} component.
|
|
282
|
-
*
|
|
283
|
-
* @public
|
|
284
|
-
*/
|
|
285
|
-
export declare interface MarkdownProps {
|
|
286
|
-
/** Stringified markdown. */
|
|
287
|
-
content: string;
|
|
288
|
-
/** The response ID correlates to the current message. */
|
|
289
|
-
responseId?: string;
|
|
290
|
-
/** Classnames for the container. */
|
|
291
|
-
className?: string;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
254
|
/**
|
|
295
255
|
* A component that displays the provided message.
|
|
296
256
|
*
|
|
@@ -350,6 +310,26 @@ export declare interface MessageBubbleProps {
|
|
|
350
310
|
customCssClasses?: MessageBubbleCssClasses;
|
|
351
311
|
}
|
|
352
312
|
|
|
313
|
+
/**
|
|
314
|
+
* The CSS class interface for the MessageSuggestion component.
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
export declare interface MessageSuggestionCssClasses {
|
|
319
|
+
container?: string;
|
|
320
|
+
suggestion?: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The props for the MessageSuggestions component.
|
|
325
|
+
*
|
|
326
|
+
* @public
|
|
327
|
+
*/
|
|
328
|
+
export declare interface MessageSuggestionsProps {
|
|
329
|
+
suggestions: string[];
|
|
330
|
+
customCssClasses?: MessageSuggestionCssClasses;
|
|
331
|
+
}
|
|
332
|
+
|
|
353
333
|
/**
|
|
354
334
|
* useComposedCssClasses merges a component's built-in tailwind classes with custom tailwind classes.
|
|
355
335
|
*
|
|
@@ -380,48 +360,11 @@ export declare interface MessageBubbleProps {
|
|
|
380
360
|
*/
|
|
381
361
|
export declare function useComposedCssClasses<ClassInterface extends Partial<Record<keyof ClassInterface, string | object>>>(builtInClasses: Readonly<ClassInterface>, customClasses?: Partial<ClassInterface>): ClassInterface;
|
|
382
362
|
|
|
383
|
-
/**
|
|
384
|
-
* Returns a default handler function for API errors. It will log the error and
|
|
385
|
-
* add a default error message to state.
|
|
386
|
-
*
|
|
387
|
-
* @public
|
|
388
|
-
*/
|
|
389
|
-
export declare function useDefaultHandleApiError(): (e: unknown) => void;
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Sends a request to Chat API to fetch the initial message when the
|
|
393
|
-
* conversation first start or when the message history is reset.
|
|
394
|
-
*
|
|
395
|
-
* @public
|
|
396
|
-
*
|
|
397
|
-
* @param handleError - A function which is called when an error occurs while fetching for initial message.
|
|
398
|
-
* By default, the error is logged to the console and an error message is added to state.
|
|
399
|
-
* @param stream - Enable streaming behavior by making a request to Chat Streaming API. Defaults to false.
|
|
400
|
-
* @param customCondition - additional condition for when to fetch initial message
|
|
401
|
-
*/
|
|
402
|
-
export declare function useFetchInitialMessage(handleError?: (e: unknown) => void, stream?: boolean, customCondition?: boolean): void;
|
|
403
|
-
|
|
404
363
|
/**
|
|
405
364
|
* Returns a function to send requests to Yext Analytics API.
|
|
406
|
-
* The payload will automatically includes chat-ui-react's
|
|
407
|
-
* package version for "clientSdk" field.
|
|
408
365
|
*
|
|
409
366
|
* @public
|
|
410
367
|
*/
|
|
411
368
|
export declare function useReportAnalyticsEvent(): ChatHeadless["report"];
|
|
412
369
|
|
|
413
|
-
/**
|
|
414
|
-
* Scroll the messsages container to the top of the last message whenever there's
|
|
415
|
-
* an update to the messages state.
|
|
416
|
-
*
|
|
417
|
-
* @public
|
|
418
|
-
*
|
|
419
|
-
* @returns a ref to set on the messages container element and
|
|
420
|
-
* a function to set ref on individual message element
|
|
421
|
-
*/
|
|
422
|
-
export declare function useScrollToLastMessage(): [
|
|
423
|
-
React_2.RefObject<HTMLDivElement>,
|
|
424
|
-
(index: number) => ((message: HTMLDivElement) => void) | undefined
|
|
425
|
-
];
|
|
426
|
-
|
|
427
370
|
export { }
|
package/lib/esm/package.json.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import React, { useState, useCallback } from 'react';
|
|
|
2
2
|
import { useChatActions, useChatState } from '@yext/chat-headless-react';
|
|
3
3
|
import { ArrowIcon } from '../icons/Arrow.mjs';
|
|
4
4
|
import { useComposedCssClasses } from '../hooks/useComposedCssClasses.mjs';
|
|
5
|
-
import { useDefaultHandleApiError } from '../hooks/useDefaultHandleApiError.mjs';
|
|
6
5
|
import TextareaAutosize from 'react-textarea-autosize';
|
|
6
|
+
import { useDefaultHandleApiError } from '../hooks/useDefaultHandleApiError.mjs';
|
|
7
7
|
import { withStylelessCssClasses } from '../utils/withStylelessCssClasses.mjs';
|
|
8
8
|
|
|
9
9
|
const builtInCssClasses = withStylelessCssClasses("Input", {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import { MessageBubbleCssClasses, MessageBubbleProps } from "./MessageBubble";
|
|
3
3
|
import { ChatInputCssClasses, ChatInputProps } from "./ChatInput";
|
|
4
|
+
import { MessageSuggestionCssClasses } from "./MessageSuggestions";
|
|
4
5
|
/**
|
|
5
6
|
* The CSS class interface for the {@link ChatPanel} component.
|
|
6
7
|
*
|
|
@@ -13,6 +14,7 @@ export interface ChatPanelCssClasses {
|
|
|
13
14
|
inputContainer?: string;
|
|
14
15
|
inputCssClasses?: ChatInputCssClasses;
|
|
15
16
|
messageBubbleCssClasses?: MessageBubbleCssClasses;
|
|
17
|
+
messageSuggestionClasses?: MessageSuggestionCssClasses;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* The props for the {@link ChatPanel} component.
|
|
@@ -20,14 +22,17 @@ export interface ChatPanelCssClasses {
|
|
|
20
22
|
* @public
|
|
21
23
|
*/
|
|
22
24
|
export interface ChatPanelProps extends Omit<MessageBubbleProps, "customCssClasses" | "message">, Omit<ChatInputProps, "customCssClasses"> {
|
|
23
|
-
/** A
|
|
24
|
-
header?:
|
|
25
|
-
/** A custom input component to render at the bottom of the panel. */
|
|
26
|
-
input?: JSX.Element;
|
|
25
|
+
/** A header to render at the top of the panel. */
|
|
26
|
+
header?: ReactNode;
|
|
27
27
|
/**
|
|
28
28
|
* CSS classes for customizing the component styling.
|
|
29
29
|
*/
|
|
30
30
|
customCssClasses?: ChatPanelCssClasses;
|
|
31
|
+
/**
|
|
32
|
+
* A set of pre-written initial messages that the user
|
|
33
|
+
* can click on instead of typing their own.
|
|
34
|
+
*/
|
|
35
|
+
messageSuggestions?: string[];
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* A component that renders a full panel for chat bot interactions. This includes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/ChatPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/ChatPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAa,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7E,OAAO,EACL,2BAA2B,EAE5B,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,wBAAwB,CAAC,EAAE,2BAA2B,CAAC;CACxD;AAeD;;;;GAIG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,CAAC,EAC9D,IAAI,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAC1C,kDAAkD;IAClD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IACvC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAoF9C"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useCallback } from 'react';
|
|
2
2
|
import { useChatState } from '@yext/chat-headless-react';
|
|
3
3
|
import { MessageBubble } from './MessageBubble.mjs';
|
|
4
4
|
import { ChatInput } from './ChatInput.mjs';
|
|
5
5
|
import { LoadingDots } from './LoadingDots.mjs';
|
|
6
6
|
import { useComposedCssClasses } from '../hooks/useComposedCssClasses.mjs';
|
|
7
|
-
import { useFetchInitialMessage } from '../hooks/useFetchInitialMessage.mjs';
|
|
8
7
|
import { useReportAnalyticsEvent } from '../hooks/useReportAnalyticsEvent.mjs';
|
|
9
|
-
import { useScrollToLastMessage } from '../hooks/useScrollToLastMessage.mjs';
|
|
10
8
|
import { withStylelessCssClasses } from '../utils/withStylelessCssClasses.mjs';
|
|
9
|
+
import { useFetchInitialMessage } from '../hooks/useFetchInitialMessage.mjs';
|
|
10
|
+
import { MessageSuggestions } from './MessageSuggestions.mjs';
|
|
11
11
|
|
|
12
12
|
const builtInCssClasses = withStylelessCssClasses("Panel", {
|
|
13
13
|
container: "h-full w-full flex flex-col relative shadow-2xl bg-white",
|
|
@@ -28,27 +28,60 @@ const builtInCssClasses = withStylelessCssClasses("Panel", {
|
|
|
28
28
|
* @param props - {@link ChatPanelProps}
|
|
29
29
|
*/
|
|
30
30
|
function ChatPanel(props) {
|
|
31
|
-
const { header,
|
|
31
|
+
const { header, customCssClasses, stream, handleError, messageSuggestions } = props;
|
|
32
32
|
const messages = useChatState((state) => state.conversation.messages);
|
|
33
33
|
const loading = useChatState((state) => state.conversation.isLoading);
|
|
34
34
|
const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);
|
|
35
35
|
const reportAnalyticsEvent = useReportAnalyticsEvent();
|
|
36
36
|
useFetchInitialMessage(handleError, stream);
|
|
37
|
-
const [messagesContainerRef, setMessageRef] = useScrollToLastMessage();
|
|
38
37
|
useEffect(() => {
|
|
39
38
|
reportAnalyticsEvent({
|
|
40
39
|
action: "CHAT_IMPRESSION",
|
|
41
40
|
});
|
|
42
41
|
}, [reportAnalyticsEvent]);
|
|
42
|
+
const suggestions = useMemo(() => {
|
|
43
|
+
if (messages.length === 0 ||
|
|
44
|
+
(messages.length === 1 && messages[0].source === "BOT")) {
|
|
45
|
+
return messageSuggestions;
|
|
46
|
+
}
|
|
47
|
+
// TODO: Chat API will send suggestions in the message notes eventually; add that here. [CLIP-852]
|
|
48
|
+
return null;
|
|
49
|
+
}, [messages, messageSuggestions]);
|
|
50
|
+
const messagesRef = useRef([]);
|
|
51
|
+
const messagesContainer = useRef(null);
|
|
52
|
+
// Handle scrolling when messages change
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
let scrollTop = 0;
|
|
55
|
+
messagesRef.current = messagesRef.current.slice(0, messages.length);
|
|
56
|
+
// Sums up scroll heights of all messages except the last one
|
|
57
|
+
if (messagesRef?.current.length > 1) {
|
|
58
|
+
scrollTop = messagesRef.current
|
|
59
|
+
.slice(0, -1)
|
|
60
|
+
.map((elem, _) => elem?.scrollHeight ?? 0)
|
|
61
|
+
.reduce((total, height) => total + height);
|
|
62
|
+
}
|
|
63
|
+
// Scroll to the top of the last message
|
|
64
|
+
messagesContainer.current?.scroll({
|
|
65
|
+
top: scrollTop,
|
|
66
|
+
behavior: "smooth",
|
|
67
|
+
});
|
|
68
|
+
}, [messages]);
|
|
69
|
+
const setMessagesRef = useCallback((index) => {
|
|
70
|
+
if (!messagesRef?.current)
|
|
71
|
+
return null;
|
|
72
|
+
return (message) => (messagesRef.current[index] = message);
|
|
73
|
+
}, []);
|
|
43
74
|
return (React.createElement("div", { className: "yext-chat w-full h-full" },
|
|
44
75
|
React.createElement("div", { className: cssClasses.container },
|
|
45
76
|
header,
|
|
46
77
|
React.createElement("div", { className: cssClasses.messagesScrollContainer },
|
|
47
|
-
React.createElement("div", { ref:
|
|
48
|
-
messages.map((message, index) => (React.createElement("div", { key: index, ref:
|
|
78
|
+
React.createElement("div", { ref: messagesContainer, className: cssClasses.messagesContainer },
|
|
79
|
+
messages.map((message, index) => (React.createElement("div", { key: index, ref: setMessagesRef(index) },
|
|
49
80
|
React.createElement(MessageBubble, { ...props, customCssClasses: cssClasses.messageBubbleCssClasses, message: message })))),
|
|
50
|
-
loading && React.createElement(LoadingDots, null)
|
|
51
|
-
|
|
81
|
+
loading && React.createElement(LoadingDots, null),
|
|
82
|
+
suggestions && (React.createElement(MessageSuggestions, { suggestions: suggestions, customCssClasses: cssClasses.messageSuggestionClasses })))),
|
|
83
|
+
React.createElement("div", { className: cssClasses.inputContainer },
|
|
84
|
+
React.createElement(ChatInput, { ...props, customCssClasses: cssClasses.inputCssClasses })))));
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
export { ChatPanel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatPanel.mjs","sources":["../../../../src/components/ChatPanel.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"ChatPanel.mjs","sources":["../../../../src/components/ChatPanel.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { useChatState } from \"@yext/chat-headless-react\";\nimport {\n MessageBubble,\n MessageBubbleCssClasses,\n MessageBubbleProps,\n} from \"./MessageBubble\";\nimport { ChatInput, ChatInputCssClasses, ChatInputProps } from \"./ChatInput\";\nimport { LoadingDots } from \"./LoadingDots\";\nimport { useComposedCssClasses } from \"../hooks\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { useReportAnalyticsEvent } from \"../hooks/useReportAnalyticsEvent\";\nimport { useFetchInitialMessage } from \"../hooks/useFetchInitialMessage\";\nimport {\n MessageSuggestionCssClasses,\n MessageSuggestions,\n} from \"./MessageSuggestions\";\n\n/**\n * The CSS class interface for the {@link ChatPanel} component.\n *\n * @public\n */\nexport interface ChatPanelCssClasses {\n container?: string;\n messagesContainer?: string;\n messagesScrollContainer?: string;\n inputContainer?: string;\n inputCssClasses?: ChatInputCssClasses;\n messageBubbleCssClasses?: MessageBubbleCssClasses;\n messageSuggestionClasses?: MessageSuggestionCssClasses;\n}\n\nconst builtInCssClasses: ChatPanelCssClasses = withStylelessCssClasses(\n \"Panel\",\n {\n container: \"h-full w-full flex flex-col relative shadow-2xl bg-white\",\n messagesScrollContainer: \"flex flex-col mt-auto overflow-hidden\",\n messagesContainer: \"flex flex-col gap-y-1 px-4 overflow-auto\",\n inputContainer: \"w-full p-4\",\n messageBubbleCssClasses: {\n topContainer: \"first:mt-4\",\n },\n }\n);\n\n/**\n * The props for the {@link ChatPanel} component.\n *\n * @public\n */\nexport interface ChatPanelProps\n extends Omit<MessageBubbleProps, \"customCssClasses\" | \"message\">,\n Omit<ChatInputProps, \"customCssClasses\"> {\n /** A header to render at the top of the panel. */\n header?: ReactNode;\n /**\n * CSS classes for customizing the component styling.\n */\n customCssClasses?: ChatPanelCssClasses;\n /**\n * A set of pre-written initial messages that the user\n * can click on instead of typing their own.\n */\n messageSuggestions?: string[];\n}\n\n/**\n * A component that renders a full panel for chat bot interactions. This includes\n * the message bubbles for the conversation, input box with send button, and header\n * (if provided).\n *\n * @public\n *\n * @param props - {@link ChatPanelProps}\n */\nexport function ChatPanel(props: ChatPanelProps) {\n const { header, customCssClasses, stream, handleError, messageSuggestions } =\n props;\n const messages = useChatState((state) => state.conversation.messages);\n const loading = useChatState((state) => state.conversation.isLoading);\n const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);\n const reportAnalyticsEvent = useReportAnalyticsEvent();\n useFetchInitialMessage(handleError, stream);\n\n useEffect(() => {\n reportAnalyticsEvent({\n action: \"CHAT_IMPRESSION\",\n });\n }, [reportAnalyticsEvent]);\n\n const suggestions = useMemo(() => {\n if (\n messages.length === 0 ||\n (messages.length === 1 && messages[0].source === \"BOT\")\n ) {\n return messageSuggestions;\n }\n // TODO: Chat API will send suggestions in the message notes eventually; add that here. [CLIP-852]\n return null;\n }, [messages, messageSuggestions]);\n\n const messagesRef = useRef<Array<HTMLDivElement | null>>([]);\n const messagesContainer = useRef<HTMLDivElement>(null);\n\n // Handle scrolling when messages change\n useEffect(() => {\n let scrollTop = 0;\n messagesRef.current = messagesRef.current.slice(0, messages.length);\n\n // Sums up scroll heights of all messages except the last one\n if (messagesRef?.current.length > 1) {\n scrollTop = messagesRef.current\n .slice(0, -1)\n .map((elem, _) => elem?.scrollHeight ?? 0)\n .reduce((total, height) => total + height);\n }\n\n // Scroll to the top of the last message\n messagesContainer.current?.scroll({\n top: scrollTop,\n behavior: \"smooth\",\n });\n }, [messages]);\n\n const setMessagesRef = useCallback((index) => {\n if (!messagesRef?.current) return null;\n return (message) => (messagesRef.current[index] = message);\n }, []);\n\n return (\n <div className=\"yext-chat w-full h-full\">\n <div className={cssClasses.container}>\n {header}\n <div className={cssClasses.messagesScrollContainer}>\n <div ref={messagesContainer} className={cssClasses.messagesContainer}>\n {messages.map((message, index) => (\n <div key={index} ref={setMessagesRef(index)}>\n <MessageBubble\n {...props}\n customCssClasses={cssClasses.messageBubbleCssClasses}\n message={message}\n />\n </div>\n ))}\n {loading && <LoadingDots />}\n {suggestions && (\n <MessageSuggestions\n suggestions={suggestions}\n customCssClasses={cssClasses.messageSuggestionClasses}\n />\n )}\n </div>\n </div>\n <div className={cssClasses.inputContainer}>\n <ChatInput {...props} customCssClasses={cssClasses.inputCssClasses} />\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAuCA,MAAM,iBAAiB,GAAwB,uBAAuB,CACpE,OAAO,EACP;AACE,IAAA,SAAS,EAAE,0DAA0D;AACrE,IAAA,uBAAuB,EAAE,uCAAuC;AAChE,IAAA,iBAAiB,EAAE,0CAA0C;AAC7D,IAAA,cAAc,EAAE,YAAY;AAC5B,IAAA,uBAAuB,EAAE;AACvB,QAAA,YAAY,EAAE,YAAY;AAC3B,KAAA;AACF,CAAA,CACF,CAAC;AAuBF;;;;;;;;AAQG;AACG,SAAU,SAAS,CAAC,KAAqB,EAAA;AAC7C,IAAA,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,GACzE,KAAK,CAAC;AACR,IAAA,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACtE,IAAA,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,Y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UAAU,CAAC,uBAAuB,EACpD,OAAO,EAAE,OAAO,EAChB,CAAA,CACE,CACP,CAAC;oBACD,OAAO,IAAI,KAAC,CAAA,aAAA,CAAA,WAAW,EAAG,IAAA,CAAA;AAC1B,oBAAA,WAAW,KACV,KAAA,CAAA,aAAA,CAAC,kBAAkB,EAAA,EACjB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,UAAU,CAAC,wBAAwB,EACrD,CAAA,CACH,CACG,CACF;AACN,YAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,cAAc,EAAA;AACvC,gBAAA,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EAAA,GAAK,KAAK,EAAE,gBAAgB,EAAE,UAAU,CAAC,eAAe,EAAI,CAAA,CAClE,CACF,CACF,EACN;AACJ;;;;"}
|
|
@@ -29,7 +29,7 @@ export interface ChatPopUpCssClasses {
|
|
|
29
29
|
*
|
|
30
30
|
* @public
|
|
31
31
|
*/
|
|
32
|
-
export interface ChatPopUpProps extends Omit<ChatHeaderProps, "showCloseButton" | "customCssClasses">, Omit<ChatPanelProps, "header" | "
|
|
32
|
+
export interface ChatPopUpProps extends Omit<ChatHeaderProps, "showCloseButton" | "customCssClasses">, Omit<ChatPanelProps, "header" | "customCssClasses"> {
|
|
33
33
|
/** Custom icon for the popup button to open the panel. */
|
|
34
34
|
openPanelButtonIcon?: JSX.Element;
|
|
35
35
|
/** CSS classes for customizing the component styling. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatPopUp.d.ts","sourceRoot":"","sources":["../../../../src/components/ChatPopUp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAa,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAEL,oBAAoB,EACpB,eAAe,EAChB,MAAM,cAAc,CAAC;AAKtB,OAAO,EAEL,6BAA6B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|
6
6
|
import { useComposedCssClasses } from '../hooks/useComposedCssClasses.mjs';
|
|
7
|
-
import { useChatState } from '@yext/chat-headless-react';
|
|
8
|
-
import { useFetchInitialMessage } from '../hooks/useFetchInitialMessage.mjs';
|
|
9
7
|
import { useReportAnalyticsEvent } from '../hooks/useReportAnalyticsEvent.mjs';
|
|
10
8
|
import { withStylelessCssClasses } from '../utils/withStylelessCssClasses.mjs';
|
|
11
9
|
import { InitialMessagePopUp } from './InitialMessagePopUp.mjs';
|
|
10
|
+
import { useChatState } from '@yext/chat-headless-react';
|
|
11
|
+
import { useFetchInitialMessage } from '../hooks/useFetchInitialMessage.mjs';
|
|
12
12
|
|
|
13
13
|
const fixedPosition = "fixed bottom-6 right-4 lg:bottom-14 lg:right-10 z-50 ";
|
|
14
14
|
const builtInCssClasses = withStylelessCssClasses("PopUp", {
|