@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,13 +1 @@
1
- import '../styles/markdown2.css';var e = {
2
- markdownContent: "_markdownContent_1ajdm_27",
3
- inlineParagraph: "_inlineParagraph_1ajdm_31",
4
- tableWrapper: "_tableWrapper_1ajdm_37",
5
- hljs: "_hljs_1ajdm_81",
6
- hljsLanguage: "_hljsLanguage_1ajdm_93",
7
- hljsLine: "_hljsLine_1ajdm_123",
8
- hljsLineNumber: "_hljsLineNumber_1ajdm_128",
9
- hljsLineContent: "_hljsLineContent_1ajdm_140",
10
- inlineCitation: "_inlineCitation_1ajdm_145",
11
- inlineCitationWrapper: "_inlineCitationWrapper_1ajdm_170"
12
- };
13
- export { e as t };
1
+ import '../styles/markdown2.css';var markdown_module_default={markdownContent:`_markdownContent_1ajdm_27`,inlineParagraph:`_inlineParagraph_1ajdm_31`,tableWrapper:`_tableWrapper_1ajdm_37`,hljs:`_hljs_1ajdm_81`,hljsLanguage:`_hljsLanguage_1ajdm_93`,hljsLine:`_hljsLine_1ajdm_123`,hljsLineNumber:`_hljsLineNumber_1ajdm_128`,hljsLineContent:`_hljsLineContent_1ajdm_140`,inlineCitation:`_inlineCitation_1ajdm_145`,inlineCitationWrapper:`_inlineCitationWrapper_1ajdm_170`};export{markdown_module_default as t};
@@ -1,32 +1 @@
1
- import e from "clsx";
2
- import "react";
3
- import { Card as t } from "@box/blueprint-web";
4
- import { jsx as n } from "react/jsx-runtime";
5
- import '../styles/media-container.css';var r = {
6
- mediaContainer: "_mediaContainer_kxcsp_27",
7
- figure: "_figure_kxcsp_33",
8
- sidebar: "_sidebar_kxcsp_39",
9
- "center-aligned": "_center-aligned_kxcsp_42",
10
- "top-aligned": "_top-aligned_kxcsp_49",
11
- welcomeMessage: "_welcomeMessage_kxcsp_58",
12
- contentCard: "_contentCard_kxcsp_62",
13
- question: "_question_kxcsp_67",
14
- answer: "_answer_kxcsp_89",
15
- body: "_body_kxcsp_93",
16
- error: "_error_kxcsp_126"
17
- }, i = ({ children: t, className: i, variant: a = "modal" }) => /* @__PURE__ */ n("div", {
18
- className: e(r.mediaContainer, r[i], a === "sidebar" && r.sidebar),
19
- "data-testid": "content-answers-grid-card",
20
- children: t
21
- }), a = i;
22
- a.Figure = ({ children: t, isUsedInsideSidebar: i = !1, variant: a }) => /* @__PURE__ */ n("div", {
23
- className: e(r.figure, r[a], i && r.sidebar),
24
- children: t
25
- }), a.Content = ({ children: i, isUsedInsideSidebar: a = !1, variant: o, shouldAddCard: s = !0 }) => /* @__PURE__ */ n("div", {
26
- className: e(r.body, r[o], a && r.sidebar),
27
- children: s ? /* @__PURE__ */ n(t, {
28
- className: r.contentCard,
29
- children: i
30
- }) : i
31
- });
32
- export { i as n, a as t };
1
+ import clsx from"clsx";import"react";import{Card}from"@box/blueprint-web";import{jsx}from"react/jsx-runtime";import '../styles/media-container.css';var media_container_module_default={mediaContainer:`_mediaContainer_kxcsp_27`,figure:`_figure_kxcsp_33`,sidebar:`_sidebar_kxcsp_39`,"center-aligned":`_center-aligned_kxcsp_42`,"top-aligned":`_top-aligned_kxcsp_49`,welcomeMessage:`_welcomeMessage_kxcsp_58`,contentCard:`_contentCard_kxcsp_62`,question:`_question_kxcsp_67`,answer:`_answer_kxcsp_89`,body:`_body_kxcsp_93`,error:`_error_kxcsp_126`},MediaContainerBase=({children,className,variant=`modal`})=>jsx(`div`,{className:clsx(media_container_module_default.mediaContainer,media_container_module_default[className],variant===`sidebar`&&media_container_module_default.sidebar),"data-testid":`content-answers-grid-card`,children}),MediaContainer=MediaContainerBase;MediaContainer.Figure=({children,isUsedInsideSidebar=!1,variant})=>jsx(`div`,{className:clsx(media_container_module_default.figure,media_container_module_default[variant],isUsedInsideSidebar&&media_container_module_default.sidebar),children}),MediaContainer.Content=({children,isUsedInsideSidebar=!1,variant,shouldAddCard=!0})=>jsx(`div`,{className:clsx(media_container_module_default.body,media_container_module_default[variant],isUsedInsideSidebar&&media_container_module_default.sidebar),children:shouldAddCard?jsx(Card,{className:media_container_module_default.contentCard,children}):children});export{MediaContainerBase as n,MediaContainer as t};
@@ -1,29 +1 @@
1
- import { t as e } from "./media-container.js";
2
- import t from "clsx";
3
- import { Text as n } from "@box/blueprint-web";
4
- import { jsx as r } from "react/jsx-runtime";
5
- import '../styles/question.css';var i = {
6
- question: "_question_12q5v_27",
7
- sidebar: "_sidebar_12q5v_32",
8
- text: "_text_12q5v_35"
9
- }, a = ({ prompt: a, variant: o = "modal" }) => {
10
- let s = o === "sidebar", c = /* @__PURE__ */ r(e.Content, {
11
- isUsedInsideSidebar: s,
12
- variant: "question",
13
- children: /* @__PURE__ */ r(n, {
14
- as: "span",
15
- className: i.text,
16
- children: a
17
- })
18
- });
19
- return /* @__PURE__ */ r("div", {
20
- className: t(i.question, s && i.sidebar),
21
- "data-testid": "content-answers-question",
22
- children: /* @__PURE__ */ r(e, {
23
- className: "question",
24
- variant: o,
25
- children: c
26
- })
27
- });
28
- };
29
- export { a as t };
1
+ import{t as MediaContainer}from"./media-container.js";import clsx from"clsx";import{Text}from"@box/blueprint-web";import{jsx}from"react/jsx-runtime";import '../styles/question.css';var question_module_default={question:`_question_12q5v_27`,sidebar:`_sidebar_12q5v_32`,text:`_text_12q5v_35`},Question=({prompt,variant=`modal`})=>{let hasSidebarVariant=variant===`sidebar`,content=jsx(MediaContainer.Content,{isUsedInsideSidebar:hasSidebarVariant,variant:`question`,children:jsx(Text,{as:`span`,className:question_module_default.text,children:prompt})});return jsx(`div`,{className:clsx(question_module_default.question,hasSidebarVariant&&question_module_default.sidebar),"data-testid":`content-answers-question`,children:jsx(MediaContainer,{className:`question`,variant,children:content})})};export{Question as t};
@@ -1,43 +1 @@
1
- import e from "../esm/lib/components/answer/messages.js";
2
- import { LOGGER_BASE_CONFIG as t } from "../esm/lib/components/common/constants.js";
3
- import { t as n } from "./citation.js";
4
- import { NoCitationsIcon as r } from "../esm/lib/components/answer/no-citations.js";
5
- import { useEffect as i } from "react";
6
- import { Text as a } from "@box/blueprint-web";
7
- import { useIntl as o } from "react-intl";
8
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
9
- import '../styles/references.css';var u = { label: "_label_1wqmn_1" }, d = ({ animate: d = !0, citations: f, recordAction: p, onCitationClick: m }) => {
10
- let h = f && f.length > 0, { formatMessage: g } = o();
11
- return i(() => {
12
- h && p && p({
13
- ...t,
14
- feature: "answers-citations",
15
- target: "shown",
16
- data: { count: f.length }
17
- });
18
- }, []), f === null ? /* @__PURE__ */ c("div", {
19
- className: u.references,
20
- "data-testid": "content-answers-references-null"
21
- }) : /* @__PURE__ */ l("div", {
22
- className: u.references,
23
- "data-testid": "content-answers-references",
24
- children: [h && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(a, {
25
- as: "span",
26
- className: u.label,
27
- color: "textOnLightSecondary",
28
- "data-testid": "content-answers-references-label",
29
- variant: "caption",
30
- children: g(e.basedOn)
31
- }), f.map(({ content: e, location: t, title: r, fileId: i, source: a }, o) => /* @__PURE__ */ c(n, {
32
- animate: d,
33
- content: e,
34
- fileId: i,
35
- id: o + 1,
36
- onCitationClick: m,
37
- recordAction: p,
38
- source: a,
39
- title: r
40
- }, `${t}-${o + 1}`))] }), f?.length === 0 && /* @__PURE__ */ c(r, { recordAction: p })]
41
- });
42
- };
43
- export { d as t };
1
+ import messages from"../esm/lib/components/answer/messages.js";import{LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import{t as Citation}from"./citation.js";import{NoCitationsIcon}from"../esm/lib/components/answer/no-citations.js";import{useEffect}from"react";import{Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import '../styles/references.css';var references_module_default={label:`_label_1wqmn_1`},References=({animate=!0,citations,recordAction,onCitationClick})=>{let showCitations=citations&&citations.length>0,{formatMessage}=useIntl();return useEffect(()=>{showCitations&&recordAction&&recordAction({...LOGGER_BASE_CONFIG,feature:`answers-citations`,target:`shown`,data:{count:citations.length}})},[]),citations===null?jsx(`div`,{className:references_module_default.references,"data-testid":`content-answers-references-null`}):jsxs(`div`,{className:references_module_default.references,"data-testid":`content-answers-references`,children:[showCitations&&jsxs(Fragment,{children:[jsx(Text,{as:`span`,className:references_module_default.label,color:`textOnLightSecondary`,"data-testid":`content-answers-references-label`,variant:`caption`,children:formatMessage(messages.basedOn)}),citations.map(({content,location,title,fileId,source},idx)=>jsx(Citation,{animate,content,fileId,id:idx+1,onCitationClick,recordAction,source,title},`${location}-${idx+1}`))]}),citations?.length===0&&jsx(NoCitationsIcon,{recordAction})]})};export{References as t};
@@ -1,45 +1 @@
1
- import { LOGGER_ACTION_CLICK as e, LOGGER_BASE_CONFIG as t } from "../esm/lib/components/common/constants.js";
2
- import n from "../esm/lib/components/footer/messages.js";
3
- import * as r from "react";
4
- import { Button as i, Tooltip as a } from "@box/blueprint-web";
5
- import { useIntl as o } from "react-intl";
6
- import { jsx as s } from "react/jsx-runtime";
7
- import { Stop as c } from "@box/blueprint-web-assets/icons/Fill";
8
- import '../styles/stopResponseButton.css';var l = {
9
- questionInput: "_questionInput_ankiu_27",
10
- questionInputWithOutPromptLibrary: "_questionInputWithOutPromptLibrary_ankiu_41",
11
- inputAreaButton: "_inputAreaButton_ankiu_56",
12
- textArea: "_textArea_ankiu_78",
13
- sidebar: "_sidebar_ankiu_104",
14
- actionContainer: "_actionContainer_ankiu_117",
15
- promptButton: "_promptButton_ankiu_123"
16
- };
17
- function u({ recordAction: u, lastQuestion: d, onStopQuestion: f, size: p = "large" }) {
18
- let m = o(), h = r.useCallback(() => {
19
- u && u({
20
- ...t,
21
- action: e,
22
- target: "stopResponse"
23
- }), f(d);
24
- }, [
25
- d,
26
- f,
27
- u
28
- ]);
29
- return /* @__PURE__ */ s(a, {
30
- content: m.formatMessage(n.stopResponse),
31
- "data-testid": "stop-response-tooltip",
32
- variant: "standard",
33
- children: /* @__PURE__ */ s(i, {
34
- "aria-label": m.formatMessage(n.stopResponse),
35
- "aria-live": "polite",
36
- className: l.inputAreaButton,
37
- "data-testid": "content-answers-stop-response-button",
38
- endIcon: c,
39
- onClick: h,
40
- size: p,
41
- "data-target-id": "Button-stopResponse"
42
- })
43
- });
44
- }
45
- export { l as n, u as t };
1
+ import{LOGGER_ACTION_CLICK,LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import messages from"../esm/lib/components/footer/messages.js";import*as React$1 from"react";import{Button,Tooltip}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx}from"react/jsx-runtime";import{Stop}from"@box/blueprint-web-assets/icons/Fill";import '../styles/stopResponseButton.css';var footer_module_default={questionInput:`_questionInput_ankiu_27`,questionInputWithOutPromptLibrary:`_questionInputWithOutPromptLibrary_ankiu_41`,inputAreaButton:`_inputAreaButton_ankiu_56`,textArea:`_textArea_ankiu_78`,sidebar:`_sidebar_ankiu_104`,actionContainer:`_actionContainer_ankiu_117`,promptButton:`_promptButton_ankiu_123`};function StopResponseButton({recordAction,lastQuestion,onStopQuestion,size=`large`}){let intl=useIntl(),handleStopResponseClick=React$1.useCallback(()=>{recordAction&&recordAction({...LOGGER_BASE_CONFIG,action:LOGGER_ACTION_CLICK,target:`stopResponse`}),onStopQuestion(lastQuestion)},[lastQuestion,onStopQuestion,recordAction]);return jsx(Tooltip,{content:intl.formatMessage(messages.stopResponse),"data-testid":`stop-response-tooltip`,variant:`standard`,children:jsx(Button,{"aria-label":intl.formatMessage(messages.stopResponse),"aria-live":`polite`,className:footer_module_default.inputAreaButton,"data-testid":`content-answers-stop-response-button`,endIcon:Stop,onClick:handleStopResponseClick,size,"data-target-id":`Button-stopResponse`})})}export{footer_module_default as n,StopResponseButton as t};
@@ -1,70 +1 @@
1
- import { a as e } from "./types.js";
2
- import { LOGGER_BASE_CONFIG as t } from "../esm/lib/components/common/constants.js";
3
- import { t as n } from "./suggestions.js";
4
- import r from "../esm/lib/components/suggested-questions/messages.js";
5
- import i from "clsx";
6
- import * as a from "react";
7
- import { LoadingIndicator as o, Text as s } from "@box/blueprint-web";
8
- import { useIntl as c } from "react-intl";
9
- import { Gray65 as l, Size4 as u } from "@box/blueprint-web-assets/tokens/tokens";
10
- import { AlertTriangle as d } from "@box/blueprint-web-assets/icons/Line";
11
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
- import '../styles/suggested-questions.css';var m = {
13
- wrapper: "_wrapper_1yyy4_27",
14
- label: "_label_1yyy4_27",
15
- sidebar: "_sidebar_1yyy4_32",
16
- loadingIndicator: "_loadingIndicator_1yyy4_36",
17
- alertIcon: "_alertIcon_1yyy4_44"
18
- }, h = ({ askSuggestedQuestion: h, hasCustomSuggestedQuestions: g, isLoading: _, onSuggestedQuestionInteraction: v, recordAction: y, setAskSuggestedQuestion: b, suggestedQuestions: x, suggestedQuestionsRequestState: S = e.SUCCESS, variant: C = "modal" }) => {
19
- let w = C === "sidebar", { formatMessage: T } = c(), E = a.useCallback((e) => {
20
- let { prompt: n, type: r } = e;
21
- b && (b(e), y && n && y({
22
- ...t,
23
- target: "suggested_questions",
24
- data: {
25
- selectedQuestion: g ? "dynamic" : n,
26
- type: r
27
- }
28
- }));
29
- }, [
30
- b,
31
- y,
32
- g
33
- ]);
34
- return /* @__PURE__ */ p("div", {
35
- className: i(m.wrapper, w && m.sidebar),
36
- children: [
37
- (S === e.IN_PROGRESS || S === e.ERROR) && /* @__PURE__ */ f(s, {
38
- as: "p",
39
- className: i(m.label, w && m.sidebar),
40
- color: "textOnLightSecondary",
41
- children: S === e.IN_PROGRESS ? T(r.loadingSuggestedQuestions) : T(r.loadingSuggestedQuestionsFailed)
42
- }),
43
- S === e.SUCCESS && /* @__PURE__ */ f(n, {
44
- askSuggestedQuestion: h,
45
- isLoading: _,
46
- onSuggestedQuestionClick: E,
47
- onSuggestedQuestionInteraction: v,
48
- suggestedQuestions: x,
49
- variant: C
50
- }),
51
- S === e.IN_PROGRESS && /* @__PURE__ */ f("div", {
52
- className: m.loadingIndicator,
53
- children: /* @__PURE__ */ f(o, {
54
- "aria-label": T(r.loadingSuggestedQuestions),
55
- className: m.loadingIndicator,
56
- variant: "dark"
57
- })
58
- }),
59
- S === e.ERROR && /* @__PURE__ */ f(d, {
60
- className: m.alertIcon,
61
- color: l,
62
- "data-testid": "content-answers-suggested-questions-failed-alert-icon",
63
- height: u,
64
- role: "presentation",
65
- width: u
66
- })
67
- ]
68
- });
69
- };
70
- export { h as t };
1
+ import{a as REQUEST_STATE}from"./types.js";import{LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import{t as Suggestions}from"./suggestions.js";import messages from"../esm/lib/components/suggested-questions/messages.js";import clsx from"clsx";import*as React$1 from"react";import{LoadingIndicator,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/suggested-questions.css';var suggested_questions_module_default={wrapper:`_wrapper_1yyy4_27`,label:`_label_1yyy4_27`,sidebar:`_sidebar_1yyy4_32`,loadingIndicator:`_loadingIndicator_1yyy4_36`,alertIcon:`_alertIcon_1yyy4_44`},SuggestedQuestions=({askSuggestedQuestion,hasCustomSuggestedQuestions,isLoading,onSuggestedQuestionInteraction,recordAction,setAskSuggestedQuestion,suggestedQuestions,suggestedQuestionsRequestState=REQUEST_STATE.SUCCESS,variant=`modal`})=>{let hasSidebarVariant=variant===`sidebar`,{formatMessage}=useIntl(),handleOnValueChange=React$1.useCallback(selectedValue=>{let{prompt,type}=selectedValue;setAskSuggestedQuestion&&(setAskSuggestedQuestion(selectedValue),recordAction&&prompt&&recordAction({...LOGGER_BASE_CONFIG,target:`suggested_questions`,data:{selectedQuestion:hasCustomSuggestedQuestions?`dynamic`:prompt,type}}))},[setAskSuggestedQuestion,recordAction,hasCustomSuggestedQuestions]);return jsxs(`div`,{className:clsx(suggested_questions_module_default.wrapper,hasSidebarVariant&&suggested_questions_module_default.sidebar),children:[(suggestedQuestionsRequestState===REQUEST_STATE.IN_PROGRESS||suggestedQuestionsRequestState===REQUEST_STATE.ERROR)&&jsx(Text,{as:`p`,className:clsx(suggested_questions_module_default.label,hasSidebarVariant&&suggested_questions_module_default.sidebar),color:`textOnLightSecondary`,children:suggestedQuestionsRequestState===REQUEST_STATE.IN_PROGRESS?formatMessage(messages.loadingSuggestedQuestions):formatMessage(messages.loadingSuggestedQuestionsFailed)}),suggestedQuestionsRequestState===REQUEST_STATE.SUCCESS&&jsx(Suggestions,{askSuggestedQuestion,isLoading,onSuggestedQuestionClick:handleOnValueChange,onSuggestedQuestionInteraction,suggestedQuestions,variant}),suggestedQuestionsRequestState===REQUEST_STATE.IN_PROGRESS&&jsx(`div`,{className:suggested_questions_module_default.loadingIndicator,children:jsx(LoadingIndicator,{"aria-label":formatMessage(messages.loadingSuggestedQuestions),className:suggested_questions_module_default.loadingIndicator,variant:`dark`})}),suggestedQuestionsRequestState===REQUEST_STATE.ERROR&&jsx(AlertTriangle,{className:suggested_questions_module_default.alertIcon,color:Gray65,"data-testid":`content-answers-suggested-questions-failed-alert-icon`,height:Size4,role:`presentation`,width:Size4})]})};export{SuggestedQuestions as t};
@@ -1,35 +1 @@
1
- import e from "clsx";
2
- import "react";
3
- import { FilterChip as t } from "@box/blueprint-web";
4
- import { jsx as n } from "react/jsx-runtime";
5
- import r from "lodash/noop";
6
- import '../styles/suggestions.css';var i = {
7
- suggestions: "_suggestions_it5yb_27",
8
- suggestion: "_suggestion_it5yb_27"
9
- }, a = ({ askSuggestedQuestion: a, isLoading: o, onSuggestedQuestionClick: s, onSuggestedQuestionInteraction: c = r, suggestedQuestions: l, variant: u = "modal" }) => {
10
- let d = a?.prompt;
11
- return /* @__PURE__ */ n(t.Group, {
12
- className: e(i.suggestions, u === "sidebar" && i.sidebar),
13
- "data-testid": "content-answers-suggested-questions",
14
- name: "Singleselect SuggestedQuestions",
15
- onKeyDown: (e) => {
16
- (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") && e.stopPropagation();
17
- },
18
- type: "single",
19
- value: d,
20
- children: l.map((e) => {
21
- let r = e.label || e.prompt;
22
- return /* @__PURE__ */ n(t.ChipButton, {
23
- className: i.suggestion,
24
- "data-testid": `content-answers-${e.id}`,
25
- disabled: o,
26
- onClick: () => s(e),
27
- onFocus: c,
28
- onMouseEnter: c,
29
- value: r,
30
- children: /* @__PURE__ */ n(t.Label, { children: r })
31
- }, e.id);
32
- })
33
- });
34
- };
35
- export { a as t };
1
+ import clsx from"clsx";import"react";import{FilterChip}from"@box/blueprint-web";import{jsx}from"react/jsx-runtime";import noop from"lodash/noop";import '../styles/suggestions.css';var suggestions_module_default={suggestions:`_suggestions_it5yb_27`,suggestion:`_suggestion_it5yb_27`},Suggestions=({askSuggestedQuestion,isLoading,onSuggestedQuestionClick,onSuggestedQuestionInteraction=noop,suggestedQuestions,variant=`modal`})=>{let prompt=askSuggestedQuestion?.prompt;return jsx(FilterChip.Group,{className:clsx(suggestions_module_default.suggestions,variant===`sidebar`&&suggestions_module_default.sidebar),"data-testid":`content-answers-suggested-questions`,name:`Singleselect SuggestedQuestions`,onKeyDown:event=>{(event.key===`ArrowUp`||event.key===`ArrowDown`||event.key===`ArrowLeft`||event.key===`ArrowRight`)&&event.stopPropagation()},type:`single`,value:prompt,children:suggestedQuestions.map(question=>{let value=question.label||question.prompt;return jsx(FilterChip.ChipButton,{className:suggestions_module_default.suggestion,"data-testid":`content-answers-${question.id}`,disabled:isLoading,onClick:()=>onSuggestedQuestionClick(question),onFocus:onSuggestedQuestionInteraction,onMouseEnter:onSuggestedQuestionInteraction,value,children:jsx(FilterChip.Label,{children:value})},question.id)})})};export{Suggestions as t};
@@ -1,111 +1 @@
1
- import { BoxAILoadingIndicator as e } from "../esm/lib/components/thinkingBubble/boxAILoadingIndicator.js";
2
- import t from "../esm/lib/components/common/markdown-react.js";
3
- import n from "../esm/lib/components/thinkingBubble/messages.js";
4
- import r from "clsx";
5
- import { useCallback as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
6
- import { Text as l, Tooltip as u } from "@box/blueprint-web";
7
- import { useIntl as d } from "react-intl";
8
- import { BlackOpacity50 as f } from "@box/blueprint-web-assets/tokens/tokens";
9
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
- import { BoxAi as h, ChevronRight as g } from "@box/blueprint-web-assets/icons/Medium";
11
- import '../styles/thinkingBubble.css';var _ = {
12
- thinkingBubbleContainer: "_thinkingBubbleContainer_1t2ug_1",
13
- thinkingBubbleHeader: "_thinkingBubbleHeader_1t2ug_7",
14
- headerLeft: "_headerLeft_1t2ug_19",
15
- thinkingBubbleLogo: "_thinkingBubbleLogo_1t2ug_24",
16
- chevronIcon: "_chevronIcon_1t2ug_28",
17
- chevronRotated: "_chevronRotated_1t2ug_33",
18
- chevronDisabled: "_chevronDisabled_1t2ug_36",
19
- logoState: "_logoState_1t2ug_40",
20
- headerExpanded: "_headerExpanded_1t2ug_53",
21
- thinkingBubbleContent: "_thinkingBubbleContent_1t2ug_58",
22
- scrollableContainer: "_scrollableContainer_1t2ug_66",
23
- contentExpanded: "_contentExpanded_1t2ug_84",
24
- sidebar: "_sidebar_1t2ug_90",
25
- pillState: "_pillState_1t2ug_105"
26
- }, v = 5, y = 50, b = 300, x = 120, S = ({ content: S, className: C, variant: w = "modal", isThinkingComplete: T = !1, onDropdownOpenChange: E, ...D }) => {
27
- let { formatMessage: O } = d(), k = w === "sidebar", [A, j] = c(!1), [M, N] = c(!1), [P, F] = c(!1), I = o(), L = o(), R = s(null), z = s(!1);
28
- a(() => {
29
- if (S) {
30
- let e = [setTimeout(() => F(!0), y), setTimeout(() => {
31
- j(!0), E(!0);
32
- }, b)];
33
- return () => e.forEach(clearTimeout);
34
- }
35
- }, [S]);
36
- let B = i(() => {
37
- R.current && S && A && !z.current && R.current.scrollTo({
38
- top: R.current.scrollHeight,
39
- behavior: "smooth"
40
- });
41
- }, [S, A]);
42
- a(() => {
43
- B();
44
- }, [B]);
45
- let V = i(() => {
46
- if (R.current) {
47
- let e = R.current;
48
- z.current = !(e.scrollTop + e.clientHeight >= e.scrollHeight - v);
49
- }
50
- }, []), H = i(() => R.current ? R.current.scrollHeight > x : !1, []), U = () => {
51
- let e = !M;
52
- N(e), E(e), T && j(e);
53
- };
54
- a(() => {
55
- T && (N(!1), j(!1), E(!1));
56
- }, [T]);
57
- let W = () => T ? /* @__PURE__ */ p(h, {
58
- color: f,
59
- height: 24,
60
- width: 24
61
- }) : /* @__PURE__ */ p(e, {}), G = !H() && !T, K = r(_.thinkingBubbleContainer, {
62
- [_.logoState]: !P,
63
- [_.headerExpanded]: P,
64
- [_.contentExpanded]: M,
65
- [_.pillState]: T && !M,
66
- [_.sidebar]: k
67
- }, C), q = !H() && !T, J = A && (!T || M);
68
- return /* @__PURE__ */ m("div", {
69
- className: K,
70
- ...D,
71
- children: [/* @__PURE__ */ m("button", {
72
- "aria-controls": L,
73
- "aria-expanded": J,
74
- "aria-labelledby": I,
75
- className: _.thinkingBubbleHeader,
76
- disabled: q,
77
- onClick: U,
78
- type: "button",
79
- "data-target-id": "button-thinkingCompleted|thinkingInProgress|thinkingCompleted|thinkingInProgress|collapseThinkingContent|expandThinkingContent",
80
- children: [/* @__PURE__ */ m("div", {
81
- className: _.headerLeft,
82
- children: [/* @__PURE__ */ p("div", {
83
- className: _.thinkingBubbleLogo,
84
- children: W()
85
- }), P && /* @__PURE__ */ p(l, {
86
- as: "h3",
87
- color: T ? "textOnLightSecondary" : "textOnLightDefault",
88
- id: I,
89
- variant: "titleMedium",
90
- children: O(T ? n.thinkingCompleted : n.thinkingInProgress)
91
- })]
92
- }), P && /* @__PURE__ */ p(u, {
93
- content: O(M ? n.collapseThinkingContent : n.expandThinkingContent),
94
- children: /* @__PURE__ */ p(g, {
95
- "aria-hidden": "true",
96
- className: r(_.chevronIcon, M && _.chevronRotated, G && _.chevronDisabled)
97
- })
98
- })]
99
- }), A && (!T || M) && /* @__PURE__ */ p("div", {
100
- className: _.thinkingBubbleContent,
101
- children: /* @__PURE__ */ p("div", {
102
- ref: R,
103
- "aria-label": O(n.thinkingContentScrollableArea),
104
- className: _.scrollableContainer,
105
- onScroll: V,
106
- children: /* @__PURE__ */ p(t, { children: S })
107
- })
108
- })]
109
- });
110
- };
111
- export { S as t };
1
+ import{BoxAILoadingIndicator}from"../esm/lib/components/thinkingBubble/boxAILoadingIndicator.js";import MarkdownRenderer from"../esm/lib/components/common/markdown-react.js";import messages from"../esm/lib/components/thinkingBubble/messages.js";import clsx from"clsx";import{useCallback,useEffect,useId,useRef,useState}from"react";import{Text,Tooltip}from"@box/blueprint-web";import{useIntl}from"react-intl";import{BlackOpacity50}from"@box/blueprint-web-assets/tokens/tokens";import{jsx,jsxs}from"react/jsx-runtime";import{BoxAi,ChevronRight}from"@box/blueprint-web-assets/icons/Medium";import '../styles/thinkingBubble.css';var thinkingBubble_module_default={thinkingBubbleContainer:`_thinkingBubbleContainer_1t2ug_1`,thinkingBubbleHeader:`_thinkingBubbleHeader_1t2ug_7`,headerLeft:`_headerLeft_1t2ug_19`,thinkingBubbleLogo:`_thinkingBubbleLogo_1t2ug_24`,chevronIcon:`_chevronIcon_1t2ug_28`,chevronRotated:`_chevronRotated_1t2ug_33`,chevronDisabled:`_chevronDisabled_1t2ug_36`,logoState:`_logoState_1t2ug_40`,headerExpanded:`_headerExpanded_1t2ug_53`,thinkingBubbleContent:`_thinkingBubbleContent_1t2ug_58`,scrollableContainer:`_scrollableContainer_1t2ug_66`,contentExpanded:`_contentExpanded_1t2ug_84`,sidebar:`_sidebar_1t2ug_90`,pillState:`_pillState_1t2ug_105`},SCROLL_TOLERANCE=5,EXPAND_HEADER_DELAY=50,OPEN_CONTENT_DELAY=300,COLLAPSED_MAX_HEIGHT=120,ThinkingBubble=({content,className,variant=`modal`,isThinkingComplete=!1,onDropdownOpenChange,...rest})=>{let{formatMessage}=useIntl(),isSidebarVariant=variant===`sidebar`,[isContentOpen,setIsContentOpen]=useState(!1),[isContentExpanded,setIsContentExpanded]=useState(!1),[isHeaderExpanded,setIsHeaderExpanded]=useState(!1),titleId=useId(),contentAreaId=useId(),scrollableRef=useRef(null),isUserScrolledRef=useRef(!1);useEffect(()=>{if(content){let timers=[setTimeout(()=>setIsHeaderExpanded(!0),EXPAND_HEADER_DELAY),setTimeout(()=>{setIsContentOpen(!0),onDropdownOpenChange(!0)},OPEN_CONTENT_DELAY)];return()=>timers.forEach(clearTimeout)}},[content]);let scrollToBottom=useCallback(()=>{scrollableRef.current&&content&&isContentOpen&&!isUserScrolledRef.current&&scrollableRef.current.scrollTo({top:scrollableRef.current.scrollHeight,behavior:`smooth`})},[content,isContentOpen]);useEffect(()=>{scrollToBottom()},[scrollToBottom]);let handleScroll=useCallback(()=>{if(scrollableRef.current){let element=scrollableRef.current;isUserScrolledRef.current=!(element.scrollTop+element.clientHeight>=element.scrollHeight-SCROLL_TOLERANCE)}},[]),hasScrollableContent=useCallback(()=>scrollableRef.current?scrollableRef.current.scrollHeight>COLLAPSED_MAX_HEIGHT:!1,[]),handleHeaderClick=()=>{let newIsContentExpanded=!isContentExpanded;setIsContentExpanded(newIsContentExpanded),onDropdownOpenChange(newIsContentExpanded),isThinkingComplete&&setIsContentOpen(newIsContentExpanded)};useEffect(()=>{isThinkingComplete&&(setIsContentExpanded(!1),setIsContentOpen(!1),onDropdownOpenChange(!1))},[isThinkingComplete]);let renderLogo=()=>isThinkingComplete?jsx(BoxAi,{color:BlackOpacity50,height:24,width:24}):jsx(BoxAILoadingIndicator,{}),isDisabled=!hasScrollableContent()&&!isThinkingComplete,containerClasses=clsx(thinkingBubble_module_default.thinkingBubbleContainer,{[thinkingBubble_module_default.logoState]:!isHeaderExpanded,[thinkingBubble_module_default.headerExpanded]:isHeaderExpanded,[thinkingBubble_module_default.contentExpanded]:isContentExpanded,[thinkingBubble_module_default.pillState]:isThinkingComplete&&!isContentExpanded,[thinkingBubble_module_default.sidebar]:isSidebarVariant},className),isToggleDisabled=!hasScrollableContent()&&!isThinkingComplete,isExpanded=isContentOpen&&(!isThinkingComplete||isContentExpanded);return jsxs(`div`,{className:containerClasses,...rest,children:[jsxs(`button`,{"aria-controls":contentAreaId,"aria-expanded":isExpanded,"aria-labelledby":titleId,className:thinkingBubble_module_default.thinkingBubbleHeader,disabled:isToggleDisabled,onClick:handleHeaderClick,type:`button`,"data-target-id":`button-thinkingCompleted|thinkingInProgress|thinkingCompleted|thinkingInProgress|collapseThinkingContent|expandThinkingContent`,children:[jsxs(`div`,{className:thinkingBubble_module_default.headerLeft,children:[jsx(`div`,{className:thinkingBubble_module_default.thinkingBubbleLogo,children:renderLogo()}),isHeaderExpanded&&jsx(Text,{as:`h3`,color:isThinkingComplete?`textOnLightSecondary`:`textOnLightDefault`,id:titleId,variant:`titleMedium`,children:formatMessage(isThinkingComplete?messages.thinkingCompleted:messages.thinkingInProgress)})]}),isHeaderExpanded&&jsx(Tooltip,{content:formatMessage(isContentExpanded?messages.collapseThinkingContent:messages.expandThinkingContent),children:jsx(ChevronRight,{"aria-hidden":`true`,className:clsx(thinkingBubble_module_default.chevronIcon,isContentExpanded&&thinkingBubble_module_default.chevronRotated,isDisabled&&thinkingBubble_module_default.chevronDisabled)})})]}),isContentOpen&&(!isThinkingComplete||isContentExpanded)&&jsx(`div`,{className:thinkingBubble_module_default.thinkingBubbleContent,children:jsx(`div`,{ref:scrollableRef,"aria-label":formatMessage(messages.thinkingContentScrollableArea),className:thinkingBubble_module_default.scrollableContainer,onScroll:handleScroll,children:jsx(MarkdownRenderer,{children:content})})})]})};export{ThinkingBubble as t};
@@ -1,103 +1 @@
1
- import e from "../esm/lib/messages.js";
2
- import t from "../esm/lib/components/answer/messages.js";
3
- import { LOGGER_ACTION_PROGRAMMATIC as n, LOGGER_BASE_CONFIG as r } from "../esm/lib/components/common/constants.js";
4
- import { focusInput as i } from "../esm/lib/components/common/focusInputUtils.js";
5
- import { t as a } from "./feedback-tooltip.js";
6
- import o from "react";
7
- import { IconButton as s, Tooltip as c, useBlueprintModernization as l, useNotification as u } from "@box/blueprint-web";
8
- import { useIntl as d } from "react-intl";
9
- import { ThumbDown as f, ThumbUp as p } from "@box/blueprint-web-assets/icons/Line";
10
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
11
- import { ThumbsDown as _, ThumbsUp as v } from "@box/blueprint-web-assets/icons/Medium";
12
- import { ThumbDown as y, ThumbUp as b } from "@box/blueprint-web-assets/icons/Fill";
13
- import { ThumbsDown as x, ThumbsUp as S } from "@box/blueprint-web-assets/icons/MediumFilled";
14
- import { useAgents as C } from "@box/box-ai-agent-selector";
15
- import '../styles/thumb-buttons.css';var w = { thumbDown: "_thumbDown_1axcd_1" }, T = {
16
- THUMB_UP: "positive",
17
- THUMB_DOWN: "negative",
18
- NONE: "none"
19
- }, E = ({ feedbackValue: E, hostAppName: D, isFeedbackFormEnabled: O = !1, isFeedbackTooltipOpen: k = !1, items: A, onFeedbackFormSubmit: j, onFeedbackTooltipOpenChange: M, prompt: N, promptType: P, questionId: F, recordAction: I, response: L, setAnswerFeedback: R, shouldFeedbackFormIncludeFeedbackText: z = !1, shouldFeedbackIncludePromptData: B = !1, variant: V }) => {
20
- let { enableModernizedComponents: H } = l(), { formatMessage: U } = d(), { addNotification: W } = u(), { selectedAgent: G } = C(), K = E, q = o.useMemo(() => A.filter((e) => e.status === "supported").map((e) => e.fileType), [A]), J = o.useCallback((e) => {
21
- K !== e && (R?.(F, e), I?.({
22
- ...r,
23
- action: n,
24
- target: "answer_feedback",
25
- component: V,
26
- data: {
27
- feedback_value: e,
28
- file_types: q,
29
- feature: D,
30
- prompt_type: P
31
- }
32
- }), i());
33
- }, [
34
- D,
35
- I,
36
- K,
37
- V,
38
- q,
39
- F,
40
- R,
41
- P
42
- ]), Y = ({ feedback: n, feedbackPromptShareConsent: r, issueType: i }) => {
43
- if (M?.(!1, F), !j) return;
44
- let a = {
45
- fileTypes: q,
46
- hasPromptData: !1,
47
- hostApp: D,
48
- issueType: i,
49
- timestamp: Date.now(),
50
- questionId: F
51
- };
52
- z && (a.feedback = n, a.hasFeedback = !!n), B && r && N && L && (a.hasPromptData = !0, a.prompt = N, a.response = L), G && (a.selectedAgentName = G.name), j(a, () => {
53
- W({
54
- sensitivity: "foreground",
55
- styledText: U(t.feedbackTooltipConfirmation),
56
- variant: "success",
57
- typeIconAriaLabel: U(e.ariaTypeSuccessIconLabel),
58
- closeButtonAriaLabel: U(e.closeButtonText)
59
- });
60
- });
61
- }, X = (e) => {
62
- e || M?.(!1, F);
63
- }, Z = o.useCallback(() => J(T.THUMB_UP), [J]), Q = o.useCallback(() => {
64
- J(T.THUMB_DOWN), M?.(!0, F);
65
- }, [
66
- J,
67
- M,
68
- F
69
- ]), $ = H ? v : p, ee = H ? _ : f, te = H ? S : b, ne = H ? x : y;
70
- return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(c, {
71
- content: U(t.thumbsUpAriaLabel),
72
- children: /* @__PURE__ */ h(s, {
73
- "aria-label": U(t.thumbsUpAriaLabel),
74
- disabled: K === T.THUMB_DOWN,
75
- icon: K === T.THUMB_UP ? te : $,
76
- onClick: Z,
77
- size: "x-small",
78
- variant: H ? "icon-logo" : "default",
79
- "data-target-id": "IconButton-thumbsUpAriaLabel"
80
- })
81
- }), /* @__PURE__ */ h(a, {
82
- isOpen: k,
83
- onOpenChange: X,
84
- onSubmit: Y,
85
- shouldIncludeFeedbackText: z,
86
- shouldIncludePromptShareConsent: B,
87
- shouldShow: O,
88
- children: /* @__PURE__ */ h(c, {
89
- content: U(t.thumbsDownAriaLabel),
90
- children: /* @__PURE__ */ h(s, {
91
- "aria-label": U(t.thumbsDownAriaLabel),
92
- className: H ? "" : w.thumbDown,
93
- disabled: K === T.THUMB_UP,
94
- icon: K === T.THUMB_DOWN ? ne : ee,
95
- onClick: Q,
96
- size: "x-small",
97
- variant: H ? "icon-logo" : "default",
98
- "data-target-id": "IconButton-thumbsDownAriaLabel"
99
- })
100
- })
101
- })] });
102
- };
103
- export { E as t };
1
+ import messages from"../esm/lib/messages.js";import messages$1 from"../esm/lib/components/answer/messages.js";import{LOGGER_ACTION_PROGRAMMATIC,LOGGER_BASE_CONFIG}from"../esm/lib/components/common/constants.js";import{focusInput}from"../esm/lib/components/common/focusInputUtils.js";import{t as FeedbackTooltip}from"./feedback-tooltip.js";import React from"react";import{IconButton,Tooltip,useBlueprintModernization,useNotification}from"@box/blueprint-web";import{useIntl}from"react-intl";import{ThumbDown,ThumbUp}from"@box/blueprint-web-assets/icons/Line";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import{ThumbsDown,ThumbsUp}from"@box/blueprint-web-assets/icons/Medium";import{ThumbDown as ThumbDown$1,ThumbUp as ThumbUp$1}from"@box/blueprint-web-assets/icons/Fill";import{ThumbsDown as ThumbsDown$1,ThumbsUp as ThumbsUp$1}from"@box/blueprint-web-assets/icons/MediumFilled";import{useAgents}from"@box/box-ai-agent-selector";import '../styles/thumb-buttons.css';var thumb_buttons_module_default={thumbDown:`_thumbDown_1axcd_1`},Feedback={THUMB_UP:`positive`,THUMB_DOWN:`negative`,NONE:`none`},ThumbButtons=({feedbackValue,hostAppName,isFeedbackFormEnabled=!1,isFeedbackTooltipOpen=!1,items,onFeedbackFormSubmit,onFeedbackTooltipOpenChange,prompt,promptType,questionId,recordAction,response,setAnswerFeedback,shouldFeedbackFormIncludeFeedbackText=!1,shouldFeedbackIncludePromptData=!1,variant})=>{let{enableModernizedComponents}=useBlueprintModernization(),{formatMessage}=useIntl(),{addNotification}=useNotification(),{selectedAgent}=useAgents(),selected=feedbackValue,supportedFileTypes=React.useMemo(()=>items.filter(item=>item.status===`supported`).map(item=>item.fileType),[items]),handleThumb=React.useCallback(direction=>{selected!==direction&&(setAnswerFeedback?.(questionId,direction),recordAction?.({...LOGGER_BASE_CONFIG,action:LOGGER_ACTION_PROGRAMMATIC,target:`answer_feedback`,component:variant,data:{feedback_value:direction,file_types:supportedFileTypes,feature:hostAppName,prompt_type:promptType}}),focusInput())},[hostAppName,recordAction,selected,variant,supportedFileTypes,questionId,setAnswerFeedback,promptType]),handleFeedbackFormSubmit=({feedback,feedbackPromptShareConsent,issueType})=>{if(onFeedbackTooltipOpenChange?.(!1,questionId),!onFeedbackFormSubmit)return;let feedbackData={fileTypes:supportedFileTypes,hasPromptData:!1,hostApp:hostAppName,issueType,timestamp:Date.now(),questionId};shouldFeedbackFormIncludeFeedbackText&&(feedbackData.feedback=feedback,feedbackData.hasFeedback=!!feedback),shouldFeedbackIncludePromptData&&feedbackPromptShareConsent&&prompt&&response&&(feedbackData.hasPromptData=!0,feedbackData.prompt=prompt,feedbackData.response=response),selectedAgent&&(feedbackData.selectedAgentName=selectedAgent.name),onFeedbackFormSubmit(feedbackData,()=>{addNotification({sensitivity:`foreground`,styledText:formatMessage(messages$1.feedbackTooltipConfirmation),variant:`success`,typeIconAriaLabel:formatMessage(messages.ariaTypeSuccessIconLabel),closeButtonAriaLabel:formatMessage(messages.closeButtonText)})})},handleFeedbackTooltipOpenChange=isOpen=>{isOpen||onFeedbackTooltipOpenChange?.(!1,questionId)},handleThumbUp=React.useCallback(()=>handleThumb(Feedback.THUMB_UP),[handleThumb]),handleThumbDown=React.useCallback(()=>{handleThumb(Feedback.THUMB_DOWN),onFeedbackTooltipOpenChange?.(!0,questionId)},[handleThumb,onFeedbackTooltipOpenChange,questionId]),ThumbUpIcon=enableModernizedComponents?ThumbsUp:ThumbUp,ThumbDownIcon=enableModernizedComponents?ThumbsDown:ThumbDown,ThumbUpIconFilled=enableModernizedComponents?ThumbsUp$1:ThumbUp$1,ThumbDownIconFilled=enableModernizedComponents?ThumbsDown$1:ThumbDown$1;return jsxs(Fragment,{children:[jsx(Tooltip,{content:formatMessage(messages$1.thumbsUpAriaLabel),children:jsx(IconButton,{"aria-label":formatMessage(messages$1.thumbsUpAriaLabel),disabled:selected===Feedback.THUMB_DOWN,icon:selected===Feedback.THUMB_UP?ThumbUpIconFilled:ThumbUpIcon,onClick:handleThumbUp,size:`x-small`,variant:enableModernizedComponents?`icon-logo`:`default`,"data-target-id":`IconButton-thumbsUpAriaLabel`})}),jsx(FeedbackTooltip,{isOpen:isFeedbackTooltipOpen,onOpenChange:handleFeedbackTooltipOpenChange,onSubmit:handleFeedbackFormSubmit,shouldIncludeFeedbackText:shouldFeedbackFormIncludeFeedbackText,shouldIncludePromptShareConsent:shouldFeedbackIncludePromptData,shouldShow:isFeedbackFormEnabled,children:jsx(Tooltip,{content:formatMessage(messages$1.thumbsDownAriaLabel),children:jsx(IconButton,{"aria-label":formatMessage(messages$1.thumbsDownAriaLabel),className:enableModernizedComponents?``:thumb_buttons_module_default.thumbDown,disabled:selected===Feedback.THUMB_UP,icon:selected===Feedback.THUMB_DOWN?ThumbDownIconFilled:ThumbDownIcon,onClick:handleThumbDown,size:`x-small`,variant:enableModernizedComponents?`icon-logo`:`default`,"data-target-id":`IconButton-thumbsDownAriaLabel`})})})]})};export{ThumbButtons as t};
@@ -1,14 +1 @@
1
- var e = /* @__PURE__ */ function(e) {
2
- return e.GENERAL = "general", e.RATE_LIMITING = "rate_limiting", e.NO_CONTENT = "no_content", e.PRECONDITION_FAILED = "precondition_failed", e.AGENT_NOT_FOUND = "agent_not_found", e.RESPONSE_FAILED = "response_failed", e.RESPONSE_INTERRUPTED = "response_interrupted", e.RESPONSE_STOPPED = "response_stopped", e;
3
- }({}), t = /* @__PURE__ */ function(e) {
4
- return e.LARGE_FILE = "large_file", e.GENERAL = "general", e;
5
- }({}), n = /* @__PURE__ */ function(e) {
6
- return e.NOT_STARTED = "not_started", e.IN_PROGRESS = "in_progress", e.SUCCESS = "success", e.ERROR = "error", e.CANCELLED = "cancelled", e;
7
- }({}), r = /* @__PURE__ */ function(e) {
8
- return e.CUSTOM = "suggested_question_custom", e.INTELLIGENT = "suggested_question_intelligent", e.STATIC = "suggested_question_static", e;
9
- }({}), i = "user_input", a = /* @__PURE__ */ function(e) {
10
- return e.DID_NOT_FOLLOW_REQUEST = "did_not_follow_request", e.INACCURATE_ANSWER = "inaccurate_answer", e.OTHER = "other", e;
11
- }({}), o = /* @__PURE__ */ function(e) {
12
- return e.HUBS_METADATA = "hubs_metadata", e;
13
- }({});
14
- export { n as a, a as i, o as n, r as o, t as r, i as s, e as t };
1
+ var ANSWER_ERROR=function(ANSWER_ERROR){return ANSWER_ERROR.GENERAL=`general`,ANSWER_ERROR.RATE_LIMITING=`rate_limiting`,ANSWER_ERROR.NO_CONTENT=`no_content`,ANSWER_ERROR.PRECONDITION_FAILED=`precondition_failed`,ANSWER_ERROR.AGENT_NOT_FOUND=`agent_not_found`,ANSWER_ERROR.RESPONSE_FAILED=`response_failed`,ANSWER_ERROR.RESPONSE_INTERRUPTED=`response_interrupted`,ANSWER_ERROR.RESPONSE_STOPPED=`response_stopped`,ANSWER_ERROR}({}),CONTENT_ERROR=function(CONTENT_ERROR){return CONTENT_ERROR.LARGE_FILE=`large_file`,CONTENT_ERROR.GENERAL=`general`,CONTENT_ERROR}({}),REQUEST_STATE=function(REQUEST_STATE){return REQUEST_STATE.NOT_STARTED=`not_started`,REQUEST_STATE.IN_PROGRESS=`in_progress`,REQUEST_STATE.SUCCESS=`success`,REQUEST_STATE.ERROR=`error`,REQUEST_STATE.CANCELLED=`cancelled`,REQUEST_STATE}({}),SUGGESTED_QUESTION_PROMPT_TYPE=function(SUGGESTED_QUESTION_PROMPT_TYPE){return SUGGESTED_QUESTION_PROMPT_TYPE.CUSTOM=`suggested_question_custom`,SUGGESTED_QUESTION_PROMPT_TYPE.INTELLIGENT=`suggested_question_intelligent`,SUGGESTED_QUESTION_PROMPT_TYPE.STATIC=`suggested_question_static`,SUGGESTED_QUESTION_PROMPT_TYPE}({}),USER_INPUT_PROMPT_TYPE=`user_input`,FeedbackIssueType=function(FeedbackIssueType){return FeedbackIssueType.DID_NOT_FOLLOW_REQUEST=`did_not_follow_request`,FeedbackIssueType.INACCURATE_ANSWER=`inaccurate_answer`,FeedbackIssueType.OTHER=`other`,FeedbackIssueType}({}),CITATION_SOURCE=function(CITATION_SOURCE){return CITATION_SOURCE.HUBS_METADATA=`hubs_metadata`,CITATION_SOURCE}({});export{REQUEST_STATE as a,FeedbackIssueType as i,CITATION_SOURCE as n,SUGGESTED_QUESTION_PROMPT_TYPE as o,CONTENT_ERROR as r,USER_INPUT_PROMPT_TYPE as s,ANSWER_ERROR as t};
@@ -1,25 +1 @@
1
- import e from "../esm/lib/components/welcome-message/messages.js";
2
- import { t } from "./items-dropdown.js";
3
- import { InlineNotice as n } from "@box/blueprint-web";
4
- import { FormattedMessage as r } from "react-intl";
5
- import { jsx as i } from "react/jsx-runtime";
6
- import '../styles/unsupported-items-notice.css';var a = { inlineNotice: "_inlineNotice_14reh_1" }, o = ({ unsupportedItems: o, noPermissionsItems: s, onItemClick: c, onDropdownOpenChange: l }) => /* @__PURE__ */ i(n, {
7
- className: a.inlineNotice,
8
- "data-testid": "content-answers-unsupported-items-notice",
9
- variant: "warning",
10
- variantIconAriaLabel: "warning",
11
- children: /* @__PURE__ */ i(r, {
12
- ...e.unsupportedItems,
13
- values: {
14
- files: /* @__PURE__ */ i(t, {
15
- className: a.itemsDropdown,
16
- noPermissionItems: s,
17
- onDropdownOpenChange: l,
18
- onItemClick: c,
19
- unsupportedItems: o
20
- }),
21
- numberOfFiles: o.length + s.length
22
- }
23
- })
24
- });
25
- export { o as t };
1
+ import messages from"../esm/lib/components/welcome-message/messages.js";import{t as ItemsDropdown}from"./items-dropdown.js";import{InlineNotice}from"@box/blueprint-web";import{FormattedMessage}from"react-intl";import{jsx}from"react/jsx-runtime";import '../styles/unsupported-items-notice.css';var unsupported_items_notice_module_default={inlineNotice:`_inlineNotice_14reh_1`},UnsupportedItemsNotice=({unsupportedItems,noPermissionsItems,onItemClick,onDropdownOpenChange})=>jsx(InlineNotice,{className:unsupported_items_notice_module_default.inlineNotice,"data-testid":`content-answers-unsupported-items-notice`,variant:`warning`,variantIconAriaLabel:`warning`,children:jsx(FormattedMessage,{...messages.unsupportedItems,values:{files:jsx(ItemsDropdown,{className:unsupported_items_notice_module_default.itemsDropdown,noPermissionItems:noPermissionsItems,onDropdownOpenChange,onItemClick,unsupportedItems}),numberOfFiles:unsupportedItems.length+noPermissionsItems.length}})});export{UnsupportedItemsNotice as t};
@@ -1,21 +1 @@
1
- import { InlineNotice as e, Text as t } from "@box/blueprint-web";
2
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
3
- import '../styles/warning-message.css';var i = {
4
- welcomeMessage: "_welcomeMessage_1tcd5_27",
5
- warnings: "_warnings_1tcd5_30",
6
- warningNotice: "_warningNotice_1tcd5_35"
7
- }, a = ({ ariaLabel: a, title: o, description: s }) => /* @__PURE__ */ r(e, {
8
- className: i.warningNotice,
9
- variant: "warning",
10
- variantIconAriaLabel: a,
11
- children: [/* @__PURE__ */ n(t, {
12
- as: "p",
13
- variant: "bodyDefaultBold",
14
- children: o
15
- }), s && /* @__PURE__ */ n(t, {
16
- as: "p",
17
- variant: "bodyDefault",
18
- children: s
19
- })]
20
- });
21
- export { i as n, a as t };
1
+ import{InlineNotice,Text}from"@box/blueprint-web";import{jsx,jsxs}from"react/jsx-runtime";import '../styles/warning-message.css';var welcome_message_module_default={welcomeMessage:`_welcomeMessage_1tcd5_27`,warnings:`_warnings_1tcd5_30`,warningNotice:`_warningNotice_1tcd5_35`},WarningMessage=({ariaLabel,title,description})=>jsxs(InlineNotice,{className:welcome_message_module_default.warningNotice,variant:`warning`,variantIconAriaLabel:ariaLabel,children:[jsx(Text,{as:`p`,variant:`bodyDefaultBold`,children:title}),description&&jsx(Text,{as:`p`,variant:`bodyDefault`,children:description})]});export{welcome_message_module_default as n,WarningMessage as t};
package/dist/esm/index.js CHANGED
@@ -1,11 +1 @@
1
- import { t as e } from "../chunks/box-ai-content-answers.js";
2
- import { a as t, i as n, n as r, o as i, r as a, s as o, t as s } from "../chunks/types.js";
3
- import { t as c } from "../chunks/answer-content.js";
4
- import { t as l } from "../chunks/references.js";
5
- import u from "./lib/components/api-wrapper/api-wrapper.js";
6
- import { t as d } from "../chunks/clear-conversation-button.js";
7
- import { IntelligenceModal as f } from "./lib/components/modal/modal.js";
8
- import { IntelligenceSidebar as p } from "./lib/components/sidebar/sidebar.js";
9
- import { AI_AGENTS_LOCAL_STORAGE_KEY as m, APP_MODE as h } from "./lib/constants.js";
10
- import { usePromptFocus as g } from "./lib/hooks/usePromptFocus.js";
11
- export { m as AI_AGENTS_LOCAL_STORAGE_KEY, s as ANSWER_ERROR, h as APP_MODE, c as AnswerContent, e as BoxAiContentAnswers, r as CITATION_SOURCE, a as CONTENT_ERROR, d as ClearConversationButton, n as FeedbackIssueType, f as IntelligenceModal, p as IntelligenceSidebar, t as REQUEST_STATE, l as References, i as SUGGESTED_QUESTION_PROMPT_TYPE, o as USER_INPUT_PROMPT_TYPE, g as usePromptFocus, u as withApiWrapper };
1
+ import{t as BoxAiContentAnswers}from"../chunks/box-ai-content-answers.js";import{a as REQUEST_STATE,i as FeedbackIssueType,n as CITATION_SOURCE,o as SUGGESTED_QUESTION_PROMPT_TYPE,r as CONTENT_ERROR,s as USER_INPUT_PROMPT_TYPE,t as ANSWER_ERROR}from"../chunks/types.js";import{t as AnswerContent}from"../chunks/answer-content.js";import{t as References}from"../chunks/references.js";import withApiWrapper from"./lib/components/api-wrapper/api-wrapper.js";import{t as ClearConversationButton}from"../chunks/clear-conversation-button.js";import{IntelligenceModal}from"./lib/components/modal/modal.js";import{IntelligenceSidebar}from"./lib/components/sidebar/sidebar.js";import{AI_AGENTS_LOCAL_STORAGE_KEY,APP_MODE}from"./lib/constants.js";import{usePromptFocus}from"./lib/hooks/usePromptFocus.js";export{AI_AGENTS_LOCAL_STORAGE_KEY,ANSWER_ERROR,APP_MODE,AnswerContent,BoxAiContentAnswers,CITATION_SOURCE,CONTENT_ERROR,ClearConversationButton,FeedbackIssueType,IntelligenceModal,IntelligenceSidebar,REQUEST_STATE,References,SUGGESTED_QUESTION_PROMPT_TYPE,USER_INPUT_PROMPT_TYPE,usePromptFocus,withApiWrapper};
@@ -1,2 +1 @@
1
- import { t as e } from "../../chunks/box-ai-content-answers.js";
2
- export { e as BoxAiContentAnswers, e as default };
1
+ import{t as BoxAiContentAnswers}from"../../chunks/box-ai-content-answers.js";export{BoxAiContentAnswers,BoxAiContentAnswers as default};
@@ -1,2 +1 @@
1
- import { t as e } from "../../../../chunks/answer-content.js";
2
- export { e as AnswerContent, e as default };
1
+ import{t as AnswerContent}from"../../../../chunks/answer-content.js";export{AnswerContent,AnswerContent as default};
@@ -1,2 +1 @@
1
- import { t as e } from "../../../../chunks/answer.js";
2
- export { e as Answer, e as default };
1
+ import{t as Answer}from"../../../../chunks/answer.js";export{Answer,Answer as default};