@box/box-ai-content-answers 0.73.0 → 0.73.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/lib/components/footer/footer.js +97 -89
- package/package.json +3 -3
- package/styles/footer.css +1 -1
|
@@ -1,139 +1,147 @@
|
|
|
1
1
|
import "../../../../styles/footer.css";
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useBreakpoint as
|
|
6
|
-
import { ArrowUp as
|
|
7
|
-
import {
|
|
8
|
-
import { useAgents as
|
|
9
|
-
import {
|
|
10
|
-
import et from "
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
2
|
+
import V from "clsx";
|
|
3
|
+
import * as r from "react";
|
|
4
|
+
import { useIntl as Y } from "react-intl";
|
|
5
|
+
import { useBreakpoint as g, Breakpoint as q, Avatar as J, TextArea as Q, Button as Z } from "@box/blueprint-web";
|
|
6
|
+
import { ArrowUp as P } from "@box/blueprint-web-assets/icons/Fill";
|
|
7
|
+
import { ArrowUp as tt } from "@box/blueprint-web-assets/icons/Line";
|
|
8
|
+
import { useAgents as at } from "@box/box-ai-agent-selector";
|
|
9
|
+
import { useAgents as rt } from "../../contexts/AgentsContext.js";
|
|
10
|
+
import { FooterActions as et } from "./footer-actions.js";
|
|
11
|
+
import st from "../../messages.js";
|
|
12
|
+
import { getAIAgentConfig as X } from "../common/agentUtils.js";
|
|
13
|
+
import { isDebugModeTrigger as it, isEnterTrigger as ot } from "../common/keyInputUtils.js";
|
|
13
14
|
import { TEXT_AREA as o } from "./constants.js";
|
|
14
|
-
import
|
|
15
|
-
import { LOGGER_BASE_CONFIG as R, LOGGER_ACTION_CLICK as
|
|
16
|
-
import { jsxs as
|
|
17
|
-
const
|
|
18
|
-
questionInput:
|
|
19
|
-
avatar:
|
|
20
|
-
submitButton:
|
|
21
|
-
textArea:
|
|
22
|
-
sidebar:
|
|
23
|
-
submitButtonTooltip:
|
|
24
|
-
},
|
|
25
|
-
askSuggestedQuestion:
|
|
26
|
-
contentType:
|
|
27
|
-
enableDebugMode:
|
|
28
|
-
hasRequestInProgress:
|
|
15
|
+
import c from "./messages.js";
|
|
16
|
+
import { LOGGER_BASE_CONFIG as R, LOGGER_ACTION_CLICK as nt, LOGGER_ACTION_KEYPRESS as mt } from "../common/constants.js";
|
|
17
|
+
import { jsxs as H, jsx as f } from "react/jsx-runtime";
|
|
18
|
+
const ct = "_questionInput_1hh1s_1", ut = "_avatar_1hh1s_11", lt = "_submitButton_1hh1s_14", ft = "_textArea_1hh1s_17", pt = "_sidebar_1hh1s_25", _t = "_submitButtonTooltip_1hh1s_44", p = {
|
|
19
|
+
questionInput: ct,
|
|
20
|
+
avatar: ut,
|
|
21
|
+
submitButton: lt,
|
|
22
|
+
textArea: ft,
|
|
23
|
+
sidebar: pt,
|
|
24
|
+
submitButtonTooltip: _t
|
|
25
|
+
}, Xt = ({
|
|
26
|
+
askSuggestedQuestion: A,
|
|
27
|
+
contentType: k,
|
|
28
|
+
enableDebugMode: L = !1,
|
|
29
|
+
hasRequestInProgress: e,
|
|
29
30
|
isAgentSelectorEnabled: _,
|
|
30
|
-
isAIStudioAgentSelectorEnabled:
|
|
31
|
-
isDebugModeShown:
|
|
32
|
-
isStopResponseEnabled:
|
|
33
|
-
isStreamingEnabled:
|
|
34
|
-
lastQuestion:
|
|
35
|
-
onRetryQuestion:
|
|
31
|
+
isAIStudioAgentSelectorEnabled: h,
|
|
32
|
+
isDebugModeShown: M,
|
|
33
|
+
isStopResponseEnabled: y,
|
|
34
|
+
isStreamingEnabled: I,
|
|
35
|
+
lastQuestion: T,
|
|
36
|
+
onRetryQuestion: E,
|
|
36
37
|
onStopQuestion: F,
|
|
37
38
|
recordAction: s,
|
|
38
|
-
sendQuestion:
|
|
39
|
-
setAskSuggestedQuestion:
|
|
39
|
+
sendQuestion: B,
|
|
40
|
+
setAskSuggestedQuestion: G,
|
|
40
41
|
toggleDebugMode: n,
|
|
41
|
-
user:
|
|
42
|
-
variant:
|
|
42
|
+
user: N,
|
|
43
|
+
variant: K = "modal"
|
|
43
44
|
}) => {
|
|
44
|
-
const
|
|
45
|
+
const C = K === "sidebar", i = Y(), U = g(), a = /* @__PURE__ */ r.createRef(), d = U <= q.Medium || C, [u, O] = r.useState(!0), [$, w] = r.useState(!1), {
|
|
46
|
+
selectedAgent: b
|
|
47
|
+
} = rt(), {
|
|
45
48
|
selectedAgent: v
|
|
46
|
-
} =
|
|
47
|
-
selectedAgent: C
|
|
48
|
-
} = P(), x = e.useCallback(() => {
|
|
49
|
+
} = at(), x = r.useCallback(() => {
|
|
49
50
|
a.current && a.current.focus();
|
|
50
|
-
}, [a]),
|
|
51
|
+
}, [a]), j = r.useCallback(() => {
|
|
51
52
|
var m;
|
|
52
53
|
let t = ((m = a.current) == null ? void 0 : m.value) ?? "";
|
|
53
|
-
a.current && t.length > o.MAX_LENGTH && (a.current.value = t.slice(0, o.MAX_LENGTH), t = a.current.value),
|
|
54
|
-
}, [a]),
|
|
55
|
-
if (x(), !
|
|
54
|
+
a.current && t.length > o.MAX_LENGTH && (a.current.value = t.slice(0, o.MAX_LENGTH), t = a.current.value), w(t.length >= o.MAX_LENGTH), O(t.trim().length === 0);
|
|
55
|
+
}, [a]), l = r.useCallback(() => {
|
|
56
|
+
if (x(), !e && a.current) {
|
|
56
57
|
const t = {
|
|
57
58
|
prompt: a.current.value
|
|
58
59
|
};
|
|
59
60
|
if (t.prompt && t.prompt.trim()) {
|
|
60
|
-
const m =
|
|
61
|
-
|
|
61
|
+
const m = X(_, b, h, v);
|
|
62
|
+
B(t, m), a.current.value = "", O(!0), w(!1);
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
+
M && n && n();
|
|
64
65
|
}
|
|
65
|
-
}, [
|
|
66
|
-
t.preventDefault(), !
|
|
66
|
+
}, [v, x, e, a, h, _, M, b, B, n]), S = r.useCallback((t) => {
|
|
67
|
+
t.preventDefault(), !e && !u && s && s({
|
|
67
68
|
...R,
|
|
68
|
-
action:
|
|
69
|
+
action: nt,
|
|
69
70
|
target: "ask"
|
|
70
|
-
}),
|
|
71
|
-
}, [
|
|
72
|
-
|
|
71
|
+
}), l();
|
|
72
|
+
}, [e, u, s, l]), W = r.useCallback((t) => {
|
|
73
|
+
L && n && it(t) && n(), ot(t) && (t.preventDefault(), !e && !u && s && s({
|
|
73
74
|
...R,
|
|
74
|
-
action:
|
|
75
|
+
action: mt,
|
|
75
76
|
target: "ask"
|
|
76
|
-
}),
|
|
77
|
-
}, [
|
|
78
|
-
const m =
|
|
79
|
-
|
|
80
|
-
}, [
|
|
81
|
-
|
|
77
|
+
}), l());
|
|
78
|
+
}, [L, e, u, s, l, n]), z = r.useCallback((t) => {
|
|
79
|
+
const m = X(_, b, h, v);
|
|
80
|
+
E(t, m);
|
|
81
|
+
}, [v, h, _, E, b]);
|
|
82
|
+
r.useEffect(() => {
|
|
82
83
|
queueMicrotask(x);
|
|
83
|
-
}, []),
|
|
84
|
-
|
|
85
|
-
}, [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
}, []), r.useEffect(() => {
|
|
85
|
+
A && a.current && !e && G && (a.current.value = A, l(), G(null));
|
|
86
|
+
}, [A]);
|
|
87
|
+
function D() {
|
|
88
|
+
if (C)
|
|
89
|
+
return P;
|
|
90
|
+
if (d)
|
|
91
|
+
return tt;
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ H("div", {
|
|
94
|
+
children: [T && /* @__PURE__ */ f(et, {
|
|
95
|
+
isStopResponseEnabled: y,
|
|
96
|
+
isStreamingEnabled: I,
|
|
97
|
+
lastQuestion: T,
|
|
98
|
+
onRetryQuestion: z,
|
|
91
99
|
onStopQuestion: F,
|
|
92
100
|
recordAction: s
|
|
93
|
-
}), /* @__PURE__ */
|
|
94
|
-
className:
|
|
95
|
-
children: [!
|
|
101
|
+
}), /* @__PURE__ */ H("div", {
|
|
102
|
+
className: V(p.questionInput, C && p.sidebar),
|
|
103
|
+
children: [!d && /* @__PURE__ */ f("div", {
|
|
96
104
|
className: p.avatar,
|
|
97
105
|
"data-testid": "content-answers-question-input-avatar",
|
|
98
106
|
children: /* @__PURE__ */ f(J, {
|
|
99
|
-
alt: i.formatMessage(
|
|
107
|
+
alt: i.formatMessage(st.userAvatar),
|
|
100
108
|
colorIndex: 0,
|
|
101
|
-
src:
|
|
102
|
-
text:
|
|
109
|
+
src: N.avatarURL,
|
|
110
|
+
text: N.name.charAt(0)
|
|
103
111
|
})
|
|
104
112
|
}), /* @__PURE__ */ f(Q, {
|
|
105
113
|
ref: a,
|
|
106
114
|
className: p.textArea,
|
|
107
115
|
"data-testid": "content-answers-question-input",
|
|
108
|
-
error:
|
|
116
|
+
error: $ && i.formatMessage(c.maxCharactersReachedError, {
|
|
109
117
|
characterLimit: o.MAX_LENGTH
|
|
110
118
|
}),
|
|
111
119
|
hideLabel: !0,
|
|
112
|
-
label: i.formatMessage(
|
|
113
|
-
type:
|
|
120
|
+
label: i.formatMessage(c.askQuestionPlaceholder, {
|
|
121
|
+
type: k
|
|
114
122
|
}),
|
|
115
123
|
maxLength: o.MAX_LENGTH,
|
|
116
|
-
maxRows:
|
|
117
|
-
onChange:
|
|
124
|
+
maxRows: d ? o.MAX_ROWS_MOBILE : o.MAX_ROWS,
|
|
125
|
+
onChange: j,
|
|
118
126
|
onKeyDown: W,
|
|
119
|
-
placeholder: i.formatMessage(
|
|
120
|
-
type:
|
|
127
|
+
placeholder: i.formatMessage(c.askQuestionPlaceholder, {
|
|
128
|
+
type: k
|
|
121
129
|
})
|
|
122
130
|
}), /* @__PURE__ */ f(Z, {
|
|
123
|
-
"aria-label": i.formatMessage(
|
|
131
|
+
"aria-label": i.formatMessage(c.ask),
|
|
124
132
|
className: p.submitButton,
|
|
125
133
|
"data-testid": "content-answers-submit-button",
|
|
126
|
-
disabled:
|
|
127
|
-
icon:
|
|
128
|
-
loading:
|
|
129
|
-
loadingAriaLabel: i.formatMessage(
|
|
130
|
-
onClick:
|
|
134
|
+
disabled: u || e,
|
|
135
|
+
icon: D(),
|
|
136
|
+
loading: e,
|
|
137
|
+
loadingAriaLabel: i.formatMessage(c.askDisabledTooltip),
|
|
138
|
+
onClick: S,
|
|
131
139
|
size: "large",
|
|
132
|
-
children:
|
|
140
|
+
children: d ? void 0 : i.formatMessage(c.ask)
|
|
133
141
|
})]
|
|
134
142
|
})]
|
|
135
143
|
});
|
|
136
144
|
};
|
|
137
145
|
export {
|
|
138
|
-
|
|
146
|
+
Xt as Footer
|
|
139
147
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/box-ai-content-answers",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.8.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@box/blueprint-web": "^9.3.1",
|
|
18
18
|
"@box/blueprint-web-assets": "^4.30.1",
|
|
19
|
-
"@box/box-ai-agent-selector": "^0.17.
|
|
19
|
+
"@box/box-ai-agent-selector": "^0.17.14",
|
|
20
20
|
"@box/storybook-utils": "^0.8.0",
|
|
21
21
|
"@testing-library/react": "^15.0.6",
|
|
22
22
|
"react": "^18.3.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"**/*.css"
|
|
55
55
|
],
|
|
56
56
|
"license": "SEE LICENSE IN LICENSE",
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "a5de5c04371f4e8fcf9ea7471aba3e6aaa05f704"
|
|
58
58
|
}
|
package/styles/footer.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._questionInput_1hh1s_1{position:relative;z-index:1;display:flex;flex:1 1 auto;align-items:end;padding:1rem 1.25rem;background:#fff;box-shadow:0 0 8px #0000000d,0 -1px #e8e8e8}._questionInput_1hh1s_1 ._avatar_1hh1s_11{margin-bottom:.25rem}._questionInput_1hh1s_1 ._submitButton_1hh1s_14{margin:0}._questionInput_1hh1s_1 ._textArea_1hh1s_17{gap:0;width:100%;margin:0 1rem}._questionInput_1hh1s_1 ._textArea_1hh1s_17 textarea{border:none}._questionInput_1hh1s_1._sidebar_1hh1s_25{padding:1rem}._questionInput_1hh1s_1._sidebar_1hh1s_25 div{height:2.5rem}._questionInput_1hh1s_1._sidebar_1hh1s_25 ._textArea_1hh1s_17{margin:0 .75rem 0 0}._questionInput_1hh1s_1._sidebar_1hh1s_25 ._textArea_1hh1s_17 div{height:100%;align-items:center}._questionInput_1hh1s_1._sidebar_1hh1s_25 ._textArea_1hh1s_17 textarea{width:100%;padding-top:.75rem;padding-bottom:.75rem}._submitButtonTooltip_1hh1s_44{text-align:center}@media (max-width: 767px){._questionInput_1hh1s_1{padding:1rem}._questionInput_1hh1s_1 ._textArea_1hh1s_17{margin:0 .75rem 0 0}}
|