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