@box/box-ai-content-answers 0.105.0 → 0.106.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -1,18 +1,20 @@
1
1
  import { BoxAiContentAnswers as e } from "./lib/box-ai-content-answers.js";
2
- import { AnswerContent as n } from "./lib/components/answer/answer-content.js";
3
- import { withApiWrapper as R } from "./lib/components/api-wrapper/api-wrapper.js";
4
- import { C as s } from "../chunks/clear-conversation-button.js";
5
- import { IntelligenceModal as A } from "./lib/components/modal/modal.js";
6
- import { A as f, C as m, R as C } from "../chunks/types.js";
7
- import { APP_MODE as T } from "./lib/constants.js";
2
+ import { AnswerContent as p } from "./lib/components/answer/answer-content.js";
3
+ import { withApiWrapper as s } from "./lib/components/api-wrapper/api-wrapper.js";
4
+ import { C as x } from "../chunks/clear-conversation-button.js";
5
+ import { IntelligenceModal as a } from "./lib/components/modal/modal.js";
6
+ import { usePromptFocus as A } from "./lib/hooks/usePromptFocus.js";
7
+ import { A as C, C as i, R as T } from "../chunks/types.js";
8
+ import { APP_MODE as O } from "./lib/constants.js";
8
9
  export {
9
- f as ANSWER_ERROR,
10
- T as APP_MODE,
11
- n as AnswerContent,
10
+ C as ANSWER_ERROR,
11
+ O as APP_MODE,
12
+ p as AnswerContent,
12
13
  e as BoxAiContentAnswers,
13
- m as CONTENT_ERROR,
14
- s as ClearConversationButton,
15
- A as IntelligenceModal,
16
- C as REQUEST_STATE,
17
- R as withApiWrapper
14
+ i as CONTENT_ERROR,
15
+ x as ClearConversationButton,
16
+ a as IntelligenceModal,
17
+ T as REQUEST_STATE,
18
+ A as usePromptFocus,
19
+ s as withApiWrapper
18
20
  };
@@ -1,96 +1,97 @@
1
- import { LoadingIndicator as W } from "@box/blueprint-web";
2
- import q from "clsx";
1
+ import { LoadingIndicator as F } from "@box/blueprint-web";
2
+ import M from "clsx";
3
3
  import * as t from "react";
4
- import { useIntl as F } from "react-intl";
5
- import M from "../../messages.js";
6
- import { C as j } from "../../../../chunks/types.js";
7
- import { Chat as k } from "../chat/chat.js";
8
- import { ModalError as y } from "../modal-error/modal-error.js";
9
- import { jsx as n, jsxs as H, Fragment as S } from "react/jsx-runtime";
10
- import '../../../../styles/content.css';const V = "_loadingIndicatorWrapper_1qwsa_1", A = "_content_1qwsa_5", B = "_sidebar_1qwsa_14", G = "_isLoading_1qwsa_17", D = "_messagesEnd_1qwsa_21", J = "_innerContent_1qwsa_25", r = {
11
- loadingIndicatorWrapper: V,
12
- content: A,
13
- sidebar: B,
14
- isLoading: G,
15
- messagesEnd: D,
16
- innerContent: J
17
- }, ee = ({
4
+ import { useIntl as S } from "react-intl";
5
+ import j from "../../messages.js";
6
+ import { C as k } from "../../../../chunks/types.js";
7
+ import { Chat as y } from "../chat/chat.js";
8
+ import { ModalError as H } from "../modal-error/modal-error.js";
9
+ import { jsx as n, jsxs as V, Fragment as A } from "react/jsx-runtime";
10
+ import '../../../../styles/content.css';const B = "_loadingIndicatorWrapper_1qwsa_1", D = "_content_1qwsa_5", G = "_sidebar_1qwsa_14", J = "_isLoading_1qwsa_17", K = "_messagesEnd_1qwsa_21", Q = "_innerContent_1qwsa_25", r = {
11
+ loadingIndicatorWrapper: B,
12
+ content: D,
13
+ sidebar: G,
14
+ isLoading: J,
15
+ messagesEnd: K,
16
+ innerContent: Q
17
+ }, ne = ({
18
18
  error: u,
19
- hasCustomSuggestedQuestions: E,
19
+ hasCustomSuggestedQuestions: C,
20
20
  hasRequestInProgress: c = !1,
21
- isErrorMessageShown: C = !1,
21
+ isErrorMessageShown: h = !1,
22
22
  isStreamingEnabled: i = !1,
23
- questions: R,
23
+ questions: w,
24
24
  recordAction: m,
25
- showLoadingIndicator: _ = !1,
26
- suggestedQuestions: b,
27
- askSuggestedQuestion: h,
28
- setAskSuggestedQuestion: w,
29
- useAnimation: v,
30
- variant: p = "modal",
25
+ showLoadingIndicator: p = !1,
26
+ suggestedQuestions: R,
27
+ askSuggestedQuestion: b,
28
+ setAskSuggestedQuestion: v,
29
+ useAnimation: I,
30
+ variant: _ = "modal",
31
31
  hostAppName: L = "",
32
32
  ...N
33
33
  }) => {
34
- const d = t.useRef(null), l = t.useRef(null), f = t.useRef(null), a = t.useRef(!0), {
35
- formatMessage: I
36
- } = F(), g = u === j.LARGE_FILE, s = t.useCallback((o) => {
34
+ const d = t.useRef(null), l = t.useRef(null), f = t.useRef(null), s = t.useRef(!0), [g, O] = t.useState(!1), {
35
+ formatMessage: x
36
+ } = S(), E = u === k.LARGE_FILE, o = t.useCallback((a) => {
37
37
  var e;
38
- (e = f.current) != null && e.scrollIntoView && l.current && (!i || a.current) && f.current.scrollIntoView({
39
- behavior: o,
38
+ (e = f.current) != null && e.scrollIntoView && l.current && (!i || s.current) && f.current.scrollIntoView({
39
+ behavior: a,
40
40
  block: "nearest"
41
41
  });
42
- }, [i]), x = () => {
42
+ }, [i]), z = () => {
43
43
  if (l.current) {
44
44
  const {
45
- scrollTop: o,
45
+ scrollTop: a,
46
46
  clientHeight: e,
47
- scrollHeight: O
48
- } = l.current, T = O - (o + e);
49
- if (c && T > 100) {
50
- a.current = !1;
47
+ scrollHeight: W
48
+ } = l.current, q = W - (a + e);
49
+ if (c && q > 100) {
50
+ s.current = !1;
51
51
  return;
52
52
  }
53
- a.current = !0;
53
+ s.current = !0;
54
54
  }
55
55
  };
56
56
  t.useEffect(() => {
57
- c && (a.current = !0, s("instant"));
58
- }, [s, c]), t.useEffect(() => {
59
- a.current = !0, s("instant");
60
- }, [s]), t.useLayoutEffect(() => {
57
+ g ? s.current = !1 : c && (s.current = !0, o("instant"));
58
+ }, [g, o, c]), t.useEffect(() => {
59
+ s.current = !0, o("instant");
60
+ }, [o]), t.useLayoutEffect(() => {
61
61
  if (!d.current)
62
62
  return;
63
- const o = new ResizeObserver(() => {
64
- s(i ? "instant" : "smooth");
63
+ const a = new ResizeObserver(() => {
64
+ o(i ? "instant" : "smooth");
65
65
  }), e = d.current;
66
- return e && o.observe(e), () => {
67
- e && o.unobserve(e);
66
+ return e && a.observe(e), () => {
67
+ e && a.unobserve(e);
68
68
  };
69
- }, [s, i]);
70
- const z = () => C && !g ? /* @__PURE__ */ n(y, {
69
+ }, [o, i]);
70
+ const T = () => h && !E ? /* @__PURE__ */ n(H, {
71
71
  error: u,
72
72
  recordAction: m
73
- }) : _ ? /* @__PURE__ */ n("div", {
73
+ }) : p ? /* @__PURE__ */ n("div", {
74
74
  className: r.loadingIndicatorWrapper,
75
- children: /* @__PURE__ */ n(W, {
76
- "aria-label": I(M.loading),
75
+ children: /* @__PURE__ */ n(F, {
76
+ "aria-label": x(j.loading),
77
77
  className: r.loadingIndicator,
78
78
  "data-testid": "content-answers-modal-loading-indicator",
79
79
  size: "large"
80
80
  })
81
- }) : /* @__PURE__ */ H(S, {
82
- children: [/* @__PURE__ */ n(k, {
83
- askSuggestedQuestion: h,
84
- hasCustomSuggestedQuestions: E,
81
+ }) : /* @__PURE__ */ V(A, {
82
+ children: [/* @__PURE__ */ n(y, {
83
+ askSuggestedQuestion: b,
84
+ hasCustomSuggestedQuestions: C,
85
85
  hasRequestInProgress: c,
86
86
  hostAppName: L,
87
- isFileSizeError: g,
88
- questions: R,
87
+ isFileSizeError: E,
88
+ onDropdownOpenChange: O,
89
+ questions: w,
89
90
  recordAction: m,
90
- setAskSuggestedQuestion: w,
91
- suggestedQuestions: b,
92
- useAnimation: v,
93
- variant: p,
91
+ setAskSuggestedQuestion: v,
92
+ suggestedQuestions: R,
93
+ useAnimation: I,
94
+ variant: _,
94
95
  ...N
95
96
  }), /* @__PURE__ */ n("div", {
96
97
  ref: f,
@@ -99,17 +100,17 @@ import '../../../../styles/content.css';const V = "_loadingIndicatorWrapper_1qws
99
100
  });
100
101
  return /* @__PURE__ */ n("div", {
101
102
  ref: l,
102
- className: q(r.content, p === "sidebar" && r.sidebar, _ && r.isLoading),
103
+ className: M(r.content, _ === "sidebar" && r.sidebar, p && r.isLoading),
103
104
  "data-testid": "content-answers-content",
104
- onScroll: x,
105
+ onScroll: z,
105
106
  children: /* @__PURE__ */ n("div", {
106
107
  ref: d,
107
108
  className: r.innerContent,
108
- children: z()
109
+ children: T()
109
110
  })
110
111
  });
111
112
  };
112
113
  export {
113
- ee as Content,
114
- ee as default
114
+ ne as Content,
115
+ ne as default
115
116
  };
@@ -1,37 +1,39 @@
1
- import l from "clsx";
2
- import { FormattedMessage as f } from "react-intl";
3
- import { ItemsDropdown as x } from "./items-dropdown.js";
4
- import _ from "./messages.js";
5
- import { jsx as o, jsxs as u } from "react/jsx-runtime";
6
- import '../../../../styles/contextual-items-message.css';const b = "_askQuestionText_145d3_1", w = "_sidebar_145d3_5", k = "_itemsDropdown_145d3_8", i = {
7
- askQuestionText: b,
8
- sidebar: w,
9
- itemsDropdown: k
10
- }, h = ({
1
+ import f from "clsx";
2
+ import { FormattedMessage as x } from "react-intl";
3
+ import { ItemsDropdown as _ } from "./items-dropdown.js";
4
+ import u from "./messages.js";
5
+ import { jsx as o, jsxs as b } from "react/jsx-runtime";
6
+ import '../../../../styles/contextual-items-message.css';const w = "_askQuestionText_145d3_1", k = "_sidebar_145d3_5", D = "_itemsDropdown_145d3_8", i = {
7
+ askQuestionText: w,
8
+ sidebar: k,
9
+ itemsDropdown: D
10
+ }, v = ({
11
11
  contentName: n,
12
12
  isUsedInsideSidebar: r = !1,
13
13
  supportedItems: e,
14
14
  onItemClick: a,
15
- parentItem: s
15
+ parentItem: s,
16
+ onDropdownOpenChange: d
16
17
  }) => {
17
18
  var m;
18
- const d = e.length || 1, c = ((m = e[0]) == null ? void 0 : m.name) || n, t = (s == null ? void 0 : s.id) !== "0" ? s == null ? void 0 : s.name : void 0;
19
+ const c = e.length || 1, l = ((m = e[0]) == null ? void 0 : m.name) || n, t = (s == null ? void 0 : s.id) !== "0" ? s == null ? void 0 : s.name : void 0;
19
20
  return /* @__PURE__ */ o("div", {
20
- className: l(i.askQuestionText, {
21
+ className: f(i.askQuestionText, {
21
22
  [i.sidebar]: r
22
23
  }),
23
- children: /* @__PURE__ */ o(f, {
24
- ..._.welcomeAskQuestionText,
24
+ children: /* @__PURE__ */ o(x, {
25
+ ...u.welcomeAskQuestionText,
25
26
  values: {
26
27
  firstItemName: /* @__PURE__ */ o("b", {
27
- children: c
28
+ children: l
28
29
  }),
29
- parentItem: t && /* @__PURE__ */ u("b", {
30
+ parentItem: t && /* @__PURE__ */ b("b", {
30
31
  children: ["“", t, "”"]
31
32
  }),
32
- numberOfItems: d,
33
- files: /* @__PURE__ */ o(x, {
33
+ numberOfItems: c,
34
+ files: /* @__PURE__ */ o(_, {
34
35
  className: i.itemsDropdown,
36
+ onDropdownOpenChange: d,
35
37
  onItemClick: a,
36
38
  supportedItems: e
37
39
  })
@@ -40,6 +42,6 @@ import '../../../../styles/contextual-items-message.css';const b = "_askQuestion
40
42
  });
41
43
  };
42
44
  export {
43
- h as ContextualItemsMessage,
44
- h as default
45
+ v as ContextualItemsMessage,
46
+ v as default
45
47
  };
@@ -1,48 +1,49 @@
1
- import { useBreakpoint as N, Breakpoint as T, DropdownMenu as e, Link as I, Text as _ } from "@box/blueprint-web";
2
- import { Size5 as k } from "@box/blueprint-web-assets/tokens/tokens";
3
- import { ItemIcon as x } from "@box/item-icon";
1
+ import { useBreakpoint as T, Breakpoint as I, DropdownMenu as e, Link as k, Text as _ } from "@box/blueprint-web";
2
+ import { Size5 as x } from "@box/blueprint-web-assets/tokens/tokens";
3
+ import { ItemIcon as C } from "@box/item-icon";
4
4
  import M from "clsx";
5
- import { useMemo as g, useCallback as C } from "react";
6
- import { useIntl as F } from "react-intl";
5
+ import { useMemo as g, useCallback as F } from "react";
6
+ import { useIntl as H } from "react-intl";
7
7
  import r from "./messages.js";
8
- import { jsxs as s, jsx as n, Fragment as H } from "react/jsx-runtime";
9
- import '../../../../styles/items-dropdown.css';const y = "_itemsDropdownTriggerLink_12lcp_1", S = "_itemsDropdownContent_12lcp_6", B = "_itemsDropdownItemIcon_12lcp_11", O = "_itemsDropdownItemName_12lcp_15", j = "_itemsDropdownLabel_12lcp_21", o = {
10
- itemsDropdownTriggerLink: y,
8
+ import { jsxs as s, jsx as n, Fragment as y } from "react/jsx-runtime";
9
+ import '../../../../styles/items-dropdown.css';const O = "_itemsDropdownTriggerLink_12lcp_1", S = "_itemsDropdownContent_12lcp_6", B = "_itemsDropdownItemIcon_12lcp_11", j = "_itemsDropdownItemName_12lcp_15", z = "_itemsDropdownLabel_12lcp_21", o = {
10
+ itemsDropdownTriggerLink: O,
11
11
  itemsDropdownContent: S,
12
12
  itemsDropdownItemIcon: B,
13
- itemsDropdownItemName: O,
14
- itemsDropdownLabel: j
15
- }, J = ({
13
+ itemsDropdownItemName: j,
14
+ itemsDropdownLabel: z
15
+ }, K = ({
16
16
  className: b,
17
17
  supportedItems: t = [],
18
18
  unsupportedItems: d = [],
19
19
  noPermissionItems: p = [],
20
- onItemClick: i
20
+ onItemClick: i,
21
+ onDropdownOpenChange: u
21
22
  }) => {
22
23
  const {
23
- formatMessage: m
24
- } = F(), D = N(), h = g(() => D === T.Small, [D]), u = C(({
25
- id: a,
24
+ formatMessage: a
25
+ } = H(), D = T(), h = g(() => D === I.Small, [D]), N = F(({
26
+ id: m,
26
27
  name: l
27
28
  }) => {
28
- i == null || i(a, l);
29
- }, [i]), L = g(() => t.length > 0 ? r.welcomeMessageFilesLink : r.welcomeMessageItemsLink, [t]), f = g(() => m(L, {
29
+ i == null || i(m, l);
30
+ }, [i]), L = g(() => t.length > 0 ? r.welcomeMessageFilesLink : r.welcomeMessageItemsLink, [t]), f = g(() => a(L, {
30
31
  numberOfItems: t.length + d.length + p.length
31
- }), [t, d, p, L]), w = (a, l) => l.length === 0 ? null : /* @__PURE__ */ s(H, {
32
- children: [a && /* @__PURE__ */ n(e.Header, {
32
+ }), [t, d, p, L]), w = (m, l) => l.length === 0 ? null : /* @__PURE__ */ s(y, {
33
+ children: [m && /* @__PURE__ */ n(e.Header, {
33
34
  className: o.itemsDropdownLabel,
34
35
  children: /* @__PURE__ */ n(_, {
35
36
  as: "label",
36
37
  color: "textOnLightSecondary",
37
- children: a
38
+ children: m
38
39
  })
39
40
  }), l.map((c) => /* @__PURE__ */ s(e.Item, {
40
41
  className: o.itemsDropdownItem,
41
- onClick: () => u(c),
42
- children: [/* @__PURE__ */ n(x, {
42
+ onClick: () => N(c),
43
+ children: [/* @__PURE__ */ n(C, {
43
44
  ariaHidden: !0,
44
45
  className: o.itemsDropdownItemIcon,
45
- dimension: k,
46
+ dimension: x,
46
47
  iconType: c.fileType
47
48
  }), /* @__PURE__ */ n(_, {
48
49
  as: "span",
@@ -53,9 +54,10 @@ import '../../../../styles/items-dropdown.css';const y = "_itemsDropdownTriggerL
53
54
  });
54
55
  return /* @__PURE__ */ s(e.Root, {
55
56
  isFullScreenEnabled: h,
57
+ onOpenChange: u,
56
58
  children: [/* @__PURE__ */ n(e.Trigger, {
57
59
  className: M(b, o.itemsDropdownTrigger),
58
- children: /* @__PURE__ */ n(I, {
60
+ children: /* @__PURE__ */ n(k, {
59
61
  className: o.itemsDropdownTriggerLink,
60
62
  href: "#",
61
63
  children: f
@@ -68,13 +70,13 @@ import '../../../../styles/items-dropdown.css';const y = "_itemsDropdownTriggerL
68
70
  children: [/* @__PURE__ */ n(e.Header.TextContent, {
69
71
  title: f
70
72
  }), /* @__PURE__ */ n(e.Header.MenuCloseButton, {
71
- "aria-label": m(r.closeItemList)
73
+ "aria-label": a(r.closeItemList)
72
74
  })]
73
- }), w(null, t), w(m(r.unsupportedFormatLabel), d), w(m(r.noPermissionsLabel), p)]
75
+ }), w(null, t), w(a(r.unsupportedFormatLabel), d), w(a(r.noPermissionsLabel), p)]
74
76
  })]
75
77
  });
76
78
  };
77
79
  export {
78
- J as ItemsDropdown,
79
- J as default
80
+ K as ItemsDropdown,
81
+ K as default
80
82
  };
@@ -1,25 +1,27 @@
1
- import { InlineNotice as s } from "@box/blueprint-web";
2
- import { FormattedMessage as r } from "react-intl";
3
- import { ItemsDropdown as a } from "./items-dropdown.js";
4
- import m from "./messages.js";
1
+ import { InlineNotice as r } from "@box/blueprint-web";
2
+ import { FormattedMessage as a } from "react-intl";
3
+ import { ItemsDropdown as m } from "./items-dropdown.js";
4
+ import l from "./messages.js";
5
5
  import { jsx as e } from "react/jsx-runtime";
6
- import '../../../../styles/unsupported-items-notice.css';const l = "_inlineNotice_15y3b_1", i = {
7
- inlineNotice: l
8
- }, u = ({
6
+ import '../../../../styles/unsupported-items-notice.css';const c = "_inlineNotice_15y3b_1", i = {
7
+ inlineNotice: c
8
+ }, g = ({
9
9
  unsupportedItems: t,
10
10
  noPermissionsItems: n,
11
- onItemClick: o
12
- }) => /* @__PURE__ */ e(s, {
11
+ onItemClick: o,
12
+ onDropdownOpenChange: s
13
+ }) => /* @__PURE__ */ e(r, {
13
14
  className: i.inlineNotice,
14
15
  "data-testid": "content-answers-unsupported-items-notice",
15
16
  variant: "warning",
16
17
  variantIconAriaLabel: "warning",
17
- children: /* @__PURE__ */ e(r, {
18
- ...m.unsupportedItems,
18
+ children: /* @__PURE__ */ e(a, {
19
+ ...l.unsupportedItems,
19
20
  values: {
20
- files: /* @__PURE__ */ e(a, {
21
+ files: /* @__PURE__ */ e(m, {
21
22
  className: i.itemsDropdown,
22
23
  noPermissionItems: n,
24
+ onDropdownOpenChange: s,
23
25
  onItemClick: o,
24
26
  unsupportedItems: t
25
27
  }),
@@ -28,6 +30,6 @@ import '../../../../styles/unsupported-items-notice.css';const l = "_inlineNotic
28
30
  })
29
31
  });
30
32
  export {
31
- u as UnsupportedItemsNotice,
32
- u as default
33
+ g as UnsupportedItemsNotice,
34
+ g as default
33
35
  };
@@ -1,64 +1,67 @@
1
1
  import { Text as w } from "@box/blueprint-web";
2
- import { useMemo as i } from "react";
2
+ import { useMemo as o } from "react";
3
3
  import { useIntl as C } from "react-intl";
4
- import { MediaContainer as f } from "../common/media-container.js";
5
- import { ContextualItemsMessage as T } from "./contextual-items-message.js";
4
+ import { MediaContainer as u } from "../common/media-container.js";
5
+ import { ContextualItemsMessage as z } from "./contextual-items-message.js";
6
6
  import a from "./messages.js";
7
- import { s as u, W as h } from "../../../../chunks/warning-message.js";
8
- import { UnsupportedItemsNotice as z } from "./unsupported-items-notice.js";
9
- import { jsx as e, jsxs as F } from "react/jsx-runtime";
10
- const V = ({
11
- contentName: I,
12
- contentType: M,
13
- isFileSizeError: b = !1,
7
+ import { s as h, W as I } from "../../../../chunks/warning-message.js";
8
+ import { UnsupportedItemsNotice as F } from "./unsupported-items-notice.js";
9
+ import { jsx as e, jsxs as N } from "react/jsx-runtime";
10
+ const A = ({
11
+ contentName: M,
12
+ contentType: b,
13
+ isFileSizeError: x = !1,
14
14
  items: s = [],
15
- parentItem: x,
15
+ parentItem: S,
16
16
  onItemClick: n,
17
17
  variant: l = "modal",
18
18
  warningNotice: m,
19
- warningNoticeAriaLabel: S,
20
- welcomeMessageClearText: W
19
+ warningNoticeAriaLabel: W,
20
+ welcomeMessageClearText: T,
21
+ onDropdownOpenChange: c
21
22
  }) => {
22
- const p = l === "sidebar", {
23
+ const d = l === "sidebar", {
23
24
  formatMessage: r
24
- } = C(), d = i(() => s.filter((t) => t.status === "supported"), [s]), c = i(() => s.filter((t) => t.status === "unsupported"), [s]), g = i(() => s.filter((t) => t.status === "no_permission"), [s]), o = d.length || 1;
25
+ } = C(), p = o(() => s.filter((t) => t.status === "supported"), [s]), g = o(() => s.filter((t) => t.status === "unsupported"), [s]), f = o(() => s.filter((t) => t.status === "no_permission"), [s]), i = p.length || 1;
25
26
  return /* @__PURE__ */ e("div", {
26
- className: u.welcomeMessage,
27
+ className: h.welcomeMessage,
27
28
  "data-testid": "content-answers-welcome-message",
28
- children: /* @__PURE__ */ e(f, {
29
+ children: /* @__PURE__ */ e(u, {
29
30
  className: "welcomeMessage",
30
31
  variant: l,
31
- children: /* @__PURE__ */ F(f.Content, {
32
- isUsedInsideSidebar: p,
32
+ children: /* @__PURE__ */ N(u.Content, {
33
+ isUsedInsideSidebar: d,
33
34
  variant: "welcomeMessage",
34
- children: [b && /* @__PURE__ */ e(h, {
35
+ children: [x && /* @__PURE__ */ e(I, {
35
36
  ariaLabel: r(a.largeFileSizeWarningTitle, {
36
- numberOfItems: o
37
+ numberOfItems: i
37
38
  }),
38
39
  description: r(a.largeFileSizeWarningDescription, {
39
- numberOfItems: o
40
+ numberOfItems: i
40
41
  }),
41
42
  title: r(a.largeFileSizeWarningTitle, {
42
- numberOfItems: o
43
+ numberOfItems: i
43
44
  })
44
- }), m && /* @__PURE__ */ e(h, {
45
- ariaLabel: S,
45
+ }), m && /* @__PURE__ */ e(I, {
46
+ ariaLabel: W,
46
47
  title: m
47
- }), (c.length > 0 || g.length > 0) && /* @__PURE__ */ e(z, {
48
- noPermissionsItems: g,
48
+ }), (g.length > 0 || f.length > 0) && /* @__PURE__ */ e(F, {
49
+ noPermissionsItems: f,
50
+ onDropdownOpenChange: c,
49
51
  onItemClick: n,
50
- unsupportedItems: c
51
- }), /* @__PURE__ */ e(T, {
52
- contentName: I,
53
- isUsedInsideSidebar: p,
52
+ unsupportedItems: g
53
+ }), /* @__PURE__ */ e(z, {
54
+ contentName: M,
55
+ isUsedInsideSidebar: d,
56
+ onDropdownOpenChange: c,
54
57
  onItemClick: n,
55
- parentItem: x,
56
- supportedItems: d
58
+ parentItem: S,
59
+ supportedItems: p
57
60
  }), /* @__PURE__ */ e(w, {
58
61
  as: "p",
59
- className: u.clearChatText,
60
- children: W || r(a.welcomeClearChatText, {
61
- type: M
62
+ className: h.clearChatText,
63
+ children: T || r(a.welcomeClearChatText, {
64
+ type: b
62
65
  })
63
66
  })]
64
67
  })
@@ -66,6 +69,6 @@ const V = ({
66
69
  });
67
70
  };
68
71
  export {
69
- V as WelcomeMessage,
70
- V as default
72
+ A as WelcomeMessage,
73
+ A as default
71
74
  };
@@ -0,0 +1,34 @@
1
+ import { useRef as c, useEffect as u } from "react";
2
+ import { INPUT_TARGET_ID as s } from "../components/footer/constants.js";
3
+ const l = (o, e, n) => () => {
4
+ const r = e.querySelector(o);
5
+ r && (r.focus(), n());
6
+ }, i = (o, e, n) => {
7
+ const r = document.querySelector(e);
8
+ if (!r)
9
+ return null;
10
+ const t = new MutationObserver(l(o, r, () => {
11
+ t.disconnect(), n();
12
+ }));
13
+ return t.observe(document, {
14
+ childList: !0,
15
+ subtree: !0
16
+ }), t;
17
+ };
18
+ function a(o) {
19
+ const e = c(null), n = `[data-target-id="${s}"]`, r = () => {
20
+ const t = document.querySelector(n);
21
+ t ? t.focus() : e != null && e.current || (e.current = i(n, o, () => {
22
+ e.current = null;
23
+ }));
24
+ };
25
+ return u(() => () => {
26
+ var t;
27
+ (t = e == null ? void 0 : e.current) == null || t.disconnect();
28
+ }, [e]), {
29
+ focusPrompt: r
30
+ };
31
+ }
32
+ export {
33
+ a as usePromptFocus
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.105.0",
3
+ "version": "0.106.1",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.35.0",
@@ -16,10 +16,10 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@box/babel-plugin-target-attributes": "1.3.0",
19
- "@box/blueprint-web": "^9.18.9",
20
- "@box/blueprint-web-assets": "^4.35.0",
21
- "@box/box-ai-agent-selector": "^0.32.0",
22
- "@box/item-icon": "^0.9.91",
19
+ "@box/blueprint-web": "^9.18.10",
20
+ "@box/blueprint-web-assets": "^4.36.0",
21
+ "@box/box-ai-agent-selector": "^0.32.1",
22
+ "@box/item-icon": "^0.9.92",
23
23
  "@box/storybook-utils": "^0.8.3",
24
24
  "@testing-library/react": "^15.0.6",
25
25
  "react": "^18.3.0",
@@ -57,5 +57,5 @@
57
57
  "**/*.css"
58
58
  ],
59
59
  "license": "SEE LICENSE IN LICENSE",
60
- "gitHead": "d9896953657518cadffe1c467b9c60b05b13b1e7"
60
+ "gitHead": "23bed42d9a6652cfb6069f38db36bf3eb529dc9b"
61
61
  }
package/types/index.d.ts CHANGED
@@ -3,5 +3,6 @@ export * from './lib/components/answer/answer-content';
3
3
  export * from './lib/components/api-wrapper/api-wrapper';
4
4
  export * from './lib/components/modal/clear-conversation-button';
5
5
  export * from './lib/components/modal/modal';
6
+ export * from './lib/hooks/usePromptFocus';
6
7
  export * from './lib/types';
7
8
  export * from './lib/constants';
@@ -5,6 +5,7 @@ export interface Props {
5
5
  parentItem: ItemType;
6
6
  supportedItems: Array<ItemType>;
7
7
  onItemClick?: ItemClickHandler;
8
+ onDropdownOpenChange?: (open: boolean) => void;
8
9
  }
9
- export declare const ContextualItemsMessage: ({ contentName, isUsedInsideSidebar, supportedItems, onItemClick, parentItem, }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const ContextualItemsMessage: ({ contentName, isUsedInsideSidebar, supportedItems, onItemClick, parentItem, onDropdownOpenChange, }: Props) => import("react/jsx-runtime").JSX.Element;
10
11
  export default ContextualItemsMessage;
@@ -1,3 +1,3 @@
1
1
  import { ItemsDropdownProps } from '../../types';
2
- export declare const ItemsDropdown: ({ className, supportedItems, unsupportedItems, noPermissionItems, onItemClick, }: ItemsDropdownProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ItemsDropdown: ({ className, supportedItems, unsupportedItems, noPermissionItems, onItemClick, onDropdownOpenChange, }: ItemsDropdownProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default ItemsDropdown;
@@ -9,6 +9,7 @@ export declare const defaultItemsDropdownProps: {
9
9
  unsupportedItems: import('../../../types').ItemType[];
10
10
  noPermissionItems: import('../../../types').ItemType[];
11
11
  onItemClick: (...args: any[]) => void;
12
+ onDropdownOpenChange: (...args: any[]) => void;
12
13
  };
13
14
  export declare const DefaultWelcomeMessage: (props: WelcomeMessageProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export declare const DefaultItemsDropdown: (props: ItemsDropdownProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,6 +3,7 @@ export interface Props {
3
3
  unsupportedItems?: Array<ItemType>;
4
4
  noPermissionsItems?: Array<ItemType>;
5
5
  onItemClick?: ItemClickHandler;
6
+ onDropdownOpenChange?: (open: boolean) => void;
6
7
  }
7
- export declare const UnsupportedItemsNotice: ({ unsupportedItems, noPermissionsItems, onItemClick }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const UnsupportedItemsNotice: ({ unsupportedItems, noPermissionsItems, onItemClick, onDropdownOpenChange, }: Props) => import("react/jsx-runtime").JSX.Element;
8
9
  export default UnsupportedItemsNotice;
@@ -1,3 +1,3 @@
1
1
  import { WelcomeMessageProps } from '../../types';
2
- export declare const WelcomeMessage: ({ contentName, contentType, isFileSizeError, items, parentItem, onItemClick, variant, warningNotice, warningNoticeAriaLabel, welcomeMessageClearText, }: WelcomeMessageProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const WelcomeMessage: ({ contentName, contentType, isFileSizeError, items, parentItem, onItemClick, variant, warningNotice, warningNoticeAriaLabel, welcomeMessageClearText, onDropdownOpenChange, }: WelcomeMessageProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default WelcomeMessage;
@@ -0,0 +1,3 @@
1
+ export declare function usePromptFocus(containerSelector: string): {
2
+ focusPrompt: () => void;
3
+ };
@@ -35,3 +35,4 @@ export declare const defaultBoxAiContentAnswersProps: {
35
35
  export declare const WithUpdatedRequestInProgress: (props: BoxAiContentAnswersProps) => import("react/jsx-runtime").JSX.Element;
36
36
  export declare const DefaultBoxAIContentAnswers: (props: BoxAiContentAnswersProps) => import("react/jsx-runtime").JSX.Element;
37
37
  export declare const DefaultBoxAISidebar: (props: BoxAiContentAnswersProps) => import("react/jsx-runtime").JSX.Element;
38
+ export declare const WithFocusableBoxAISidebarInput: (props: BoxAiContentAnswersProps) => import("react/jsx-runtime").JSX.Element;
@@ -46,6 +46,8 @@ export type WelcomeMessageProps = {
46
46
  parentItem?: ItemType;
47
47
  /** Callback action passed from the host application to do an action when the user clicks an item within the dropdown */
48
48
  onItemClick?: ItemClickHandler;
49
+ /** Function passed from parent component to update state when the user opens the dropdown */
50
+ onDropdownOpenChange?: (open: boolean) => void;
49
51
  /** If keyframe animation should be applied to chat elements; defaults to true */
50
52
  useAnimation?: boolean;
51
53
  /** Styling variant of welcome message */
@@ -204,6 +206,7 @@ export type ItemsDropdownProps = {
204
206
  supportedItems?: Array<ItemType>;
205
207
  unsupportedItems?: Array<ItemType>;
206
208
  onItemClick?: ItemClickHandler;
209
+ onDropdownOpenChange?: (open: boolean) => void;
207
210
  };
208
211
  export type EventLogOptions = {
209
212
  eventType: string;