@box/box-ai-content-answers 0.57.7 → 0.58.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.
- package/esm/lib/components/answer/answer.js +39 -37
- package/esm/lib/components/answer/copy-button.js +27 -26
- package/esm/lib/components/chat/chat.js +38 -36
- package/package.json +3 -3
- package/types/lib/box-ai-content-answers.d.ts +2 -0
- package/types/lib/components/answer/answer.d.ts +2 -0
- package/types/lib/components/answer/copy-button.d.ts +2 -1
- package/types/lib/components/chat/chat.d.ts +1 -1
- package/types/lib/types.d.ts +2 -0
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import "../../../../styles/answer.css";
|
|
2
|
-
import { useBreakpoint as
|
|
3
|
-
import { BoxAi as
|
|
4
|
-
import { Size5 as
|
|
5
|
-
import
|
|
2
|
+
import { useBreakpoint as P, Breakpoint as T, Text as j } from "@box/blueprint-web";
|
|
3
|
+
import { BoxAi as L, AlertTriangle as x } from "@box/blueprint-web-assets/icons/Line";
|
|
4
|
+
import { Size5 as D, Size6 as F, Gray65 as M, Size4 as f } from "@box/blueprint-web-assets/tokens/tokens";
|
|
5
|
+
import U from "clsx";
|
|
6
6
|
import * as m from "react";
|
|
7
|
-
import { useIntl as
|
|
7
|
+
import { useIntl as k } from "react-intl";
|
|
8
8
|
import { A as t } from "../../../../chunks/types.js";
|
|
9
9
|
import { MediaContainer as l } from "../common/media-container.js";
|
|
10
|
-
import { AnswerContent as
|
|
11
|
-
import { CopyButton as
|
|
12
|
-
import { InlineError as
|
|
13
|
-
import { LoadingElement as
|
|
10
|
+
import { AnswerContent as y } from "./answer-content.js";
|
|
11
|
+
import { CopyButton as z } from "./copy-button.js";
|
|
12
|
+
import { InlineError as B } from "./inline-error.js";
|
|
13
|
+
import { LoadingElement as H } from "./loading-element.js";
|
|
14
14
|
import d from "./messages.js";
|
|
15
|
-
import { References as
|
|
15
|
+
import { References as C } from "./references.js";
|
|
16
16
|
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
17
|
-
const
|
|
18
|
-
answer:
|
|
19
|
-
alertIcon:
|
|
20
|
-
error:
|
|
21
|
-
footer:
|
|
22
|
-
shouldUseAnimation:
|
|
23
|
-
shouldAnimateHeight:
|
|
24
|
-
iconAvatar:
|
|
25
|
-
},
|
|
17
|
+
const G = "_answer_17ojr_1", b = "_alertIcon_17ojr_4", W = "_error_17ojr_7", q = "_footer_17ojr_11", J = "_shouldUseAnimation_17ojr_16", K = "_shouldAnimateHeight_17ojr_20", Q = "_iconAvatar_17ojr_24", r = {
|
|
18
|
+
answer: G,
|
|
19
|
+
alertIcon: b,
|
|
20
|
+
error: W,
|
|
21
|
+
footer: q,
|
|
22
|
+
shouldUseAnimation: J,
|
|
23
|
+
shouldAnimateHeight: K,
|
|
24
|
+
iconAvatar: Q
|
|
25
|
+
}, V = /* @__PURE__ */ new Set([t.RATE_LIMITING, t.NO_CONTENT, t.PRECONDITION_FAILED, t.GENERAL]), _o = /* @__PURE__ */ m.memo(({
|
|
26
26
|
answer: a,
|
|
27
27
|
citations: h,
|
|
28
28
|
error: o,
|
|
@@ -32,24 +32,25 @@ const C = "_answer_17ojr_1", G = "_alertIcon_17ojr_4", b = "_error_17ojr_7", W =
|
|
|
32
32
|
isLoading: A = !1,
|
|
33
33
|
isMarkdownEnabled: I = !1,
|
|
34
34
|
onCitationClick: N,
|
|
35
|
+
onAnswerCopy: R,
|
|
35
36
|
recordAction: i,
|
|
36
|
-
useAnimation:
|
|
37
|
+
useAnimation: w = !0
|
|
37
38
|
}) => {
|
|
38
|
-
const E =
|
|
39
|
+
const E = V.has(o), p = A && !a && !o, [g, O] = m.useState(s), {
|
|
39
40
|
formatMessage: c
|
|
40
|
-
} =
|
|
41
|
+
} = k(), _ = P() === T.Small ? D : F;
|
|
41
42
|
m.useEffect(() => {
|
|
42
|
-
setTimeout(() =>
|
|
43
|
+
setTimeout(() => O(s), 0);
|
|
43
44
|
}, [s]);
|
|
44
|
-
const
|
|
45
|
+
const v = () => /* @__PURE__ */ n(j, {
|
|
45
46
|
as: "p",
|
|
46
47
|
className: r.error,
|
|
47
48
|
color: "textOnLightSecondary",
|
|
48
49
|
"data-testid": "content-answers-error",
|
|
49
50
|
variant: "caption",
|
|
50
|
-
children: [o === t.RESPONSE_INTERRUPTED && c(d.responseInterruptedError), o === t.RESPONSE_FAILED && c(d.responseFailedError), o === t.RESPONSE_STOPPED && c(d.responseStoppedError), o !== t.RESPONSE_STOPPED && /* @__PURE__ */ e(
|
|
51
|
+
children: [o === t.RESPONSE_INTERRUPTED && c(d.responseInterruptedError), o === t.RESPONSE_FAILED && c(d.responseFailedError), o === t.RESPONSE_STOPPED && c(d.responseStoppedError), o !== t.RESPONSE_STOPPED && /* @__PURE__ */ e(x, {
|
|
51
52
|
className: r.alertIcon,
|
|
52
|
-
color:
|
|
53
|
+
color: M,
|
|
53
54
|
"data-testid": "content-answers-error-alert-icon",
|
|
54
55
|
height: f,
|
|
55
56
|
role: "presentation",
|
|
@@ -64,40 +65,41 @@ const C = "_answer_17ojr_1", G = "_alertIcon_17ojr_4", b = "_error_17ojr_7", W =
|
|
|
64
65
|
children: [/* @__PURE__ */ e(l.Figure, {
|
|
65
66
|
children: /* @__PURE__ */ e("div", {
|
|
66
67
|
className: r.iconAvatar,
|
|
67
|
-
children: /* @__PURE__ */ e(
|
|
68
|
+
children: /* @__PURE__ */ e(L, {
|
|
68
69
|
height: _,
|
|
69
70
|
role: "presentation",
|
|
70
71
|
width: _
|
|
71
72
|
})
|
|
72
73
|
})
|
|
73
74
|
}), /* @__PURE__ */ n(l.Content, {
|
|
74
|
-
children: [/* @__PURE__ */ e(
|
|
75
|
+
children: [/* @__PURE__ */ e(y, {
|
|
75
76
|
answer: a,
|
|
76
77
|
isMarkdownEnabled: I
|
|
77
78
|
}), s && /* @__PURE__ */ n("div", {
|
|
78
|
-
className:
|
|
79
|
-
[r.shouldUseAnimation]:
|
|
80
|
-
[r.shouldAnimateHeight]:
|
|
79
|
+
className: U(r.footer, {
|
|
80
|
+
[r.shouldUseAnimation]: w,
|
|
81
|
+
[r.shouldAnimateHeight]: g
|
|
81
82
|
}),
|
|
82
83
|
"data-testid": "content-answers-answer-footer",
|
|
83
|
-
children: [o &&
|
|
84
|
+
children: [o && v(), u && !o && /* @__PURE__ */ e(C, {
|
|
84
85
|
citations: h,
|
|
85
86
|
onCitationClick: N,
|
|
86
87
|
recordAction: i
|
|
87
|
-
}), /* @__PURE__ */ e(
|
|
88
|
+
}), /* @__PURE__ */ e(z, {
|
|
88
89
|
answer: a,
|
|
90
|
+
onAnswerCopy: R,
|
|
89
91
|
recordAction: i
|
|
90
92
|
})]
|
|
91
93
|
})]
|
|
92
94
|
})]
|
|
93
|
-
}), E && /* @__PURE__ */ e(
|
|
95
|
+
}), E && /* @__PURE__ */ e(B, {
|
|
94
96
|
contentType: S,
|
|
95
97
|
error: o,
|
|
96
98
|
recordAction: i
|
|
97
|
-
}), p && /* @__PURE__ */ e(
|
|
99
|
+
}), p && /* @__PURE__ */ e(H, {})]
|
|
98
100
|
});
|
|
99
101
|
});
|
|
100
102
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
_o as Answer,
|
|
104
|
+
_o as default
|
|
103
105
|
};
|
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
import "../../../../styles/copy-button.css";
|
|
2
|
-
import { useNotification as
|
|
3
|
-
import { Clipboard as
|
|
4
|
-
import { useIntl as
|
|
2
|
+
import { useNotification as p, Tooltip as l, IconButton as m } from "@box/blueprint-web";
|
|
3
|
+
import { Clipboard as u } from "@box/blueprint-web-assets/icons/Fill";
|
|
4
|
+
import { useIntl as f } from "react-intl";
|
|
5
5
|
import d from "../../messages.js";
|
|
6
|
-
import { LOGGER_BASE_CONFIG as
|
|
6
|
+
import { LOGGER_BASE_CONFIG as b, LOGGER_ACTION_CLICK as y } from "../common/constants.js";
|
|
7
7
|
import t from "./messages.js";
|
|
8
|
-
import { jsx as
|
|
9
|
-
const
|
|
10
|
-
copyButton:
|
|
11
|
-
},
|
|
8
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
9
|
+
const C = "_copyButton_1mhca_1", T = {
|
|
10
|
+
copyButton: C
|
|
11
|
+
}, h = ({
|
|
12
12
|
answer: i,
|
|
13
|
-
|
|
13
|
+
onAnswerCopy: a,
|
|
14
|
+
recordAction: s
|
|
14
15
|
}) => {
|
|
15
16
|
const {
|
|
16
17
|
formatMessage: o
|
|
17
|
-
} =
|
|
18
|
-
addNotification:
|
|
19
|
-
} =
|
|
20
|
-
|
|
21
|
-
...
|
|
22
|
-
action:
|
|
18
|
+
} = f(), {
|
|
19
|
+
addNotification: r
|
|
20
|
+
} = p(), n = () => {
|
|
21
|
+
s && s({
|
|
22
|
+
...b,
|
|
23
|
+
action: y,
|
|
23
24
|
target: "copyToClipboard"
|
|
24
25
|
}), i && navigator && navigator.clipboard && navigator.clipboard.writeText && navigator.clipboard.writeText(i).then(() => {
|
|
25
|
-
|
|
26
|
+
r({
|
|
26
27
|
sensitivity: "foreground",
|
|
27
28
|
styledText: o(t.copyToClipboardSucceeded),
|
|
28
29
|
variant: "success",
|
|
29
30
|
typeIconAriaLabel: o(t.copyButtonSuccessText),
|
|
30
31
|
closeButtonAriaLabel: o(d.closeButtonText)
|
|
31
|
-
});
|
|
32
|
+
}), a && a(i);
|
|
32
33
|
});
|
|
33
34
|
};
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ e(l, {
|
|
35
36
|
content: o(t.copyToClipboard),
|
|
36
|
-
children: /* @__PURE__ */
|
|
37
|
+
children: /* @__PURE__ */ e(m, {
|
|
37
38
|
"aria-label": o(t.copyToClipboard),
|
|
38
|
-
className:
|
|
39
|
-
icon:
|
|
40
|
-
onClick:
|
|
41
|
-
onFocusCapture: (
|
|
42
|
-
|
|
39
|
+
className: T.copyButton,
|
|
40
|
+
icon: u,
|
|
41
|
+
onClick: n,
|
|
42
|
+
onFocusCapture: (c) => {
|
|
43
|
+
c.target.matches(":focus-visible") || c.stopPropagation();
|
|
43
44
|
},
|
|
44
45
|
size: "x-small"
|
|
45
46
|
})
|
|
46
47
|
});
|
|
47
48
|
};
|
|
48
49
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
h as CopyButton,
|
|
51
|
+
h as default
|
|
51
52
|
};
|
|
@@ -1,67 +1,69 @@
|
|
|
1
1
|
import "../../../../styles/chat.css";
|
|
2
|
-
import { Answer as
|
|
3
|
-
import { Question as
|
|
4
|
-
import { SuggestedQuestions as
|
|
5
|
-
import { WelcomeMessage as
|
|
2
|
+
import { Answer as C } from "../answer/answer.js";
|
|
3
|
+
import { Question as L } from "../question/question.js";
|
|
4
|
+
import { SuggestedQuestions as N } from "../suggested-questions/suggested-questions.js";
|
|
5
|
+
import { WelcomeMessage as W } from "../welcome-message/welcome-message.js";
|
|
6
6
|
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
7
|
-
const
|
|
8
|
-
chat:
|
|
9
|
-
},
|
|
7
|
+
const b = "_chat_fj1ue_1", q = {
|
|
8
|
+
chat: b
|
|
9
|
+
}, H = ({
|
|
10
10
|
askSuggestedQuestion: c,
|
|
11
11
|
hasRequestInProgress: e,
|
|
12
12
|
isCitationsEnabled: m,
|
|
13
13
|
isMarkdownEnabled: s,
|
|
14
14
|
onCitationClick: h,
|
|
15
|
-
|
|
15
|
+
onAnswerCopy: p,
|
|
16
|
+
questions: d,
|
|
16
17
|
recordAction: o,
|
|
17
18
|
setAskSuggestedQuestion: r,
|
|
18
19
|
suggestedQuestions: a,
|
|
19
|
-
suggestedQuestionsRequestState:
|
|
20
|
-
useAnimation:
|
|
21
|
-
userInfo:
|
|
20
|
+
suggestedQuestionsRequestState: l,
|
|
21
|
+
useAnimation: f,
|
|
22
|
+
userInfo: j,
|
|
22
23
|
...i
|
|
23
24
|
}) => /* @__PURE__ */ n("div", {
|
|
24
|
-
className:
|
|
25
|
+
className: q.chat,
|
|
25
26
|
"data-testid": "content-answers-chat",
|
|
26
|
-
children: [/* @__PURE__ */ t(
|
|
27
|
+
children: [/* @__PURE__ */ t(W, {
|
|
27
28
|
...i
|
|
28
|
-
}), a !== void 0 && r !== void 0 && /* @__PURE__ */ t(
|
|
29
|
+
}), a !== void 0 && r !== void 0 && /* @__PURE__ */ t(N, {
|
|
29
30
|
askSuggestedQuestion: c,
|
|
30
31
|
isLoading: e,
|
|
31
32
|
recordAction: o,
|
|
32
33
|
setAskSuggestedQuestion: r,
|
|
33
34
|
suggestedQuestions: a,
|
|
34
|
-
suggestedQuestionsRequestState:
|
|
35
|
+
suggestedQuestionsRequestState: l
|
|
35
36
|
}), /* @__PURE__ */ t("ul", {
|
|
36
|
-
children:
|
|
37
|
-
answer:
|
|
38
|
-
citations:
|
|
39
|
-
id:
|
|
40
|
-
isCompleted:
|
|
41
|
-
isLoading:
|
|
42
|
-
error:
|
|
43
|
-
prompt:
|
|
37
|
+
children: d.map(({
|
|
38
|
+
answer: u,
|
|
39
|
+
citations: v,
|
|
40
|
+
id: x,
|
|
41
|
+
isCompleted: y,
|
|
42
|
+
isLoading: _,
|
|
43
|
+
error: T,
|
|
44
|
+
prompt: w
|
|
44
45
|
}) => /* @__PURE__ */ n("li", {
|
|
45
|
-
children: [/* @__PURE__ */ t(
|
|
46
|
-
prompt:
|
|
47
|
-
userInfo:
|
|
48
|
-
}), /* @__PURE__ */ t(
|
|
49
|
-
answer:
|
|
50
|
-
citations:
|
|
46
|
+
children: [/* @__PURE__ */ t(L, {
|
|
47
|
+
prompt: w,
|
|
48
|
+
userInfo: j
|
|
49
|
+
}), /* @__PURE__ */ t(C, {
|
|
50
|
+
answer: u,
|
|
51
|
+
citations: v,
|
|
51
52
|
contentType: i.contentType,
|
|
52
|
-
error:
|
|
53
|
+
error: T,
|
|
53
54
|
isCitationsEnabled: m,
|
|
54
|
-
isCompleted:
|
|
55
|
-
isLoading:
|
|
55
|
+
isCompleted: y,
|
|
56
|
+
isLoading: _,
|
|
56
57
|
isMarkdownEnabled: s,
|
|
58
|
+
onAnswerCopy: p,
|
|
57
59
|
onCitationClick: h,
|
|
58
60
|
recordAction: o,
|
|
59
|
-
useAnimation:
|
|
61
|
+
useAnimation: f
|
|
60
62
|
})]
|
|
61
|
-
},
|
|
63
|
+
}, x))
|
|
62
64
|
})]
|
|
63
65
|
});
|
|
64
66
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
H as Chat,
|
|
68
|
+
H as default
|
|
67
69
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/box-ai-content-answers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.8.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"remarkable": "^2.0.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@box/blueprint-web": "^7.
|
|
16
|
+
"@box/blueprint-web": "^7.34.1",
|
|
17
17
|
"@box/blueprint-web-assets": "^4.27.0",
|
|
18
18
|
"@box/storybook-utils": "^0.6.1",
|
|
19
19
|
"@testing-library/react": "^15.0.6",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"**/*.css"
|
|
53
53
|
],
|
|
54
54
|
"license": "SEE LICENSE IN LICENSE",
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "35b9456f5e326f5f66d7cb19ba4bb773bffc2cb8"
|
|
56
56
|
}
|
|
@@ -12,6 +12,8 @@ export type BoxAiContentAnswersProps = Omit<ContentProps, 'isErrorMessageShown'
|
|
|
12
12
|
onAgentEditorToggle?: (agent: AgentType) => void;
|
|
13
13
|
/** Callback function when citation button is clicked */
|
|
14
14
|
onCitationClick?: (fileId: CitationResponseRecordType, title: CitationResponseRecordType) => void;
|
|
15
|
+
/** Callback function when the user clicks on the answer copy button */
|
|
16
|
+
onAnswerCopy?: (answer: string) => void;
|
|
15
17
|
};
|
|
16
18
|
export declare const BoxAiContentAnswers: React.FC<BoxAiContentAnswersProps>;
|
|
17
19
|
export default BoxAiContentAnswers;
|
|
@@ -18,6 +18,8 @@ export interface AnswerProps {
|
|
|
18
18
|
isMarkdownEnabled?: boolean;
|
|
19
19
|
/** Callback function when citation button is clicked */
|
|
20
20
|
onCitationClick?: (fileId: CitationResponseRecordType, title: CitationResponseRecordType) => void;
|
|
21
|
+
/** Callback function when the user clicks on the answer copy button */
|
|
22
|
+
onAnswerCopy?: (answer: string) => void;
|
|
21
23
|
/** Callback function to handle logging events */
|
|
22
24
|
recordAction?: (params: RecordActionType) => void;
|
|
23
25
|
/** If keyframe animation for appearing answer should be applied */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type RecordActionType } from '../../types';
|
|
2
2
|
export type CopyButtonProps = {
|
|
3
3
|
answer?: string;
|
|
4
|
+
onAnswerCopy?: (answer: string) => void;
|
|
4
5
|
recordAction?: (params: RecordActionType) => void;
|
|
5
6
|
};
|
|
6
|
-
export declare const CopyButton: ({ answer, recordAction }: CopyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const CopyButton: ({ answer, onAnswerCopy, recordAction }: CopyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default CopyButton;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ChatProps } from '../../types';
|
|
2
|
-
export declare const Chat: ({ askSuggestedQuestion, hasRequestInProgress, isCitationsEnabled, isMarkdownEnabled, onCitationClick, questions, recordAction, setAskSuggestedQuestion, suggestedQuestions, suggestedQuestionsRequestState, useAnimation, userInfo, ...welcomeMessageProps }: ChatProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Chat: ({ askSuggestedQuestion, hasRequestInProgress, isCitationsEnabled, isMarkdownEnabled, onCitationClick, onAnswerCopy, questions, recordAction, setAskSuggestedQuestion, suggestedQuestions, suggestedQuestionsRequestState, useAnimation, userInfo, ...welcomeMessageProps }: ChatProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default Chat;
|
package/types/lib/types.d.ts
CHANGED
|
@@ -65,6 +65,8 @@ export type ChatProps = WelcomeMessageProps & {
|
|
|
65
65
|
hasRequestInProgress?: boolean;
|
|
66
66
|
/** Callback function when citation button is clicked */
|
|
67
67
|
onCitationClick?: (fileId: CitationResponseRecordType, title: CitationResponseRecordType) => void;
|
|
68
|
+
/** Callback function when the user clicks on the answer copy button */
|
|
69
|
+
onAnswerCopy?: (answer: string) => void;
|
|
68
70
|
};
|
|
69
71
|
export type ContentProps = Omit<ChatProps, 'handleScrollToBottom'> & {
|
|
70
72
|
/** Error state to show instead of the content */
|