@box/box-ai-content-answers 2.1.37 → 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.
Files changed (107) hide show
  1. package/dist/chunks/answer-content.js +1 -32
  2. package/dist/chunks/answer.js +1 -183
  3. package/dist/chunks/box-ai-content-answers.js +1 -78
  4. package/dist/chunks/chat.js +1 -116
  5. package/dist/chunks/citation.js +1 -124
  6. package/dist/chunks/clear-conversation-button.js +1 -37
  7. package/dist/chunks/content.js +1 -89
  8. package/dist/chunks/content2.js +1 -213
  9. package/dist/chunks/contextual-items-message.js +1 -43
  10. package/dist/chunks/embed-the-answer-button.js +1 -52
  11. package/dist/chunks/feedback-tooltip.js +1 -130
  12. package/dist/chunks/footer-actions.js +1 -44
  13. package/dist/chunks/inline-error.js +1 -63
  14. package/dist/chunks/items-dropdown.js +1 -67
  15. package/dist/chunks/markdown.js +6 -6776
  16. package/dist/chunks/markdown.module.js +1 -13
  17. package/dist/chunks/media-container.js +1 -32
  18. package/dist/chunks/question.js +1 -29
  19. package/dist/chunks/references.js +1 -43
  20. package/dist/chunks/stopResponseButton.js +1 -45
  21. package/dist/chunks/suggested-questions.js +1 -70
  22. package/dist/chunks/suggestions.js +1 -35
  23. package/dist/chunks/thinkingBubble.js +1 -111
  24. package/dist/chunks/thumb-buttons.js +1 -103
  25. package/dist/chunks/types.js +1 -14
  26. package/dist/chunks/unsupported-items-notice.js +1 -25
  27. package/dist/chunks/warning-message.js +1 -21
  28. package/dist/esm/index.js +1 -11
  29. package/dist/esm/lib/box-ai-content-answers.js +1 -2
  30. package/dist/esm/lib/components/answer/answer-content.js +1 -2
  31. package/dist/esm/lib/components/answer/answer.js +1 -2
  32. package/dist/esm/lib/components/answer/citation.js +1 -2
  33. package/dist/esm/lib/components/answer/constants.js +1 -2
  34. package/dist/esm/lib/components/answer/copy-button.js +1 -46
  35. package/dist/esm/lib/components/answer/embed-the-answer-button.js +1 -2
  36. package/dist/esm/lib/components/answer/feedback-tooltip.js +1 -2
  37. package/dist/esm/lib/components/answer/inline-error.js +1 -2
  38. package/dist/esm/lib/components/answer/loading-indicator.js +1 -29
  39. package/dist/esm/lib/components/answer/messages.js +1 -148
  40. package/dist/esm/lib/components/answer/no-citations.js +1 -29
  41. package/dist/esm/lib/components/answer/references.js +1 -2
  42. package/dist/esm/lib/components/answer/thumb-buttons.js +1 -2
  43. package/dist/esm/lib/components/api-wrapper/actions.js +1 -2
  44. package/dist/esm/lib/components/api-wrapper/api-wrapper.js +1 -8
  45. package/dist/esm/lib/components/api-wrapper/constants.js +1 -30
  46. package/dist/esm/lib/components/api-wrapper/content-answers-component.js +1 -83
  47. package/dist/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +1 -211
  48. package/dist/esm/lib/components/api-wrapper/records.js +1 -38
  49. package/dist/esm/lib/components/api-wrapper/reducer.js +1 -42
  50. package/dist/esm/lib/components/api-wrapper/utils/format.js +1 -13
  51. package/dist/esm/lib/components/api-wrapper/utils/request.js +1 -12
  52. package/dist/esm/lib/components/api-wrapper/utils/stream.js +2 -116
  53. package/dist/esm/lib/components/api-wrapper/utils/typed-record.js +1 -3
  54. package/dist/esm/lib/components/chat/chat.js +1 -2
  55. package/dist/esm/lib/components/chat/index.js +1 -2
  56. package/dist/esm/lib/components/common/agentUtils.js +1 -5
  57. package/dist/esm/lib/components/common/constants.js +1 -19
  58. package/dist/esm/lib/components/common/focusInputUtils.js +1 -5
  59. package/dist/esm/lib/components/common/inline-citation.js +1 -24
  60. package/dist/esm/lib/components/common/keyInputUtils.js +1 -3
  61. package/dist/esm/lib/components/common/markdown-react.js +1 -97
  62. package/dist/esm/lib/components/common/markdown.js +1 -2
  63. package/dist/esm/lib/components/common/media-container.js +1 -2
  64. package/dist/esm/lib/components/common/mock-data.js +1 -305
  65. package/dist/esm/lib/components/common/performance.js +1 -3
  66. package/dist/esm/lib/components/content/content.js +1 -2
  67. package/dist/esm/lib/components/content/index.js +1 -2
  68. package/dist/esm/lib/components/footer/constants.js +1 -12
  69. package/dist/esm/lib/components/footer/footer-actions.js +1 -2
  70. package/dist/esm/lib/components/footer/footer.js +1 -151
  71. package/dist/esm/lib/components/footer/index.js +1 -2
  72. package/dist/esm/lib/components/footer/messages.js +1 -36
  73. package/dist/esm/lib/components/footer/stopResponseButton.js +1 -2
  74. package/dist/esm/lib/components/modal/clear-conversation-button.js +1 -2
  75. package/dist/esm/lib/components/modal/hooks/useEventListeners.js +1 -10
  76. package/dist/esm/lib/components/modal/hooks/useStopPropagationOnEsc.js +1 -19
  77. package/dist/esm/lib/components/modal/messages.js +1 -20
  78. package/dist/esm/lib/components/modal/modal.js +1 -143
  79. package/dist/esm/lib/components/modal/title.js +1 -14
  80. package/dist/esm/lib/components/modal-error/index.js +1 -2
  81. package/dist/esm/lib/components/modal-error/messages.js +1 -16
  82. package/dist/esm/lib/components/modal-error/modal-error.js +1 -33
  83. package/dist/esm/lib/components/question/question.js +1 -2
  84. package/dist/esm/lib/components/sidebar/content.js +1 -2
  85. package/dist/esm/lib/components/sidebar/context.js +1 -16
  86. package/dist/esm/lib/components/sidebar/messages.js +1 -28
  87. package/dist/esm/lib/components/sidebar/sidebar.js +1 -80
  88. package/dist/esm/lib/components/sidebar/title.js +1 -14
  89. package/dist/esm/lib/components/suggested-questions/messages.js +1 -16
  90. package/dist/esm/lib/components/suggested-questions/mocks.js +1 -36
  91. package/dist/esm/lib/components/suggested-questions/suggested-questions.js +1 -2
  92. package/dist/esm/lib/components/suggested-questions/suggestions.js +1 -2
  93. package/dist/esm/lib/components/thinkingBubble/boxAILoadingIndicator.js +11 -277
  94. package/dist/esm/lib/components/thinkingBubble/messages.js +1 -24
  95. package/dist/esm/lib/components/thinkingBubble/thinkingBubble.js +1 -2
  96. package/dist/esm/lib/components/welcome-message/contextual-items-message.js +1 -2
  97. package/dist/esm/lib/components/welcome-message/items-dropdown.js +1 -2
  98. package/dist/esm/lib/components/welcome-message/messages.js +10 -52
  99. package/dist/esm/lib/components/welcome-message/unsupported-items-notice.js +1 -2
  100. package/dist/esm/lib/components/welcome-message/warning-message.js +1 -2
  101. package/dist/esm/lib/components/welcome-message/welcome-message.js +1 -53
  102. package/dist/esm/lib/constants.js +1 -9
  103. package/dist/esm/lib/hooks/usePromptFocus.js +1 -28
  104. package/dist/esm/lib/messages.js +1 -56
  105. package/dist/esm/lib/utils/constants.js +1 -2
  106. package/dist/esm/lib/utils/inlineCitationsUtils.js +1 -18
  107. package/package.json +11 -11
@@ -1,32 +1 @@
1
- import { t as e } from "./markdown.js";
2
- import t from "../esm/lib/utils/inlineCitationsUtils.js";
3
- import n from "../esm/lib/components/common/markdown-react.js";
4
- import r from "clsx";
5
- import "react";
6
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
7
- import '../styles/answer-content.css';var s = {
8
- answerContent: "_answerContent_xrq8x_27",
9
- answerMarkdown: "_answerMarkdown_xrq8x_53"
10
- }, c = ({ answer: c, items: l, isCompleted: u, isInlineCitationV2Enabled: d, isInlineCitationsEnabled: f, isMarkdownEnabled: p, isReactMarkdownEnabled: m = !1, className: h, variant: g = "modal", ..._ }) => {
11
- let v = g === "sidebar", y = (r) => {
12
- let i = t(r, {
13
- items: l,
14
- isCompleted: u,
15
- isInlineCitationsEnabled: f
16
- });
17
- return m ? /* @__PURE__ */ a(n, {
18
- isInlineCitationV2Enabled: d,
19
- children: i
20
- }) : /* @__PURE__ */ a("div", { dangerouslySetInnerHTML: { __html: e(i) } });
21
- };
22
- return /* @__PURE__ */ o(i, { children: [!p && /* @__PURE__ */ a("div", {
23
- className: r(s.answerContent, v && s.sidebar, "Answer-text", h),
24
- ..._,
25
- children: c
26
- }), p && c && /* @__PURE__ */ a("div", {
27
- className: r(s.answerContent, s.answerMarkdown, v && s.sidebar, "Answer-text", h),
28
- ..._,
29
- children: y(c)
30
- })] });
31
- };
32
- export { c as t };
1
+ import{t as markdownToHtmlString}from"./markdown.js";import injectInlineCitation from"../esm/lib/utils/inlineCitationsUtils.js";import MarkdownRenderer from"../esm/lib/components/common/markdown-react.js";import clsx from"clsx";import"react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import '../styles/answer-content.css';var answer_content_module_default={answerContent:`_answerContent_xrq8x_27`,answerMarkdown:`_answerMarkdown_xrq8x_53`},AnswerContent=({answer,items,isCompleted,isInlineCitationV2Enabled,isInlineCitationsEnabled,isMarkdownEnabled,isReactMarkdownEnabled=!1,className,variant=`modal`,...rest})=>{let hasSidebarVariant=variant===`sidebar`,renderMarkdown=content=>{let processedContent=injectInlineCitation(content,{items,isCompleted,isInlineCitationsEnabled});return isReactMarkdownEnabled?jsx(MarkdownRenderer,{isInlineCitationV2Enabled,children:processedContent}):jsx(`div`,{dangerouslySetInnerHTML:{__html:markdownToHtmlString(processedContent)}})};return jsxs(Fragment,{children:[!isMarkdownEnabled&&jsx(`div`,{className:clsx(answer_content_module_default.answerContent,hasSidebarVariant&&answer_content_module_default.sidebar,`Answer-text`,className),...rest,children:answer}),isMarkdownEnabled&&answer&&jsx(`div`,{className:clsx(answer_content_module_default.answerContent,answer_content_module_default.answerMarkdown,hasSidebarVariant&&answer_content_module_default.sidebar,`Answer-text`,className),...rest,children:renderMarkdown(answer)})]})};export{AnswerContent as t};
@@ -1,183 +1 @@
1
- import { t as e } from "./types.js";
2
- import { t } from "./media-container.js";
3
- import n from "../esm/lib/components/answer/messages.js";
4
- import { BoxAILoadingIndicator as r } from "../esm/lib/components/thinkingBubble/boxAILoadingIndicator.js";
5
- import { t as i } from "./answer-content.js";
6
- import { CopyButton as a } from "../esm/lib/components/answer/copy-button.js";
7
- import { t as o } from "./embed-the-answer-button.js";
8
- import { t as s } from "./inline-error.js";
9
- import { t as c } from "./references.js";
10
- import { t as l } from "./thumb-buttons.js";
11
- import u from "clsx";
12
- import { memo as d, useEffect as f, useState as p } from "react";
13
- import { Text as m } from "@box/blueprint-web";
14
- import { useIntl as ee } from "react-intl";
15
- import { Gray65 as h, Size4 as g } from "@box/blueprint-web-assets/tokens/tokens";
16
- import { AlertTriangle as _ } from "@box/blueprint-web-assets/icons/Line";
17
- import { jsx as v, jsxs as y } from "react/jsx-runtime";
18
- import '../styles/answer.css';var b = {
19
- answer: "_answer_ihjmy_27",
20
- loadingContainer: "_loadingContainer_ihjmy_31",
21
- loadingText: "_loadingText_ihjmy_38",
22
- fadeIn: "_fadeIn_ihjmy_1",
23
- alertIcon: "_alertIcon_ihjmy_47",
24
- error: "_error_ihjmy_50",
25
- footer: "_footer_ihjmy_54",
26
- copyButtonContainer: "_copyButtonContainer_ihjmy_60",
27
- feedbackButtonsContainer: "_feedbackButtonsContainer_ihjmy_61",
28
- shouldHaveMarginTop: "_shouldHaveMarginTop_ihjmy_65",
29
- shouldUseAnimation: "_shouldUseAnimation_ihjmy_68",
30
- shouldAnimateHeight: "_shouldAnimateHeight_ihjmy_72",
31
- footerButtons: "_footerButtons_ihjmy_76",
32
- embedTheAnswerButtonContainer: "_embedTheAnswerButtonContainer_ihjmy_82",
33
- buttonsVisible: "_buttonsVisible_ihjmy_90"
34
- }, x = new Set([
35
- e.RATE_LIMITING,
36
- e.NO_CONTENT,
37
- e.PRECONDITION_FAILED,
38
- e.GENERAL,
39
- e.AGENT_NOT_FOUND
40
- ]), S = /*#__PURE__*/ d(({ answer: d, citations: S, error: C, contentType: te, hostAppName: w, feedbackValue: T, isCitationsEnabled: E = !1, isCompleted: D = !1, isFeedbackEnabled: O = !1, isFeedbackFormEnabled: k, isFeedbackTooltipOpen: A, isInlineCitationsEnabled: j = !1, isInlineCitationV2Enabled: M, isLoading: N = !1, isMarkdownEnabled: P = !1, items: F = [], onAnswerCopy: I, embedTheAnswerButtonConfig: L, onCitationClick: R, onFeedbackFormSubmit: z, onFeedbackTooltipOpenChange: ne, prompt: B, promptType: V, recordAction: H, shouldFeedbackFormIncludeFeedbackText: U, shouldFeedbackIncludePromptData: W, useAnimation: G = !0, variant: K = "modal", isReactMarkdownEnabled: q, setAnswerFeedback: J, questionId: Y }) => {
41
- let X = x.has(C), Z = N && !d && !C, [re, ie] = p(D), { formatMessage: Q } = ee();
42
- f(() => {
43
- d && H && D && F.some((e) => d.includes(e.name)) && H({
44
- action: "programmatic",
45
- component: K,
46
- feature: "answers",
47
- target: "links_detected",
48
- data: {
49
- hostAppName: w,
50
- linkCount: F.length,
51
- fileNameCount: F.length
52
- }
53
- });
54
- }, [
55
- d,
56
- K,
57
- w,
58
- D,
59
- H,
60
- F
61
- ]), f(() => {
62
- setTimeout(() => ie(D), 0);
63
- }, [D]);
64
- let $ = () => /* @__PURE__ */ v(_, {
65
- className: b.alertIcon,
66
- color: h,
67
- "data-testid": "content-answers-error-alert-icon",
68
- height: g,
69
- role: "presentation",
70
- width: g
71
- }), ae = () => /* @__PURE__ */ y(m, {
72
- as: "p",
73
- className: b.error,
74
- color: "textOnLightSecondary",
75
- "data-testid": "content-answers-error",
76
- variant: "caption",
77
- children: [
78
- C === e.RESPONSE_INTERRUPTED && Q(n.responseInterruptedError),
79
- C === e.RESPONSE_FAILED && Q(n.responseFailedError),
80
- C === e.RESPONSE_STOPPED && Q(n.responseStoppedError),
81
- C !== e.RESPONSE_STOPPED && $()
82
- ]
83
- }), oe = () => C === e.RESPONSE_STOPPED ? d ? null : $() : /* @__PURE__ */ y("div", {
84
- className: u(b.footerButtons, "footer-buttons-container", { [b.buttonsVisible]: A }),
85
- children: [O ? /* @__PURE__ */ v("div", {
86
- className: b.feedbackButtonsContainer,
87
- children: /* @__PURE__ */ v(l, {
88
- feedbackValue: T,
89
- hostAppName: w,
90
- isFeedbackFormEnabled: k,
91
- isFeedbackTooltipOpen: A,
92
- items: F,
93
- onFeedbackFormSubmit: z,
94
- onFeedbackTooltipOpenChange: ne,
95
- prompt: B,
96
- promptType: V,
97
- questionId: Y,
98
- recordAction: H,
99
- response: d,
100
- setAnswerFeedback: J,
101
- shouldFeedbackFormIncludeFeedbackText: U,
102
- shouldFeedbackIncludePromptData: W,
103
- variant: K
104
- })
105
- }) : null, /* @__PURE__ */ v("div", {
106
- className: b.copyButtonContainer,
107
- children: /* @__PURE__ */ v(a, {
108
- answer: d,
109
- onAnswerCopy: I,
110
- recordAction: H
111
- })
112
- })]
113
- });
114
- return /* @__PURE__ */ y("div", {
115
- "aria-live": "polite",
116
- className: b.answer,
117
- "data-testid": "content-answers-answer",
118
- children: [
119
- Z && /* @__PURE__ */ y("div", {
120
- className: b.loadingContainer,
121
- children: [/* @__PURE__ */ v(r, {}), /* @__PURE__ */ v(m, {
122
- as: "span",
123
- className: b.loadingText,
124
- color: "textOnLightDefault",
125
- variant: "titleMedium",
126
- children: Q(n.analyzingRequest)
127
- })]
128
- }),
129
- !X && !Z && /* @__PURE__ */ v(t, {
130
- className: "answer",
131
- variant: K,
132
- children: /* @__PURE__ */ y(t.Content, {
133
- isUsedInsideSidebar: K === "sidebar",
134
- variant: "answer",
135
- children: [/* @__PURE__ */ v(i, {
136
- answer: d,
137
- isCompleted: D,
138
- isInlineCitationsEnabled: j,
139
- isInlineCitationV2Enabled: M,
140
- isMarkdownEnabled: P,
141
- isReactMarkdownEnabled: q,
142
- items: F,
143
- variant: K
144
- }), D && /* @__PURE__ */ y("div", {
145
- className: u(b.footer, {
146
- [b.shouldHaveMarginTop]: d,
147
- [b.shouldAnimateHeight]: re,
148
- [b.shouldUseAnimation]: G
149
- }),
150
- "data-testid": "content-answers-answer-footer",
151
- children: [
152
- C && ae(),
153
- E && !C && /* @__PURE__ */ v(c, {
154
- citations: S,
155
- onCitationClick: R,
156
- recordAction: H
157
- }),
158
- oe()
159
- ]
160
- })]
161
- })
162
- }),
163
- !X && !Z && D && L?.onAction && /* @__PURE__ */ v("div", {
164
- className: b.embedTheAnswerButtonContainer,
165
- children: /* @__PURE__ */ v(o, {
166
- answer: d,
167
- embedTheAnswerButtonConfig: L,
168
- hostAppName: w,
169
- questionId: Y,
170
- recordAction: H,
171
- variant: K
172
- })
173
- }),
174
- X && /* @__PURE__ */ v(s, {
175
- contentType: te,
176
- error: C,
177
- recordAction: H,
178
- variant: K
179
- })
180
- ]
181
- });
182
- });
183
- export { S as t };
1
+ import{t as ANSWER_ERROR}from"./types.js";import{t as MediaContainer}from"./media-container.js";import messages from"../esm/lib/components/answer/messages.js";import{BoxAILoadingIndicator}from"../esm/lib/components/thinkingBubble/boxAILoadingIndicator.js";import{t as AnswerContent}from"./answer-content.js";import{CopyButton}from"../esm/lib/components/answer/copy-button.js";import{t as EmbedTheAnswerButton}from"./embed-the-answer-button.js";import{t as InlineError}from"./inline-error.js";import{t as References}from"./references.js";import{t as ThumbButtons}from"./thumb-buttons.js";import clsx from"clsx";import{memo,useEffect,useState}from"react";import{Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Gray65,Size4}from"@box/blueprint-web-assets/tokens/tokens";import{AlertTriangle}from"@box/blueprint-web-assets/icons/Line";import{jsx,jsxs}from"react/jsx-runtime";import '../styles/answer.css';var answer_module_default={answer:`_answer_ihjmy_27`,loadingContainer:`_loadingContainer_ihjmy_31`,loadingText:`_loadingText_ihjmy_38`,fadeIn:`_fadeIn_ihjmy_1`,alertIcon:`_alertIcon_ihjmy_47`,error:`_error_ihjmy_50`,footer:`_footer_ihjmy_54`,copyButtonContainer:`_copyButtonContainer_ihjmy_60`,feedbackButtonsContainer:`_feedbackButtonsContainer_ihjmy_61`,shouldHaveMarginTop:`_shouldHaveMarginTop_ihjmy_65`,shouldUseAnimation:`_shouldUseAnimation_ihjmy_68`,shouldAnimateHeight:`_shouldAnimateHeight_ihjmy_72`,footerButtons:`_footerButtons_ihjmy_76`,embedTheAnswerButtonContainer:`_embedTheAnswerButtonContainer_ihjmy_82`,buttonsVisible:`_buttonsVisible_ihjmy_90`},INLINE_ERRORS=new Set([ANSWER_ERROR.RATE_LIMITING,ANSWER_ERROR.NO_CONTENT,ANSWER_ERROR.PRECONDITION_FAILED,ANSWER_ERROR.GENERAL,ANSWER_ERROR.AGENT_NOT_FOUND]),Answer=memo(({answer,citations,error,contentType,hostAppName,feedbackValue,isCitationsEnabled=!1,isCompleted=!1,isFeedbackEnabled=!1,isFeedbackFormEnabled,isFeedbackTooltipOpen,isInlineCitationsEnabled=!1,isInlineCitationV2Enabled,isLoading=!1,isMarkdownEnabled=!1,items=[],onAnswerCopy,embedTheAnswerButtonConfig,onCitationClick,onFeedbackFormSubmit,onFeedbackTooltipOpenChange,prompt,promptType,recordAction,shouldFeedbackFormIncludeFeedbackText,shouldFeedbackIncludePromptData,useAnimation=!0,variant=`modal`,isReactMarkdownEnabled,setAnswerFeedback,questionId})=>{let isInlineError=INLINE_ERRORS.has(error),shouldShowLoadingIndicator=isLoading&&!answer&&!error,[isFooterMounted,setIsFooterMounted]=useState(isCompleted),{formatMessage}=useIntl();useEffect(()=>{answer&&recordAction&&isCompleted&&items.some(item=>answer.includes(item.name))&&recordAction({action:`programmatic`,component:variant,feature:`answers`,target:`links_detected`,data:{hostAppName,linkCount:items.length,fileNameCount:items.length}})},[answer,variant,hostAppName,isCompleted,recordAction,items]),useEffect(()=>{setTimeout(()=>setIsFooterMounted(isCompleted),0)},[isCompleted]);let renderAlertTriangle=()=>jsx(AlertTriangle,{className:answer_module_default.alertIcon,color:Gray65,"data-testid":`content-answers-error-alert-icon`,height:Size4,role:`presentation`,width:Size4}),renderErrorInsideAnswer=()=>jsxs(Text,{as:`p`,className:answer_module_default.error,color:`textOnLightSecondary`,"data-testid":`content-answers-error`,variant:`caption`,children:[error===ANSWER_ERROR.RESPONSE_INTERRUPTED&&formatMessage(messages.responseInterruptedError),error===ANSWER_ERROR.RESPONSE_FAILED&&formatMessage(messages.responseFailedError),error===ANSWER_ERROR.RESPONSE_STOPPED&&formatMessage(messages.responseStoppedError),error!==ANSWER_ERROR.RESPONSE_STOPPED&&renderAlertTriangle()]}),renderFooterContent=()=>error===ANSWER_ERROR.RESPONSE_STOPPED?answer?null:renderAlertTriangle():jsxs(`div`,{className:clsx(answer_module_default.footerButtons,`footer-buttons-container`,{[answer_module_default.buttonsVisible]:isFeedbackTooltipOpen}),children:[isFeedbackEnabled?jsx(`div`,{className:answer_module_default.feedbackButtonsContainer,children:jsx(ThumbButtons,{feedbackValue,hostAppName,isFeedbackFormEnabled,isFeedbackTooltipOpen,items,onFeedbackFormSubmit,onFeedbackTooltipOpenChange,prompt,promptType,questionId,recordAction,response:answer,setAnswerFeedback,shouldFeedbackFormIncludeFeedbackText,shouldFeedbackIncludePromptData,variant})}):null,jsx(`div`,{className:answer_module_default.copyButtonContainer,children:jsx(CopyButton,{answer,onAnswerCopy,recordAction})})]});return jsxs(`div`,{"aria-live":`polite`,className:answer_module_default.answer,"data-testid":`content-answers-answer`,children:[shouldShowLoadingIndicator&&jsxs(`div`,{className:answer_module_default.loadingContainer,children:[jsx(BoxAILoadingIndicator,{}),jsx(Text,{as:`span`,className:answer_module_default.loadingText,color:`textOnLightDefault`,variant:`titleMedium`,children:formatMessage(messages.analyzingRequest)})]}),!isInlineError&&!shouldShowLoadingIndicator&&jsx(MediaContainer,{className:`answer`,variant,children:jsxs(MediaContainer.Content,{isUsedInsideSidebar:variant===`sidebar`,variant:`answer`,children:[jsx(AnswerContent,{answer,isCompleted,isInlineCitationsEnabled,isInlineCitationV2Enabled,isMarkdownEnabled,isReactMarkdownEnabled,items,variant}),isCompleted&&jsxs(`div`,{className:clsx(answer_module_default.footer,{[answer_module_default.shouldHaveMarginTop]:answer,[answer_module_default.shouldAnimateHeight]:isFooterMounted,[answer_module_default.shouldUseAnimation]:useAnimation}),"data-testid":`content-answers-answer-footer`,children:[error&&renderErrorInsideAnswer(),isCitationsEnabled&&!error&&jsx(References,{citations,onCitationClick,recordAction}),renderFooterContent()]})]})}),!isInlineError&&!shouldShowLoadingIndicator&&isCompleted&&embedTheAnswerButtonConfig?.onAction&&jsx(`div`,{className:answer_module_default.embedTheAnswerButtonContainer,children:jsx(EmbedTheAnswerButton,{answer,embedTheAnswerButtonConfig,hostAppName,questionId,recordAction,variant})}),isInlineError&&jsx(InlineError,{contentType,error,recordAction,variant})]})});export{Answer as t};
@@ -1,78 +1 @@
1
- import { r as e } from "./types.js";
2
- import { t } from "./content.js";
3
- import { Footer as n } from "../esm/lib/components/footer/footer.js";
4
- import r from "clsx";
5
- import * as i from "react";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
- import '../styles/box-ai-content-answers.css';var s = {
8
- container: "_container_h5a00_1",
9
- contentAnswers: "_contentAnswers_h5a00_8",
10
- sidebar: "_sidebar_h5a00_19"
11
- }, c = ({ className: c, contentType: l, contentName: u, error: d, hasCustomSuggestedQuestions: f, hasRequestInProgress: p, isAIStudioAgentSelectorEnabled: m, isDebugModeEnabled: h, isStopResponseEnabled: g, isStreamingEnabled: _, items: v, promptValue: y, questions: b, recordAction: x, retryQuestion: S, setPromptValue: C, showLoadingIndicator: w, stopQuestion: T, submitQuestion: E, suggestedQuestions: D, useAnimation: O, onAgentEditorToggle: k, onUserIntentToUseAI: A, promptButtonClickHandler: j, variant: M = "modal", hostAppName: N, isReactMarkdownEnabled: P, isInlineCitationV2Enabled: F, ...I }) => {
12
- let [L, R] = i.useState(null), [z, B] = i.useState(d != null), [V, H] = i.useState(!1), U = d === e.LARGE_FILE, W = (!z || U) && !w, G = (e) => {
13
- x && x({
14
- ...e,
15
- component: M
16
- });
17
- }, K = () => {
18
- A && A(!1);
19
- }, q = (e) => {
20
- R(e), A && A(!0);
21
- }, J = () => {
22
- A && A(!0);
23
- };
24
- return i.useEffect(() => {
25
- B(d != null);
26
- }, [d]), /* @__PURE__ */ a("div", {
27
- className: r(c, s.container),
28
- children: /* @__PURE__ */ o("div", {
29
- className: r(s.contentAnswers, M === "sidebar" && s.sidebar),
30
- children: [!V && /* @__PURE__ */ a(t, {
31
- ...I,
32
- askSuggestedQuestion: L,
33
- contentName: u,
34
- contentType: l,
35
- error: d,
36
- hasCustomSuggestedQuestions: f,
37
- hasRequestInProgress: p,
38
- hostAppName: N,
39
- isErrorMessageShown: z,
40
- isInlineCitationV2Enabled: F,
41
- isReactMarkdownEnabled: P,
42
- isStreamingEnabled: _,
43
- items: v,
44
- onSuggestedQuestionInteraction: K,
45
- questions: b,
46
- recordAction: G,
47
- setAskSuggestedQuestion: q,
48
- showLoadingIndicator: w,
49
- suggestedQuestions: D,
50
- useAnimation: _ && O,
51
- variant: M
52
- }), W && /* @__PURE__ */ a(n, {
53
- askSuggestedQuestion: L,
54
- enableDebugMode: h,
55
- hasRequestInProgress: p,
56
- isAIStudioAgentSelectorEnabled: m,
57
- isDebugModeShown: V,
58
- isStopResponseEnabled: g,
59
- isStreamingEnabled: _,
60
- lastQuestion: b[b.length - 1],
61
- onRetryQuestion: S,
62
- onStopQuestion: T,
63
- onUserInteraction: J,
64
- promptButtonClickHandler: j,
65
- promptValue: y,
66
- recordAction: G,
67
- sendQuestion: E,
68
- setAskSuggestedQuestion: R,
69
- setPromptValue: C,
70
- toggleDebugMode: () => {
71
- H(!V);
72
- },
73
- variant: M
74
- })]
75
- })
76
- });
77
- };
78
- export { c as t };
1
+ import{r as CONTENT_ERROR}from"./types.js";import{t as Content}from"./content.js";import{Footer}from"../esm/lib/components/footer/footer.js";import clsx from"clsx";import*as React$1 from"react";import{jsx,jsxs}from"react/jsx-runtime";import '../styles/box-ai-content-answers.css';var box_ai_content_answers_module_default={container:`_container_h5a00_1`,contentAnswers:`_contentAnswers_h5a00_8`,sidebar:`_sidebar_h5a00_19`},BoxAiContentAnswers=({className,contentType,contentName,error,hasCustomSuggestedQuestions,hasRequestInProgress,isAIStudioAgentSelectorEnabled,isDebugModeEnabled,isStopResponseEnabled,isStreamingEnabled,items,promptValue,questions,recordAction,retryQuestion,setPromptValue,showLoadingIndicator,stopQuestion,submitQuestion,suggestedQuestions,useAnimation,onAgentEditorToggle,onUserIntentToUseAI,promptButtonClickHandler,variant=`modal`,hostAppName,isReactMarkdownEnabled,isInlineCitationV2Enabled,...rest})=>{let[askSuggestedQuestion,setAskSuggestedQuestion]=React$1.useState(null),[isErrorMessageShown,setIsErrorMessageShown]=React$1.useState(error!=null),[isDebugModeShown,setIsDebugModeShown]=React$1.useState(!1),isFileSizeError=error===CONTENT_ERROR.LARGE_FILE,isFooterEnabled=(!isErrorMessageShown||isFileSizeError)&&!showLoadingIndicator,handleRecordAction=event=>{recordAction&&recordAction({...event,component:variant})},handleSuggestedQuestionInteraction=()=>{onUserIntentToUseAI&&onUserIntentToUseAI(!1)},handleSuggestedQuestionChange=selectedValue=>{setAskSuggestedQuestion(selectedValue),onUserIntentToUseAI&&onUserIntentToUseAI(!0)},handleFooterInteraction=()=>{onUserIntentToUseAI&&onUserIntentToUseAI(!0)};return React$1.useEffect(()=>{setIsErrorMessageShown(error!=null)},[error]),jsx(`div`,{className:clsx(className,box_ai_content_answers_module_default.container),children:jsxs(`div`,{className:clsx(box_ai_content_answers_module_default.contentAnswers,variant===`sidebar`&&box_ai_content_answers_module_default.sidebar),children:[!isDebugModeShown&&jsx(Content,{...rest,askSuggestedQuestion,contentName,contentType,error,hasCustomSuggestedQuestions,hasRequestInProgress,hostAppName,isErrorMessageShown,isInlineCitationV2Enabled,isReactMarkdownEnabled,isStreamingEnabled,items,onSuggestedQuestionInteraction:handleSuggestedQuestionInteraction,questions,recordAction:handleRecordAction,setAskSuggestedQuestion:handleSuggestedQuestionChange,showLoadingIndicator,suggestedQuestions,useAnimation:isStreamingEnabled&&useAnimation,variant}),isFooterEnabled&&jsx(Footer,{askSuggestedQuestion,enableDebugMode:isDebugModeEnabled,hasRequestInProgress,isAIStudioAgentSelectorEnabled,isDebugModeShown,isStopResponseEnabled,isStreamingEnabled,lastQuestion:questions[questions.length-1],onRetryQuestion:retryQuestion,onStopQuestion:stopQuestion,onUserInteraction:handleFooterInteraction,promptButtonClickHandler,promptValue,recordAction:handleRecordAction,sendQuestion:submitQuestion,setAskSuggestedQuestion,setPromptValue,toggleDebugMode:()=>{setIsDebugModeShown(!isDebugModeShown)},variant})]})})};export{BoxAiContentAnswers as t};
@@ -1,116 +1 @@
1
- import { t as e } from "./media-container.js";
2
- import { t } from "./answer.js";
3
- import { t as n } from "./question.js";
4
- import { t as r } from "./suggested-questions.js";
5
- import { t as i } from "./thinkingBubble.js";
6
- import a from "../esm/lib/components/welcome-message/messages.js";
7
- import { WelcomeMessage as o } from "../esm/lib/components/welcome-message/welcome-message.js";
8
- import s from "clsx";
9
- import * as c from "react";
10
- import { Text as l } from "@box/blueprint-web";
11
- import { useIntl as u } from "react-intl";
12
- import { BoxAiLogo as d } from "@box/blueprint-web-assets/icons/Logo";
13
- import { Size10 as f } from "@box/blueprint-web-assets/tokens/tokens";
14
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
15
- import '../styles/chat.css';var h = {
16
- chat: "_chat_ei94z_27",
17
- clearChatText: "_clearChatText_ei94z_27",
18
- landingPage: "_landingPage_ei94z_33",
19
- iconAvatar: "_iconAvatar_ei94z_46",
20
- sidebar: "_sidebar_ei94z_64"
21
- }, g = ({ askSuggestedQuestion: g, contentType: _, hasCustomSuggestedQuestions: v, hasRequestInProgress: y, isCitationsEnabled: b, isFeedbackEnabled: x, isFeedbackFormEnabled: S, isInlineCitationsEnabled: C = !1, isInlineCitationV2Enabled: w, isMarkdownEnabled: T, isSessionLoading: E = !1, onCitationClick: D, onAnswerCopy: O, embedTheAnswerButtonConfig: k, onFeedbackFormSubmit: A, onDropdownOpenChange: j, onSuggestedQuestionInteraction: M, questions: N, recordAction: P, setAnswerFeedback: F, setAskSuggestedQuestion: I, suggestedQuestions: L, suggestedQuestionsRequestState: R, shouldFeedbackFormIncludeFeedbackText: z, shouldFeedbackIncludePromptData: B, shouldShowLandingPage: V, useAnimation: H, variant: U = "modal", hostAppName: W = "", isReactMarkdownEnabled: G, welcomeMessageClearText: K, ...q }) => {
22
- let { formatMessage: J } = u(), [Y, X] = c.useState(null), Z = (e, t) => {
23
- X(e ? t : null);
24
- };
25
- return /* @__PURE__ */ p("div", {
26
- className: h.chat,
27
- "data-testid": "content-answers-chat",
28
- children: /* @__PURE__ */ m("div", {
29
- className: s({
30
- [h.landingPage]: V,
31
- [h.sidebar]: U === "sidebar"
32
- }),
33
- children: [
34
- V && /* @__PURE__ */ p(e.Figure, {
35
- variant: U,
36
- children: /* @__PURE__ */ p("div", {
37
- className: h.iconAvatar,
38
- children: /* @__PURE__ */ p(d, {
39
- height: f,
40
- role: "presentation",
41
- width: f
42
- })
43
- })
44
- }),
45
- /* @__PURE__ */ p(o, {
46
- contentType: "",
47
- shouldShowLandingPage: V,
48
- ...q,
49
- variant: U
50
- }),
51
- V && L !== void 0 && I !== void 0 && /* @__PURE__ */ p(r, {
52
- askSuggestedQuestion: g,
53
- hasCustomSuggestedQuestions: v,
54
- isLoading: y,
55
- onSuggestedQuestionInteraction: M,
56
- recordAction: P,
57
- setAskSuggestedQuestion: I,
58
- suggestedQuestions: L,
59
- suggestedQuestionsRequestState: R,
60
- variant: U
61
- }),
62
- /* @__PURE__ */ p(l, {
63
- as: "p",
64
- className: h.clearChatText,
65
- children: K || J(a.welcomeClearChatText, { type: _ })
66
- }),
67
- !V && /* @__PURE__ */ p("ul", { children: N.map(({ answer: e, thinkingAnswer: r, citations: a, id: o, isCompleted: s, isLoading: c, error: l, prompt: u, promptType: d, feedbackValue: f }) => /* @__PURE__ */ m("li", { children: [
68
- /* @__PURE__ */ p(n, {
69
- prompt: u,
70
- variant: U
71
- }),
72
- r && /* @__PURE__ */ p(i, {
73
- content: r,
74
- isThinkingComplete: !!e,
75
- onDropdownOpenChange: j,
76
- variant: U
77
- }),
78
- /* @__PURE__ */ p(t, {
79
- answer: e,
80
- citations: a,
81
- contentType: _,
82
- embedTheAnswerButtonConfig: k,
83
- error: l,
84
- feedbackValue: f,
85
- hostAppName: W,
86
- isCitationsEnabled: b,
87
- isCompleted: s,
88
- isFeedbackEnabled: x,
89
- isFeedbackFormEnabled: S,
90
- isFeedbackTooltipOpen: Y === o,
91
- isInlineCitationsEnabled: C,
92
- isInlineCitationV2Enabled: w,
93
- isLoading: c || E,
94
- isMarkdownEnabled: T,
95
- isReactMarkdownEnabled: G,
96
- items: q.items,
97
- onAnswerCopy: O,
98
- onCitationClick: D,
99
- onFeedbackFormSubmit: A,
100
- onFeedbackTooltipOpenChange: Z,
101
- prompt: u,
102
- promptType: d,
103
- questionId: o,
104
- recordAction: P,
105
- setAnswerFeedback: F,
106
- shouldFeedbackFormIncludeFeedbackText: z,
107
- shouldFeedbackIncludePromptData: B,
108
- useAnimation: H,
109
- variant: U
110
- })
111
- ] }, o)) })
112
- ]
113
- })
114
- });
115
- };
116
- export { g as t };
1
+ import{t as MediaContainer}from"./media-container.js";import{t as Answer}from"./answer.js";import{t as Question}from"./question.js";import{t as SuggestedQuestions}from"./suggested-questions.js";import{t as ThinkingBubble}from"./thinkingBubble.js";import messages from"../esm/lib/components/welcome-message/messages.js";import{WelcomeMessage}from"../esm/lib/components/welcome-message/welcome-message.js";import clsx from"clsx";import*as React$1 from"react";import{Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{BoxAiLogo}from"@box/blueprint-web-assets/icons/Logo";import{Size10}from"@box/blueprint-web-assets/tokens/tokens";import{jsx,jsxs}from"react/jsx-runtime";import '../styles/chat.css';var chat_module_default={chat:`_chat_ei94z_27`,clearChatText:`_clearChatText_ei94z_27`,landingPage:`_landingPage_ei94z_33`,iconAvatar:`_iconAvatar_ei94z_46`,sidebar:`_sidebar_ei94z_64`},Chat=({askSuggestedQuestion,contentType,hasCustomSuggestedQuestions,hasRequestInProgress,isCitationsEnabled,isFeedbackEnabled,isFeedbackFormEnabled,isInlineCitationsEnabled=!1,isInlineCitationV2Enabled,isMarkdownEnabled,isSessionLoading=!1,onCitationClick,onAnswerCopy,embedTheAnswerButtonConfig,onFeedbackFormSubmit,onDropdownOpenChange,onSuggestedQuestionInteraction,questions,recordAction,setAnswerFeedback,setAskSuggestedQuestion,suggestedQuestions,suggestedQuestionsRequestState,shouldFeedbackFormIncludeFeedbackText,shouldFeedbackIncludePromptData,shouldShowLandingPage,useAnimation,variant=`modal`,hostAppName=``,isReactMarkdownEnabled,welcomeMessageClearText,...welcomeMessageProps})=>{let{formatMessage}=useIntl(),[openFeedbackTooltipAnswerId,setOpenFeedbackTooltipAnswerId]=React$1.useState(null),handleFeedbackTooltipOpenChange=(isOpen,questionId)=>{setOpenFeedbackTooltipAnswerId(isOpen?questionId:null)};return jsx(`div`,{className:chat_module_default.chat,"data-testid":`content-answers-chat`,children:jsxs(`div`,{className:clsx({[chat_module_default.landingPage]:shouldShowLandingPage,[chat_module_default.sidebar]:variant===`sidebar`}),children:[shouldShowLandingPage&&jsx(MediaContainer.Figure,{variant,children:jsx(`div`,{className:chat_module_default.iconAvatar,children:jsx(BoxAiLogo,{height:Size10,role:`presentation`,width:Size10})})}),jsx(WelcomeMessage,{contentType:``,shouldShowLandingPage,...welcomeMessageProps,variant}),shouldShowLandingPage&&suggestedQuestions!==void 0&&setAskSuggestedQuestion!==void 0&&jsx(SuggestedQuestions,{askSuggestedQuestion,hasCustomSuggestedQuestions,isLoading:hasRequestInProgress,onSuggestedQuestionInteraction,recordAction,setAskSuggestedQuestion,suggestedQuestions,suggestedQuestionsRequestState,variant}),jsx(Text,{as:`p`,className:chat_module_default.clearChatText,children:welcomeMessageClearText||formatMessage(messages.welcomeClearChatText,{type:contentType})}),!shouldShowLandingPage&&jsx(`ul`,{children:questions.map(({answer,thinkingAnswer,citations,id,isCompleted,isLoading,error,prompt,promptType,feedbackValue})=>jsxs(`li`,{children:[jsx(Question,{prompt,variant}),thinkingAnswer&&jsx(ThinkingBubble,{content:thinkingAnswer,isThinkingComplete:!!answer,onDropdownOpenChange,variant}),jsx(Answer,{answer,citations,contentType,embedTheAnswerButtonConfig,error,feedbackValue,hostAppName,isCitationsEnabled,isCompleted,isFeedbackEnabled,isFeedbackFormEnabled,isFeedbackTooltipOpen:openFeedbackTooltipAnswerId===id,isInlineCitationsEnabled,isInlineCitationV2Enabled,isLoading:isLoading||isSessionLoading,isMarkdownEnabled,isReactMarkdownEnabled,items:welcomeMessageProps.items,onAnswerCopy,onCitationClick,onFeedbackFormSubmit,onFeedbackTooltipOpenChange:handleFeedbackTooltipOpenChange,prompt,promptType,questionId:id,recordAction,setAnswerFeedback,shouldFeedbackFormIncludeFeedbackText,shouldFeedbackIncludePromptData,useAnimation,variant})]},id))})]})})};export{Chat as t};
@@ -1,124 +1 @@
1
- import { n as e } from "./types.js";
2
- import t from "../esm/lib/components/answer/messages.js";
3
- import { LOGGER_ACTION_CLICK as n, LOGGER_BASE_CONFIG as r } from "../esm/lib/components/common/constants.js";
4
- import "../esm/lib/components/answer/constants.js";
5
- import i from "clsx";
6
- import { useCallback as a, useEffect as o, useRef as s, useState as c } from "react";
7
- import { Popover as l, Status as u, Text as d, TextButton as f } from "@box/blueprint-web";
8
- import { useIntl as p } from "react-intl";
9
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
10
- import { ArrowUpRightSquare as g } from "@box/blueprint-web-assets/icons/Fill";
11
- import _ from "lodash/debounce";
12
- import v from "lodash/truncate";
13
- import '../styles/citation.css';var y = {
14
- citationTrigger: "_citationTrigger_4yo68_1",
15
- citationStatus: "_citationStatus_4yo68_5",
16
- animate: "_animate_4yo68_26",
17
- fadeIn: "_fadeIn_4yo68_30",
18
- cardTooltip: "_cardTooltip_4yo68_34",
19
- cardTooltipTitle: "_cardTooltipTitle_4yo68_38",
20
- cardTooltipCitation: "_cardTooltipCitation_4yo68_42",
21
- cardTooltipButton: "_cardTooltipButton_4yo68_47"
22
- }, b = ({ animate: b, content: x, id: S, recordAction: C, fileId: w, title: T, onCitationClick: E, source: D }) => {
23
- let [O, k] = c(!1), [A, j] = c(!b), { formatMessage: M } = p(), N = !!E && D !== e.HUBS_METADATA, P = s(null), F;
24
- F = T ? M(t.cardTooltipTitleWithDocumentName, { title: T.toString() }) : M(t.cardTooltipTitle);
25
- let I = _((e) => {
26
- k(e), e === !0 && C && C({
27
- ...r,
28
- feature: "answers-citations",
29
- target: "hovered",
30
- data: { index: S }
31
- });
32
- }, 100), L = () => {
33
- I(!0);
34
- }, R = () => {
35
- I(!1);
36
- }, z = a(() => {
37
- E && C && (E(w, T), C({
38
- ...r,
39
- feature: "answers-citations",
40
- target: n,
41
- data: { index: S }
42
- }));
43
- }, [
44
- E,
45
- C,
46
- S,
47
- w,
48
- T
49
- ]);
50
- o(() => {
51
- b && j(!0);
52
- }, []);
53
- let B = x ? v(x.toString(), {
54
- length: 500,
55
- separator: /,? +/
56
- }) : void 0;
57
- return /* @__PURE__ */ h(l.Root, {
58
- modal: !1,
59
- open: O,
60
- children: [/* @__PURE__ */ m(l.Trigger, {
61
- className: y.citationTrigger,
62
- onMouseEnter: L,
63
- onMouseLeave: R,
64
- children: /* @__PURE__ */ m(u, {
65
- ref: P,
66
- "aria-label": O ? B : M(t.referenceAriaLabel, { number: S }),
67
- className: i(y.citationStatus, {
68
- [y.animate]: b,
69
- [y.fadeIn]: A
70
- }),
71
- colorIndex: 0,
72
- "data-testid": "content-answers-citation-status",
73
- onBlur: R,
74
- onFocus: L,
75
- tabIndex: 0,
76
- text: `${S}`
77
- })
78
- }), /* @__PURE__ */ m(l.ContentContainer, {
79
- "aria-label": B,
80
- collisionPadding: 10,
81
- "data-testid": "content-answers-citation-card",
82
- onBlur: R,
83
- onCloseAutoFocus: (e) => e.preventDefault(),
84
- onEscapeKeyDown: () => {
85
- P.current?.focus(), R();
86
- },
87
- onFocus: L,
88
- onMouseEnter: L,
89
- onMouseLeave: R,
90
- onOpenAutoFocus: (e) => {
91
- N || e.preventDefault();
92
- },
93
- side: "top",
94
- sideOffset: 5,
95
- children: /* @__PURE__ */ m(l.MainContent, { children: /* @__PURE__ */ h("div", {
96
- className: y.cardTooltip,
97
- children: [
98
- /* @__PURE__ */ m(d, {
99
- as: "h4",
100
- className: y.cardTooltipTitle,
101
- variant: "bodyDefaultBold",
102
- children: F
103
- }),
104
- /* @__PURE__ */ m(d, {
105
- as: "p",
106
- className: y.cardTooltipCitation,
107
- color: "textOnLightDefault",
108
- variant: "caption",
109
- children: B
110
- }),
111
- N && /* @__PURE__ */ m(f, {
112
- "aria-label": M(t.cardTooltipButton),
113
- className: y.cardTooltipButton,
114
- icon: g,
115
- onClick: z,
116
- "data-target-id": "TextButton-cardTooltipButton",
117
- children: M(t.cardTooltipButton)
118
- })
119
- ]
120
- }) })
121
- })]
122
- });
123
- };
124
- export { b as t };
1
+ import{n as CITATION_SOURCE}from"./types.js";import messages from"../esm/lib/components/answer/messages.js";import{LOGGER_ACTION_CLICK,LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import"../esm/lib/components/answer/constants.js";import clsx from"clsx";import{useCallback,useEffect,useRef,useState}from"react";import{Popover,Status,Text,TextButton}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{ArrowUpRightSquare}from"@box/blueprint-web-assets/icons/Fill";import debounce from"lodash/debounce";import truncate from"lodash/truncate";import '../styles/citation.css';var citation_module_default={citationTrigger:`_citationTrigger_4yo68_1`,citationStatus:`_citationStatus_4yo68_5`,animate:`_animate_4yo68_26`,fadeIn:`_fadeIn_4yo68_30`,cardTooltip:`_cardTooltip_4yo68_34`,cardTooltipTitle:`_cardTooltipTitle_4yo68_38`,cardTooltipCitation:`_cardTooltipCitation_4yo68_42`,cardTooltipButton:`_cardTooltipButton_4yo68_47`},Citation=({animate,content,id,recordAction,fileId,title,onCitationClick,source})=>{let[open,setOpen]=useState(!1),[showCitation,setShowCitation]=useState(!animate),{formatMessage}=useIntl(),showCitationButton=!!onCitationClick&&source!==CITATION_SOURCE.HUBS_METADATA,statusRef=useRef(null),cardTooltipTitle;cardTooltipTitle=title?formatMessage(messages.cardTooltipTitleWithDocumentName,{title:title.toString()}):formatMessage(messages.cardTooltipTitle);let debouncedTooltipUpdate=debounce(state=>{setOpen(state),state===!0&&recordAction&&recordAction({...LOGGER_BASE_CONFIG,feature:`answers-citations`,target:`hovered`,data:{index:id}})},100),showTooltip=()=>{debouncedTooltipUpdate(!0)},hideTooltip=()=>{debouncedTooltipUpdate(!1)},handleCitationClick=useCallback(()=>{onCitationClick&&recordAction&&(onCitationClick(fileId,title),recordAction({...LOGGER_BASE_CONFIG,feature:`answers-citations`,target:LOGGER_ACTION_CLICK,data:{index:id}}))},[onCitationClick,recordAction,id,fileId,title]);useEffect(()=>{animate&&setShowCitation(!0)},[]);let contentTruncated=content?truncate(content.toString(),{length:500,separator:/,? +/}):void 0;return jsxs(Popover.Root,{modal:!1,open,children:[jsx(Popover.Trigger,{className:citation_module_default.citationTrigger,onMouseEnter:showTooltip,onMouseLeave:hideTooltip,children:jsx(Status,{ref:statusRef,"aria-label":open?contentTruncated:formatMessage(messages.referenceAriaLabel,{number:id}),className:clsx(citation_module_default.citationStatus,{[citation_module_default.animate]:animate,[citation_module_default.fadeIn]:showCitation}),colorIndex:0,"data-testid":`content-answers-citation-status`,onBlur:hideTooltip,onFocus:showTooltip,tabIndex:0,text:`${id}`})}),jsx(Popover.ContentContainer,{"aria-label":contentTruncated,collisionPadding:10,"data-testid":`content-answers-citation-card`,onBlur:hideTooltip,onCloseAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:()=>{statusRef.current?.focus(),hideTooltip()},onFocus:showTooltip,onMouseEnter:showTooltip,onMouseLeave:hideTooltip,onOpenAutoFocus:e=>{showCitationButton||e.preventDefault()},side:`top`,sideOffset:5,children:jsx(Popover.MainContent,{children:jsxs(`div`,{className:citation_module_default.cardTooltip,children:[jsx(Text,{as:`h4`,className:citation_module_default.cardTooltipTitle,variant:`bodyDefaultBold`,children:cardTooltipTitle}),jsx(Text,{as:`p`,className:citation_module_default.cardTooltipCitation,color:`textOnLightDefault`,variant:`caption`,children:contentTruncated}),showCitationButton&&jsx(TextButton,{"aria-label":formatMessage(messages.cardTooltipButton),className:citation_module_default.cardTooltipButton,icon:ArrowUpRightSquare,onClick:handleCitationClick,"data-target-id":`TextButton-cardTooltipButton`,children:formatMessage(messages.cardTooltipButton)})]})})})]})};export{Citation as t};
@@ -1,37 +1 @@
1
- import e from "../esm/lib/components/modal/messages.js";
2
- import t from "clsx";
3
- import { IconButton as n, Tooltip as r, useBlueprintModernization as i } from "@box/blueprint-web";
4
- import { useIntl as a } from "react-intl";
5
- import { Trash as o } from "@box/blueprint-web-assets/icons/Line";
6
- import { jsx as s } from "react/jsx-runtime";
7
- import { Trash as c } from "@box/blueprint-web-assets/icons/Medium";
8
- import '../styles/clear-conversation-button.css';var l = {
9
- BoxAIIconColor: "_BoxAIIconColor_ild3b_1",
10
- modalHeader: "_modalHeader_ild3b_5",
11
- contentAnswersModal: "_contentAnswersModal_ild3b_10",
12
- boxAiContentAnswers: "_boxAiContentAnswers_ild3b_18",
13
- clearButton: "_clearButton_ild3b_26",
14
- "modal-close-button": "_modal-close-button_ild3b_30",
15
- contentAnswerModal: "_contentAnswerModal_ild3b_1",
16
- modalHeaderContainer: "_modalHeaderContainer_ild3b_55",
17
- agentSelectorTrigger: "_agentSelectorTrigger_ild3b_63",
18
- agentSelectorContent: "_agentSelectorContent_ild3b_74"
19
- }, u = ({ onClick: u, hasRequestInProgress: d, className: f }) => {
20
- let p = a(), { enableModernizedComponents: m } = i(), h = m ? c : o;
21
- return /* @__PURE__ */ s(r, {
22
- content: p.formatMessage(e.clearConversationLabel),
23
- "data-testid": "clear-conversation-tooltip",
24
- variant: "standard",
25
- children: /* @__PURE__ */ s(n, {
26
- "aria-label": p.formatMessage(e.clearConversationLabel),
27
- className: t(l.clearButton, f),
28
- "data-testid": "clear-conversation-button",
29
- disabled: d,
30
- icon: h,
31
- onClick: u,
32
- size: "small",
33
- "data-target-id": "IconButton-clearConversationLabel"
34
- })
35
- });
36
- };
37
- export { l as n, u as t };
1
+ import messages from"../esm/lib/components/modal/messages.js";import clsx from"clsx";import{IconButton,Tooltip,useBlueprintModernization}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Trash}from"@box/blueprint-web-assets/icons/Line";import{jsx}from"react/jsx-runtime";import{Trash as Trash$1}from"@box/blueprint-web-assets/icons/Medium";import '../styles/clear-conversation-button.css';var modal_module_default={BoxAIIconColor:`_BoxAIIconColor_ild3b_1`,modalHeader:`_modalHeader_ild3b_5`,contentAnswersModal:`_contentAnswersModal_ild3b_10`,boxAiContentAnswers:`_boxAiContentAnswers_ild3b_18`,clearButton:`_clearButton_ild3b_26`,"modal-close-button":`_modal-close-button_ild3b_30`,contentAnswerModal:`_contentAnswerModal_ild3b_1`,modalHeaderContainer:`_modalHeaderContainer_ild3b_55`,agentSelectorTrigger:`_agentSelectorTrigger_ild3b_63`,agentSelectorContent:`_agentSelectorContent_ild3b_74`},ClearConversationButton=({onClick,hasRequestInProgress,className})=>{let intl=useIntl(),{enableModernizedComponents}=useBlueprintModernization(),TrashIcon=enableModernizedComponents?Trash$1:Trash;return jsx(Tooltip,{content:intl.formatMessage(messages.clearConversationLabel),"data-testid":`clear-conversation-tooltip`,variant:`standard`,children:jsx(IconButton,{"aria-label":intl.formatMessage(messages.clearConversationLabel),className:clsx(modal_module_default.clearButton,className),"data-testid":`clear-conversation-button`,disabled:hasRequestInProgress,icon:TrashIcon,onClick,size:`small`,"data-target-id":`IconButton-clearConversationLabel`})})};export{modal_module_default as n,ClearConversationButton as t};