@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 +16 -14
- package/esm/lib/components/content/content.js +66 -65
- package/esm/lib/components/welcome-message/contextual-items-message.js +23 -21
- package/esm/lib/components/welcome-message/items-dropdown.js +30 -28
- package/esm/lib/components/welcome-message/unsupported-items-notice.js +16 -14
- package/esm/lib/components/welcome-message/welcome-message.js +41 -38
- package/esm/lib/hooks/usePromptFocus.js +34 -0
- package/package.json +6 -6
- package/types/index.d.ts +1 -0
- package/types/lib/components/welcome-message/contextual-items-message.d.ts +2 -1
- package/types/lib/components/welcome-message/items-dropdown.d.ts +1 -1
- package/types/lib/components/welcome-message/stories/shared.d.ts +1 -0
- package/types/lib/components/welcome-message/unsupported-items-notice.d.ts +2 -1
- package/types/lib/components/welcome-message/welcome-message.d.ts +1 -1
- package/types/lib/hooks/usePromptFocus.d.ts +3 -0
- package/types/lib/stories/shared.d.ts +1 -0
- package/types/lib/types.d.ts +3 -0
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
|
|
3
|
-
import { withApiWrapper as
|
|
4
|
-
import { C as
|
|
5
|
-
import { IntelligenceModal as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
C as ANSWER_ERROR,
|
|
11
|
+
O as APP_MODE,
|
|
12
|
+
p as AnswerContent,
|
|
12
13
|
e as BoxAiContentAnswers,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
2
|
-
import
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import { C as
|
|
7
|
-
import { Chat as
|
|
8
|
-
import { ModalError as
|
|
9
|
-
import { jsx as n, jsxs as
|
|
10
|
-
import '../../../../styles/content.css';const
|
|
11
|
-
loadingIndicatorWrapper:
|
|
12
|
-
content:
|
|
13
|
-
sidebar:
|
|
14
|
-
isLoading:
|
|
15
|
-
messagesEnd:
|
|
16
|
-
innerContent:
|
|
17
|
-
},
|
|
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:
|
|
19
|
+
hasCustomSuggestedQuestions: C,
|
|
20
20
|
hasRequestInProgress: c = !1,
|
|
21
|
-
isErrorMessageShown:
|
|
21
|
+
isErrorMessageShown: h = !1,
|
|
22
22
|
isStreamingEnabled: i = !1,
|
|
23
|
-
questions:
|
|
23
|
+
questions: w,
|
|
24
24
|
recordAction: m,
|
|
25
|
-
showLoadingIndicator:
|
|
26
|
-
suggestedQuestions:
|
|
27
|
-
askSuggestedQuestion:
|
|
28
|
-
setAskSuggestedQuestion:
|
|
29
|
-
useAnimation:
|
|
30
|
-
variant:
|
|
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),
|
|
35
|
-
formatMessage:
|
|
36
|
-
} =
|
|
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 ||
|
|
39
|
-
behavior:
|
|
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]),
|
|
42
|
+
}, [i]), z = () => {
|
|
43
43
|
if (l.current) {
|
|
44
44
|
const {
|
|
45
|
-
scrollTop:
|
|
45
|
+
scrollTop: a,
|
|
46
46
|
clientHeight: e,
|
|
47
|
-
scrollHeight:
|
|
48
|
-
} = l.current,
|
|
49
|
-
if (c &&
|
|
50
|
-
|
|
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
|
-
|
|
53
|
+
s.current = !0;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
t.useEffect(() => {
|
|
57
|
-
c && (
|
|
58
|
-
}, [
|
|
59
|
-
|
|
60
|
-
}, [
|
|
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
|
|
64
|
-
|
|
63
|
+
const a = new ResizeObserver(() => {
|
|
64
|
+
o(i ? "instant" : "smooth");
|
|
65
65
|
}), e = d.current;
|
|
66
|
-
return e &&
|
|
67
|
-
e &&
|
|
66
|
+
return e && a.observe(e), () => {
|
|
67
|
+
e && a.unobserve(e);
|
|
68
68
|
};
|
|
69
|
-
}, [
|
|
70
|
-
const
|
|
69
|
+
}, [o, i]);
|
|
70
|
+
const T = () => h && !E ? /* @__PURE__ */ n(H, {
|
|
71
71
|
error: u,
|
|
72
72
|
recordAction: m
|
|
73
|
-
}) :
|
|
73
|
+
}) : p ? /* @__PURE__ */ n("div", {
|
|
74
74
|
className: r.loadingIndicatorWrapper,
|
|
75
|
-
children: /* @__PURE__ */ n(
|
|
76
|
-
"aria-label":
|
|
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__ */
|
|
82
|
-
children: [/* @__PURE__ */ n(
|
|
83
|
-
askSuggestedQuestion:
|
|
84
|
-
hasCustomSuggestedQuestions:
|
|
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:
|
|
88
|
-
|
|
87
|
+
isFileSizeError: E,
|
|
88
|
+
onDropdownOpenChange: O,
|
|
89
|
+
questions: w,
|
|
89
90
|
recordAction: m,
|
|
90
|
-
setAskSuggestedQuestion:
|
|
91
|
-
suggestedQuestions:
|
|
92
|
-
useAnimation:
|
|
93
|
-
variant:
|
|
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:
|
|
103
|
+
className: M(r.content, _ === "sidebar" && r.sidebar, p && r.isLoading),
|
|
103
104
|
"data-testid": "content-answers-content",
|
|
104
|
-
onScroll:
|
|
105
|
+
onScroll: z,
|
|
105
106
|
children: /* @__PURE__ */ n("div", {
|
|
106
107
|
ref: d,
|
|
107
108
|
className: r.innerContent,
|
|
108
|
-
children:
|
|
109
|
+
children: T()
|
|
109
110
|
})
|
|
110
111
|
});
|
|
111
112
|
};
|
|
112
113
|
export {
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
ne as Content,
|
|
115
|
+
ne as default
|
|
115
116
|
};
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FormattedMessage as
|
|
3
|
-
import { ItemsDropdown as
|
|
4
|
-
import
|
|
5
|
-
import { jsx as o, jsxs as
|
|
6
|
-
import '../../../../styles/contextual-items-message.css';const
|
|
7
|
-
askQuestionText:
|
|
8
|
-
sidebar:
|
|
9
|
-
itemsDropdown:
|
|
10
|
-
},
|
|
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
|
|
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:
|
|
21
|
+
className: f(i.askQuestionText, {
|
|
21
22
|
[i.sidebar]: r
|
|
22
23
|
}),
|
|
23
|
-
children: /* @__PURE__ */ o(
|
|
24
|
-
...
|
|
24
|
+
children: /* @__PURE__ */ o(x, {
|
|
25
|
+
...u.welcomeAskQuestionText,
|
|
25
26
|
values: {
|
|
26
27
|
firstItemName: /* @__PURE__ */ o("b", {
|
|
27
|
-
children:
|
|
28
|
+
children: l
|
|
28
29
|
}),
|
|
29
|
-
parentItem: t && /* @__PURE__ */
|
|
30
|
+
parentItem: t && /* @__PURE__ */ b("b", {
|
|
30
31
|
children: ["“", t, "”"]
|
|
31
32
|
}),
|
|
32
|
-
numberOfItems:
|
|
33
|
-
files: /* @__PURE__ */ o(
|
|
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
|
-
|
|
44
|
-
|
|
45
|
+
v as ContextualItemsMessage,
|
|
46
|
+
v as default
|
|
45
47
|
};
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import { useBreakpoint as
|
|
2
|
-
import { Size5 as
|
|
3
|
-
import { ItemIcon as
|
|
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
|
|
6
|
-
import { useIntl as
|
|
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
|
|
9
|
-
import '../../../../styles/items-dropdown.css';const
|
|
10
|
-
itemsDropdownTriggerLink:
|
|
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:
|
|
14
|
-
itemsDropdownLabel:
|
|
15
|
-
},
|
|
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:
|
|
24
|
-
} =
|
|
25
|
-
id:
|
|
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(
|
|
29
|
-
}, [i]), L = g(() => t.length > 0 ? r.welcomeMessageFilesLink : r.welcomeMessageItemsLink, [t]), f = g(() =>
|
|
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 = (
|
|
32
|
-
children: [
|
|
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:
|
|
38
|
+
children: m
|
|
38
39
|
})
|
|
39
40
|
}), l.map((c) => /* @__PURE__ */ s(e.Item, {
|
|
40
41
|
className: o.itemsDropdownItem,
|
|
41
|
-
onClick: () =>
|
|
42
|
-
children: [/* @__PURE__ */ n(
|
|
42
|
+
onClick: () => N(c),
|
|
43
|
+
children: [/* @__PURE__ */ n(C, {
|
|
43
44
|
ariaHidden: !0,
|
|
44
45
|
className: o.itemsDropdownItemIcon,
|
|
45
|
-
dimension:
|
|
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(
|
|
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":
|
|
73
|
+
"aria-label": a(r.closeItemList)
|
|
72
74
|
})]
|
|
73
|
-
}), w(null, t), w(
|
|
75
|
+
}), w(null, t), w(a(r.unsupportedFormatLabel), d), w(a(r.noPermissionsLabel), p)]
|
|
74
76
|
})]
|
|
75
77
|
});
|
|
76
78
|
};
|
|
77
79
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
K as ItemsDropdown,
|
|
81
|
+
K as default
|
|
80
82
|
};
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { InlineNotice as
|
|
2
|
-
import { FormattedMessage as
|
|
3
|
-
import { ItemsDropdown as
|
|
4
|
-
import
|
|
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
|
|
7
|
-
inlineNotice:
|
|
8
|
-
},
|
|
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
|
-
|
|
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(
|
|
18
|
-
...
|
|
18
|
+
children: /* @__PURE__ */ e(a, {
|
|
19
|
+
...l.unsupportedItems,
|
|
19
20
|
values: {
|
|
20
|
-
files: /* @__PURE__ */ e(
|
|
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
|
-
|
|
32
|
-
|
|
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
|
|
2
|
+
import { useMemo as o } from "react";
|
|
3
3
|
import { useIntl as C } from "react-intl";
|
|
4
|
-
import { MediaContainer as
|
|
5
|
-
import { ContextualItemsMessage as
|
|
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
|
|
8
|
-
import { UnsupportedItemsNotice as
|
|
9
|
-
import { jsx as e, jsxs as
|
|
10
|
-
const
|
|
11
|
-
contentName:
|
|
12
|
-
contentType:
|
|
13
|
-
isFileSizeError:
|
|
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:
|
|
15
|
+
parentItem: S,
|
|
16
16
|
onItemClick: n,
|
|
17
17
|
variant: l = "modal",
|
|
18
18
|
warningNotice: m,
|
|
19
|
-
warningNoticeAriaLabel:
|
|
20
|
-
welcomeMessageClearText:
|
|
19
|
+
warningNoticeAriaLabel: W,
|
|
20
|
+
welcomeMessageClearText: T,
|
|
21
|
+
onDropdownOpenChange: c
|
|
21
22
|
}) => {
|
|
22
|
-
const
|
|
23
|
+
const d = l === "sidebar", {
|
|
23
24
|
formatMessage: r
|
|
24
|
-
} = C(),
|
|
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:
|
|
27
|
+
className: h.welcomeMessage,
|
|
27
28
|
"data-testid": "content-answers-welcome-message",
|
|
28
|
-
children: /* @__PURE__ */ e(
|
|
29
|
+
children: /* @__PURE__ */ e(u, {
|
|
29
30
|
className: "welcomeMessage",
|
|
30
31
|
variant: l,
|
|
31
|
-
children: /* @__PURE__ */
|
|
32
|
-
isUsedInsideSidebar:
|
|
32
|
+
children: /* @__PURE__ */ N(u.Content, {
|
|
33
|
+
isUsedInsideSidebar: d,
|
|
33
34
|
variant: "welcomeMessage",
|
|
34
|
-
children: [
|
|
35
|
+
children: [x && /* @__PURE__ */ e(I, {
|
|
35
36
|
ariaLabel: r(a.largeFileSizeWarningTitle, {
|
|
36
|
-
numberOfItems:
|
|
37
|
+
numberOfItems: i
|
|
37
38
|
}),
|
|
38
39
|
description: r(a.largeFileSizeWarningDescription, {
|
|
39
|
-
numberOfItems:
|
|
40
|
+
numberOfItems: i
|
|
40
41
|
}),
|
|
41
42
|
title: r(a.largeFileSizeWarningTitle, {
|
|
42
|
-
numberOfItems:
|
|
43
|
+
numberOfItems: i
|
|
43
44
|
})
|
|
44
|
-
}), m && /* @__PURE__ */ e(
|
|
45
|
-
ariaLabel:
|
|
45
|
+
}), m && /* @__PURE__ */ e(I, {
|
|
46
|
+
ariaLabel: W,
|
|
46
47
|
title: m
|
|
47
|
-
}), (
|
|
48
|
-
noPermissionsItems:
|
|
48
|
+
}), (g.length > 0 || f.length > 0) && /* @__PURE__ */ e(F, {
|
|
49
|
+
noPermissionsItems: f,
|
|
50
|
+
onDropdownOpenChange: c,
|
|
49
51
|
onItemClick: n,
|
|
50
|
-
unsupportedItems:
|
|
51
|
-
}), /* @__PURE__ */ e(
|
|
52
|
-
contentName:
|
|
53
|
-
isUsedInsideSidebar:
|
|
52
|
+
unsupportedItems: g
|
|
53
|
+
}), /* @__PURE__ */ e(z, {
|
|
54
|
+
contentName: M,
|
|
55
|
+
isUsedInsideSidebar: d,
|
|
56
|
+
onDropdownOpenChange: c,
|
|
54
57
|
onItemClick: n,
|
|
55
|
-
parentItem:
|
|
56
|
-
supportedItems:
|
|
58
|
+
parentItem: S,
|
|
59
|
+
supportedItems: p
|
|
57
60
|
}), /* @__PURE__ */ e(w, {
|
|
58
61
|
as: "p",
|
|
59
|
-
className:
|
|
60
|
-
children:
|
|
61
|
-
type:
|
|
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
|
-
|
|
70
|
-
|
|
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.
|
|
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.
|
|
20
|
-
"@box/blueprint-web-assets": "^4.
|
|
21
|
-
"@box/box-ai-agent-selector": "^0.32.
|
|
22
|
-
"@box/item-icon": "^0.9.
|
|
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": "
|
|
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;
|
|
@@ -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;
|
package/types/lib/types.d.ts
CHANGED
|
@@ -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;
|