@box/box-ai-agent-selector 0.30.1 → 0.31.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,27 +1,28 @@
|
|
1
|
-
import { useState as
|
2
|
-
import { BoxAiAgentSelector as
|
1
|
+
import { useState as I, useCallback as m, useEffect as f } from "react";
|
2
|
+
import { BoxAiAgentSelector as L } from "./box-ai-agent-selector.js";
|
3
3
|
import { LOGGER_BASE_CONFIG as a, LOGGER_TARGET as l } from "./constants.js";
|
4
4
|
import { ACTIONS as S } from "./contexts/actions.js";
|
5
|
-
import { useAgentsDispatch as
|
5
|
+
import { useAgentsDispatch as U, useAgents as x } from "./contexts/context.js";
|
6
6
|
import { R as r } from "../../chunks/types.js";
|
7
|
-
import { jsx as
|
8
|
-
function
|
7
|
+
import { jsx as D } from "react/jsx-runtime";
|
8
|
+
function k({
|
9
9
|
fetcher: u,
|
10
10
|
hostAppName: R,
|
11
11
|
onSelectAgent: i,
|
12
12
|
recordAction: T,
|
13
13
|
requestState: s,
|
14
14
|
disabled: G,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
onAgentsListOpen: C,
|
16
|
+
shouldHideAgentSelectorOnLoad: h,
|
17
|
+
triggerChipClassName: p,
|
18
|
+
contentClassName: O,
|
19
|
+
variant: N = "modal"
|
19
20
|
}) {
|
20
|
-
const e =
|
21
|
+
const e = U(), {
|
21
22
|
agents: A,
|
22
23
|
requestState: E,
|
23
24
|
selectedAgent: n
|
24
|
-
} =
|
25
|
+
} = x(), [d, _] = I(!1), o = m((t) => {
|
25
26
|
T && (t.data ?? (t.data = {}), t.data.hostAppName = R, T(t));
|
26
27
|
}, [R, T]), c = m(async () => {
|
27
28
|
e({
|
@@ -61,19 +62,20 @@ function j({
|
|
61
62
|
}));
|
62
63
|
}, [e, E, s]), f(() => {
|
63
64
|
i && i(n);
|
64
|
-
}, [i, n]),
|
65
|
+
}, [i, n]), h && !d || E === r.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(L, {
|
65
66
|
agents: A,
|
66
|
-
contentClassName:
|
67
|
+
contentClassName: O,
|
67
68
|
disabled: G,
|
69
|
+
onAgentsListOpen: C,
|
68
70
|
onErrorAction: c,
|
69
71
|
recordAction: o,
|
70
72
|
requestState: E,
|
71
73
|
selectedAgent: n,
|
72
|
-
triggerChipClassName:
|
73
|
-
variant:
|
74
|
+
triggerChipClassName: p,
|
75
|
+
variant: N
|
74
76
|
});
|
75
77
|
}
|
76
78
|
export {
|
77
|
-
|
78
|
-
|
79
|
+
k as BoxAiAgentSelectorWithApi,
|
80
|
+
k as default
|
79
81
|
};
|
@@ -1,52 +1,53 @@
|
|
1
|
-
import { useFullTextTooltip as
|
2
|
-
import { AlertBadge as
|
1
|
+
import { useFullTextTooltip as X, FilterChip as c, Popover as d, Tooltip as Z, Status as $, LoadingIndicator as q, SmallList as tt, Button as et } from "@box/blueprint-web";
|
2
|
+
import { AlertBadge as at } from "@box/blueprint-web-assets/icons/Fill";
|
3
3
|
import m from "clsx";
|
4
|
-
import { useState as
|
5
|
-
import { useIntl as
|
6
|
-
import { BoxAiAgent as
|
4
|
+
import { useState as B, useRef as rt, useEffect as ot, useCallback as f } from "react";
|
5
|
+
import { useIntl as nt } from "react-intl";
|
6
|
+
import { BoxAiAgent as st } from "./box-ai-agent.js";
|
7
7
|
import { LOGGER_BASE_CONFIG as E, LOGGER_ACTION_CLICK as S, LOGGER_TARGET as T } from "./constants.js";
|
8
|
-
import { ACTIONS as
|
9
|
-
import { useAgentsDispatch as
|
8
|
+
import { ACTIONS as it } from "./contexts/actions.js";
|
9
|
+
import { useAgentsDispatch as lt } from "./contexts/context.js";
|
10
10
|
import s from "./messages.js";
|
11
11
|
import { R } from "../../chunks/types.js";
|
12
12
|
import { jsx as e, jsxs as I } from "react/jsx-runtime";
|
13
|
-
import '../../styles/box-ai-agent-selector.css';const
|
14
|
-
agentSelector:
|
15
|
-
agentStatus:
|
16
|
-
agentLoader:
|
17
|
-
agentError:
|
18
|
-
triggerChip:
|
19
|
-
agentLabel:
|
20
|
-
dropdownIndicator:
|
21
|
-
sidebar:
|
22
|
-
agentListItemIcon:
|
23
|
-
agentListContainer:
|
24
|
-
agentListRetryButton:
|
13
|
+
import '../../styles/box-ai-agent-selector.css';const pt = "_agentSelector_prbzs_1", gt = "_agentStatus_prbzs_4", ct = "_agentLoader_prbzs_18", dt = "_agentError_prbzs_21", mt = "_triggerChip_prbzs_24", ft = "_agentLabel_prbzs_30", _t = "_dropdownIndicator_prbzs_36", Lt = "_sidebar_prbzs_51", ht = "_agentListItemIcon_prbzs_64", ut = "_agentListContainer_prbzs_69", Ct = "_agentListRetryButton_prbzs_99", a = {
|
14
|
+
agentSelector: pt,
|
15
|
+
agentStatus: gt,
|
16
|
+
agentLoader: ct,
|
17
|
+
agentError: dt,
|
18
|
+
triggerChip: mt,
|
19
|
+
agentLabel: ft,
|
20
|
+
dropdownIndicator: _t,
|
21
|
+
sidebar: Lt,
|
22
|
+
agentListItemIcon: ht,
|
23
|
+
agentListContainer: ut,
|
24
|
+
agentListRetryButton: Ct
|
25
25
|
};
|
26
|
-
function
|
26
|
+
function At({
|
27
27
|
agents: _,
|
28
|
-
contentClassName:
|
28
|
+
contentClassName: P,
|
29
29
|
onErrorAction: y,
|
30
30
|
recordAction: r,
|
31
31
|
requestState: L,
|
32
32
|
disabled: k,
|
33
|
+
onAgentsListOpen: N,
|
33
34
|
selectedAgent: i,
|
34
35
|
triggerChipClassName: D,
|
35
|
-
variant:
|
36
|
+
variant: K = "modal"
|
36
37
|
}) {
|
37
38
|
const {
|
38
39
|
formatMessage: o
|
39
|
-
} =
|
40
|
+
} = nt(), [l, p] = B(!1), n = L === R.ERROR, [v, h] = B(n), w = lt(), O = L === R.SUCCESS, u = L === R.IN_PROGRESS, G = o(s.selectAgent), M = o(s.defaultAgent);
|
40
41
|
let g = "";
|
41
|
-
O ? g = (i == null ? void 0 : i.name) ||
|
42
|
-
const
|
43
|
-
Wrapper:
|
44
|
-
wrapperProps:
|
45
|
-
} =
|
46
|
-
ref:
|
42
|
+
O ? g = (i == null ? void 0 : i.name) || G : n && (g = M);
|
43
|
+
const z = rt(null), {
|
44
|
+
Wrapper: F,
|
45
|
+
wrapperProps: U
|
46
|
+
} = X({
|
47
|
+
ref: z,
|
47
48
|
textValue: g
|
48
49
|
});
|
49
|
-
|
50
|
+
ot(() => {
|
50
51
|
l && r && r({
|
51
52
|
...E,
|
52
53
|
action: S,
|
@@ -54,73 +55,75 @@ function Gt({
|
|
54
55
|
});
|
55
56
|
}, [l, r]);
|
56
57
|
const C = f((t) => {
|
57
|
-
p(!1),
|
58
|
-
type:
|
58
|
+
p(!1), w({
|
59
|
+
type: it.SET_SELECTED_AGENT,
|
59
60
|
id: t.id
|
60
61
|
}), r && r({
|
61
62
|
...E,
|
62
63
|
action: S,
|
63
64
|
target: T.SELECT_AGENT
|
64
65
|
});
|
65
|
-
}, [
|
66
|
+
}, [w, r]), j = f(() => {
|
66
67
|
p(!1), y(), r && r({
|
67
68
|
...E,
|
68
69
|
action: S,
|
69
70
|
target: T.RETRY_LOADING_AGENTS
|
70
71
|
});
|
71
|
-
}, [y, r]),
|
72
|
+
}, [y, r]), Q = f((t) => {
|
72
73
|
if (t.key === "Escape" && (p(!1), t.stopPropagation()), t.key === " ") {
|
73
74
|
const A = t.target;
|
74
75
|
if (A) {
|
75
|
-
const
|
76
|
-
|
76
|
+
const H = A.getAttribute("data-key"), x = _.find((J) => J.id === H);
|
77
|
+
x && C(x);
|
77
78
|
}
|
78
79
|
}
|
79
|
-
}, [_, C]),
|
80
|
+
}, [_, C]), V = f((t) => h(n && n && !l && t ? t : !1), [n, l]), W = (t) => {
|
81
|
+
t && N && N(), p(t);
|
82
|
+
}, b = K === "sidebar" && a.sidebar, Y = (t) => {
|
80
83
|
(t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") && t.stopPropagation();
|
81
84
|
};
|
82
85
|
return /* @__PURE__ */ e(c.Group, {
|
83
86
|
className: m(a.agentSelector, D, b),
|
84
|
-
name:
|
85
|
-
onKeyDown:
|
87
|
+
name: G,
|
88
|
+
onKeyDown: Y,
|
86
89
|
type: "multiple",
|
87
90
|
children: /* @__PURE__ */ I(d.Root, {
|
88
91
|
modal: !1,
|
89
|
-
onOpenChange:
|
92
|
+
onOpenChange: W,
|
90
93
|
open: l,
|
91
|
-
children: [/* @__PURE__ */ e(
|
94
|
+
children: [/* @__PURE__ */ e(Z, {
|
92
95
|
content: o(s.errorTooltip),
|
93
|
-
onOpenChange:
|
94
|
-
open:
|
96
|
+
onOpenChange: V,
|
97
|
+
open: v,
|
95
98
|
side: "bottom",
|
96
99
|
variant: "error",
|
97
100
|
children: /* @__PURE__ */ e(d.Trigger, {
|
98
|
-
disabled: k ||
|
101
|
+
disabled: k || u,
|
99
102
|
children: /* @__PURE__ */ I(c.TriggerChip, {
|
100
103
|
className: a.triggerChip,
|
101
104
|
"data-target-id": "FilterChip.TriggerChip-agentSelectorTrigger",
|
102
105
|
value: "trigger-chip",
|
103
|
-
children: [/* @__PURE__ */ e(
|
106
|
+
children: [/* @__PURE__ */ e($, {
|
104
107
|
className: a.agentStatus,
|
105
108
|
colorIndex: 0,
|
106
109
|
text: o(s.agent)
|
107
|
-
}),
|
110
|
+
}), u && /* @__PURE__ */ e(q, {
|
108
111
|
"aria-label": o(s.loadingMessage),
|
109
112
|
className: a.agentLoader,
|
110
113
|
variant: "default"
|
111
|
-
}), n && /* @__PURE__ */ e(
|
114
|
+
}), n && /* @__PURE__ */ e(at, {
|
112
115
|
className: a.agentError,
|
113
116
|
height: "1rem",
|
114
117
|
role: "presentation",
|
115
118
|
width: "1rem"
|
116
|
-
}), /* @__PURE__ */ e(
|
117
|
-
...
|
119
|
+
}), /* @__PURE__ */ e(F, {
|
120
|
+
...U,
|
118
121
|
children: /* @__PURE__ */ e(c.Label, {
|
119
|
-
ref:
|
122
|
+
ref: z,
|
120
123
|
className: a.agentLabel,
|
121
124
|
children: g
|
122
125
|
})
|
123
|
-
}), !
|
126
|
+
}), !u && /* @__PURE__ */ e("div", {
|
124
127
|
className: a.dropdownIndicator,
|
125
128
|
children: /* @__PURE__ */ e(c.DropdownIndicator, {})
|
126
129
|
})]
|
@@ -129,19 +132,19 @@ function Gt({
|
|
129
132
|
}), /* @__PURE__ */ e(d.ContentContainer, {
|
130
133
|
align: "start",
|
131
134
|
className: m(a.agentListContainer, b),
|
132
|
-
onKeyDownCapture:
|
135
|
+
onKeyDownCapture: Q,
|
133
136
|
children: /* @__PURE__ */ I(d.MainContent, {
|
134
|
-
children: [O && /* @__PURE__ */ e(
|
137
|
+
children: [O && /* @__PURE__ */ e(tt, {
|
135
138
|
"aria-label": o(s.agentList),
|
136
|
-
className: m([a.agentList,
|
139
|
+
className: m([a.agentList, P]),
|
137
140
|
selectedKeys: [(i == null ? void 0 : i.id) || ""],
|
138
|
-
children: _.map((t) => /* @__PURE__ */ e(
|
141
|
+
children: _.map((t) => /* @__PURE__ */ e(st, {
|
139
142
|
agent: t,
|
140
143
|
onAction: () => C(t)
|
141
144
|
}, t.id))
|
142
|
-
}), n && /* @__PURE__ */ e(
|
145
|
+
}), n && /* @__PURE__ */ e(et, {
|
143
146
|
className: m(a.agentListRetryButton, b),
|
144
|
-
onClick:
|
147
|
+
onClick: j,
|
145
148
|
variant: "tertiary",
|
146
149
|
"data-target-id": "Button-errorMessage",
|
147
150
|
children: o(s.errorMessage)
|
@@ -152,6 +155,6 @@ function Gt({
|
|
152
155
|
});
|
153
156
|
}
|
154
157
|
export {
|
155
|
-
|
156
|
-
|
158
|
+
At as BoxAiAgentSelector,
|
159
|
+
At as default
|
157
160
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/box-ai-agent-selector",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.31.0",
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
5
5
|
"peerDependencies": {
|
6
6
|
"@box/blueprint-web": "^7.31.1",
|
@@ -47,5 +47,5 @@
|
|
47
47
|
"sideEffects": [
|
48
48
|
"**/*.css"
|
49
49
|
],
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "ec2e8664d2c77d849940a92b113f099ef18dd829"
|
51
51
|
}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { BoxAiAgentSelectorWithApiProps } from './types';
|
2
|
-
export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, disabled, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, variant, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
|
2
|
+
export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, disabled, onAgentsListOpen, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, variant, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
|
3
3
|
export default BoxAiAgentSelectorWithApi;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { BoxAiAgentSelectorProps } from './types';
|
2
|
-
export declare function BoxAiAgentSelector({ agents, contentClassName, onErrorAction, recordAction, requestState, disabled, selectedAgent, triggerChipClassName, variant, }: BoxAiAgentSelectorProps): import("react/jsx-runtime").JSX.Element;
|
2
|
+
export declare function BoxAiAgentSelector({ agents, contentClassName, onErrorAction, recordAction, requestState, disabled, onAgentsListOpen, selectedAgent, triggerChipClassName, variant, }: BoxAiAgentSelectorProps): import("react/jsx-runtime").JSX.Element;
|
3
3
|
export default BoxAiAgentSelector;
|
package/types/lib/types.d.ts
CHANGED
@@ -70,6 +70,8 @@ export interface BoxAiAgentSelectorWithApiProps {
|
|
70
70
|
* Renders the dropdown in disabled state.
|
71
71
|
*/
|
72
72
|
disabled?: boolean;
|
73
|
+
/** Callback function when user opens agents list */
|
74
|
+
onAgentsListOpen?: () => void;
|
73
75
|
/**
|
74
76
|
* Determines whether the agent selector component should remain hidden
|
75
77
|
* until the initial data fetch is complete.
|
@@ -104,6 +106,10 @@ export interface BoxAiAgentSelectorProps {
|
|
104
106
|
* Renders the dropdown in disabled state.
|
105
107
|
*/
|
106
108
|
disabled?: boolean;
|
109
|
+
/**
|
110
|
+
* Callback function triggered when agents list is opened
|
111
|
+
* */
|
112
|
+
onAgentsListOpen?: () => void;
|
107
113
|
/**
|
108
114
|
* The currently selected agent, or null if no agent is selected.
|
109
115
|
*/
|