@box/box-ai-agent-selector 0.19.2 → 0.19.4
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/box-ai-agent-selector.js +109 -108
- package/package.json +5 -5
@@ -1,144 +1,145 @@
|
|
1
1
|
import "../../styles/box-ai-agent-selector.css";
|
2
|
-
import { useFullTextTooltip as
|
3
|
-
import { AlertBadge as
|
2
|
+
import { useFullTextTooltip as W, FilterChip as p, Popover as d, Tooltip as Y, Status as z, LoadingIndicator as H, SmallList as J, Button as X } from "@box/blueprint-web";
|
3
|
+
import { AlertBadge as Z } from "@box/blueprint-web-assets/icons/Fill";
|
4
4
|
import m from "clsx";
|
5
|
-
import { useState as
|
6
|
-
import { useIntl as
|
7
|
-
import { BoxAiAgent as
|
8
|
-
import { LOGGER_BASE_CONFIG as
|
9
|
-
import { ACTIONS as
|
10
|
-
import { useAgentsDispatch as
|
11
|
-
import
|
12
|
-
import { R
|
13
|
-
import { jsx as t, jsxs as
|
14
|
-
const
|
15
|
-
agentSelector:
|
16
|
-
agentStatus:
|
17
|
-
agentLoader:
|
18
|
-
agentError:
|
19
|
-
triggerChip:
|
20
|
-
agentLabel:
|
21
|
-
dropdownIndicator:
|
22
|
-
sidebar:
|
23
|
-
agentListItemIcon:
|
24
|
-
agentListContainer:
|
25
|
-
agentListRetryButton:
|
5
|
+
import { useState as w, useRef as $, useEffect as tt, useCallback as _ } from "react";
|
6
|
+
import { useIntl as et } from "react-intl";
|
7
|
+
import { BoxAiAgent as at } from "./box-ai-agent.js";
|
8
|
+
import { LOGGER_BASE_CONFIG as S, LOGGER_ACTION_CLICK as T, LOGGER_TARGET as I } from "./constants.js";
|
9
|
+
import { ACTIONS as nt } from "./contexts/actions.js";
|
10
|
+
import { useAgentsDispatch as ot } from "./contexts/context.js";
|
11
|
+
import r from "./messages.js";
|
12
|
+
import { R } from "../../chunks/types.js";
|
13
|
+
import { jsx as t, jsxs as b } from "react/jsx-runtime";
|
14
|
+
const it = "_agentSelector_ak9iq_1", rt = "_agentStatus_ak9iq_4", st = "_agentLoader_ak9iq_18", lt = "_agentError_ak9iq_21", ct = "_triggerChip_ak9iq_24", gt = "_agentLabel_ak9iq_29", pt = "_dropdownIndicator_ak9iq_35", dt = "_sidebar_ak9iq_47", mt = "_agentListItemIcon_ak9iq_66", _t = "_agentListContainer_ak9iq_71", ft = "_agentListRetryButton_ak9iq_90", a = {
|
15
|
+
agentSelector: it,
|
16
|
+
agentStatus: rt,
|
17
|
+
agentLoader: st,
|
18
|
+
agentError: lt,
|
19
|
+
triggerChip: ct,
|
20
|
+
agentLabel: gt,
|
21
|
+
dropdownIndicator: pt,
|
22
|
+
sidebar: dt,
|
23
|
+
agentListItemIcon: mt,
|
24
|
+
agentListContainer: _t,
|
25
|
+
agentListRetryButton: ft
|
26
26
|
};
|
27
|
-
function
|
28
|
-
agents:
|
29
|
-
contentClassName:
|
30
|
-
onErrorAction:
|
27
|
+
function yt({
|
28
|
+
agents: f,
|
29
|
+
contentClassName: B,
|
30
|
+
onErrorAction: N,
|
31
31
|
recordAction: n,
|
32
|
-
requestState:
|
33
|
-
selectedAgent:
|
34
|
-
triggerChipClassName:
|
35
|
-
variant:
|
32
|
+
requestState: L,
|
33
|
+
selectedAgent: s,
|
34
|
+
triggerChipClassName: v,
|
35
|
+
variant: A = "modal"
|
36
36
|
}) {
|
37
37
|
const {
|
38
38
|
formatMessage: o
|
39
|
-
} =
|
39
|
+
} = et(), [l, c] = w(!1), i = L === R.ERROR, [P, u] = w(i), O = ot(), k = L === R.SUCCESS, E = L === R.IN_PROGRESS, y = o(r.selectAgent), D = o(r.defaultAgent);
|
40
40
|
let g = "";
|
41
|
-
|
42
|
-
const G =
|
43
|
-
Wrapper:
|
44
|
-
wrapperProps:
|
45
|
-
} =
|
41
|
+
k ? g = (s == null ? void 0 : s.name) || y : i && (g = D);
|
42
|
+
const G = $(null), {
|
43
|
+
Wrapper: K,
|
44
|
+
wrapperProps: M
|
45
|
+
} = W({
|
46
46
|
ref: G,
|
47
47
|
textValue: g
|
48
48
|
});
|
49
|
-
|
50
|
-
|
51
|
-
...
|
52
|
-
action:
|
53
|
-
target:
|
49
|
+
tt(() => {
|
50
|
+
l && n && n({
|
51
|
+
...S,
|
52
|
+
action: T,
|
53
|
+
target: I.OPEN_SELECTOR
|
54
54
|
});
|
55
|
-
}, [
|
56
|
-
const
|
57
|
-
|
58
|
-
type:
|
59
|
-
id:
|
55
|
+
}, [l, n]);
|
56
|
+
const h = _((e) => {
|
57
|
+
c(!1), O({
|
58
|
+
type: nt.SET_SELECTED_AGENT,
|
59
|
+
id: e.id
|
60
60
|
}), n && n({
|
61
|
-
...
|
62
|
-
action:
|
63
|
-
target:
|
61
|
+
...S,
|
62
|
+
action: T,
|
63
|
+
target: I.SELECT_AGENT
|
64
64
|
});
|
65
|
-
}, [
|
66
|
-
|
67
|
-
...
|
68
|
-
action:
|
69
|
-
target:
|
65
|
+
}, [O, n]), F = _(() => {
|
66
|
+
c(!1), N(), n && n({
|
67
|
+
...S,
|
68
|
+
action: T,
|
69
|
+
target: I.RETRY_LOADING_AGENTS
|
70
70
|
});
|
71
|
-
}, [
|
72
|
-
if (
|
73
|
-
const
|
74
|
-
if (
|
75
|
-
const
|
76
|
-
|
71
|
+
}, [N, n]), j = _((e) => {
|
72
|
+
if (e.key === "Escape" && (c(!1), e.stopPropagation()), e.key === " ") {
|
73
|
+
const x = e.target;
|
74
|
+
if (x) {
|
75
|
+
const Q = x.getAttribute("data-key"), q = f.find((V) => V.id === Q);
|
76
|
+
q && h(q);
|
77
77
|
}
|
78
78
|
}
|
79
|
-
}, [_,
|
80
|
-
return /* @__PURE__ */ t(
|
81
|
-
className: m(
|
82
|
-
name:
|
79
|
+
}, [f, h]), U = _((e) => u(i && i && !l && e ? e : !1), [i, l]), C = A === "sidebar" && a.sidebar;
|
80
|
+
return /* @__PURE__ */ t(p.Group, {
|
81
|
+
className: m(a.agentSelector, v, C),
|
82
|
+
name: y,
|
83
83
|
type: "multiple",
|
84
|
-
children: /* @__PURE__ */
|
84
|
+
children: /* @__PURE__ */ b(d.Root, {
|
85
85
|
modal: !1,
|
86
|
-
onOpenChange:
|
87
|
-
open:
|
88
|
-
children: [/* @__PURE__ */ t(
|
89
|
-
content: o(
|
90
|
-
|
86
|
+
onOpenChange: c,
|
87
|
+
open: l,
|
88
|
+
children: [/* @__PURE__ */ t(Y, {
|
89
|
+
content: o(r.errorTooltip),
|
90
|
+
onOpenChange: U,
|
91
|
+
open: P,
|
91
92
|
side: "bottom",
|
92
93
|
variant: "error",
|
93
|
-
children: /* @__PURE__ */ t(
|
94
|
-
disabled:
|
95
|
-
children: /* @__PURE__ */
|
96
|
-
className:
|
94
|
+
children: /* @__PURE__ */ t(d.Trigger, {
|
95
|
+
disabled: E,
|
96
|
+
children: /* @__PURE__ */ b(p.TriggerChip, {
|
97
|
+
className: a.triggerChip,
|
97
98
|
value: "trigger-chip",
|
98
|
-
children: [/* @__PURE__ */ t(
|
99
|
-
className:
|
99
|
+
children: [/* @__PURE__ */ t(z, {
|
100
|
+
className: a.agentStatus,
|
100
101
|
colorIndex: 0,
|
101
|
-
text: o(
|
102
|
-
}),
|
103
|
-
"aria-label": o(
|
104
|
-
className:
|
102
|
+
text: o(r.agent)
|
103
|
+
}), E && /* @__PURE__ */ t(H, {
|
104
|
+
"aria-label": o(r.loadingMessage),
|
105
|
+
className: a.agentLoader,
|
105
106
|
variant: "default"
|
106
|
-
}),
|
107
|
-
className:
|
107
|
+
}), i && /* @__PURE__ */ t(Z, {
|
108
|
+
className: a.agentError,
|
108
109
|
height: "1rem",
|
109
110
|
role: "presentation",
|
110
111
|
width: "1rem"
|
111
|
-
}), /* @__PURE__ */ t(
|
112
|
-
...
|
113
|
-
children: /* @__PURE__ */ t(
|
112
|
+
}), /* @__PURE__ */ t(K, {
|
113
|
+
...M,
|
114
|
+
children: /* @__PURE__ */ t(p.Label, {
|
114
115
|
ref: G,
|
115
|
-
className:
|
116
|
+
className: a.agentLabel,
|
116
117
|
children: g
|
117
118
|
})
|
118
|
-
}), !
|
119
|
-
className:
|
120
|
-
children: /* @__PURE__ */ t(
|
119
|
+
}), !E && /* @__PURE__ */ t("div", {
|
120
|
+
className: a.dropdownIndicator,
|
121
|
+
children: /* @__PURE__ */ t(p.DropdownIndicator, {})
|
121
122
|
})]
|
122
123
|
})
|
123
124
|
})
|
124
|
-
}), /* @__PURE__ */ t(
|
125
|
+
}), /* @__PURE__ */ t(d.ContentContainer, {
|
125
126
|
align: "start",
|
126
|
-
className: m(
|
127
|
-
onKeyDownCapture:
|
128
|
-
children: /* @__PURE__ */
|
129
|
-
children: [
|
130
|
-
"aria-label": o(
|
131
|
-
className: m([
|
132
|
-
selectedKeys: [(
|
133
|
-
children:
|
134
|
-
agent:
|
135
|
-
onAction: () =>
|
136
|
-
},
|
137
|
-
}),
|
138
|
-
className: m(
|
139
|
-
onClick:
|
127
|
+
className: m(a.agentListContainer, C),
|
128
|
+
onKeyDownCapture: j,
|
129
|
+
children: /* @__PURE__ */ b(d.MainContent, {
|
130
|
+
children: [k && /* @__PURE__ */ t(J, {
|
131
|
+
"aria-label": o(r.agentList),
|
132
|
+
className: m([a.agentList, B]),
|
133
|
+
selectedKeys: [(s == null ? void 0 : s.id) || ""],
|
134
|
+
children: f.map((e) => /* @__PURE__ */ t(at, {
|
135
|
+
agent: e,
|
136
|
+
onAction: () => h(e)
|
137
|
+
}, e.id))
|
138
|
+
}), i && /* @__PURE__ */ t(X, {
|
139
|
+
className: m(a.agentListRetryButton, C),
|
140
|
+
onClick: F,
|
140
141
|
variant: "tertiary",
|
141
|
-
children: o(
|
142
|
+
children: o(r.errorMessage)
|
142
143
|
})]
|
143
144
|
})
|
144
145
|
})]
|
@@ -146,6 +147,6 @@ function Nt({
|
|
146
147
|
});
|
147
148
|
}
|
148
149
|
export {
|
149
|
-
|
150
|
-
|
150
|
+
yt as BoxAiAgentSelector,
|
151
|
+
yt as default
|
151
152
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/box-ai-agent-selector",
|
3
|
-
"version": "0.19.
|
3
|
+
"version": "0.19.4",
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
5
5
|
"peerDependencies": {
|
6
6
|
"@box/blueprint-web": "^7.31.1",
|
@@ -10,10 +10,10 @@
|
|
10
10
|
"react-intl": "^6.4.2"
|
11
11
|
},
|
12
12
|
"devDependencies": {
|
13
|
-
"@box/blueprint-web": "^9.7.
|
14
|
-
"@box/blueprint-web-assets": "^4.31.
|
13
|
+
"@box/blueprint-web": "^9.7.3",
|
14
|
+
"@box/blueprint-web-assets": "^4.31.1",
|
15
15
|
"@box/eslint-plugin-blueprint": "^1.0.3",
|
16
|
-
"@box/storybook-utils": "^0.8.
|
16
|
+
"@box/storybook-utils": "^0.8.1",
|
17
17
|
"react-intl": "^6.4.2"
|
18
18
|
},
|
19
19
|
"scripts": {
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"sideEffects": [
|
47
47
|
"**/*.css"
|
48
48
|
],
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "ce8788c77a7c7c083cb57af2d5b14abb566ce6e2"
|
50
50
|
}
|