@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,48 @@
1
+ import "../../../../styles/media-container.css";
2
+ import { Card as s } from "@box/blueprint-web";
3
+ import n from "clsx";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ const _ = "_mediaContainer_ydawk_9", c = "_question_ydawk_15", m = "_body_ydawk_18", u = "_animated_ydawk_25", y = "_heightExpand_ydawk_1", g = "_error_ydawk_29", l = "_figure_ydawk_42", e = {
6
+ mediaContainer: _,
7
+ question: c,
8
+ body: m,
9
+ animated: u,
10
+ heightExpand: y,
11
+ error: g,
12
+ figure: l,
13
+ "center-aligned": "_center-aligned_ydawk_49",
14
+ "top-aligned": "_top-aligned_ydawk_53"
15
+ }, p = ({
16
+ children: a,
17
+ className: t
18
+ }) => /* @__PURE__ */ r("div", {
19
+ className: n(e.mediaContainer, e[t]),
20
+ "data-testid": "content-answers-grid-card",
21
+ children: a
22
+ }), i = p;
23
+ i.Figure = ({
24
+ children: a,
25
+ variant: t
26
+ }) => /* @__PURE__ */ r("div", {
27
+ className: n(e.figure, e[t]),
28
+ children: a
29
+ });
30
+ i.Content = ({
31
+ children: a,
32
+ variant: t,
33
+ shouldAddCard: d = !0,
34
+ useAnimation: o = !0
35
+ }) => /* @__PURE__ */ r("div", {
36
+ className: n(e.body, e[t]),
37
+ children: d ? /* @__PURE__ */ r(s, {
38
+ className: n({
39
+ [e.animated]: o
40
+ }),
41
+ children: a
42
+ }) : a
43
+ });
44
+ export {
45
+ i as MediaContainer,
46
+ p as MediaContainerBase,
47
+ i as default
48
+ };
@@ -0,0 +1,98 @@
1
+ import { A as e } from "../../../../chunks/types.js";
2
+ import "@box/blueprint-web";
3
+ import "react";
4
+ import "@box/blueprint-web-assets/icons/Line";
5
+ import "@box/blueprint-web-assets/tokens/tokens";
6
+ import "clsx";
7
+ import "react-intl";
8
+ import "./media-container.js";
9
+ import "./markdown.js";
10
+ import "../../../../chunks/answer-content.module.js";
11
+ import "react/jsx-runtime";
12
+ import "@box/blueprint-web-assets/icons/Fill";
13
+ import "../../messages.js";
14
+ import "../answer/messages.js";
15
+ import "../../../../chunks/copy-button.module.js";
16
+ import "../../../../chunks/inline-error.module.js";
17
+ import "../../../../chunks/loading.module.js";
18
+ import "lodash/debounce";
19
+ import "lodash/truncate";
20
+ import "../../../../chunks/citation.module.js";
21
+ import "../../../../chunks/references.module.js";
22
+ import "../../../../chunks/answer.module.js";
23
+ import { agentList as i, agentState as t } from "../api-wrapper/constants.js";
24
+ const a = [{
25
+ location: "location1",
26
+ fileId: "123",
27
+ content: "In the heart of the bustling city, amidst the cacophony of car horns and distant chatter, lies a hidden oasis of tranquility. This serene sanctuary, with its lush greenery and gentle trickling streams, offers a reprieve from the relentless pace of urban life. Here, amidst the whispering leaves and the soft rustle of wildlife, one can find solace and renewal."
28
+ }, {
29
+ location: "location2",
30
+ fileId: "456",
31
+ content: "High above the world, where the air is thin and the sky stretches endlessly, a lone eagle soars. With wings outstretched, it rides the currents of wind, a majestic silhouette against the backdrop of clouds. From this lofty vantage point, the world below seems small and insignificant, its troubles and worries mere specks in the grand tapestry of existence."
32
+ }, {
33
+ location: "location3",
34
+ fileId: "789",
35
+ content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst."
36
+ }], R = [{
37
+ answer: "I am a mock answer",
38
+ id: "1",
39
+ isCompleted: !0,
40
+ isLoading: !1,
41
+ error: null,
42
+ prompt: "Can you summarize this?",
43
+ citations: a
44
+ }, {
45
+ answer: "",
46
+ id: "2",
47
+ isCompleted: !0,
48
+ isLoading: !0,
49
+ error: null,
50
+ prompt: "Can you provide an answer for this?"
51
+ }, {
52
+ answer: "Paris",
53
+ id: "3",
54
+ isCompleted: !0,
55
+ isLoading: !1,
56
+ error: e.GENERAL,
57
+ prompt: "What is the capital of France?"
58
+ }, {
59
+ answer: "4",
60
+ id: "4",
61
+ isCompleted: !0,
62
+ isLoading: !1,
63
+ error: e.RATE_LIMITING,
64
+ prompt: "What is the square root of 16?"
65
+ }, {
66
+ answer: "Harper Lee",
67
+ id: "5",
68
+ isCompleted: !0,
69
+ isLoading: !1,
70
+ error: e.RESPONSE_FAILED,
71
+ prompt: 'Who is the author of "To Kill a Mockingbird"?'
72
+ }, {
73
+ answer: "Tokyo",
74
+ id: "6",
75
+ isCompleted: !0,
76
+ isLoading: !1,
77
+ error: e.RESPONSE_INTERRUPTED,
78
+ prompt: "What is the capital of Japan?"
79
+ }, {
80
+ answer: "Jupiter",
81
+ id: "7",
82
+ isCompleted: !0,
83
+ isLoading: !1,
84
+ error: e.RESPONSE_STOPPED,
85
+ prompt: "What is the largest planet in our solar system?"
86
+ }, {
87
+ answer: "Washing",
88
+ id: "8",
89
+ isCompleted: !1,
90
+ isLoading: !1,
91
+ error: null,
92
+ prompt: "What is the capital of the United States?"
93
+ }], k = i, A = t;
94
+ export {
95
+ A as mockAgentState,
96
+ k as mockAgents,
97
+ R as mockQuestions
98
+ };
@@ -0,0 +1,94 @@
1
+ import "../../../../styles/content.css";
2
+ import { LoadingIndicator as v } from "@box/blueprint-web";
3
+ import w from "clsx";
4
+ import * as t from "react";
5
+ import { useIntl as M } from "react-intl";
6
+ import j from "../../messages.js";
7
+ import { Chat as k } from "../chat/chat.js";
8
+ import { ModalError as H } from "../modal-error/modal-error.js";
9
+ import { jsx as e, jsxs as T, Fragment as V } from "react/jsx-runtime";
10
+ const y = "_loadingIndicatorWrapper_12a8t_1", z = "_content_12a8t_5", B = "_isLoading_12a8t_12", F = "_messagesEnd_12a8t_16", r = {
11
+ loadingIndicatorWrapper: y,
12
+ content: z,
13
+ isLoading: B,
14
+ messagesEnd: F
15
+ }, Y = ({
16
+ error: m,
17
+ hasRequestInProgress: a = !1,
18
+ isErrorMessageShown: u = !1,
19
+ setIsErrorMessageShown: g,
20
+ onModalClose: p,
21
+ questions: _,
22
+ recordAction: d,
23
+ showLoadingIndicator: f = !1,
24
+ userInfo: E,
25
+ suggestedQuestions: h,
26
+ askSuggestedQuestion: I,
27
+ setAskSuggestedQuestion: x,
28
+ useAnimation: C,
29
+ ...L
30
+ }) => {
31
+ const o = t.useRef(null), s = t.useRef(null), l = t.useRef(null), {
32
+ formatMessage: N
33
+ } = M(), n = t.useCallback((c, i = !1) => {
34
+ s.current && s.current.scrollIntoView && o.current && (!i || !l.current) && s.current.scrollIntoView({
35
+ behavior: c,
36
+ block: "nearest"
37
+ });
38
+ }, []), R = () => {
39
+ if (o.current) {
40
+ const {
41
+ scrollTop: c,
42
+ clientHeight: i,
43
+ scrollHeight: W
44
+ } = o.current, b = W - (c + i);
45
+ l.current = b > 5;
46
+ }
47
+ };
48
+ t.useEffect(() => {
49
+ n("instant");
50
+ }, [n]), t.useEffect(() => {
51
+ a && (l.current = !1, n("instant"));
52
+ }, [n, a]);
53
+ const S = () => u ? /* @__PURE__ */ e(H, {
54
+ clearError: () => g(!1),
55
+ error: m,
56
+ onModalClose: p,
57
+ recordAction: d
58
+ }) : f ? /* @__PURE__ */ e("div", {
59
+ className: r.loadingIndicatorWrapper,
60
+ children: /* @__PURE__ */ e(v, {
61
+ "aria-label": N(j.loading),
62
+ className: r.loadingIndicator,
63
+ "data-testid": "content-answers-modal-loading-indicator",
64
+ size: "large"
65
+ })
66
+ }) : /* @__PURE__ */ T(V, {
67
+ children: [/* @__PURE__ */ e(k, {
68
+ askSuggestedQuestion: I,
69
+ handleScrollToBottom: n,
70
+ hasRequestInProgress: a,
71
+ questions: _,
72
+ recordAction: d,
73
+ setAskSuggestedQuestion: x,
74
+ suggestedQuestions: h,
75
+ useAnimation: C,
76
+ userInfo: E,
77
+ ...L
78
+ }), /* @__PURE__ */ e("div", {
79
+ ref: s,
80
+ className: r.messagesEnd
81
+ })]
82
+ });
83
+ return /* @__PURE__ */ e("div", {
84
+ ref: o,
85
+ className: w(r.content, f ? r.isLoading : null),
86
+ "data-testid": "content-answers-content",
87
+ onScroll: R,
88
+ children: S()
89
+ });
90
+ };
91
+ export {
92
+ Y as Content,
93
+ Y as default
94
+ };
@@ -0,0 +1,4 @@
1
+ import { Content as e } from "./content.js";
2
+ export {
3
+ e as Content
4
+ };
@@ -0,0 +1,15 @@
1
+ const E = {
2
+ ENTER: 13,
3
+ X: 88,
4
+ X_LOWERCASE: 120
5
+ }, _ = {
6
+ DEBUG_MAX_ROWS: 25,
7
+ MAX_ROWS: 4,
8
+ MAX_ROWS_MOBILE: 10,
9
+ MAX_LENGTH: 1e3,
10
+ MIN_ROWS: 1
11
+ };
12
+ export {
13
+ E as KEY_CODE,
14
+ _ as TEXT_AREA
15
+ };
@@ -0,0 +1,65 @@
1
+ import "../../../../styles/footer-actions.css";
2
+ import { Button as l } from "@box/blueprint-web";
3
+ import { useRef as N, useCallback as p, useEffect as O } from "react";
4
+ import { useIntl as w } from "react-intl";
5
+ import { A as m } from "../../../../chunks/types.js";
6
+ import { LOGGER_BASE_CONFIG as u, LOGGER_ACTION_CLICK as R } from "../common/constants.js";
7
+ import d from "./messages.js";
8
+ import { jsxs as y, jsx as E } from "react/jsx-runtime";
9
+ const g = "_footerActions_poeou_1", k = "_footerActionButton_poeou_11", a = {
10
+ footerActions: g,
11
+ footerActionButton: k
12
+ }, j = ({
13
+ isStreamingEnabled: _ = !1,
14
+ lastQuestion: o,
15
+ onRetryQuestion: s,
16
+ onStopQuestion: c,
17
+ recordAction: t
18
+ }) => {
19
+ const {
20
+ answer: B,
21
+ error: n,
22
+ isCompleted: S
23
+ } = o, e = s && n && n !== m.RESPONSE_STOPPED && n !== m.RESPONSE_INTERRUPTED, i = _ && !S && B, h = i || e, r = N(null), {
24
+ formatMessage: f
25
+ } = w(), A = p(() => {
26
+ t && t({
27
+ ...u,
28
+ action: R,
29
+ target: "stopResponse"
30
+ }), c(o);
31
+ }, [o, c, t]), C = p(() => {
32
+ t && t({
33
+ ...u,
34
+ action: R,
35
+ target: "retryResponse"
36
+ }), s(o);
37
+ }, [o, s, t]);
38
+ return O(() => {
39
+ e && r.current && r.current.focus();
40
+ }, [e]), h ? /* @__PURE__ */ y("div", {
41
+ className: a.footerActions,
42
+ "data-testid": "content-answers-modal-footer-actions",
43
+ children: [i && /* @__PURE__ */ E(l, {
44
+ "aria-live": "polite",
45
+ className: a.footerActionButton,
46
+ "data-testid": "content-answers-stop-response-button",
47
+ onClick: A,
48
+ size: "large",
49
+ variant: "secondary",
50
+ children: f(d.stopResponse)
51
+ }), e && /* @__PURE__ */ E(l, {
52
+ ref: r,
53
+ "aria-live": "polite",
54
+ className: a.footerActionButton,
55
+ "data-testid": "content-answers-retry-response-button",
56
+ onClick: C,
57
+ size: "large",
58
+ variant: "secondary",
59
+ children: f(d.retryResponse)
60
+ })]
61
+ }) : null;
62
+ };
63
+ export {
64
+ j as FooterActions
65
+ };
@@ -0,0 +1,124 @@
1
+ import "../../../../styles/footer.css";
2
+ import * as r from "react";
3
+ import { useIntl as F } from "react-intl";
4
+ import { useBreakpoint as j, Breakpoint as U, Avatar as W, TextArea as z, Button as D } from "@box/blueprint-web";
5
+ import { ArrowUp as Y } from "@box/blueprint-web-assets/icons/Line";
6
+ import { useAgents as $ } from "../../contexts/AgentsContext.js";
7
+ import { FooterActions as J } from "./footer-actions.js";
8
+ import Q from "../../messages.js";
9
+ import { isDebugModeTrigger as V, isEnterTrigger as Z } from "../common/keyInputUtils.js";
10
+ import { TEXT_AREA as n } from "./constants.js";
11
+ import m from "./messages.js";
12
+ import { LOGGER_BASE_CONFIG as N, LOGGER_ACTION_CLICK as q, LOGGER_ACTION_KEYPRESS as g } from "../common/constants.js";
13
+ import { jsxs as O, jsx as u } from "react/jsx-runtime";
14
+ const P = "_questionInput_1pdo1_1", tt = "_avatar_1pdo1_11", at = "_submitButton_1pdo1_14", rt = "_textArea_1pdo1_17", et = "_submitButtonTooltip_1pdo1_26", d = {
15
+ questionInput: P,
16
+ avatar: tt,
17
+ submitButton: at,
18
+ textArea: rt,
19
+ submitButtonTooltip: et
20
+ }, vt = ({
21
+ askSuggestedQuestion: v,
22
+ contentType: C,
23
+ enableDebugMode: E = !1,
24
+ hasRequestInProgress: e,
25
+ isAgentSelectorEnabled: f,
26
+ isDebugModeShown: h,
27
+ isStreamingEnabled: X,
28
+ lastQuestion: x,
29
+ onRetryQuestion: T,
30
+ onStopQuestion: w,
31
+ recordAction: o,
32
+ sendQuestion: k,
33
+ setAskSuggestedQuestion: A,
34
+ toggleDebugMode: s,
35
+ user: L
36
+ }) => {
37
+ const i = F(), H = j(), a = /* @__PURE__ */ r.createRef(), p = H <= U.Medium, [c, M] = r.useState(!0), [I, B] = r.useState(!1), {
38
+ selectedAgent: _
39
+ } = $(), b = r.useCallback(() => {
40
+ a.current && a.current.focus();
41
+ }, [a]), R = r.useCallback(() => {
42
+ var G;
43
+ let t = ((G = a.current) == null ? void 0 : G.value) ?? "";
44
+ a.current && t.length > n.MAX_LENGTH && (a.current.value = t.slice(0, n.MAX_LENGTH), t = a.current.value), B(t.length >= n.MAX_LENGTH), M(t.trim().length === 0);
45
+ }, [a]), l = r.useCallback(() => {
46
+ if (b(), !e && a.current) {
47
+ const t = {
48
+ prompt: a.current.value
49
+ };
50
+ t.prompt && t.prompt.trim() && (k(t, f ? _.config : void 0), a.current.value = "", M(!0), B(!1)), h && s && s();
51
+ }
52
+ }, [b, e, a, f, h, _.config, k, s]), y = r.useCallback((t) => {
53
+ t.preventDefault(), !e && !c && o && o({
54
+ ...N,
55
+ action: q,
56
+ target: "ask"
57
+ }), l();
58
+ }, [e, c, o, l]), K = r.useCallback((t) => {
59
+ E && s && V(t) && s(), Z(t) && (t.preventDefault(), !e && !c && o && o({
60
+ ...N,
61
+ action: g,
62
+ target: "ask"
63
+ }), l());
64
+ }, [E, e, c, o, l, s]), S = r.useCallback((t) => {
65
+ T(t, f ? _.config : void 0);
66
+ }, [f, T, _.config]);
67
+ return r.useEffect(() => {
68
+ setTimeout(b, 0);
69
+ }, []), r.useEffect(() => {
70
+ v && a.current && !e && A && (a.current.value = v, l(), A(null));
71
+ }, [v]), /* @__PURE__ */ O("div", {
72
+ children: [x && /* @__PURE__ */ u(J, {
73
+ isStreamingEnabled: X,
74
+ lastQuestion: x,
75
+ onRetryQuestion: S,
76
+ onStopQuestion: w,
77
+ recordAction: o
78
+ }), /* @__PURE__ */ O("div", {
79
+ className: d.questionInput,
80
+ children: [!p && /* @__PURE__ */ u("div", {
81
+ className: d.avatar,
82
+ "data-testid": "content-answers-question-input-avatar",
83
+ children: /* @__PURE__ */ u(W, {
84
+ alt: i.formatMessage(Q.userAvatar),
85
+ colorIndex: 0,
86
+ src: L.avatarURL,
87
+ text: L.name.charAt(0)
88
+ })
89
+ }), /* @__PURE__ */ u(z, {
90
+ ref: a,
91
+ className: d.textArea,
92
+ "data-testid": "content-answers-question-input",
93
+ error: I && i.formatMessage(m.maxCharactersReachedError, {
94
+ characterLimit: n.MAX_LENGTH
95
+ }),
96
+ hideLabel: !0,
97
+ label: i.formatMessage(m.askQuestionPlaceholder, {
98
+ type: C
99
+ }),
100
+ maxLength: n.MAX_LENGTH,
101
+ maxRows: p ? n.MAX_ROWS_MOBILE : n.MAX_ROWS,
102
+ onChange: R,
103
+ onKeyDown: K,
104
+ placeholder: i.formatMessage(m.askQuestionPlaceholder, {
105
+ type: C
106
+ })
107
+ }), /* @__PURE__ */ u(D, {
108
+ "aria-label": i.formatMessage(m.ask),
109
+ className: d.submitButton,
110
+ "data-testid": "content-answers-submit-button",
111
+ disabled: c || e,
112
+ icon: p ? Y : void 0,
113
+ loading: e,
114
+ loadingAriaLabel: i.formatMessage(m.askDisabledTooltip),
115
+ onClick: y,
116
+ size: "large",
117
+ children: p ? void 0 : i.formatMessage(m.ask)
118
+ })]
119
+ })]
120
+ });
121
+ };
122
+ export {
123
+ vt as Footer
124
+ };
@@ -0,0 +1,4 @@
1
+ import { Footer as e } from "./footer.js";
2
+ export {
3
+ e as Footer
4
+ };
@@ -0,0 +1,30 @@
1
+ import { defineMessages as e } from "react-intl";
2
+ const a = e({
3
+ maxCharactersReachedError: {
4
+ id: "boxAI.contentAnswers.maxCharactersReachedError",
5
+ defaultMessage: "Maximum of {characterLimit} characters reached"
6
+ },
7
+ askQuestionPlaceholder: {
8
+ id: "boxAI.contentAnswers.askQuestionPlaceholder",
9
+ defaultMessage: "Ask anything about this {type}"
10
+ },
11
+ askDisabledTooltip: {
12
+ id: "boxAI.contentAnswers.askDisabledTooltip",
13
+ defaultMessage: "You can submit another question once Box AI has finished responding"
14
+ },
15
+ ask: {
16
+ id: "boxAI.contentAnswers.ask",
17
+ defaultMessage: "Ask"
18
+ },
19
+ retryResponse: {
20
+ id: "boxAI.contentAnswers.retryResponse",
21
+ defaultMessage: "Retry"
22
+ },
23
+ stopResponse: {
24
+ id: "boxAI.contentAnswers.stopResponse",
25
+ defaultMessage: "Stop Response"
26
+ }
27
+ });
28
+ export {
29
+ a as default
30
+ };
@@ -0,0 +1,15 @@
1
+ import { useCallback as n } from "react";
2
+ const s = () => {
3
+ const t = n((e) => {
4
+ document.addEventListener("keydown", e);
5
+ }, []), o = n((e) => {
6
+ document.removeEventListener("keydown", e);
7
+ }, []);
8
+ return {
9
+ addKeydownEventListener: t,
10
+ removeKeydownEventListener: o
11
+ };
12
+ };
13
+ export {
14
+ s as default
15
+ };
@@ -0,0 +1,21 @@
1
+ import { useCallback as a, useEffect as i } from "react";
2
+ import u from "./useEventListeners.js";
3
+ const f = (t, n) => {
4
+ const e = a((s) => {
5
+ s.key === "Escape" && s.stopPropagation();
6
+ }, []), {
7
+ addKeydownEventListener: r,
8
+ removeKeydownEventListener: o
9
+ } = u();
10
+ return i(() => {
11
+ if (!(!t || !n))
12
+ return r(e), () => {
13
+ o(e);
14
+ };
15
+ }, [t, n, e, r, o]), {
16
+ handleKeyDownOnEsc: e
17
+ };
18
+ };
19
+ export {
20
+ f as default
21
+ };
@@ -0,0 +1,18 @@
1
+ import { defineMessages as e } from "react-intl";
2
+ const o = e({
3
+ contentAnswersTitle: {
4
+ id: "boxAI.contentAnswers.contentAnswersTitle",
5
+ defaultMessage: "Box AI"
6
+ },
7
+ closeModalAriaLabel: {
8
+ id: "boxAI.contentAnswers.closeModalAriaLabel",
9
+ defaultMessage: "Close Modal"
10
+ },
11
+ resetConversationLabel: {
12
+ id: "boxAI.contentAnswers.resetConversationLabel",
13
+ defaultMessage: "Reset conversation"
14
+ }
15
+ });
16
+ export {
17
+ o as default
18
+ };
@@ -0,0 +1,126 @@
1
+ import "../../../../styles/modal.css";
2
+ import { useBreakpoint as T, Breakpoint as G, Modal as s, Text as H, Tooltip as P, IconButton as E } from "@box/blueprint-web";
3
+ import { ArrowCurveForward as S } from "@box/blueprint-web-assets/icons/Fill";
4
+ import { BoxAiLogo as R } from "@box/blueprint-web-assets/icons/Logo";
5
+ import { Size8 as p } from "@box/blueprint-web-assets/tokens/tokens";
6
+ import C from "react";
7
+ import { useIntl as j } from "react-intl";
8
+ import { BoxAiContentAnswers as F } from "../../box-ai-content-answers.js";
9
+ import { AgentsProvider as K } from "../../contexts/AgentsContext.js";
10
+ import { AgentSelector as q } from "../agents/agent-selector.js";
11
+ import { LOGGER_BASE_CONFIG as b, LOGGER_ACTION_CLICK as D } from "../common/constants.js";
12
+ import J from "./hooks/useStopPropagationOnEsc.js";
13
+ import i from "./messages.js";
14
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
15
+ const Q = "_BoxAIIconColor_8bmuz_1", U = "_modalHeader_8bmuz_5", V = "_contentAnswersModal_8bmuz_10", W = "_boxAiContentAnswers_8bmuz_17", X = "_resetButton_8bmuz_25", Y = "_contentAnswerModal_8bmuz_1", t = {
16
+ BoxAIIconColor: Q,
17
+ modalHeader: U,
18
+ contentAnswersModal: V,
19
+ boxAiContentAnswers: W,
20
+ resetButton: X,
21
+ "modal-close-button": "_modal-close-button_8bmuz_29",
22
+ contentAnswerModal: Y
23
+ }, ue = ({
24
+ children: g,
25
+ hostAppName: m,
26
+ isAgentSelectorEnabled: c,
27
+ isDebugModeEnabled: w,
28
+ isResetChatEnabled: M,
29
+ itemSize: d,
30
+ extension: u,
31
+ onResetAction: _,
32
+ onSelectAgent: x,
33
+ recordAction: r,
34
+ shouldRenderProviders: B = !0,
35
+ stopPropagationOnEsc: I,
36
+ ...h
37
+ }) => {
38
+ const {
39
+ open: f,
40
+ defaultOpen: v,
41
+ onOpenChange: z,
42
+ modal: L,
43
+ ...N
44
+ } = h, a = j(), O = T() <= G.Medium;
45
+ J(I, f);
46
+ const o = C.useCallback((n) => {
47
+ r && (n.data ?? (n.data = {}), n.data.hostAppName = m, r(n));
48
+ }, [m, r]);
49
+ C.useEffect(() => {
50
+ o({
51
+ ...b,
52
+ target: "loaded",
53
+ data: {
54
+ fileSize: d,
55
+ fileType: u
56
+ }
57
+ });
58
+ }, [o, u, d, r]);
59
+ const k = () => {
60
+ _ && (_(), o({
61
+ ...b,
62
+ action: D,
63
+ target: "resetChat"
64
+ }));
65
+ }, A = /* @__PURE__ */ l(s, {
66
+ defaultOpen: v,
67
+ modal: L,
68
+ onOpenChange: z,
69
+ open: f,
70
+ children: [/* @__PURE__ */ e(s.Trigger, {
71
+ children: g
72
+ }), /* @__PURE__ */ l(s.Content, {
73
+ className: t.contentAnswersModal,
74
+ "data-testid": "content-answers-modal",
75
+ size: "xlarge",
76
+ children: [/* @__PURE__ */ e(s.Header, {
77
+ children: /* @__PURE__ */ l("div", {
78
+ className: t.modalHeader,
79
+ children: [!O && /* @__PURE__ */ e(R, {
80
+ className: t.BoxAIIconColor,
81
+ "data-testid": "content-answers-icon-color",
82
+ height: p,
83
+ width: p
84
+ }), /* @__PURE__ */ e(H, {
85
+ as: "span",
86
+ variant: "titleMedium",
87
+ children: a.formatMessage(i.contentAnswersTitle)
88
+ }), c && /* @__PURE__ */ e(q, {
89
+ onSelectAgent: x,
90
+ recordAction: o
91
+ })]
92
+ })
93
+ }), M && /* @__PURE__ */ e(P, {
94
+ content: a.formatMessage(i.resetConversationLabel),
95
+ "data-testid": "reset-conversation-tooltip",
96
+ side: "top",
97
+ variant: "standard",
98
+ children: /* @__PURE__ */ e(E, {
99
+ "aria-label": a.formatMessage(i.resetConversationLabel),
100
+ className: t.resetButton,
101
+ "data-testid": "reset-conversation-button",
102
+ icon: S,
103
+ onClick: k,
104
+ size: "small"
105
+ })
106
+ }), /* @__PURE__ */ e(s.Close, {
107
+ "aria-label": a.formatMessage(i.closeModalAriaLabel),
108
+ className: t["modal-close-button"],
109
+ size: "small"
110
+ }), /* @__PURE__ */ e(F, {
111
+ className: t.boxAiContentAnswers,
112
+ isAgentSelectorEnabled: c,
113
+ isDebugModeEnabled: w,
114
+ recordAction: o,
115
+ ...N
116
+ })]
117
+ })]
118
+ });
119
+ return B ? /* @__PURE__ */ e(K, {
120
+ children: A
121
+ }) : A;
122
+ };
123
+ export {
124
+ ue as IntelligenceModal,
125
+ ue as default
126
+ };
@@ -0,0 +1,4 @@
1
+ import { ModalError as a } from "./modal-error.js";
2
+ export {
3
+ a as ModalError
4
+ };