@box/box-ai-content-answers 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/LICENSE +379 -0
  2. package/chunks/answer-content.module.js +8 -0
  3. package/chunks/answer.module.js +13 -0
  4. package/chunks/citation.module.js +14 -0
  5. package/chunks/copy-button.module.js +7 -0
  6. package/chunks/inline-error.module.js +10 -0
  7. package/chunks/loading.module.js +9 -0
  8. package/chunks/references.module.js +7 -0
  9. package/chunks/types.js +9 -0
  10. package/esm/index.js +13 -0
  11. package/esm/lib/box-ai-content-answers.js +82 -0
  12. package/esm/lib/components/agents/agent-editor.js +55 -0
  13. package/esm/lib/components/agents/agent-selector.js +76 -0
  14. package/esm/lib/components/agents/messages.js +14 -0
  15. package/esm/lib/components/answer/answer-content.js +29 -0
  16. package/esm/lib/components/answer/answer.js +100 -0
  17. package/esm/lib/components/answer/citation.js +130 -0
  18. package/esm/lib/components/answer/constants.js +4 -0
  19. package/esm/lib/components/answer/copy-button.js +49 -0
  20. package/esm/lib/components/answer/inline-error.js +64 -0
  21. package/esm/lib/components/answer/loading-element.js +41 -0
  22. package/esm/lib/components/answer/messages.js +66 -0
  23. package/esm/lib/components/answer/no-citations.js +34 -0
  24. package/esm/lib/components/answer/references.js +67 -0
  25. package/esm/lib/components/api-wrapper/api-wrapper.js +13 -0
  26. package/esm/lib/components/api-wrapper/constants.js +49 -0
  27. package/esm/lib/components/api-wrapper/content-answers-component.js +55 -0
  28. package/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +197 -0
  29. package/esm/lib/components/api-wrapper/records.js +33 -0
  30. package/esm/lib/components/api-wrapper/test-utils/ReadableStreamSimulator.js +38 -0
  31. package/esm/lib/components/api-wrapper/utils/format.js +9 -0
  32. package/esm/lib/components/api-wrapper/utils/request.js +7 -0
  33. package/esm/lib/components/api-wrapper/utils/stream.js +105 -0
  34. package/esm/lib/components/chat/chat.js +73 -0
  35. package/esm/lib/components/chat/index.js +4 -0
  36. package/esm/lib/components/common/constants.js +13 -0
  37. package/esm/lib/components/common/keyInputUtils.js +6 -0
  38. package/esm/lib/components/common/markdown.js +13370 -0
  39. package/esm/lib/components/common/media-container.js +48 -0
  40. package/esm/lib/components/common/mock-data.js +98 -0
  41. package/esm/lib/components/content/content.js +94 -0
  42. package/esm/lib/components/content/index.js +4 -0
  43. package/esm/lib/components/footer/constants.js +15 -0
  44. package/esm/lib/components/footer/footer-actions.js +65 -0
  45. package/esm/lib/components/footer/footer.js +124 -0
  46. package/esm/lib/components/footer/index.js +4 -0
  47. package/esm/lib/components/footer/messages.js +30 -0
  48. package/esm/lib/components/modal/hooks/useEventListeners.js +15 -0
  49. package/esm/lib/components/modal/hooks/useStopPropagationOnEsc.js +21 -0
  50. package/esm/lib/components/modal/messages.js +18 -0
  51. package/esm/lib/components/modal/modal.js +126 -0
  52. package/esm/lib/components/modal-error/index.js +4 -0
  53. package/esm/lib/components/modal-error/messages.js +26 -0
  54. package/esm/lib/components/modal-error/modal-error.js +78 -0
  55. package/esm/lib/components/question/question.js +50 -0
  56. package/esm/lib/components/suggested-questions/messages.js +10 -0
  57. package/esm/lib/components/suggested-questions/mocks.js +16 -0
  58. package/esm/lib/components/suggested-questions/suggested-questions.js +61 -0
  59. package/esm/lib/components/welcome-message/messages.js +18 -0
  60. package/esm/lib/components/welcome-message/welcome-message.js +78 -0
  61. package/esm/lib/contexts/AgentsContext.js +59 -0
  62. package/esm/lib/messages.js +54 -0
  63. package/i18n/bn-IN.js +48 -0
  64. package/i18n/bn-IN.properties +90 -0
  65. package/i18n/da-DK.js +48 -0
  66. package/i18n/da-DK.properties +90 -0
  67. package/i18n/de-DE.js +48 -0
  68. package/i18n/de-DE.properties +90 -0
  69. package/i18n/en-AU.js +48 -0
  70. package/i18n/en-AU.properties +90 -0
  71. package/i18n/en-CA.js +48 -0
  72. package/i18n/en-CA.properties +90 -0
  73. package/i18n/en-GB.js +48 -0
  74. package/i18n/en-GB.properties +90 -0
  75. package/i18n/en-US.js +48 -0
  76. package/i18n/en-US.properties +92 -0
  77. package/i18n/en-x-pseudo.js +48 -0
  78. package/i18n/en-x-pseudo.properties +90 -0
  79. package/i18n/es-419.js +48 -0
  80. package/i18n/es-419.properties +90 -0
  81. package/i18n/es-ES.js +48 -0
  82. package/i18n/es-ES.properties +90 -0
  83. package/i18n/fi-FI.js +48 -0
  84. package/i18n/fi-FI.properties +90 -0
  85. package/i18n/fr-CA.js +48 -0
  86. package/i18n/fr-CA.properties +90 -0
  87. package/i18n/fr-FR.js +48 -0
  88. package/i18n/fr-FR.properties +90 -0
  89. package/i18n/hi-IN.js +48 -0
  90. package/i18n/hi-IN.properties +90 -0
  91. package/i18n/it-IT.js +48 -0
  92. package/i18n/it-IT.properties +90 -0
  93. package/i18n/ja-JP.js +48 -0
  94. package/i18n/ja-JP.properties +90 -0
  95. package/i18n/json/src/lib/components/agents/messages.json +1 -0
  96. package/i18n/json/src/lib/components/answer/messages.json +1 -0
  97. package/i18n/json/src/lib/components/footer/messages.json +1 -0
  98. package/i18n/json/src/lib/components/modal/messages.json +1 -0
  99. package/i18n/json/src/lib/components/modal-error/messages.json +1 -0
  100. package/i18n/json/src/lib/components/suggested-questions/messages.json +1 -0
  101. package/i18n/json/src/lib/components/welcome-message/messages.json +1 -0
  102. package/i18n/json/src/lib/messages.json +1 -0
  103. package/i18n/ko-KR.js +48 -0
  104. package/i18n/ko-KR.properties +90 -0
  105. package/i18n/nb-NO.js +48 -0
  106. package/i18n/nb-NO.properties +90 -0
  107. package/i18n/nl-NL.js +48 -0
  108. package/i18n/nl-NL.properties +90 -0
  109. package/i18n/pl-PL.js +48 -0
  110. package/i18n/pl-PL.properties +90 -0
  111. package/i18n/pt-BR.js +48 -0
  112. package/i18n/pt-BR.properties +90 -0
  113. package/i18n/ru-RU.js +48 -0
  114. package/i18n/ru-RU.properties +90 -0
  115. package/i18n/sv-SE.js +48 -0
  116. package/i18n/sv-SE.properties +90 -0
  117. package/i18n/tr-TR.js +48 -0
  118. package/i18n/tr-TR.properties +90 -0
  119. package/i18n/zh-CN.js +48 -0
  120. package/i18n/zh-CN.properties +90 -0
  121. package/i18n/zh-TW.js +48 -0
  122. package/i18n/zh-TW.properties +90 -0
  123. package/package.json +56 -0
  124. package/styles/agent-editor.css +1 -0
  125. package/styles/agent-selector.css +1 -0
  126. package/styles/answer-content.css +1 -0
  127. package/styles/answer.css +1 -0
  128. package/styles/box-ai-content-answers.css +1 -0
  129. package/styles/chat.css +1 -0
  130. package/styles/citation.css +1 -0
  131. package/styles/content.css +1 -0
  132. package/styles/copy-button.css +1 -0
  133. package/styles/footer-actions.css +1 -0
  134. package/styles/footer.css +1 -0
  135. package/styles/inline-error.css +1 -0
  136. package/styles/loading.css +1 -0
  137. package/styles/markdown.css +7 -0
  138. package/styles/media-container.css +1 -0
  139. package/styles/modal-error.css +1 -0
  140. package/styles/modal.css +1 -0
  141. package/styles/question.css +1 -0
  142. package/styles/references.css +1 -0
  143. package/styles/suggested-questions.css +1 -0
  144. package/styles/welcome-message.css +1 -0
  145. package/types/index.d.ts +5 -0
  146. package/types/lib/box-ai-content-answers.d.ts +17 -0
  147. package/types/lib/components/agents/agent-editor.d.ts +8 -0
  148. package/types/lib/components/agents/agent-selector.d.ts +6 -0
  149. package/types/lib/components/agents/messages.d.ts +13 -0
  150. package/types/lib/components/agents/stories/shared.d.ts +12 -0
  151. package/types/lib/components/answer/answer-content.d.ts +8 -0
  152. package/types/lib/components/answer/answer.d.ts +29 -0
  153. package/types/lib/components/answer/citation.d.ts +19 -0
  154. package/types/lib/components/answer/constants.d.ts +1 -0
  155. package/types/lib/components/answer/copy-button.d.ts +7 -0
  156. package/types/lib/components/answer/inline-error.d.ts +8 -0
  157. package/types/lib/components/answer/loading-element.d.ts +5 -0
  158. package/types/lib/components/answer/messages.d.ts +78 -0
  159. package/types/lib/components/answer/no-citations.d.ts +7 -0
  160. package/types/lib/components/answer/references.d.ts +13 -0
  161. package/types/lib/components/answer/stories/shared.d.ts +25 -0
  162. package/types/lib/components/api-wrapper/api-wrapper.d.ts +3 -0
  163. package/types/lib/components/api-wrapper/constants.d.ts +6 -0
  164. package/types/lib/components/api-wrapper/content-answers-component.d.ts +6 -0
  165. package/types/lib/components/api-wrapper/hooks/useContentAnswers.d.ts +16 -0
  166. package/types/lib/components/api-wrapper/records.d.ts +28 -0
  167. package/types/lib/components/api-wrapper/stories/shared.d.ts +2 -0
  168. package/types/lib/components/api-wrapper/test-utils/ReadableStreamSimulator.d.ts +25 -0
  169. package/types/lib/components/api-wrapper/types.d.ts +86 -0
  170. package/types/lib/components/api-wrapper/utils/format.d.ts +3 -0
  171. package/types/lib/components/api-wrapper/utils/request.d.ts +4 -0
  172. package/types/lib/components/api-wrapper/utils/stream.d.ts +29 -0
  173. package/types/lib/components/chat/chat.d.ts +3 -0
  174. package/types/lib/components/chat/index.d.ts +1 -0
  175. package/types/lib/components/common/constants.d.ts +10 -0
  176. package/types/lib/components/common/keyInputUtils.d.ts +2 -0
  177. package/types/lib/components/common/markdown.d.ts +2 -0
  178. package/types/lib/components/common/media-container.d.ts +21 -0
  179. package/types/lib/components/common/mock-data.d.ts +27 -0
  180. package/types/lib/components/content/content.d.ts +4 -0
  181. package/types/lib/components/content/index.d.ts +1 -0
  182. package/types/lib/components/footer/constants.d.ts +12 -0
  183. package/types/lib/components/footer/footer-actions.d.ts +9 -0
  184. package/types/lib/components/footer/footer.d.ts +34 -0
  185. package/types/lib/components/footer/index.d.ts +1 -0
  186. package/types/lib/components/footer/messages.d.ts +33 -0
  187. package/types/lib/components/footer/stories/shared.d.ts +130 -0
  188. package/types/lib/components/footer/stories/tests/mocks.d.ts +2 -0
  189. package/types/lib/components/modal/hooks/useEventListeners.d.ts +5 -0
  190. package/types/lib/components/modal/hooks/useStopPropagationOnEsc.d.ts +4 -0
  191. package/types/lib/components/modal/messages.d.ts +18 -0
  192. package/types/lib/components/modal/modal.d.ts +32 -0
  193. package/types/lib/components/modal/stories/shared.d.ts +31 -0
  194. package/types/lib/components/modal-error/index.d.ts +1 -0
  195. package/types/lib/components/modal-error/messages.d.ts +28 -0
  196. package/types/lib/components/modal-error/modal-error.d.ts +13 -0
  197. package/types/lib/components/modal-error/stories/shared.d.ts +2 -0
  198. package/types/lib/components/question/question.d.ts +11 -0
  199. package/types/lib/components/question/stories/shared.d.ts +2 -0
  200. package/types/lib/components/suggested-questions/messages.d.ts +8 -0
  201. package/types/lib/components/suggested-questions/mocks.d.ts +2 -0
  202. package/types/lib/components/suggested-questions/stories/shared.d.ts +3 -0
  203. package/types/lib/components/suggested-questions/suggested-questions.d.ts +15 -0
  204. package/types/lib/components/welcome-message/messages.d.ts +18 -0
  205. package/types/lib/components/welcome-message/stories/shared.d.ts +2 -0
  206. package/types/lib/components/welcome-message/welcome-message.d.ts +3 -0
  207. package/types/lib/contexts/AgentsContext.d.ts +15 -0
  208. package/types/lib/messages.d.ts +63 -0
  209. package/types/lib/stories/shared.d.ts +36 -0
  210. package/types/lib/types.d.ts +115 -0
@@ -0,0 +1,76 @@
1
+ import "../../../../styles/agent-selector.css";
2
+ import { FilterChip as n, Popover as a, Status as S, SmallList as i } from "@box/blueprint-web";
3
+ import { useState as f, useCallback as C } from "react";
4
+ import { useIntl as I } from "react-intl";
5
+ import { useAgents as v, useAgentsDispatch as N } from "../../contexts/AgentsContext.js";
6
+ import { LOGGER_BASE_CONFIG as G, LOGGER_ACTION_CLICK as O } from "../common/constants.js";
7
+ import p from "./messages.js";
8
+ import { jsx as e, jsxs as d } from "react/jsx-runtime";
9
+ const A = "_agentSelector_vehz7_1", E = "_agentStatus_vehz7_5", x = "_agentList_vehz7_20", T = "_agentListItem_vehz7_20", s = {
10
+ agentSelector: A,
11
+ agentStatus: E,
12
+ agentList: x,
13
+ agentListItem: T
14
+ }, K = ({
15
+ onSelectAgent: o,
16
+ recordAction: r
17
+ }) => {
18
+ const {
19
+ formatMessage: l
20
+ } = I(), {
21
+ agents: h,
22
+ selectedAgent: c
23
+ } = v(), m = N(), [_, g] = f(!1), u = l(p.selectAgent), L = C((t) => {
24
+ g(!1), m({
25
+ type: "SELECT_AGENT",
26
+ agentName: t.name
27
+ }), r && r({
28
+ ...G,
29
+ action: O,
30
+ target: "agentSelector",
31
+ data: {
32
+ agentSelected: t.name
33
+ }
34
+ }), o && o(t);
35
+ }, [m, o, r]);
36
+ return /* @__PURE__ */ e(n.Group, {
37
+ className: s.agentSelector,
38
+ name: u,
39
+ type: "multiple",
40
+ children: /* @__PURE__ */ d(a.Root, {
41
+ modal: !1,
42
+ onOpenChange: g,
43
+ open: _,
44
+ children: [/* @__PURE__ */ e(a.Trigger, {
45
+ children: /* @__PURE__ */ d(n.TriggerChip, {
46
+ value: "trigger-chip",
47
+ children: [/* @__PURE__ */ e(S, {
48
+ className: s.agentStatus,
49
+ colorIndex: 0,
50
+ text: l(p.agent)
51
+ }), /* @__PURE__ */ e(n.Label, {
52
+ children: c.name
53
+ }), /* @__PURE__ */ e(n.DropdownIndicator, {})]
54
+ })
55
+ }), /* @__PURE__ */ e(a.ContentContainer, {
56
+ children: /* @__PURE__ */ e(a.MainContent, {
57
+ children: /* @__PURE__ */ e(i, {
58
+ className: s.agentList,
59
+ selectedKeys: [c.name],
60
+ children: h.map((t) => /* @__PURE__ */ e(i.Item, {
61
+ className: s.agentListItem,
62
+ id: t.name,
63
+ onAction: () => L(t),
64
+ children: /* @__PURE__ */ e(i.Header, {
65
+ children: t.name
66
+ })
67
+ }, t.name))
68
+ })
69
+ })
70
+ })]
71
+ })
72
+ });
73
+ };
74
+ export {
75
+ K as AgentSelector
76
+ };
@@ -0,0 +1,14 @@
1
+ import { defineMessages as e } from "react-intl";
2
+ const s = e({
3
+ agent: {
4
+ id: "boxAI.contentAnswers.agent",
5
+ defaultMessage: "Agent"
6
+ },
7
+ selectAgent: {
8
+ id: "boxAI.contentAnswers.selectAgent",
9
+ defaultMessage: "Select an Agent"
10
+ }
11
+ });
12
+ export {
13
+ s as default
14
+ };
@@ -0,0 +1,29 @@
1
+ import m from "clsx";
2
+ import i from "../common/markdown.js";
3
+ import { s as r } from "../../../../chunks/answer-content.module.js";
4
+ import { jsxs as l, Fragment as f, jsx as d } from "react/jsx-runtime";
5
+ const C = ({
6
+ answer: t,
7
+ isMarkdownEnabled: e,
8
+ className: n,
9
+ ...o
10
+ }) => {
11
+ let s = t;
12
+ return e && t && (s = i.render(t)), /* @__PURE__ */ l(f, {
13
+ children: [!e && /* @__PURE__ */ d("div", {
14
+ className: m(r.answerContent, "Answer-text", n),
15
+ ...o,
16
+ children: t
17
+ }), e && /* @__PURE__ */ d("div", {
18
+ className: m(r.answerContent, r.answerMarkdown, "Answer-text", n),
19
+ dangerouslySetInnerHTML: {
20
+ __html: s
21
+ },
22
+ ...o
23
+ })]
24
+ });
25
+ };
26
+ export {
27
+ C as AnswerContent,
28
+ C as default
29
+ };
@@ -0,0 +1,100 @@
1
+ import { useBreakpoint as x, Breakpoint as A, Text as L } from "@box/blueprint-web";
2
+ import { BoxAi as T, AlertTriangle as _ } from "@box/blueprint-web-assets/icons/Line";
3
+ import { Size5 as k, Size6 as y, Gray65 as z, Size4 as R } from "@box/blueprint-web-assets/tokens/tokens";
4
+ import C from "clsx";
5
+ import * as p from "react";
6
+ import { useIntl as D } from "react-intl";
7
+ import { A as r } from "../../../../chunks/types.js";
8
+ import { MediaContainer as f } from "../common/media-container.js";
9
+ import { AnswerContent as F } from "./answer-content.js";
10
+ import { CopyButton as M } from "./copy-button.js";
11
+ import { InlineError as G } from "./inline-error.js";
12
+ import { LoadingElement as b } from "./loading-element.js";
13
+ import d from "./messages.js";
14
+ import { References as j } from "./references.js";
15
+ import { s as o } from "../../../../chunks/answer.module.js";
16
+ import { jsxs as n, jsx as t } from "react/jsx-runtime";
17
+ const ne = /* @__PURE__ */ p.memo(({
18
+ answer: s,
19
+ citations: N,
20
+ error: e,
21
+ handleScrollToBottom: i,
22
+ isCitationsEnabled: I = !1,
23
+ isCompleted: v = !1,
24
+ isLoading: P = !1,
25
+ isMarkdownEnabled: w = !1,
26
+ isStreamingEnabled: a = !1,
27
+ onCitationClick: O,
28
+ recordAction: m,
29
+ useAnimation: c = !0
30
+ }) => {
31
+ const E = p.useRef(!0), S = e === r.RATE_LIMITING || e === r.GENERAL, h = P && !s && !e, {
32
+ formatMessage: l
33
+ } = D(), u = x() === A.Small ? k : y;
34
+ p.useEffect(() => {
35
+ if (E.current) {
36
+ E.current = !1;
37
+ return;
38
+ }
39
+ s && i && i(a ? "instant" : "smooth", a);
40
+ }, [s, i, a]);
41
+ const g = () => /* @__PURE__ */ n(L, {
42
+ as: "p",
43
+ className: o.error,
44
+ color: "textOnLightSecondary",
45
+ "data-testid": "content-answers-error",
46
+ variant: "caption",
47
+ children: [e === r.RESPONSE_INTERRUPTED && l(d.responseInterruptedError), e === r.RESPONSE_FAILED && l(d.responseFailedError), e === r.RESPONSE_STOPPED && l(d.responseStoppedError), e !== r.RESPONSE_STOPPED && /* @__PURE__ */ t(_, {
48
+ className: o.alertIcon,
49
+ color: z,
50
+ "data-testid": "content-answers-error-alert-icon",
51
+ height: R,
52
+ role: "presentation",
53
+ width: R
54
+ })]
55
+ });
56
+ return /* @__PURE__ */ n("div", {
57
+ "aria-live": "polite",
58
+ className: o.answer,
59
+ "data-testid": "content-answers-answer",
60
+ children: [!S && !h && /* @__PURE__ */ n(f, {
61
+ children: [/* @__PURE__ */ t(f.Figure, {
62
+ children: /* @__PURE__ */ t("div", {
63
+ className: o.iconAvatar,
64
+ children: /* @__PURE__ */ t(T, {
65
+ height: u,
66
+ role: "presentation",
67
+ width: u
68
+ })
69
+ })
70
+ }), /* @__PURE__ */ n(f.Content, {
71
+ useAnimation: c,
72
+ children: [/* @__PURE__ */ t(F, {
73
+ answer: s,
74
+ isMarkdownEnabled: w
75
+ }), v && /* @__PURE__ */ n("div", {
76
+ className: C(o.footer, {
77
+ [o.animated]: c
78
+ }),
79
+ "data-testid": "content-answers-answer-footer",
80
+ children: [e && g(), I && !e && /* @__PURE__ */ t(j, {
81
+ citations: N,
82
+ onCitationClick: O,
83
+ recordAction: m
84
+ }), /* @__PURE__ */ t(M, {
85
+ answer: s,
86
+ recordAction: m
87
+ })]
88
+ })]
89
+ })]
90
+ }), S && /* @__PURE__ */ t(G, {
91
+ error: e,
92
+ recordAction: m,
93
+ useAnimation: c
94
+ }), h && /* @__PURE__ */ t(b, {})]
95
+ });
96
+ });
97
+ export {
98
+ ne as Answer,
99
+ ne as default
100
+ };
@@ -0,0 +1,130 @@
1
+ import { Popover as d, Status as S, Text as N, TextButton as M } from "@box/blueprint-web";
2
+ import { ArrowUpRightSquare as D } from "@box/blueprint-web-assets/icons/Fill";
3
+ import G from "clsx";
4
+ import R from "lodash/debounce";
5
+ import _ from "lodash/truncate";
6
+ import { useState as b, useRef as F, useCallback as A, useEffect as y } from "react";
7
+ import { useIntl as j } from "react-intl";
8
+ import { LOGGER_BASE_CONFIG as w, LOGGER_ACTION_CLICK as K } from "../common/constants.js";
9
+ import { MAX_CITATION_LENGTH as P } from "./constants.js";
10
+ import i from "./messages.js";
11
+ import { s as o } from "../../../../chunks/citation.module.js";
12
+ import { jsxs as B, jsx as e } from "react/jsx-runtime";
13
+ const Z = ({
14
+ animate: p,
15
+ content: T,
16
+ id: a,
17
+ recordAction: n,
18
+ fileId: h,
19
+ title: l,
20
+ onCitationClick: c
21
+ }) => {
22
+ const [g, O] = b(!1), [E, I] = b(!p), {
23
+ formatMessage: r
24
+ } = j(), x = !!c, C = F(null);
25
+ let f;
26
+ l ? f = r(i.cardTooltipTitleWithDocumentName, {
27
+ title: l.toString()
28
+ }) : f = r(i.cardTooltipTitle);
29
+ const v = R((t) => {
30
+ O(t), t === !0 && n && n({
31
+ ...w,
32
+ feature: "answers-citations",
33
+ target: "hovered",
34
+ data: {
35
+ index: a
36
+ }
37
+ });
38
+ }, 100), u = () => {
39
+ v(!0);
40
+ }, s = () => {
41
+ v(!1);
42
+ }, L = A(() => {
43
+ c && n && (c(h, l), n({
44
+ ...w,
45
+ feature: "answers-citations",
46
+ target: K,
47
+ data: {
48
+ index: a
49
+ }
50
+ }));
51
+ }, [c, n, a, h, l]);
52
+ y(() => {
53
+ p && I(!0);
54
+ }, []);
55
+ const m = T ? _(T.toString(), {
56
+ length: P,
57
+ separator: /,? +/
58
+ }) : void 0;
59
+ return /* @__PURE__ */ B(d.Root, {
60
+ modal: !1,
61
+ open: g,
62
+ children: [/* @__PURE__ */ e(d.Trigger, {
63
+ className: o.citationTrigger,
64
+ onMouseEnter: u,
65
+ onMouseLeave: s,
66
+ children: /* @__PURE__ */ e(S, {
67
+ ref: C,
68
+ "aria-label": g ? m : r(i.referenceAriaLabel, {
69
+ number: a
70
+ }),
71
+ className: G(o.citationStatus, {
72
+ [o.animate]: p,
73
+ [o.fadeIn]: E
74
+ }),
75
+ colorIndex: 0,
76
+ "data-testid": "content-answers-citation-status",
77
+ interactive: !0,
78
+ onBlur: s,
79
+ onFocus: u,
80
+ tabIndex: 0,
81
+ text: `${a}`
82
+ })
83
+ }), /* @__PURE__ */ e(d.ContentContainer, {
84
+ "aria-label": m,
85
+ collisionPadding: 10,
86
+ "data-testid": "content-answers-citation-card",
87
+ onBlur: s,
88
+ onCloseAutoFocus: (t) => t.preventDefault(),
89
+ onEscapeKeyDown: () => {
90
+ var t;
91
+ (t = C.current) == null || t.focus(), s();
92
+ },
93
+ onFocus: u,
94
+ onMouseEnter: u,
95
+ onMouseLeave: s,
96
+ onOpenAutoFocus: (t) => {
97
+ x || t.preventDefault();
98
+ },
99
+ side: "top",
100
+ sideOffset: 5,
101
+ children: /* @__PURE__ */ e(d.MainContent, {
102
+ children: /* @__PURE__ */ B("div", {
103
+ className: o.cardTooltip,
104
+ children: [/* @__PURE__ */ e(N, {
105
+ as: "h4",
106
+ className: o.cardTooltipTitle,
107
+ variant: "bodyDefaultBold",
108
+ children: f
109
+ }), /* @__PURE__ */ e(N, {
110
+ as: "p",
111
+ className: o.cardTooltipCitation,
112
+ color: "textOnLightDefault",
113
+ variant: "caption",
114
+ children: m
115
+ }), x && /* @__PURE__ */ e(M, {
116
+ "aria-label": r(i.cardTooltipButton),
117
+ className: o.cardTooltipButton,
118
+ icon: D,
119
+ onClick: L,
120
+ children: r(i.cardTooltipButton)
121
+ })]
122
+ })
123
+ })
124
+ })]
125
+ });
126
+ };
127
+ export {
128
+ Z as Citation,
129
+ Z as default
130
+ };
@@ -0,0 +1,4 @@
1
+ const T = 500;
2
+ export {
3
+ T as MAX_CITATION_LENGTH
4
+ };
@@ -0,0 +1,49 @@
1
+ import { useNotification as n, Tooltip as p, IconButton as l } from "@box/blueprint-web";
2
+ import { Clipboard as m } from "@box/blueprint-web-assets/icons/Fill";
3
+ import { useIntl as u } from "react-intl";
4
+ import f from "../../messages.js";
5
+ import { LOGGER_BASE_CONFIG as d, LOGGER_ACTION_CLICK as b } from "../common/constants.js";
6
+ import t from "./messages.js";
7
+ import { s as C } from "../../../../chunks/copy-button.module.js";
8
+ import { jsx as r } from "react/jsx-runtime";
9
+ const N = ({
10
+ answer: i,
11
+ recordAction: a
12
+ }) => {
13
+ const {
14
+ formatMessage: o
15
+ } = u(), {
16
+ addNotification: e
17
+ } = n(), c = () => {
18
+ a && a({
19
+ ...d,
20
+ action: b,
21
+ target: "copyToClipboard"
22
+ }), i && navigator && navigator.clipboard && navigator.clipboard.writeText && navigator.clipboard.writeText(i).then(() => {
23
+ e({
24
+ sensitivity: "foreground",
25
+ styledText: o(t.copyToClipboardSucceeded),
26
+ variant: "success",
27
+ typeIconAriaLabel: o(t.copyButtonSuccessText),
28
+ closeButtonAriaLabel: o(f.closeButtonText)
29
+ });
30
+ });
31
+ };
32
+ return /* @__PURE__ */ r(p, {
33
+ content: o(t.copyToClipboard),
34
+ children: /* @__PURE__ */ r(l, {
35
+ "aria-label": o(t.copyToClipboard),
36
+ className: C.copyButton,
37
+ icon: m,
38
+ onClick: c,
39
+ onFocusCapture: (s) => {
40
+ s.target.matches(":focus-visible") || s.stopPropagation();
41
+ },
42
+ size: "x-small"
43
+ })
44
+ });
45
+ };
46
+ export {
47
+ N as CopyButton,
48
+ N as default
49
+ };
@@ -0,0 +1,64 @@
1
+ import { useBreakpoint as f, Breakpoint as h, Text as E } from "@box/blueprint-web";
2
+ import { BoxAi as g, AlertTriangle as S } from "@box/blueprint-web-assets/icons/Line";
3
+ import { Size5 as n, Size6 as u } from "@box/blueprint-web-assets/tokens/tokens";
4
+ import * as s from "react";
5
+ import { useIntl as v } from "react-intl";
6
+ import { A as x } from "../../../../chunks/types.js";
7
+ import { LOGGER_BASE_CONFIG as R } from "../common/constants.js";
8
+ import { MediaContainer as a } from "../common/media-container.js";
9
+ import l from "./messages.js";
10
+ import { s as e } from "../../../../chunks/inline-error.module.js";
11
+ import { jsx as r, jsxs as m } from "react/jsx-runtime";
12
+ const z = ({
13
+ error: i,
14
+ recordAction: t,
15
+ useAnimation: c
16
+ }) => {
17
+ const {
18
+ formatMessage: d
19
+ } = v();
20
+ s.useEffect(() => {
21
+ t && t({
22
+ ...R,
23
+ target: "inlineError"
24
+ });
25
+ }, [t]);
26
+ const p = s.useCallback(() => i === x.RATE_LIMITING ? l.inlineRateLimitingErrorText : l.inlineErrorText, [i]), o = f() === h.Small ? n : u;
27
+ return /* @__PURE__ */ r("div", {
28
+ className: e.inlineError,
29
+ "data-testid": "content-answers-inline-error",
30
+ children: /* @__PURE__ */ m(a, {
31
+ children: [/* @__PURE__ */ r(a.Figure, {
32
+ variant: "center-aligned",
33
+ children: /* @__PURE__ */ r("div", {
34
+ className: e.iconAvatar,
35
+ children: /* @__PURE__ */ r(g, {
36
+ height: o,
37
+ role: "presentation",
38
+ width: o
39
+ })
40
+ })
41
+ }), /* @__PURE__ */ m(a.Content, {
42
+ shouldAddCard: !1,
43
+ useAnimation: c,
44
+ variant: "error",
45
+ children: [/* @__PURE__ */ r("div", {
46
+ className: e.icon,
47
+ children: /* @__PURE__ */ r(S, {
48
+ height: n,
49
+ role: "presentation",
50
+ width: n
51
+ })
52
+ }), /* @__PURE__ */ r(E, {
53
+ as: "p",
54
+ className: e.text,
55
+ children: i && d(p())
56
+ })]
57
+ })]
58
+ })
59
+ });
60
+ };
61
+ export {
62
+ z as InlineError,
63
+ z as default
64
+ };
@@ -0,0 +1,41 @@
1
+ import { useBreakpoint as n, Breakpoint as s, LoadingIndicator as l } from "@box/blueprint-web";
2
+ import { BoxAi as m } from "@box/blueprint-web-assets/icons/Line";
3
+ import { Size5 as d, Size6 as c } from "@box/blueprint-web-assets/tokens/tokens";
4
+ import { useIntl as p } from "react-intl";
5
+ import { MediaContainer as r } from "../common/media-container.js";
6
+ import f from "./messages.js";
7
+ import { s as i } from "../../../../chunks/loading.module.js";
8
+ import { jsx as e, jsxs as g } from "react/jsx-runtime";
9
+ const B = ({
10
+ useAnimation: a
11
+ }) => {
12
+ const {
13
+ formatMessage: t
14
+ } = p(), o = n() === s.Small ? d : c;
15
+ return /* @__PURE__ */ e("div", {
16
+ className: i.loadingElement,
17
+ children: /* @__PURE__ */ g(r, {
18
+ children: [/* @__PURE__ */ e(r.Figure, {
19
+ children: /* @__PURE__ */ e("div", {
20
+ className: i.iconAvatar,
21
+ children: /* @__PURE__ */ e(m, {
22
+ height: o,
23
+ role: "presentation",
24
+ width: o
25
+ })
26
+ })
27
+ }), /* @__PURE__ */ e(r.Content, {
28
+ useAnimation: a,
29
+ children: /* @__PURE__ */ e(l, {
30
+ "aria-label": t(f.loadingAnswer),
31
+ className: i.loadingIndicator,
32
+ "data-testid": "content-answers-loading-indicator"
33
+ })
34
+ })]
35
+ })
36
+ });
37
+ };
38
+ export {
39
+ B as LoadingElement,
40
+ B as default
41
+ };
@@ -0,0 +1,66 @@
1
+ import { defineMessages as e } from "react-intl";
2
+ const t = e({
3
+ basedOn: {
4
+ id: "boxAI.contentAnswers.basedOn",
5
+ defaultMessage: "Based on:"
6
+ },
7
+ cardTooltipButton: {
8
+ id: "boxAI.contentAnswers.cardTooltipButton",
9
+ defaultMessage: "Open document"
10
+ },
11
+ cardTooltipTitle: {
12
+ id: "boxAI.contentAnswers.cardTooltipTitle",
13
+ defaultMessage: "From document:"
14
+ },
15
+ cardTooltipTitleWithDocumentName: {
16
+ id: "boxAI.contentAnswers.cardTooltipTitleWithDocumentName",
17
+ defaultMessage: 'From "{title}":'
18
+ },
19
+ copyButtonSuccessText: {
20
+ id: "boxAI.textInputWithCopyButton.copyButtonSuccessText",
21
+ defaultMessage: "Copied"
22
+ },
23
+ copyToClipboard: {
24
+ id: "boxAI.contentAnswers.copyToClipboard",
25
+ defaultMessage: "Copy to Clipboard"
26
+ },
27
+ copyToClipboardSucceeded: {
28
+ id: "boxAI.contentAnswers.copyToClipboardSucceeded",
29
+ defaultMessage: "Copied to your clipboard"
30
+ },
31
+ inlineErrorText: {
32
+ id: "boxAI.contentAnswers.inlineErrorText",
33
+ defaultMessage: "The Box AI service was unavailable."
34
+ },
35
+ inlineRateLimitingErrorText: {
36
+ id: "boxAI.contentAnswers.inlineRateLimitingErrorText",
37
+ defaultMessage: "Box AI currently has limited capacity (we're working to expand bandwidth). Please try again in a few minutes."
38
+ },
39
+ loadingAnswer: {
40
+ id: "boxAI.contentAnswers.loadingAnswer",
41
+ defaultMessage: "Loading Answer..."
42
+ },
43
+ noReferences: {
44
+ id: "boxAI.contentAnswers.noReferences",
45
+ defaultMessage: "Response based on general document analysis"
46
+ },
47
+ referenceAriaLabel: {
48
+ id: "boxAI.contentAnswers.referenceAriaLabel",
49
+ defaultMessage: "Reference {number}"
50
+ },
51
+ responseInterruptedError: {
52
+ id: "boxAI.contentAnswers.responseInterruptedError",
53
+ defaultMessage: "Response Interrupted"
54
+ },
55
+ responseFailedError: {
56
+ id: "boxAI.contentAnswers.responseFailedError",
57
+ defaultMessage: "Response Failed"
58
+ },
59
+ responseStoppedError: {
60
+ id: "boxAI.contentAnswers.responseStoppedError",
61
+ defaultMessage: "Response Stopped"
62
+ }
63
+ });
64
+ export {
65
+ t as default
66
+ };
@@ -0,0 +1,34 @@
1
+ import { Tooltip as s, IconButton as r } from "@box/blueprint-web";
2
+ import { InfoBadge as a } from "@box/blueprint-web-assets/icons/Line";
3
+ import { useEffect as f } from "react";
4
+ import { useIntl as i } from "react-intl";
5
+ import { LOGGER_BASE_CONFIG as m } from "../common/constants.js";
6
+ import c from "./messages.js";
7
+ import { jsx as o } from "react/jsx-runtime";
8
+ const N = ({
9
+ recordAction: e
10
+ }) => {
11
+ const {
12
+ formatMessage: n
13
+ } = i(), t = n(c.noReferences);
14
+ return f(() => {
15
+ e && e({
16
+ ...m,
17
+ target: "noReferences"
18
+ });
19
+ }, [e]), /* @__PURE__ */ o(s, {
20
+ className: "Answer-NoCitations",
21
+ content: t,
22
+ "data-testid": "content-answers-references-no-references-tooltip",
23
+ children: /* @__PURE__ */ o(r, {
24
+ "aria-label": t,
25
+ "data-testid": "content-answers-references-no-references",
26
+ icon: a,
27
+ size: "x-small"
28
+ })
29
+ });
30
+ };
31
+ export {
32
+ N as NoCitationsIcon,
33
+ N as default
34
+ };
@@ -0,0 +1,67 @@
1
+ import { Text as u } from "@box/blueprint-web";
2
+ import { useEffect as g } from "react";
3
+ import { useIntl as i } from "react-intl";
4
+ import { LOGGER_BASE_CONFIG as w } from "../common/constants.js";
5
+ import { Citation as N } from "./citation.js";
6
+ import x from "./messages.js";
7
+ import { NoCitationsIcon as C } from "./no-citations.js";
8
+ import { s as t } from "../../../../chunks/references.module.js";
9
+ import { jsx as s, jsxs as m, Fragment as O } from "react/jsx-runtime";
10
+ const R = ({
11
+ animate: o = !0,
12
+ citations: e,
13
+ recordAction: r,
14
+ onCitationClick: f
15
+ }) => {
16
+ const a = e && e.length > 0, {
17
+ formatMessage: l
18
+ } = i();
19
+ return g(() => {
20
+ a && r && r({
21
+ ...w,
22
+ feature: "answers-citations",
23
+ target: "shown",
24
+ data: {
25
+ count: e.length
26
+ }
27
+ });
28
+ }, []), e === null ? /* @__PURE__ */ s("div", {
29
+ className: t.references,
30
+ "data-testid": "content-answers-references-null"
31
+ }) : /* @__PURE__ */ m("div", {
32
+ className: t.references,
33
+ "data-testid": "content-answers-references",
34
+ children: [a && /* @__PURE__ */ m(O, {
35
+ children: [/* @__PURE__ */ s(u, {
36
+ as: "span",
37
+ className: t.label,
38
+ color: "textOnLightSecondary",
39
+ "data-testid": "content-answers-references-label",
40
+ variant: "caption",
41
+ children: l(x.basedOn)
42
+ }), e.map(({
43
+ content: p,
44
+ location: d,
45
+ title: c,
46
+ fileId: h
47
+ }, n) => (
48
+ // eslint-disable-next-line react/no-array-index-key
49
+ /* @__PURE__ */ s(N, {
50
+ animate: o,
51
+ content: p,
52
+ fileId: h,
53
+ id: n + 1,
54
+ onCitationClick: f,
55
+ recordAction: r,
56
+ title: c
57
+ }, `${d}-${n + 1}`)
58
+ ))]
59
+ }), (e == null ? void 0 : e.length) === 0 && /* @__PURE__ */ s(C, {
60
+ recordAction: r
61
+ })]
62
+ });
63
+ };
64
+ export {
65
+ R as References,
66
+ R as default
67
+ };