@box/box-ai-content-answers 0.93.1 → 0.94.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.
@@ -1,151 +1,157 @@
1
- import { useBreakpoint as D, Breakpoint as I, Modal as c, Text as K } from "@box/blueprint-web";
2
- import { ArrowsCollapse as $ } from "@box/blueprint-web-assets/icons/Fill";
3
- import { BoxAiLogo as J } from "@box/blueprint-web-assets/icons/Logo";
4
- import { Size8 as L } from "@box/blueprint-web-assets/tokens/tokens";
5
- import { BoxAiAgentSelectorWithApi as V, AgentsProvider as X } from "@box/box-ai-agent-selector";
6
- import l from "react";
7
- import { useIntl as Y } from "react-intl";
8
- import { BoxAiContentAnswers as Z } from "../../box-ai-content-answers.js";
9
- import { AgentsProvider as ee } from "../../contexts/AgentsContext.js";
10
- import { A as oe, R as te } from "../../../../chunks/types.js";
11
- import { AgentSelector as se } from "../agents/agent-selector.js";
12
- import { LOGGER_BASE_CONFIG as C, LOGGER_ACTION_CLICK as ae } from "../common/constants.js";
13
- import { s as t, C as re } from "../../../../chunks/clear-conversation-button.js";
14
- import le from "./hooks/useStopPropagationOnEsc.js";
15
- import p from "./messages.js";
1
+ import { useBreakpoint as V, Breakpoint as X, Modal as i, Text as Y, TooltipProvider as Z, Tooltip as ee } from "@box/blueprint-web";
2
+ import { ArrowsCollapse as oe } from "@box/blueprint-web-assets/icons/Fill";
3
+ import { BoxAiLogo as te } from "@box/blueprint-web-assets/icons/Logo";
4
+ import { Size8 as x } from "@box/blueprint-web-assets/tokens/tokens";
5
+ import { BoxAiAgentSelectorWithApi as se, AgentsProvider as ae } from "@box/box-ai-agent-selector";
6
+ import { useState as re, useCallback as B, useEffect as C } from "react";
7
+ import { useIntl as le } from "react-intl";
8
+ import { BoxAiContentAnswers as ne } from "../../box-ai-content-answers.js";
9
+ import { AgentsProvider as ie } from "../../contexts/AgentsContext.js";
10
+ import { A as ce, R as de } from "../../../../chunks/types.js";
11
+ import { AgentSelector as me } from "../agents/agent-selector.js";
12
+ import { LOGGER_BASE_CONFIG as p, LOGGER_ACTION_CLICK as fe } from "../common/constants.js";
13
+ import { s as t, C as ge } from "../../../../chunks/clear-conversation-button.js";
14
+ import Ce from "./hooks/useStopPropagationOnEsc.js";
15
+ import u from "./messages.js";
16
16
  import { jsxs as h, jsx as e } from "react/jsx-runtime";
17
- const Ne = ({
18
- children: _,
19
- getAIStudioAgents: A,
20
- hasCustomSuggestedQuestions: x,
21
- hostAppName: d,
22
- isAgentSelectorEnabled: M,
23
- isAIStudioAgentSelectorEnabled: m,
17
+ const _e = ({
18
+ children: S,
19
+ getAIStudioAgents: M,
20
+ hasCustomSuggestedQuestions: _,
21
+ hostAppName: c,
22
+ isAgentSelectorEnabled: T,
23
+ isAIStudioAgentSelectorEnabled: d,
24
24
  isDebugModeEnabled: k,
25
- isResetChatEnabled: B,
26
- isStopResponseEnabled: S = !1,
27
- itemSize: T,
28
- extension: O,
29
- onClearAction: R,
30
- onSelectAgent: G,
25
+ isResetChatEnabled: P,
26
+ isStopResponseEnabled: G = !1,
27
+ itemSize: A,
28
+ extension: v,
29
+ onClearAction: O,
30
+ onSelectAgent: q,
31
31
  recordAction: a,
32
- shouldRenderProviders: P = !0,
33
- stopPropagationOnEsc: q,
34
- variant: f = "closable",
35
- items: n,
36
- parentItem: i,
37
- ...H
32
+ shouldRenderProviders: H = !0,
33
+ stopPropagationOnEsc: z,
34
+ variant: F = "closable",
35
+ items: l,
36
+ parentItem: n,
37
+ ...I
38
38
  }) => {
39
- var v, w;
39
+ var b, E;
40
40
  const {
41
- open: E,
42
- defaultOpen: z,
43
- onOpenChange: F,
44
- modal: j,
41
+ open: N,
42
+ defaultOpen: j,
43
+ onOpenChange: Q,
44
+ modal: U,
45
45
  ...r
46
- } = H, g = Y(), Q = D() <= I.Medium;
47
- le(q, E);
48
- const u = (w = (v = r == null ? void 0 : r.questions) == null ? void 0 : v[r.questions.length - 1]) == null ? void 0 : w.error, [U, N] = l.useState(!1), s = l.useCallback((o) => {
49
- a && (o.data ?? (o.data = {}), o.data.hostAppName = d, a(o));
50
- }, [d, a]);
51
- l.useEffect(() => {
52
- n || s({
53
- ...C,
46
+ } = I, m = le(), W = V() <= X.Medium;
47
+ Ce(z, N);
48
+ const f = (E = (b = r == null ? void 0 : r.questions) == null ? void 0 : b[r.questions.length - 1]) == null ? void 0 : E.error, [y, R] = re(!1), g = F === "collapsible", w = g ? u.collapseModalAriaLabel : u.closeModalAriaLabel, D = g ? "Modal.Close-collapseContentAnswersModal" : "Modal.Close-closeContentAnswersModal", K = g ? oe : void 0, s = B((o) => {
49
+ a && (o.data ?? (o.data = {}), o.data.hostAppName = c, a(o));
50
+ }, [c, a]);
51
+ C(() => {
52
+ l || s({
53
+ ...p,
54
54
  target: "loaded",
55
55
  data: {
56
- fileSize: T,
57
- fileType: O
56
+ fileSize: A,
57
+ fileType: v
58
58
  }
59
59
  });
60
- }, [s, O, T, n, a]), l.useEffect(() => {
61
- n && s({
62
- ...C,
60
+ }, [s, v, A, l, a]), C(() => {
61
+ l && s({
62
+ ...p,
63
63
  target: "loaded",
64
64
  data: {
65
- parentItemType: i == null ? void 0 : i.type,
66
- items: n.map((o) => ({
65
+ parentItemType: n == null ? void 0 : n.type,
66
+ items: l.map((o) => ({
67
67
  status: o.status,
68
68
  fileType: o.fileType
69
69
  }))
70
70
  }
71
71
  });
72
- }, [s, i, a]), l.useEffect(() => {
73
- u && u === oe.AGENT_NOT_FOUND && N(!0);
74
- }, [u]);
75
- const W = () => {
76
- R && (R(), s({
77
- ...C,
78
- action: ae,
72
+ }, [s, n, a]), C(() => {
73
+ f && f === ce.AGENT_NOT_FOUND && R(!0);
74
+ }, [f]);
75
+ const $ = () => {
76
+ O && (O(), s({
77
+ ...p,
78
+ action: fe,
79
79
  target: "clearChat"
80
80
  }));
81
- }, y = l.useCallback(async () => (N(!1), A()), [A]), b = /* @__PURE__ */ h(c, {
82
- defaultOpen: z,
83
- modal: j,
84
- onOpenChange: F,
85
- open: E,
86
- children: [/* @__PURE__ */ e(c.Trigger, {
87
- children: _
88
- }), /* @__PURE__ */ h(c.Content, {
81
+ }, J = B(async () => (R(!1), M()), [M]), L = /* @__PURE__ */ h(i, {
82
+ defaultOpen: j,
83
+ modal: U,
84
+ onOpenChange: Q,
85
+ open: N,
86
+ children: [/* @__PURE__ */ e(i.Trigger, {
87
+ children: S
88
+ }), /* @__PURE__ */ h(i.Content, {
89
89
  className: t.contentAnswersModal,
90
90
  "data-testid": "content-answers-modal",
91
91
  size: "xlarge",
92
- children: [/* @__PURE__ */ e(c.Header, {
92
+ children: [/* @__PURE__ */ e(i.Header, {
93
93
  className: t.modalHeaderContainer,
94
94
  children: /* @__PURE__ */ h("div", {
95
95
  className: t.modalHeader,
96
- children: [!Q && /* @__PURE__ */ e(J, {
96
+ children: [!W && /* @__PURE__ */ e(te, {
97
97
  className: t.BoxAIIconColor,
98
98
  "data-testid": "content-answers-icon-color",
99
- height: L,
100
- width: L
101
- }), /* @__PURE__ */ e(K, {
99
+ height: x,
100
+ width: x
101
+ }), /* @__PURE__ */ e(Y, {
102
102
  as: "span",
103
103
  variant: "titleMedium",
104
- children: g.formatMessage(p.contentAnswersTitle)
105
- }), !m && M && /* @__PURE__ */ e(se, {
106
- onSelectAgent: G,
104
+ children: m.formatMessage(u.contentAnswersTitle)
105
+ }), !d && T && /* @__PURE__ */ e(me, {
106
+ onSelectAgent: q,
107
107
  recordAction: s
108
- }), m && /* @__PURE__ */ e(V, {
108
+ }), d && /* @__PURE__ */ e(se, {
109
109
  contentClassName: t.agentSelectorContent,
110
110
  disabled: r.hasRequestInProgress,
111
- fetcher: y,
112
- hostAppName: d,
111
+ fetcher: J,
112
+ hostAppName: c,
113
113
  recordAction: a,
114
- requestState: U ? te.ERROR : void 0,
114
+ requestState: y ? de.ERROR : void 0,
115
115
  shouldHideAgentSelectorOnLoad: !0,
116
116
  triggerChipClassName: t.agentSelectorTrigger
117
117
  })]
118
118
  })
119
- }), /* @__PURE__ */ e(Z, {
119
+ }), /* @__PURE__ */ e(ne, {
120
120
  className: t.boxAiContentAnswers,
121
- hasCustomSuggestedQuestions: x,
122
- hostAppName: d,
123
- isAgentSelectorEnabled: !m && M,
124
- isAIStudioAgentSelectorEnabled: m,
121
+ hasCustomSuggestedQuestions: _,
122
+ hostAppName: c,
123
+ isAgentSelectorEnabled: !d && T,
124
+ isAIStudioAgentSelectorEnabled: d,
125
125
  isDebugModeEnabled: k,
126
- isStopResponseEnabled: S,
127
- items: n,
128
- parentItem: i,
126
+ isStopResponseEnabled: G,
127
+ items: l,
128
+ parentItem: n,
129
129
  recordAction: s,
130
130
  ...r
131
- }), B && /* @__PURE__ */ e(re, {
132
- onClick: W
133
- }), /* @__PURE__ */ e(c.Close, {
134
- "aria-label": f === "collapsible" ? g.formatMessage(p.collapseModalAriaLabel) : g.formatMessage(p.closeModalAriaLabel),
135
- className: t["modal-close-button"],
136
- "data-target-id": f === "collapsible" ? "Modal.Close-collapseContentAnswersModal" : "Modal.Close-closeContentAnswersModal",
137
- icon: f === "collapsible" ? $ : void 0,
138
- size: "small"
131
+ }), P && /* @__PURE__ */ e(ge, {
132
+ onClick: $
133
+ }), /* @__PURE__ */ e(Z, {
134
+ children: /* @__PURE__ */ e(ee, {
135
+ content: m.formatMessage(w),
136
+ "data-testid": "content-answers-close-modal-tooltip",
137
+ children: /* @__PURE__ */ e(i.Close, {
138
+ "aria-label": m.formatMessage(w),
139
+ className: t["modal-close-button"],
140
+ "data-target-id": D,
141
+ icon: K,
142
+ size: "small"
143
+ })
144
+ })
139
145
  })]
140
146
  })]
141
147
  });
142
- return P ? /* @__PURE__ */ e(X, {
143
- children: /* @__PURE__ */ e(ee, {
144
- children: b
148
+ return H ? /* @__PURE__ */ e(ae, {
149
+ children: /* @__PURE__ */ e(ie, {
150
+ children: L
145
151
  })
146
- }) : b;
152
+ }) : L;
147
153
  };
148
154
  export {
149
- Ne as IntelligenceModal,
150
- Ne as default
155
+ _e as IntelligenceModal,
156
+ _e as default
151
157
  };
@@ -1,37 +1,43 @@
1
- import { FilterChip as e } from "@box/blueprint-web";
2
- import l from "clsx";
3
- import { jsx as t } from "react/jsx-runtime";
4
- import '../../../../styles/suggestions.css';const c = "_suggestions_z97no_1", u = "_sidebar_z97no_6", m = "_suggestion_z97no_1", n = {
1
+ import { FilterChip as o } from "@box/blueprint-web";
2
+ import p from "clsx";
3
+ import { jsx as e } from "react/jsx-runtime";
4
+ import '../../../../styles/suggestions.css';const c = "_suggestions_z97no_1", u = "_sidebar_z97no_6", m = "_suggestion_z97no_1", t = {
5
5
  suggestions: c,
6
6
  sidebar: u,
7
7
  suggestion: m
8
- }, h = ({
9
- askSuggestedQuestion: i,
10
- isLoading: a,
11
- onSuggestedQuestionClick: r,
8
+ }, y = ({
9
+ askSuggestedQuestion: r,
10
+ isLoading: i,
11
+ onSuggestedQuestionClick: a,
12
12
  suggestedQuestions: g,
13
13
  variant: d = "modal"
14
- }) => /* @__PURE__ */ t(e.Group, {
15
- className: l(n.suggestions, d === "sidebar" && n.sidebar),
16
- "data-testid": "content-answers-suggested-questions",
17
- name: "Singleselect SuggestedQuestions",
18
- type: "single",
19
- value: i,
20
- children: g.map((s) => {
21
- const o = s.label || s.prompt;
22
- return /* @__PURE__ */ t(e.ChipButton, {
23
- className: n.suggestion,
24
- "data-testid": `content-answers-${s.id}`,
25
- disabled: a,
26
- onClick: () => r(s.prompt),
27
- value: o,
28
- children: /* @__PURE__ */ t(e.Label, {
29
- children: o
30
- })
31
- }, s.id);
32
- })
33
- });
14
+ }) => {
15
+ const l = (s) => {
16
+ (s.key === "ArrowUp" || s.key === "ArrowDown" || s.key === "ArrowLeft" || s.key === "ArrowRight") && s.stopPropagation();
17
+ };
18
+ return /* @__PURE__ */ e(o.Group, {
19
+ className: p(t.suggestions, d === "sidebar" && t.sidebar),
20
+ "data-testid": "content-answers-suggested-questions",
21
+ name: "Singleselect SuggestedQuestions",
22
+ onKeyDown: l,
23
+ type: "single",
24
+ value: r,
25
+ children: g.map((s) => {
26
+ const n = s.label || s.prompt;
27
+ return /* @__PURE__ */ e(o.ChipButton, {
28
+ className: t.suggestion,
29
+ "data-testid": `content-answers-${s.id}`,
30
+ disabled: i,
31
+ onClick: () => a(s.prompt),
32
+ value: n,
33
+ children: /* @__PURE__ */ e(o.Label, {
34
+ children: n
35
+ })
36
+ }, s.id);
37
+ })
38
+ });
39
+ };
34
40
  export {
35
- h as Suggestions,
36
- h as default
41
+ y as Suggestions,
42
+ y as default
37
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.93.1",
3
+ "version": "0.94.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",
@@ -18,7 +18,7 @@
18
18
  "@box/babel-plugin-target-attributes": "1.3.0",
19
19
  "@box/blueprint-web": "^9.18.0",
20
20
  "@box/blueprint-web-assets": "^4.33.1",
21
- "@box/box-ai-agent-selector": "^0.26.1",
21
+ "@box/box-ai-agent-selector": "^0.26.2",
22
22
  "@box/item-icon": "^0.9.82",
23
23
  "@box/storybook-utils": "^0.8.3",
24
24
  "@testing-library/react": "^15.0.6",
@@ -57,5 +57,5 @@
57
57
  "**/*.css"
58
58
  ],
59
59
  "license": "SEE LICENSE IN LICENSE",
60
- "gitHead": "a2056d2f579edc055a85156efe0e93414840445e"
60
+ "gitHead": "fae9c2ce73dd9a0d9ca6827dcd7a5264441041d4"
61
61
  }