@box/box-ai-content-answers 2.1.38 → 2.1.39
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/dist/chunks/answer-content.js +1 -32
- package/dist/chunks/answer.js +1 -183
- package/dist/chunks/box-ai-content-answers.js +1 -78
- package/dist/chunks/chat.js +1 -116
- package/dist/chunks/citation.js +1 -124
- package/dist/chunks/clear-conversation-button.js +1 -37
- package/dist/chunks/content.js +1 -89
- package/dist/chunks/content2.js +1 -213
- package/dist/chunks/contextual-items-message.js +1 -43
- package/dist/chunks/embed-the-answer-button.js +1 -52
- package/dist/chunks/feedback-tooltip.js +1 -130
- package/dist/chunks/footer-actions.js +1 -44
- package/dist/chunks/inline-error.js +1 -63
- package/dist/chunks/items-dropdown.js +1 -67
- package/dist/chunks/markdown.js +6 -6776
- package/dist/chunks/markdown.module.js +1 -13
- package/dist/chunks/media-container.js +1 -32
- package/dist/chunks/question.js +1 -29
- package/dist/chunks/references.js +1 -43
- package/dist/chunks/stopResponseButton.js +1 -45
- package/dist/chunks/suggested-questions.js +1 -70
- package/dist/chunks/suggestions.js +1 -35
- package/dist/chunks/thinkingBubble.js +1 -111
- package/dist/chunks/thumb-buttons.js +1 -103
- package/dist/chunks/types.js +1 -14
- package/dist/chunks/unsupported-items-notice.js +1 -25
- package/dist/chunks/warning-message.js +1 -21
- package/dist/esm/index.js +1 -11
- package/dist/esm/lib/box-ai-content-answers.js +1 -2
- package/dist/esm/lib/components/answer/answer-content.js +1 -2
- package/dist/esm/lib/components/answer/answer.js +1 -2
- package/dist/esm/lib/components/answer/citation.js +1 -2
- package/dist/esm/lib/components/answer/constants.js +1 -2
- package/dist/esm/lib/components/answer/copy-button.js +1 -46
- package/dist/esm/lib/components/answer/embed-the-answer-button.js +1 -2
- package/dist/esm/lib/components/answer/feedback-tooltip.js +1 -2
- package/dist/esm/lib/components/answer/inline-error.js +1 -2
- package/dist/esm/lib/components/answer/loading-indicator.js +1 -29
- package/dist/esm/lib/components/answer/messages.js +1 -148
- package/dist/esm/lib/components/answer/no-citations.js +1 -29
- package/dist/esm/lib/components/answer/references.js +1 -2
- package/dist/esm/lib/components/answer/thumb-buttons.js +1 -2
- package/dist/esm/lib/components/api-wrapper/actions.js +1 -2
- package/dist/esm/lib/components/api-wrapper/api-wrapper.js +1 -8
- package/dist/esm/lib/components/api-wrapper/constants.js +1 -30
- package/dist/esm/lib/components/api-wrapper/content-answers-component.js +1 -83
- package/dist/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +1 -211
- package/dist/esm/lib/components/api-wrapper/records.js +1 -38
- package/dist/esm/lib/components/api-wrapper/reducer.js +1 -42
- package/dist/esm/lib/components/api-wrapper/utils/format.js +1 -13
- package/dist/esm/lib/components/api-wrapper/utils/request.js +1 -12
- package/dist/esm/lib/components/api-wrapper/utils/stream.js +2 -116
- package/dist/esm/lib/components/api-wrapper/utils/typed-record.js +1 -3
- package/dist/esm/lib/components/chat/chat.js +1 -2
- package/dist/esm/lib/components/chat/index.js +1 -2
- package/dist/esm/lib/components/common/agentUtils.js +1 -5
- package/dist/esm/lib/components/common/constants.js +1 -19
- package/dist/esm/lib/components/common/focusInputUtils.js +1 -5
- package/dist/esm/lib/components/common/inline-citation.js +1 -24
- package/dist/esm/lib/components/common/keyInputUtils.js +1 -3
- package/dist/esm/lib/components/common/markdown-react.js +1 -97
- package/dist/esm/lib/components/common/markdown.js +1 -2
- package/dist/esm/lib/components/common/media-container.js +1 -2
- package/dist/esm/lib/components/common/mock-data.js +1 -305
- package/dist/esm/lib/components/common/performance.js +1 -3
- package/dist/esm/lib/components/content/content.js +1 -2
- package/dist/esm/lib/components/content/index.js +1 -2
- package/dist/esm/lib/components/footer/constants.js +1 -12
- package/dist/esm/lib/components/footer/footer-actions.js +1 -2
- package/dist/esm/lib/components/footer/footer.js +1 -151
- package/dist/esm/lib/components/footer/index.js +1 -2
- package/dist/esm/lib/components/footer/messages.js +1 -36
- package/dist/esm/lib/components/footer/stopResponseButton.js +1 -2
- package/dist/esm/lib/components/modal/clear-conversation-button.js +1 -2
- package/dist/esm/lib/components/modal/hooks/useEventListeners.js +1 -10
- package/dist/esm/lib/components/modal/hooks/useStopPropagationOnEsc.js +1 -19
- package/dist/esm/lib/components/modal/messages.js +1 -20
- package/dist/esm/lib/components/modal/modal.js +1 -143
- package/dist/esm/lib/components/modal/title.js +1 -14
- package/dist/esm/lib/components/modal-error/index.js +1 -2
- package/dist/esm/lib/components/modal-error/messages.js +1 -16
- package/dist/esm/lib/components/modal-error/modal-error.js +1 -33
- package/dist/esm/lib/components/question/question.js +1 -2
- package/dist/esm/lib/components/sidebar/content.js +1 -2
- package/dist/esm/lib/components/sidebar/context.js +1 -16
- package/dist/esm/lib/components/sidebar/messages.js +1 -28
- package/dist/esm/lib/components/sidebar/sidebar.js +1 -80
- package/dist/esm/lib/components/sidebar/title.js +1 -14
- package/dist/esm/lib/components/suggested-questions/messages.js +1 -16
- package/dist/esm/lib/components/suggested-questions/mocks.js +1 -36
- package/dist/esm/lib/components/suggested-questions/suggested-questions.js +1 -2
- package/dist/esm/lib/components/suggested-questions/suggestions.js +1 -2
- package/dist/esm/lib/components/thinkingBubble/boxAILoadingIndicator.js +11 -277
- package/dist/esm/lib/components/thinkingBubble/messages.js +1 -24
- package/dist/esm/lib/components/thinkingBubble/thinkingBubble.js +1 -2
- package/dist/esm/lib/components/welcome-message/contextual-items-message.js +1 -2
- package/dist/esm/lib/components/welcome-message/items-dropdown.js +1 -2
- package/dist/esm/lib/components/welcome-message/messages.js +10 -52
- package/dist/esm/lib/components/welcome-message/unsupported-items-notice.js +1 -2
- package/dist/esm/lib/components/welcome-message/warning-message.js +1 -2
- package/dist/esm/lib/components/welcome-message/welcome-message.js +1 -53
- package/dist/esm/lib/constants.js +1 -9
- package/dist/esm/lib/hooks/usePromptFocus.js +1 -28
- package/dist/esm/lib/messages.js +1 -56
- package/dist/esm/lib/utils/constants.js +1 -2
- package/dist/esm/lib/utils/inlineCitationsUtils.js +1 -18
- package/package.json +11 -11
package/dist/chunks/content.js
CHANGED
|
@@ -1,89 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { r as t } from "./types.js";
|
|
3
|
-
import { t as n } from "./chat.js";
|
|
4
|
-
import { ModalError as r } from "../esm/lib/components/modal-error/modal-error.js";
|
|
5
|
-
import i from "clsx";
|
|
6
|
-
import * as a from "react";
|
|
7
|
-
import { LoadingIndicator as o } from "@box/blueprint-web";
|
|
8
|
-
import { useIntl as s } from "react-intl";
|
|
9
|
-
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
-
import '../styles/content.css';var d = {
|
|
11
|
-
loadingIndicatorWrapper: "_loadingIndicatorWrapper_1hm4i_27",
|
|
12
|
-
content: "_content_1hm4i_31",
|
|
13
|
-
sidebar: "_sidebar_1hm4i_38",
|
|
14
|
-
isLoading: "_isLoading_1hm4i_45",
|
|
15
|
-
messagesEnd: "_messagesEnd_1hm4i_49",
|
|
16
|
-
innerContent: "_innerContent_1hm4i_53"
|
|
17
|
-
}, f = ({ error: f, hasCustomSuggestedQuestions: p, hasRequestInProgress: m = !1, isErrorMessageShown: h = !1, isStreamingEnabled: g = !1, questions: _, recordAction: v, showLoadingIndicator: y = !1, suggestedQuestions: b, askSuggestedQuestion: x, setAskSuggestedQuestion: S, useAnimation: C, variant: w = "modal", hostAppName: T = "", ...E }) => {
|
|
18
|
-
let D = a.useRef(null), O = a.useRef(null), k = a.useRef(null), A = a.useRef(!0), [j, M] = a.useState(!1), { formatMessage: N } = s(), P = f === t.LARGE_FILE, F = a.useCallback((e) => {
|
|
19
|
-
k.current?.scrollIntoView && O.current && (!g || A.current) && k.current.scrollIntoView({
|
|
20
|
-
behavior: e,
|
|
21
|
-
block: "nearest"
|
|
22
|
-
});
|
|
23
|
-
}, [g]);
|
|
24
|
-
return a.useEffect(() => {
|
|
25
|
-
j ? A.current = !1 : m && (A.current = !0, F("instant"));
|
|
26
|
-
}, [
|
|
27
|
-
j,
|
|
28
|
-
F,
|
|
29
|
-
m
|
|
30
|
-
]), a.useEffect(() => {
|
|
31
|
-
A.current = !0, F("instant");
|
|
32
|
-
}, [F]), a.useLayoutEffect(() => {
|
|
33
|
-
if (!D.current) return;
|
|
34
|
-
let e = new ResizeObserver(() => {
|
|
35
|
-
A.current && F(g ? "instant" : "smooth");
|
|
36
|
-
}), t = D.current;
|
|
37
|
-
return t && e.observe(t), () => {
|
|
38
|
-
t && e.unobserve(t);
|
|
39
|
-
};
|
|
40
|
-
}, [F, g]), /* @__PURE__ */ l("div", {
|
|
41
|
-
ref: O,
|
|
42
|
-
className: i(d.content, w === "sidebar" && d.sidebar, y && d.isLoading),
|
|
43
|
-
"data-testid": "content-answers-content",
|
|
44
|
-
onScroll: () => {
|
|
45
|
-
if (O.current) {
|
|
46
|
-
let { scrollTop: e, clientHeight: t, scrollHeight: n } = O.current, r = n - (e + t);
|
|
47
|
-
if (m && r > 100) {
|
|
48
|
-
A.current = !1;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
A.current = !0;
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
children: /* @__PURE__ */ l("div", {
|
|
55
|
-
ref: D,
|
|
56
|
-
className: d.innerContent,
|
|
57
|
-
children: h && !P ? /* @__PURE__ */ l(r, {
|
|
58
|
-
error: f,
|
|
59
|
-
recordAction: v
|
|
60
|
-
}) : y ? /* @__PURE__ */ l("div", {
|
|
61
|
-
className: d.loadingIndicatorWrapper,
|
|
62
|
-
children: /* @__PURE__ */ l(o, {
|
|
63
|
-
"aria-label": N(e.loading),
|
|
64
|
-
className: d.loadingIndicator,
|
|
65
|
-
"data-testid": "content-answers-modal-loading-indicator",
|
|
66
|
-
size: "large"
|
|
67
|
-
})
|
|
68
|
-
}) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(n, {
|
|
69
|
-
askSuggestedQuestion: x,
|
|
70
|
-
hasCustomSuggestedQuestions: p,
|
|
71
|
-
hasRequestInProgress: m,
|
|
72
|
-
hostAppName: T,
|
|
73
|
-
isFileSizeError: P,
|
|
74
|
-
onDropdownOpenChange: M,
|
|
75
|
-
questions: _,
|
|
76
|
-
recordAction: v,
|
|
77
|
-
setAskSuggestedQuestion: S,
|
|
78
|
-
suggestedQuestions: b,
|
|
79
|
-
useAnimation: C,
|
|
80
|
-
variant: w,
|
|
81
|
-
...E
|
|
82
|
-
}), /* @__PURE__ */ l("div", {
|
|
83
|
-
ref: k,
|
|
84
|
-
className: d.messagesEnd
|
|
85
|
-
})] })
|
|
86
|
-
})
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
export { f as t };
|
|
1
|
+
import messages from"../esm/lib/messages.js";import{r as CONTENT_ERROR}from"./types.js";import{t as Chat}from"./chat.js";import{ModalError}from"../esm/lib/components/modal-error/modal-error.js";import clsx from"clsx";import*as React$1 from"react";import{LoadingIndicator}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import '../styles/content.css';var content_module_default={loadingIndicatorWrapper:`_loadingIndicatorWrapper_1hm4i_27`,content:`_content_1hm4i_31`,sidebar:`_sidebar_1hm4i_38`,isLoading:`_isLoading_1hm4i_45`,messagesEnd:`_messagesEnd_1hm4i_49`,innerContent:`_innerContent_1hm4i_53`},Content=({error,hasCustomSuggestedQuestions,hasRequestInProgress=!1,isErrorMessageShown=!1,isStreamingEnabled=!1,questions,recordAction,showLoadingIndicator=!1,suggestedQuestions,askSuggestedQuestion,setAskSuggestedQuestion,useAnimation,variant=`modal`,hostAppName=``,...rest})=>{let chatRef=React$1.useRef(null),contentRef=React$1.useRef(null),messagesEndRef=React$1.useRef(null),isAutoScrollEnabled=React$1.useRef(!0),[interactiveElemOpen,setInteractiveElemOpen]=React$1.useState(!1),{formatMessage}=useIntl(),isFileSizeError=error===CONTENT_ERROR.LARGE_FILE,handleScrollToBottom=React$1.useCallback(behavior=>{messagesEndRef.current?.scrollIntoView&&contentRef.current&&(!isStreamingEnabled||isAutoScrollEnabled.current)&&messagesEndRef.current.scrollIntoView({behavior,block:`nearest`})},[isStreamingEnabled]);return React$1.useEffect(()=>{interactiveElemOpen?isAutoScrollEnabled.current=!1:hasRequestInProgress&&(isAutoScrollEnabled.current=!0,handleScrollToBottom(`instant`))},[interactiveElemOpen,handleScrollToBottom,hasRequestInProgress]),React$1.useEffect(()=>{isAutoScrollEnabled.current=!0,handleScrollToBottom(`instant`)},[handleScrollToBottom]),React$1.useLayoutEffect(()=>{if(!chatRef.current)return;let resizeObserver=new ResizeObserver(()=>{isAutoScrollEnabled.current&&handleScrollToBottom(isStreamingEnabled?`instant`:`smooth`)}),currentChatRef=chatRef.current;return currentChatRef&&resizeObserver.observe(currentChatRef),()=>{currentChatRef&&resizeObserver.unobserve(currentChatRef)}},[handleScrollToBottom,isStreamingEnabled]),jsx(`div`,{ref:contentRef,className:clsx(content_module_default.content,variant===`sidebar`&&content_module_default.sidebar,showLoadingIndicator&&content_module_default.isLoading),"data-testid":`content-answers-content`,onScroll:()=>{if(contentRef.current){let{scrollTop,clientHeight,scrollHeight}=contentRef.current,threshold=scrollHeight-(scrollTop+clientHeight);if(hasRequestInProgress&&threshold>100){isAutoScrollEnabled.current=!1;return}isAutoScrollEnabled.current=!0}},children:jsx(`div`,{ref:chatRef,className:content_module_default.innerContent,children:isErrorMessageShown&&!isFileSizeError?jsx(ModalError,{error,recordAction}):showLoadingIndicator?jsx(`div`,{className:content_module_default.loadingIndicatorWrapper,children:jsx(LoadingIndicator,{"aria-label":formatMessage(messages.loading),className:content_module_default.loadingIndicator,"data-testid":`content-answers-modal-loading-indicator`,size:`large`})}):jsxs(Fragment,{children:[jsx(Chat,{askSuggestedQuestion,hasCustomSuggestedQuestions,hasRequestInProgress,hostAppName,isFileSizeError,onDropdownOpenChange:setInteractiveElemOpen,questions,recordAction,setAskSuggestedQuestion,suggestedQuestions,useAnimation,variant,...rest}),jsx(`div`,{ref:messagesEndRef,className:content_module_default.messagesEnd})]})})})};export{Content as t};
|
package/dist/chunks/content2.js
CHANGED
|
@@ -1,213 +1 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { EVENT_JS_READY as t, ORIGIN_BOXAI_SIDEBAR as n } from "../esm/lib/components/common/constants.js";
|
|
3
|
-
import r from "../esm/lib/components/api-wrapper/api-wrapper.js";
|
|
4
|
-
import { t as i } from "./clear-conversation-button.js";
|
|
5
|
-
import { IntelligenceModal as a } from "../esm/lib/components/modal/modal.js";
|
|
6
|
-
import { mark as o } from "../esm/lib/components/common/performance.js";
|
|
7
|
-
import { IntelligenceSidebarContext as s } from "../esm/lib/components/sidebar/context.js";
|
|
8
|
-
import c from "../esm/lib/components/sidebar/messages.js";
|
|
9
|
-
import l from "../esm/lib/components/sidebar/title.js";
|
|
10
|
-
import u from "clsx";
|
|
11
|
-
import * as d from "react";
|
|
12
|
-
import { IconButton as f, Text as p, Tooltip as m, useBlueprintModernization as h } from "@box/blueprint-web";
|
|
13
|
-
import { useIntl as ee } from "react-intl";
|
|
14
|
-
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
15
|
-
import { ArrowsMaximize as te } from "@box/blueprint-web-assets/icons/Medium";
|
|
16
|
-
import { ArrowsExpand as ne, XMark as re } from "@box/blueprint-web-assets/icons/Fill";
|
|
17
|
-
import { BoxAiAgentSelectorWithApi as y, useAgents as ie } from "@box/box-ai-agent-selector";
|
|
18
|
-
import b from "lodash/isEqual";
|
|
19
|
-
import '../styles/content2.css';var x = {
|
|
20
|
-
bcsSidebarBase: "_bcsSidebarBase_183mo_2",
|
|
21
|
-
bcsContent: "_bcsContent_183mo_2",
|
|
22
|
-
bcsBoxAISidebar: "_bcsBoxAISidebar_183mo_2",
|
|
23
|
-
bcsContentHeader: "_bcsContentHeader_183mo_6",
|
|
24
|
-
bcsTitle: "_bcsTitle_183mo_15",
|
|
25
|
-
bcsScrollContent: "_bcsScrollContent_183mo_22",
|
|
26
|
-
withModalOpen: "_withModalOpen_183mo_32",
|
|
27
|
-
bcsBoxAISidebarAgentSelector: "_bcsBoxAISidebarAgentSelector_183mo_35",
|
|
28
|
-
bcsBoxAISidebarContent: "_bcsBoxAISidebarContent_183mo_38",
|
|
29
|
-
bcsBoxAISidebarExpand: "_bcsBoxAISidebarExpand_183mo_41",
|
|
30
|
-
bcsBoxAISidebarClear: "_bcsBoxAISidebarClear_183mo_44",
|
|
31
|
-
bcsBoxAISidebarTitlePart: "_bcsBoxAISidebarTitlePart_183mo_47",
|
|
32
|
-
bcsBoxAISidebarClose: "_bcsBoxAISidebarClose_183mo_68",
|
|
33
|
-
bcsContentSubheader: "_bcsContentSubheader_183mo_85",
|
|
34
|
-
bcsScrollContentWrapper: "_bcsScrollContentWrapper_183mo_94"
|
|
35
|
-
};
|
|
36
|
-
o(`${n}_${t}`);
|
|
37
|
-
var ae = ({ actions: e, children: t, className: n, elementId: r = "", sidebarView: i = "", title: a, subheader: o, ...s }) => {
|
|
38
|
-
let c = `${r}${r === "" ? "" : "_"}${i}`, l = `${c}-content`;
|
|
39
|
-
return /* @__PURE__ */ v("div", {
|
|
40
|
-
"aria-labelledby": c,
|
|
41
|
-
className: u(x.bcsContent, n),
|
|
42
|
-
"data-testid": "bcs-content",
|
|
43
|
-
id: l,
|
|
44
|
-
role: "tabpanel",
|
|
45
|
-
...s,
|
|
46
|
-
children: [
|
|
47
|
-
/* @__PURE__ */ v("div", {
|
|
48
|
-
className: x.bcsContentHeader,
|
|
49
|
-
children: [a && /* @__PURE__ */ _(p, {
|
|
50
|
-
as: "h3",
|
|
51
|
-
className: x.bcsTitle,
|
|
52
|
-
children: a
|
|
53
|
-
}), e]
|
|
54
|
-
}),
|
|
55
|
-
o && /* @__PURE__ */ _("div", {
|
|
56
|
-
className: x.bcsContentSubheader,
|
|
57
|
-
children: o
|
|
58
|
-
}),
|
|
59
|
-
/* @__PURE__ */ _("div", {
|
|
60
|
-
className: x.bcsScrollContentWrapper,
|
|
61
|
-
children: /* @__PURE__ */ _("div", {
|
|
62
|
-
className: x.bcsScrollContent,
|
|
63
|
-
children: t
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
function S(t) {
|
|
70
|
-
let { createSession: n, encodedSession: r, onClearAction: o, getAIStudioAgents: p, hasRequestInProgress: S, hostAppName: C, isAIStudioAgentSelectorEnabled: w, isLoading: T, onSelectAgent: E, questions: D, shouldShowLandingPage: O = !0, sendQuestion: k, stopQuestion: A, embedTheAnswerButtonConfig: oe, onClose: j, ...M } = t, { formatMessage: N } = ee(), { enableModernizedComponents: se } = h(), P = d.useRef(!1), [F, I] = d.useState(!1), { cache: L, contentName: R, elementId: ce, fileExtension: le, isFeedbackEnabled: z, isFeedbackFormEnabled: B, isStopResponseEnabled: V, items: H, itemSize: U, onFeedbackFormSubmit: W, onUserInteraction: G, onSelectedAgentCallback: ue, recordAction: K, setCacheValue: q, shouldPreinitSession: J } = d.useContext(s), { agents: de, requestState: fe, selectedAgent: Y } = ie(), { questions: X } = L, [Z, Q] = d.useState("");
|
|
71
|
-
L.shouldShowLandingPage !== O && q("shouldShowLandingPage", O), L.encodedSession !== r && q("encodedSession", r), b(L.questions, D) || q("questions", D), b(L.agents.selectedAgent, Y) || q("agents", {
|
|
72
|
-
agents: de,
|
|
73
|
-
requestState: fe,
|
|
74
|
-
selectedAgent: Y
|
|
75
|
-
});
|
|
76
|
-
let $ = (e = !1) => {
|
|
77
|
-
!J && !r && !T && n && n(!0, !1), e && G && G();
|
|
78
|
-
}, pe = () => {
|
|
79
|
-
I(!1);
|
|
80
|
-
};
|
|
81
|
-
return d.useEffect(() => (J && !r && n && n(!0, !0), r && X.length > 0 && X[X.length - 1].isCompleted === !1 && k({ prompt: X[X.length - 1].prompt }), K && K({
|
|
82
|
-
action: "programmatic",
|
|
83
|
-
component: "sidebar",
|
|
84
|
-
feature: "answers",
|
|
85
|
-
target: "loaded",
|
|
86
|
-
data: { items: H.map((e) => ({
|
|
87
|
-
status: e.status,
|
|
88
|
-
fileType: e.fileType
|
|
89
|
-
})) }
|
|
90
|
-
}), () => {
|
|
91
|
-
A();
|
|
92
|
-
}), []), d.useEffect(() => {
|
|
93
|
-
let e = X[X.length - 1];
|
|
94
|
-
!J && !P.current && r && e?.isLoading && (k(e, Y, !1), P.current = !0);
|
|
95
|
-
}, [r]), /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(ae, {
|
|
96
|
-
actions: /* @__PURE__ */ v(g, { children: [
|
|
97
|
-
/* @__PURE__ */ v("div", {
|
|
98
|
-
className: x.bcsBoxAISidebarTitlePart,
|
|
99
|
-
children: [/* @__PURE__ */ _(l, { isAIStudioAgentSelectorEnabled: w }), w && /* @__PURE__ */ _("div", {
|
|
100
|
-
className: x.bcsBoxAISidebarAgentSelector,
|
|
101
|
-
children: /* @__PURE__ */ _(y, {
|
|
102
|
-
disabled: S,
|
|
103
|
-
fetcher: p,
|
|
104
|
-
hostAppName: C,
|
|
105
|
-
onAgentsListOpen: $,
|
|
106
|
-
onSelectAgent: E,
|
|
107
|
-
onSelectedAgentCallback: ue,
|
|
108
|
-
recordAction: K,
|
|
109
|
-
shouldHideAgentSelectorOnLoad: !0,
|
|
110
|
-
useAgentLocalStorage: !0,
|
|
111
|
-
variant: "sidebar"
|
|
112
|
-
})
|
|
113
|
-
})]
|
|
114
|
-
}),
|
|
115
|
-
/* @__PURE__ */ _(i, {
|
|
116
|
-
className: x.bcsBoxAISidebarClear,
|
|
117
|
-
hasRequestInProgress: S,
|
|
118
|
-
onClick: o
|
|
119
|
-
}),
|
|
120
|
-
/* @__PURE__ */ _(m, {
|
|
121
|
-
content: N(c.sidebarBoxAISwitchToModalView),
|
|
122
|
-
"data-testid": "content-answers-open-modal-tooltip",
|
|
123
|
-
variant: "standard",
|
|
124
|
-
children: /* @__PURE__ */ _(f, {
|
|
125
|
-
"aria-label": N(c.sidebarBoxAISwitchToModalView),
|
|
126
|
-
className: x.bcsBoxAISidebarExpand,
|
|
127
|
-
"data-target-id": "IconButton-expandBoxAISidebar",
|
|
128
|
-
icon: se ? te : ne,
|
|
129
|
-
onClick: () => {
|
|
130
|
-
$(), I(!0);
|
|
131
|
-
},
|
|
132
|
-
size: "small"
|
|
133
|
-
})
|
|
134
|
-
}),
|
|
135
|
-
j && /* @__PURE__ */ _(m, {
|
|
136
|
-
content: N(c.sidebarBoxAIClose),
|
|
137
|
-
"data-testid": "content-answers-close-tooltip",
|
|
138
|
-
variant: "standard",
|
|
139
|
-
children: /* @__PURE__ */ _(f, {
|
|
140
|
-
"aria-label": N(c.sidebarBoxAIClose),
|
|
141
|
-
className: x.bcsBoxAISidebarClose,
|
|
142
|
-
"data-target-id": "IconButton-closeBoxAISidebar",
|
|
143
|
-
icon: re,
|
|
144
|
-
onClick: j,
|
|
145
|
-
size: "small"
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
] }),
|
|
149
|
-
className: u(x.bcsBoxAISidebar, { [x.withModalOpen]: F }),
|
|
150
|
-
elementId: ce,
|
|
151
|
-
sidebarView: "box-ai",
|
|
152
|
-
children: /* @__PURE__ */ _("div", {
|
|
153
|
-
className: x.bcsBoxAISidebarContent,
|
|
154
|
-
children: /* @__PURE__ */ _(e, {
|
|
155
|
-
className: x.bcsBoxAISidebarContentAnswers,
|
|
156
|
-
contentName: R,
|
|
157
|
-
contentType: N(c.sidebarBoxAIContent),
|
|
158
|
-
embedTheAnswerButtonConfig: oe,
|
|
159
|
-
hostAppName: C,
|
|
160
|
-
isAIStudioAgentSelectorEnabled: w,
|
|
161
|
-
isFeedbackEnabled: z,
|
|
162
|
-
isFeedbackFormEnabled: B,
|
|
163
|
-
isStopResponseEnabled: V,
|
|
164
|
-
items: H,
|
|
165
|
-
onFeedbackFormSubmit: W,
|
|
166
|
-
onUserIntentToUseAI: $,
|
|
167
|
-
promptValue: Z,
|
|
168
|
-
questions: D,
|
|
169
|
-
recordAction: K,
|
|
170
|
-
setPromptValue: Q,
|
|
171
|
-
shouldShowLandingPage: L.shouldShowLandingPage,
|
|
172
|
-
showLoadingIndicator: T && J,
|
|
173
|
-
stopQuestion: A,
|
|
174
|
-
submitQuestion: k,
|
|
175
|
-
variant: "sidebar",
|
|
176
|
-
...M
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
}), /* @__PURE__ */ _(a, {
|
|
180
|
-
contentName: R,
|
|
181
|
-
contentType: N(c.sidebarBoxAIContent),
|
|
182
|
-
extension: le,
|
|
183
|
-
getAIStudioAgents: p,
|
|
184
|
-
hasRequestInProgress: S,
|
|
185
|
-
hostAppName: C,
|
|
186
|
-
isAIStudioAgentSelectorEnabled: w,
|
|
187
|
-
isFeedbackEnabled: z,
|
|
188
|
-
isFeedbackFormEnabled: B,
|
|
189
|
-
isStopResponseEnabled: V,
|
|
190
|
-
items: H,
|
|
191
|
-
itemSize: U,
|
|
192
|
-
onClearAction: o,
|
|
193
|
-
onFeedbackFormSubmit: W,
|
|
194
|
-
onOpenChange: pe,
|
|
195
|
-
onSelectAgent: E,
|
|
196
|
-
onUserIntentToUseAI: $,
|
|
197
|
-
open: F,
|
|
198
|
-
promptValue: Z,
|
|
199
|
-
questions: D,
|
|
200
|
-
recordAction: F ? K : void 0,
|
|
201
|
-
setPromptValue: Q,
|
|
202
|
-
shouldShowLandingPage: L.shouldShowLandingPage,
|
|
203
|
-
showLoadingIndicator: !1,
|
|
204
|
-
stopPropagationOnEsc: !0,
|
|
205
|
-
stopQuestion: A,
|
|
206
|
-
submitQuestion: k,
|
|
207
|
-
variant: "collapsible",
|
|
208
|
-
...M,
|
|
209
|
-
shouldRenderProviders: !1
|
|
210
|
-
})] });
|
|
211
|
-
}
|
|
212
|
-
var C = r(S);
|
|
213
|
-
export { C as t };
|
|
1
|
+
import{t as BoxAiContentAnswers}from"./box-ai-content-answers.js";import{EVENT_JS_READY,ORIGIN_BOXAI_SIDEBAR}from"../esm/lib/components/common/constants.js";import withApiWrapper from"../esm/lib/components/api-wrapper/api-wrapper.js";import{t as ClearConversationButton}from"./clear-conversation-button.js";import{IntelligenceModal}from"../esm/lib/components/modal/modal.js";import{mark}from"../esm/lib/components/common/performance.js";import{IntelligenceSidebarContext}from"../esm/lib/components/sidebar/context.js";import messages from"../esm/lib/components/sidebar/messages.js";import IntelligenceSidebarTitle from"../esm/lib/components/sidebar/title.js";import clsx from"clsx";import*as React$1 from"react";import{IconButton,Text,Tooltip,useBlueprintModernization}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import{ArrowsMaximize}from"@box/blueprint-web-assets/icons/Medium";import{ArrowsExpand,XMark}from"@box/blueprint-web-assets/icons/Fill";import{BoxAiAgentSelectorWithApi,useAgents}from"@box/box-ai-agent-selector";import isEqual from"lodash/isEqual";import '../styles/content2.css';var sidebar_module_default={bcsSidebarBase:`_bcsSidebarBase_183mo_2`,bcsContent:`_bcsContent_183mo_2`,bcsBoxAISidebar:`_bcsBoxAISidebar_183mo_2`,bcsContentHeader:`_bcsContentHeader_183mo_6`,bcsTitle:`_bcsTitle_183mo_15`,bcsScrollContent:`_bcsScrollContent_183mo_22`,withModalOpen:`_withModalOpen_183mo_32`,bcsBoxAISidebarAgentSelector:`_bcsBoxAISidebarAgentSelector_183mo_35`,bcsBoxAISidebarContent:`_bcsBoxAISidebarContent_183mo_38`,bcsBoxAISidebarExpand:`_bcsBoxAISidebarExpand_183mo_41`,bcsBoxAISidebarClear:`_bcsBoxAISidebarClear_183mo_44`,bcsBoxAISidebarTitlePart:`_bcsBoxAISidebarTitlePart_183mo_47`,bcsBoxAISidebarClose:`_bcsBoxAISidebarClose_183mo_68`,bcsContentSubheader:`_bcsContentSubheader_183mo_85`,bcsScrollContentWrapper:`_bcsScrollContentWrapper_183mo_94`};mark(`${ORIGIN_BOXAI_SIDEBAR}_${EVENT_JS_READY}`);var ContentWrapper=({actions,children,className,elementId=``,sidebarView=``,title,subheader,...rest})=>{let label=`${elementId}${elementId===``?``:`_`}${sidebarView}`,id=`${label}-content`;return jsxs(`div`,{"aria-labelledby":label,className:clsx(sidebar_module_default.bcsContent,className),"data-testid":`bcs-content`,id,role:`tabpanel`,...rest,children:[jsxs(`div`,{className:sidebar_module_default.bcsContentHeader,children:[title&&jsx(Text,{as:`h3`,className:sidebar_module_default.bcsTitle,children:title}),actions]}),subheader&&jsx(`div`,{className:sidebar_module_default.bcsContentSubheader,children:subheader}),jsx(`div`,{className:sidebar_module_default.bcsScrollContentWrapper,children:jsx(`div`,{className:sidebar_module_default.bcsScrollContent,children})})]})};function BoxAISidebarContent(props){let{createSession,encodedSession,onClearAction,getAIStudioAgents,hasRequestInProgress,hostAppName,isAIStudioAgentSelectorEnabled,isLoading,onSelectAgent,questions,shouldShowLandingPage=!0,sendQuestion,stopQuestion,embedTheAnswerButtonConfig,onClose,...rest}=props,{formatMessage}=useIntl(),{enableModernizedComponents}=useBlueprintModernization(),isSessionInitiated=React$1.useRef(!1),[isModalOpen,setIsModalOpen]=React$1.useState(!1),{cache,contentName,elementId,fileExtension,isFeedbackEnabled,isFeedbackFormEnabled,isStopResponseEnabled,items,itemSize,onFeedbackFormSubmit,onUserInteraction,onSelectedAgentCallback,recordAction,setCacheValue,shouldPreinitSession}=React$1.useContext(IntelligenceSidebarContext),{agents,requestState,selectedAgent}=useAgents(),{questions:cacheQuestions}=cache,[promptValue,setPromptValue]=React$1.useState(``);cache.shouldShowLandingPage!==shouldShowLandingPage&&setCacheValue(`shouldShowLandingPage`,shouldShowLandingPage),cache.encodedSession!==encodedSession&&setCacheValue(`encodedSession`,encodedSession),isEqual(cache.questions,questions)||setCacheValue(`questions`,questions),isEqual(cache.agents.selectedAgent,selectedAgent)||setCacheValue(`agents`,{agents,requestState,selectedAgent});let handleUserIntentToUseAI=(userHasInteracted=!1)=>{!shouldPreinitSession&&!encodedSession&&!isLoading&&createSession&&createSession(!0,!1),userHasInteracted&&onUserInteraction&&onUserInteraction()},handleModalClose=()=>{setIsModalOpen(!1)};return React$1.useEffect(()=>(shouldPreinitSession&&!encodedSession&&createSession&&createSession(!0,!0),encodedSession&&cacheQuestions.length>0&&cacheQuestions[cacheQuestions.length-1].isCompleted===!1&&sendQuestion({prompt:cacheQuestions[cacheQuestions.length-1].prompt}),recordAction&&recordAction({action:`programmatic`,component:`sidebar`,feature:`answers`,target:`loaded`,data:{items:items.map(item=>({status:item.status,fileType:item.fileType}))}}),()=>{stopQuestion()}),[]),React$1.useEffect(()=>{let lastQuestion=cacheQuestions[cacheQuestions.length-1];!shouldPreinitSession&&!isSessionInitiated.current&&encodedSession&&lastQuestion?.isLoading&&(sendQuestion(lastQuestion,selectedAgent,!1),isSessionInitiated.current=!0)},[encodedSession]),jsxs(Fragment,{children:[jsx(ContentWrapper,{actions:jsxs(Fragment,{children:[jsxs(`div`,{className:sidebar_module_default.bcsBoxAISidebarTitlePart,children:[jsx(IntelligenceSidebarTitle,{isAIStudioAgentSelectorEnabled}),isAIStudioAgentSelectorEnabled&&jsx(`div`,{className:sidebar_module_default.bcsBoxAISidebarAgentSelector,children:jsx(BoxAiAgentSelectorWithApi,{disabled:hasRequestInProgress,fetcher:getAIStudioAgents,hostAppName,onAgentsListOpen:handleUserIntentToUseAI,onSelectAgent,onSelectedAgentCallback,recordAction,shouldHideAgentSelectorOnLoad:!0,useAgentLocalStorage:!0,variant:`sidebar`})})]}),jsx(ClearConversationButton,{className:sidebar_module_default.bcsBoxAISidebarClear,hasRequestInProgress,onClick:onClearAction}),jsx(Tooltip,{content:formatMessage(messages.sidebarBoxAISwitchToModalView),"data-testid":`content-answers-open-modal-tooltip`,variant:`standard`,children:jsx(IconButton,{"aria-label":formatMessage(messages.sidebarBoxAISwitchToModalView),className:sidebar_module_default.bcsBoxAISidebarExpand,"data-target-id":`IconButton-expandBoxAISidebar`,icon:enableModernizedComponents?ArrowsMaximize:ArrowsExpand,onClick:()=>{handleUserIntentToUseAI(),setIsModalOpen(!0)},size:`small`})}),onClose&&jsx(Tooltip,{content:formatMessage(messages.sidebarBoxAIClose),"data-testid":`content-answers-close-tooltip`,variant:`standard`,children:jsx(IconButton,{"aria-label":formatMessage(messages.sidebarBoxAIClose),className:sidebar_module_default.bcsBoxAISidebarClose,"data-target-id":`IconButton-closeBoxAISidebar`,icon:XMark,onClick:onClose,size:`small`})})]}),className:clsx(sidebar_module_default.bcsBoxAISidebar,{[sidebar_module_default.withModalOpen]:isModalOpen}),elementId,sidebarView:`box-ai`,children:jsx(`div`,{className:sidebar_module_default.bcsBoxAISidebarContent,children:jsx(BoxAiContentAnswers,{className:sidebar_module_default.bcsBoxAISidebarContentAnswers,contentName,contentType:formatMessage(messages.sidebarBoxAIContent),embedTheAnswerButtonConfig,hostAppName,isAIStudioAgentSelectorEnabled,isFeedbackEnabled,isFeedbackFormEnabled,isStopResponseEnabled,items,onFeedbackFormSubmit,onUserIntentToUseAI:handleUserIntentToUseAI,promptValue,questions,recordAction,setPromptValue,shouldShowLandingPage:cache.shouldShowLandingPage,showLoadingIndicator:isLoading&&shouldPreinitSession,stopQuestion,submitQuestion:sendQuestion,variant:`sidebar`,...rest})})}),jsx(IntelligenceModal,{contentName,contentType:formatMessage(messages.sidebarBoxAIContent),extension:fileExtension,getAIStudioAgents,hasRequestInProgress,hostAppName,isAIStudioAgentSelectorEnabled,isFeedbackEnabled,isFeedbackFormEnabled,isStopResponseEnabled,items,itemSize,onClearAction,onFeedbackFormSubmit,onOpenChange:handleModalClose,onSelectAgent,onUserIntentToUseAI:handleUserIntentToUseAI,open:isModalOpen,promptValue,questions,recordAction:isModalOpen?recordAction:void 0,setPromptValue,shouldShowLandingPage:cache.shouldShowLandingPage,showLoadingIndicator:!1,stopPropagationOnEsc:!0,stopQuestion,submitQuestion:sendQuestion,variant:`collapsible`,...rest,shouldRenderProviders:!1})]})}var content_default=withApiWrapper(BoxAISidebarContent);export{content_default as t};
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t } from "./items-dropdown.js";
|
|
3
|
-
import n from "clsx";
|
|
4
|
-
import { FormattedMessage as r } from "react-intl";
|
|
5
|
-
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
-
import '../styles/contextual-items-message.css';var o = {
|
|
7
|
-
commonWelcomeTextStyles: "_commonWelcomeTextStyles_16t3n_1",
|
|
8
|
-
fileLandingText: "_fileLandingText_16t3n_1",
|
|
9
|
-
welcomeFileDataLandingText: "_welcomeFileDataLandingText_16t3n_1",
|
|
10
|
-
askQuestionText: "_askQuestionText_16t3n_1",
|
|
11
|
-
sidebar: "_sidebar_16t3n_4",
|
|
12
|
-
itemsDropdown: "_itemsDropdown_16t3n_38"
|
|
13
|
-
}, s = ({ contentName: s, isUsedInsideSidebar: c = !1, onDropdownOpenChange: l, onItemClick: u, parentItem: d, shouldShowLandingPage: f, supportedItems: p }) => {
|
|
14
|
-
let m = p.length || 1, h = p[0]?.name || s, g = d?.id === "0" ? void 0 : d?.name;
|
|
15
|
-
return /* @__PURE__ */ a("div", {
|
|
16
|
-
className: n({
|
|
17
|
-
[o.askQuestionText]: !f,
|
|
18
|
-
[o.welcomeFileDataLandingText]: f,
|
|
19
|
-
[o.sidebar]: c
|
|
20
|
-
}),
|
|
21
|
-
children: [/* @__PURE__ */ i("div", {
|
|
22
|
-
className: o.welcomeText,
|
|
23
|
-
children: /* @__PURE__ */ i("b", { children: /* @__PURE__ */ i(r, { ...e.welcomeAskQuestionLandingText }) })
|
|
24
|
-
}), /* @__PURE__ */ i("div", {
|
|
25
|
-
className: o.fileLandingText,
|
|
26
|
-
children: /* @__PURE__ */ i(r, {
|
|
27
|
-
...e.fileLandingText,
|
|
28
|
-
values: {
|
|
29
|
-
firstItemName: h,
|
|
30
|
-
parentItem: g && `'${g}'`,
|
|
31
|
-
numberOfItems: m,
|
|
32
|
-
files: /* @__PURE__ */ i(t, {
|
|
33
|
-
className: o.itemsDropdown,
|
|
34
|
-
onDropdownOpenChange: l,
|
|
35
|
-
onItemClick: u,
|
|
36
|
-
supportedItems: p
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
})]
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
export { s as t };
|
|
1
|
+
import messages from"../esm/lib/components/welcome-message/messages.js";import{t as ItemsDropdown}from"./items-dropdown.js";import clsx from"clsx";import{FormattedMessage}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import '../styles/contextual-items-message.css';var contextual_items_message_module_default={commonWelcomeTextStyles:`_commonWelcomeTextStyles_16t3n_1`,fileLandingText:`_fileLandingText_16t3n_1`,welcomeFileDataLandingText:`_welcomeFileDataLandingText_16t3n_1`,askQuestionText:`_askQuestionText_16t3n_1`,sidebar:`_sidebar_16t3n_4`,itemsDropdown:`_itemsDropdown_16t3n_38`},ContextualItemsMessage=({contentName,isUsedInsideSidebar=!1,onDropdownOpenChange,onItemClick,parentItem,shouldShowLandingPage,supportedItems})=>{let numberOfItems=supportedItems.length||1,firstItemName=supportedItems[0]?.name||contentName,parentItemName=parentItem?.id===`0`?void 0:parentItem?.name;return jsxs(`div`,{className:clsx({[contextual_items_message_module_default.askQuestionText]:!shouldShowLandingPage,[contextual_items_message_module_default.welcomeFileDataLandingText]:shouldShowLandingPage,[contextual_items_message_module_default.sidebar]:isUsedInsideSidebar}),children:[jsx(`div`,{className:contextual_items_message_module_default.welcomeText,children:jsx(`b`,{children:jsx(FormattedMessage,{...messages.welcomeAskQuestionLandingText})})}),jsx(`div`,{className:contextual_items_message_module_default.fileLandingText,children:jsx(FormattedMessage,{...messages.fileLandingText,values:{firstItemName,parentItem:parentItemName&&`'${parentItemName}'`,numberOfItems,files:jsx(ItemsDropdown,{className:contextual_items_message_module_default.itemsDropdown,onDropdownOpenChange,onItemClick,supportedItems})}})})]})};export{ContextualItemsMessage as t};
|
|
@@ -1,52 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LOGGER_ACTION_CLICK as t, LOGGER_BASE_CONFIG as n } from "../esm/lib/components/common/constants.js";
|
|
3
|
-
import { focusInput as r } from "../esm/lib/components/common/focusInputUtils.js";
|
|
4
|
-
import { useCallback as i, useState as a } from "react";
|
|
5
|
-
import { Button as o, Tooltip as s } from "@box/blueprint-web";
|
|
6
|
-
import { useIntl as c } from "react-intl";
|
|
7
|
-
import { BoxNotes as l } from "@box/blueprint-web-assets/icons/Line";
|
|
8
|
-
import { jsx as u } from "react/jsx-runtime";
|
|
9
|
-
import '../styles/embed-the-answer-button.css';var d = {
|
|
10
|
-
embedTheAnswerButtonContainer: "_embedTheAnswerButtonContainer_ot7gc_1",
|
|
11
|
-
embedTheAnswerButton: "_embedTheAnswerButton_ot7gc_1",
|
|
12
|
-
completedText: "_completedText_ot7gc_36"
|
|
13
|
-
}, f = ({ answer: f, hostAppName: p, embedTheAnswerButtonConfig: m, questionId: h, recordAction: g, variant: _ }) => {
|
|
14
|
-
let { formatMessage: v } = c(), [y, b] = a(!1), x = () => {
|
|
15
|
-
!f || !m?.onAction || y || (g?.({
|
|
16
|
-
...n,
|
|
17
|
-
action: t,
|
|
18
|
-
target: "add_to_note",
|
|
19
|
-
component: _,
|
|
20
|
-
data: {
|
|
21
|
-
hostAppName: p,
|
|
22
|
-
questionId: h || ""
|
|
23
|
-
}
|
|
24
|
-
}), m.onAction(f), b(!0), setTimeout(() => {
|
|
25
|
-
b(!1);
|
|
26
|
-
}, 5e3), r());
|
|
27
|
-
}, S = i((e) => {
|
|
28
|
-
e.target.matches(":focus-visible") || e.stopPropagation();
|
|
29
|
-
}, []);
|
|
30
|
-
if (!f || !m?.onAction) return null;
|
|
31
|
-
let C = m.actionText || v(e.addToNote), w = m.completedText || v(e.addedToNote);
|
|
32
|
-
return /* @__PURE__ */ u(s, {
|
|
33
|
-
content: y ? w : C,
|
|
34
|
-
children: /* @__PURE__ */ u("div", {
|
|
35
|
-
className: d.embedTheAnswerButtonContainer,
|
|
36
|
-
children: y ? /* @__PURE__ */ u("span", {
|
|
37
|
-
className: d.completedText,
|
|
38
|
-
children: w
|
|
39
|
-
}) : /* @__PURE__ */ u(o, {
|
|
40
|
-
"aria-label": C,
|
|
41
|
-
className: d.embedTheAnswerButton,
|
|
42
|
-
onClick: x,
|
|
43
|
-
onFocusCapture: S,
|
|
44
|
-
size: "small",
|
|
45
|
-
startIcon: l,
|
|
46
|
-
variant: "tertiary",
|
|
47
|
-
children: C
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
export { f as t };
|
|
1
|
+
import messages from"../esm/lib/components/answer/messages.js";import{LOGGER_ACTION_CLICK,LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import{focusInput}from"../esm/lib/components/common/focusInputUtils.js";import{useCallback,useState}from"react";import{Button,Tooltip}from"@box/blueprint-web";import{useIntl}from"react-intl";import{BoxNotes}from"@box/blueprint-web-assets/icons/Line";import{jsx}from"react/jsx-runtime";import '../styles/embed-the-answer-button.css';var embed_the_answer_button_module_default={embedTheAnswerButtonContainer:`_embedTheAnswerButtonContainer_ot7gc_1`,embedTheAnswerButton:`_embedTheAnswerButton_ot7gc_1`,completedText:`_completedText_ot7gc_36`},EmbedTheAnswerButton=({answer,hostAppName,embedTheAnswerButtonConfig,questionId,recordAction,variant})=>{let{formatMessage}=useIntl(),[isCompleted,setIsCompleted]=useState(!1),handleAction=()=>{!answer||!embedTheAnswerButtonConfig?.onAction||isCompleted||(recordAction?.({...LOGGER_BASE_CONFIG,action:LOGGER_ACTION_CLICK,target:`add_to_note`,component:variant,data:{hostAppName,questionId:questionId||``}}),embedTheAnswerButtonConfig.onAction(answer),setIsCompleted(!0),setTimeout(()=>{setIsCompleted(!1)},5e3),focusInput())},handleFocusCapture=useCallback(e=>{e.target.matches(`:focus-visible`)||e.stopPropagation()},[]);if(!answer||!embedTheAnswerButtonConfig?.onAction)return null;let actionText=embedTheAnswerButtonConfig.actionText||formatMessage(messages.addToNote),completedText=embedTheAnswerButtonConfig.completedText||formatMessage(messages.addedToNote);return jsx(Tooltip,{content:isCompleted?completedText:actionText,children:jsx(`div`,{className:embed_the_answer_button_module_default.embedTheAnswerButtonContainer,children:isCompleted?jsx(`span`,{className:embed_the_answer_button_module_default.completedText,children:completedText}):jsx(Button,{"aria-label":actionText,className:embed_the_answer_button_module_default.embedTheAnswerButton,onClick:handleAction,onFocusCapture:handleFocusCapture,size:`small`,startIcon:BoxNotes,variant:`tertiary`,children:actionText})})})};export{EmbedTheAnswerButton as t};
|
|
@@ -1,130 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { i as t } from "./types.js";
|
|
3
|
-
import n from "../esm/lib/components/answer/messages.js";
|
|
4
|
-
import { ABUSE_FORM_PATH as r } from "../esm/lib/components/answer/constants.js";
|
|
5
|
-
import { Checkbox as i, GuidedTooltip as a, Link as o, Radio as s, Text as c, TextArea as l } from "@box/blueprint-web";
|
|
6
|
-
import { FormattedMessage as u, useIntl as d } from "react-intl";
|
|
7
|
-
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
8
|
-
import { Form as h, Formik as g } from "formik";
|
|
9
|
-
import '../styles/feedback-tooltip.css';var _ = {
|
|
10
|
-
feedbackTooltip: "_feedbackTooltip_um41j_1",
|
|
11
|
-
feedbackTooltipForm: "_feedbackTooltipForm_um41j_7",
|
|
12
|
-
feedbackTooltipTitle: "_feedbackTooltipTitle_um41j_11",
|
|
13
|
-
feedbackTooltipTextarea: "_feedbackTooltipTextarea_um41j_14",
|
|
14
|
-
feedbackTooltipSubmitBtn: "_feedbackTooltipSubmitBtn_um41j_17",
|
|
15
|
-
feedbackTooltipPromptShareConsent: "_feedbackTooltipPromptShareConsent_um41j_20",
|
|
16
|
-
feedbackTooltipAbuseDisclaimer: "_feedbackTooltipAbuseDisclaimer_um41j_23",
|
|
17
|
-
feedbackTooltipAbuseLink: "_feedbackTooltipAbuseLink_um41j_27"
|
|
18
|
-
}, v = (e) => {
|
|
19
|
-
let t = "";
|
|
20
|
-
if (window !== window.top && document.referrer) try {
|
|
21
|
-
t = new URL(document.referrer).origin;
|
|
22
|
-
} catch {
|
|
23
|
-
t = "";
|
|
24
|
-
}
|
|
25
|
-
let n = encodeURIComponent(window.location.href);
|
|
26
|
-
return /* @__PURE__ */ p(o, {
|
|
27
|
-
className: _.feedbackTooltipAbuseLink,
|
|
28
|
-
href: `${t}${r}/${n}`,
|
|
29
|
-
rel: "noopener noreferrer",
|
|
30
|
-
target: "_blank",
|
|
31
|
-
children: e
|
|
32
|
-
});
|
|
33
|
-
}, y = ({ children: r, isOpen: o, onOpenChange: y, onSubmit: b, shouldIncludeFeedbackText: x, shouldIncludePromptShareConsent: S, shouldShow: C }) => {
|
|
34
|
-
let { formatMessage: w } = d();
|
|
35
|
-
if (!C) return r;
|
|
36
|
-
let T = () => {
|
|
37
|
-
y(!1);
|
|
38
|
-
};
|
|
39
|
-
return /* @__PURE__ */ p(a, {
|
|
40
|
-
align: "end",
|
|
41
|
-
className: _.feedbackTooltip,
|
|
42
|
-
closeLabel: w(e.closeButtonText),
|
|
43
|
-
content: /* @__PURE__ */ p(g, {
|
|
44
|
-
initialValues: {
|
|
45
|
-
feedback: "",
|
|
46
|
-
feedbackPromptShareConsent: !0,
|
|
47
|
-
issueType: ""
|
|
48
|
-
},
|
|
49
|
-
onSubmit: (e) => {
|
|
50
|
-
b(e);
|
|
51
|
-
},
|
|
52
|
-
children: ({ submitForm: e, setFieldValue: r, values: { feedback: o, feedbackPromptShareConsent: d, issueType: g } }) => /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m(a.Body, { children: [/* @__PURE__ */ p(a.Title, {
|
|
53
|
-
className: _.feedbackTooltipTitle,
|
|
54
|
-
children: w(n.feedbackTooltipTitle)
|
|
55
|
-
}), /* @__PURE__ */ m(h, {
|
|
56
|
-
className: _.feedbackTooltipForm,
|
|
57
|
-
children: [
|
|
58
|
-
/* @__PURE__ */ p(s.Legend, {
|
|
59
|
-
header: w(n.feedbackTooltipIssueTypeLabel),
|
|
60
|
-
children: /* @__PURE__ */ m(s.Group, {
|
|
61
|
-
defaultValue: "",
|
|
62
|
-
loop: !0,
|
|
63
|
-
name: "issueType",
|
|
64
|
-
onValueChange: (e) => r("issueType", e),
|
|
65
|
-
orientation: "vertical",
|
|
66
|
-
value: g,
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ p(s.Item, {
|
|
69
|
-
label: w(n.feedbackTooltipIssueTypeAnswer1),
|
|
70
|
-
value: t.INACCURATE_ANSWER
|
|
71
|
-
}),
|
|
72
|
-
/* @__PURE__ */ p(s.Item, {
|
|
73
|
-
label: w(n.feedbackTooltipIssueTypeAnswer2),
|
|
74
|
-
value: t.DID_NOT_FOLLOW_REQUEST
|
|
75
|
-
}),
|
|
76
|
-
/* @__PURE__ */ p(s.Item, {
|
|
77
|
-
label: w(n.feedbackTooltipIssueTypeAnswer3),
|
|
78
|
-
value: t.OTHER
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
})
|
|
82
|
-
}),
|
|
83
|
-
x && /* @__PURE__ */ p(l, {
|
|
84
|
-
className: _.feedbackTooltipTextarea,
|
|
85
|
-
label: w(n.feedbackTooltipFeedbackLabel),
|
|
86
|
-
maxRows: 4,
|
|
87
|
-
minRows: 4,
|
|
88
|
-
onChange: (e) => r("feedback", e.target.value),
|
|
89
|
-
placeholder: w(n.feedbackTooltipFeedbackPlaceholder),
|
|
90
|
-
value: o
|
|
91
|
-
}),
|
|
92
|
-
S && /* @__PURE__ */ p(i.Item, {
|
|
93
|
-
checked: d,
|
|
94
|
-
className: _.feedbackTooltipPromptShareConsent,
|
|
95
|
-
"data-target-id": "Checkbox.Item-boxAiFeedbackPromptShareConsent",
|
|
96
|
-
label: w(n.feedbackTooltipPromptShareConsent),
|
|
97
|
-
onCheckedChange: (e) => {
|
|
98
|
-
r("feedbackPromptShareConsent", e);
|
|
99
|
-
},
|
|
100
|
-
value: "feedbackPromptShareConsent"
|
|
101
|
-
}),
|
|
102
|
-
x && /* @__PURE__ */ p(c, {
|
|
103
|
-
as: "p",
|
|
104
|
-
className: _.feedbackTooltipAbuseDisclaimer,
|
|
105
|
-
variant: "caption",
|
|
106
|
-
children: /* @__PURE__ */ p(u, {
|
|
107
|
-
...n.feedbackTooltipAbuseDisclaimer,
|
|
108
|
-
values: { abuseFormLink: v }
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
]
|
|
112
|
-
})] }), /* @__PURE__ */ m(a.Footer, { children: [/* @__PURE__ */ p(a.Footer.SecondaryAction, {
|
|
113
|
-
onClick: T,
|
|
114
|
-
size: "large",
|
|
115
|
-
children: w(n.feedbackTooltipCancel)
|
|
116
|
-
}), /* @__PURE__ */ p(a.Footer.PrimaryAction, {
|
|
117
|
-
className: _.feedbackTooltipSubmitBtn,
|
|
118
|
-
disabled: !g,
|
|
119
|
-
onClick: () => e(),
|
|
120
|
-
size: "large",
|
|
121
|
-
children: w(n.feedbackTooltipSubmit)
|
|
122
|
-
})] })] })
|
|
123
|
-
}),
|
|
124
|
-
onOpenChange: y,
|
|
125
|
-
open: o,
|
|
126
|
-
side: "left",
|
|
127
|
-
children: r
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
export { y as t };
|
|
1
|
+
import messages from"../esm/lib/messages.js";import{i as FeedbackIssueType}from"./types.js";import messages$1 from"../esm/lib/components/answer/messages.js";import{ABUSE_FORM_PATH}from"../esm/lib/components/answer/constants.js";import{Checkbox,GuidedTooltip,Link,Radio,Text,TextArea}from"@box/blueprint-web";import{FormattedMessage,useIntl}from"react-intl";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import{Form,Formik}from"formik";import '../styles/feedback-tooltip.css';var feedback_tooltip_module_default={feedbackTooltip:`_feedbackTooltip_um41j_1`,feedbackTooltipForm:`_feedbackTooltipForm_um41j_7`,feedbackTooltipTitle:`_feedbackTooltipTitle_um41j_11`,feedbackTooltipTextarea:`_feedbackTooltipTextarea_um41j_14`,feedbackTooltipSubmitBtn:`_feedbackTooltipSubmitBtn_um41j_17`,feedbackTooltipPromptShareConsent:`_feedbackTooltipPromptShareConsent_um41j_20`,feedbackTooltipAbuseDisclaimer:`_feedbackTooltipAbuseDisclaimer_um41j_23`,feedbackTooltipAbuseLink:`_feedbackTooltipAbuseLink_um41j_27`},getAbuseFormLink=content=>{let prefix=``;if(window!==window.top&&document.referrer)try{prefix=new URL(document.referrer).origin}catch{prefix=``}let encodedUrl=encodeURIComponent(window.location.href);return jsx(Link,{className:feedback_tooltip_module_default.feedbackTooltipAbuseLink,href:`${prefix}${ABUSE_FORM_PATH}/${encodedUrl}`,rel:`noopener noreferrer`,target:`_blank`,children:content})},FeedbackTooltip=({children,isOpen,onOpenChange,onSubmit,shouldIncludeFeedbackText,shouldIncludePromptShareConsent,shouldShow})=>{let{formatMessage}=useIntl();if(!shouldShow)return children;let handleCancel=()=>{onOpenChange(!1)};return jsx(GuidedTooltip,{align:`end`,className:feedback_tooltip_module_default.feedbackTooltip,closeLabel:formatMessage(messages.closeButtonText),content:jsx(Formik,{initialValues:{feedback:``,feedbackPromptShareConsent:!0,issueType:``},onSubmit:values=>{onSubmit(values)},children:({submitForm,setFieldValue,values:{feedback,feedbackPromptShareConsent,issueType}})=>jsxs(Fragment,{children:[jsxs(GuidedTooltip.Body,{children:[jsx(GuidedTooltip.Title,{className:feedback_tooltip_module_default.feedbackTooltipTitle,children:formatMessage(messages$1.feedbackTooltipTitle)}),jsxs(Form,{className:feedback_tooltip_module_default.feedbackTooltipForm,children:[jsx(Radio.Legend,{header:formatMessage(messages$1.feedbackTooltipIssueTypeLabel),children:jsxs(Radio.Group,{defaultValue:``,loop:!0,name:`issueType`,onValueChange:value=>setFieldValue(`issueType`,value),orientation:`vertical`,value:issueType,children:[jsx(Radio.Item,{label:formatMessage(messages$1.feedbackTooltipIssueTypeAnswer1),value:FeedbackIssueType.INACCURATE_ANSWER}),jsx(Radio.Item,{label:formatMessage(messages$1.feedbackTooltipIssueTypeAnswer2),value:FeedbackIssueType.DID_NOT_FOLLOW_REQUEST}),jsx(Radio.Item,{label:formatMessage(messages$1.feedbackTooltipIssueTypeAnswer3),value:FeedbackIssueType.OTHER})]})}),shouldIncludeFeedbackText&&jsx(TextArea,{className:feedback_tooltip_module_default.feedbackTooltipTextarea,label:formatMessage(messages$1.feedbackTooltipFeedbackLabel),maxRows:4,minRows:4,onChange:e=>setFieldValue(`feedback`,e.target.value),placeholder:formatMessage(messages$1.feedbackTooltipFeedbackPlaceholder),value:feedback}),shouldIncludePromptShareConsent&&jsx(Checkbox.Item,{checked:feedbackPromptShareConsent,className:feedback_tooltip_module_default.feedbackTooltipPromptShareConsent,"data-target-id":`Checkbox.Item-boxAiFeedbackPromptShareConsent`,label:formatMessage(messages$1.feedbackTooltipPromptShareConsent),onCheckedChange:checked=>{setFieldValue(`feedbackPromptShareConsent`,checked)},value:`feedbackPromptShareConsent`}),shouldIncludeFeedbackText&&jsx(Text,{as:`p`,className:feedback_tooltip_module_default.feedbackTooltipAbuseDisclaimer,variant:`caption`,children:jsx(FormattedMessage,{...messages$1.feedbackTooltipAbuseDisclaimer,values:{abuseFormLink:getAbuseFormLink}})})]})]}),jsxs(GuidedTooltip.Footer,{children:[jsx(GuidedTooltip.Footer.SecondaryAction,{onClick:handleCancel,size:`large`,children:formatMessage(messages$1.feedbackTooltipCancel)}),jsx(GuidedTooltip.Footer.PrimaryAction,{className:feedback_tooltip_module_default.feedbackTooltipSubmitBtn,disabled:!issueType,onClick:()=>submitForm(),size:`large`,children:formatMessage(messages$1.feedbackTooltipSubmit)})]})]})}),onOpenChange,open:isOpen,side:`left`,children})};export{FeedbackTooltip as t};
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LOGGER_ACTION_CLICK as t, LOGGER_BASE_CONFIG as n } from "../esm/lib/components/common/constants.js";
|
|
3
|
-
import r from "../esm/lib/components/footer/messages.js";
|
|
4
|
-
import { useCallback as i, useEffect as a, useRef as o } from "react";
|
|
5
|
-
import { Button as s } from "@box/blueprint-web";
|
|
6
|
-
import { useIntl as c } from "react-intl";
|
|
7
|
-
import { jsx as l } from "react/jsx-runtime";
|
|
8
|
-
import u from "lodash/noop";
|
|
9
|
-
import '../styles/footer-actions.css';var d = {
|
|
10
|
-
footerActions: "_footerActions_1l4g8_1",
|
|
11
|
-
footerActionButton: "_footerActionButton_1l4g8_11"
|
|
12
|
-
}, f = ({ lastQuestion: f, onRetryButtonInteraction: p = u, onRetryQuestion: m, recordAction: h }) => {
|
|
13
|
-
let { error: g } = f, _ = m && g && g !== e.RESPONSE_STOPPED && g !== e.RESPONSE_INTERRUPTED, v = _, y = o(null), { formatMessage: b } = c(), x = i(() => {
|
|
14
|
-
h && h({
|
|
15
|
-
...n,
|
|
16
|
-
action: t,
|
|
17
|
-
target: "retryResponse"
|
|
18
|
-
}), m(f);
|
|
19
|
-
}, [
|
|
20
|
-
f,
|
|
21
|
-
m,
|
|
22
|
-
h
|
|
23
|
-
]);
|
|
24
|
-
return a(() => {
|
|
25
|
-
_ && y.current && y.current.focus();
|
|
26
|
-
}, [_]), v ? /* @__PURE__ */ l("div", {
|
|
27
|
-
className: d.footerActions,
|
|
28
|
-
"data-testid": "content-answers-modal-footer-actions",
|
|
29
|
-
children: _ && /* @__PURE__ */ l(s, {
|
|
30
|
-
ref: y,
|
|
31
|
-
"aria-live": "polite",
|
|
32
|
-
className: d.footerActionButton,
|
|
33
|
-
"data-testid": "content-answers-retry-response-button",
|
|
34
|
-
onClick: x,
|
|
35
|
-
onFocus: p,
|
|
36
|
-
onMouseEnter: p,
|
|
37
|
-
size: "large",
|
|
38
|
-
variant: "secondary",
|
|
39
|
-
"data-target-id": "Button-retryResponse",
|
|
40
|
-
children: b(r.retryResponse)
|
|
41
|
-
})
|
|
42
|
-
}) : null;
|
|
43
|
-
};
|
|
44
|
-
export { f as t };
|
|
1
|
+
import{t as ANSWER_ERROR}from"./types.js";import{LOGGER_ACTION_CLICK,LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import messages from"../esm/lib/components/footer/messages.js";import{useCallback,useEffect,useRef}from"react";import{Button}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx}from"react/jsx-runtime";import noop from"lodash/noop";import '../styles/footer-actions.css';var footer_actions_module_default={footerActions:`_footerActions_1l4g8_1`,footerActionButton:`_footerActionButton_1l4g8_11`},FooterActions=({lastQuestion,onRetryButtonInteraction=noop,onRetryQuestion,recordAction})=>{let{error}=lastQuestion,shouldShowRetryButton=onRetryQuestion&&error&&error!==ANSWER_ERROR.RESPONSE_STOPPED&&error!==ANSWER_ERROR.RESPONSE_INTERRUPTED,canShowActionButton=shouldShowRetryButton,retryButtonRef=useRef(null),{formatMessage}=useIntl(),handleRetryClick=useCallback(()=>{recordAction&&recordAction({...LOGGER_BASE_CONFIG,action:LOGGER_ACTION_CLICK,target:`retryResponse`}),onRetryQuestion(lastQuestion)},[lastQuestion,onRetryQuestion,recordAction]);return useEffect(()=>{shouldShowRetryButton&&retryButtonRef.current&&retryButtonRef.current.focus()},[shouldShowRetryButton]),canShowActionButton?jsx(`div`,{className:footer_actions_module_default.footerActions,"data-testid":`content-answers-modal-footer-actions`,children:shouldShowRetryButton&&jsx(Button,{ref:retryButtonRef,"aria-live":`polite`,className:footer_actions_module_default.footerActionButton,"data-testid":`content-answers-retry-response-button`,onClick:handleRetryClick,onFocus:onRetryButtonInteraction,onMouseEnter:onRetryButtonInteraction,size:`large`,variant:`secondary`,"data-target-id":`Button-retryResponse`,children:formatMessage(messages.retryResponse)})}):null};export{FooterActions as t};
|