@box/box-ai-agent-selector 0.33.1 → 0.33.3
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,9 +1,9 @@
|
|
1
1
|
import { useState as I, useCallback as m, useEffect as f } from "react";
|
2
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
|
-
import { ACTIONS as
|
4
|
+
import { ACTIONS as E } from "./contexts/actions.js";
|
5
5
|
import { useAgentsDispatch as U, useAgents as x } from "./contexts/context.js";
|
6
|
-
import { R as
|
6
|
+
import { R as S } from "../../chunks/types.js";
|
7
7
|
import { jsx as D } from "react/jsx-runtime";
|
8
8
|
function k({
|
9
9
|
fetcher: u,
|
@@ -20,19 +20,19 @@ function k({
|
|
20
20
|
}) {
|
21
21
|
const e = U(), {
|
22
22
|
agents: A,
|
23
|
-
requestState:
|
23
|
+
requestState: r,
|
24
24
|
selectedAgent: n
|
25
25
|
} = x(), [d, _] = I(!1), o = m((t) => {
|
26
26
|
T && (t.data ?? (t.data = {}), t.data.hostAppName = R, T(t));
|
27
27
|
}, [R, T]), c = m(async () => {
|
28
28
|
e({
|
29
|
-
type:
|
30
|
-
requestState:
|
29
|
+
type: E.SET_REQUEST_STATE,
|
30
|
+
requestState: S.IN_PROGRESS
|
31
31
|
});
|
32
32
|
try {
|
33
33
|
const t = await u();
|
34
34
|
e({
|
35
|
-
type:
|
35
|
+
type: E.SET_AGENT_LIST,
|
36
36
|
agents: t.agents
|
37
37
|
}), o({
|
38
38
|
...a,
|
@@ -40,36 +40,36 @@ function k({
|
|
40
40
|
});
|
41
41
|
} catch {
|
42
42
|
e({
|
43
|
-
type:
|
44
|
-
requestState:
|
43
|
+
type: E.SET_REQUEST_STATE,
|
44
|
+
requestState: S.ERROR
|
45
45
|
}), o({
|
46
46
|
...a,
|
47
47
|
target: l.ERROR_LOADING_AGENTS
|
48
48
|
});
|
49
49
|
}
|
50
|
-
}, [e, o, u]), g =
|
50
|
+
}, [e, o, u]), g = r !== S.SUCCESS || !A.length || !n;
|
51
51
|
return f(() => {
|
52
52
|
g ? c().finally(() => {
|
53
53
|
_(!0);
|
54
54
|
}) : _(!0);
|
55
55
|
}, [c, g]), f(() => {
|
56
|
-
s && s !==
|
57
|
-
type:
|
56
|
+
s && s !== r && (s !== S.SUCCESS && e({
|
57
|
+
type: E.SET_AGENT_LIST,
|
58
58
|
agents: []
|
59
59
|
}), e({
|
60
|
-
type:
|
60
|
+
type: E.SET_REQUEST_STATE,
|
61
61
|
requestState: s
|
62
62
|
}));
|
63
|
-
}, [e,
|
63
|
+
}, [e, s]), f(() => {
|
64
64
|
i && i(n);
|
65
|
-
}, [i, n]), h && !d ||
|
65
|
+
}, [i, n]), h && !d || r === S.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(L, {
|
66
66
|
agents: A,
|
67
67
|
contentClassName: O,
|
68
68
|
disabled: G,
|
69
69
|
onAgentsListOpen: C,
|
70
70
|
onErrorAction: c,
|
71
71
|
recordAction: o,
|
72
|
-
requestState:
|
72
|
+
requestState: r,
|
73
73
|
selectedAgent: n,
|
74
74
|
triggerChipClassName: p,
|
75
75
|
variant: N
|
@@ -1,114 +1,114 @@
|
|
1
|
-
import { useFullTextTooltip as X, FilterChip as
|
1
|
+
import { useFullTextTooltip as X, FilterChip as p, Popover as m, Tooltip as Z, Status as $, LoadingIndicator as q, SmallList as tt, Button as et } from "@box/blueprint-web";
|
2
2
|
import { AlertBadge as at } from "@box/blueprint-web-assets/icons/Fill";
|
3
|
-
import
|
4
|
-
import { useState as
|
3
|
+
import f from "clsx";
|
4
|
+
import { useState as P, useRef as ot, useEffect as rt, useCallback as d } from "react";
|
5
5
|
import { useIntl as nt } from "react-intl";
|
6
|
-
import { BoxAiAgent as
|
7
|
-
import { LOGGER_BASE_CONFIG as
|
8
|
-
import { ACTIONS as
|
6
|
+
import { BoxAiAgent as it } from "./box-ai-agent.js";
|
7
|
+
import { LOGGER_BASE_CONFIG as S, LOGGER_ACTION_CLICK as T, LOGGER_TARGET as R } from "./constants.js";
|
8
|
+
import { ACTIONS as st } from "./contexts/actions.js";
|
9
9
|
import { useAgentsDispatch as lt } from "./contexts/context.js";
|
10
|
-
import
|
11
|
-
import { R } from "../../chunks/types.js";
|
12
|
-
import { jsx as e, jsxs as
|
13
|
-
import '../../styles/box-ai-agent-selector.css';const
|
14
|
-
agentSelector:
|
10
|
+
import i from "./messages.js";
|
11
|
+
import { R as I } from "../../chunks/types.js";
|
12
|
+
import { jsx as e, jsxs as y } from "react/jsx-runtime";
|
13
|
+
import '../../styles/box-ai-agent-selector.css';const ct = "_agentSelector_hcmlf_1", gt = "_agentStatus_hcmlf_4", pt = "_agentLoader_hcmlf_17", mt = "_agentError_hcmlf_20", ft = "_triggerChip_hcmlf_23", dt = "_agentLabel_hcmlf_29", ht = "_dropdownIndicator_hcmlf_35", _t = "_sidebar_hcmlf_50", Lt = "_agentListItemIcon_hcmlf_63", ut = "_agentListContainer_hcmlf_68", Ct = "_agentListRetryButton_hcmlf_98", a = {
|
14
|
+
agentSelector: ct,
|
15
15
|
agentStatus: gt,
|
16
|
-
agentLoader:
|
17
|
-
agentError:
|
18
|
-
triggerChip:
|
19
|
-
agentLabel:
|
20
|
-
dropdownIndicator:
|
21
|
-
sidebar:
|
22
|
-
agentListItemIcon:
|
16
|
+
agentLoader: pt,
|
17
|
+
agentError: mt,
|
18
|
+
triggerChip: ft,
|
19
|
+
agentLabel: dt,
|
20
|
+
dropdownIndicator: ht,
|
21
|
+
sidebar: _t,
|
22
|
+
agentListItemIcon: Lt,
|
23
23
|
agentListContainer: ut,
|
24
24
|
agentListRetryButton: Ct
|
25
25
|
};
|
26
|
-
function
|
27
|
-
agents:
|
28
|
-
contentClassName:
|
29
|
-
onErrorAction:
|
30
|
-
recordAction:
|
31
|
-
requestState:
|
32
|
-
disabled:
|
26
|
+
function xt({
|
27
|
+
agents: h,
|
28
|
+
contentClassName: k,
|
29
|
+
onErrorAction: b,
|
30
|
+
recordAction: o,
|
31
|
+
requestState: _,
|
32
|
+
disabled: D,
|
33
33
|
onAgentsListOpen: N,
|
34
|
-
selectedAgent:
|
35
|
-
triggerChipClassName:
|
36
|
-
variant:
|
34
|
+
selectedAgent: s,
|
35
|
+
triggerChipClassName: K,
|
36
|
+
variant: v = "modal"
|
37
37
|
}) {
|
38
38
|
const {
|
39
|
-
formatMessage:
|
40
|
-
} = nt(), [l,
|
39
|
+
formatMessage: r
|
40
|
+
} = nt(), [l, c] = P(!1), n = _ === I.ERROR, [M, L] = P(n), w = lt(), O = _ === I.SUCCESS, u = _ === I.IN_PROGRESS, G = r(i.selectAgent), F = r(i.defaultAgent);
|
41
41
|
let g = "";
|
42
|
-
O ? g = (
|
43
|
-
const
|
44
|
-
Wrapper:
|
45
|
-
wrapperProps:
|
42
|
+
O ? g = (s == null ? void 0 : s.name) || G : n && (g = F);
|
43
|
+
const A = ot(null), {
|
44
|
+
Wrapper: U,
|
45
|
+
wrapperProps: j
|
46
46
|
} = X({
|
47
|
-
ref:
|
47
|
+
ref: A,
|
48
48
|
textValue: g
|
49
49
|
});
|
50
|
-
|
51
|
-
l &&
|
52
|
-
...
|
53
|
-
action:
|
54
|
-
target:
|
50
|
+
rt(() => {
|
51
|
+
l && o && o({
|
52
|
+
...S,
|
53
|
+
action: T,
|
54
|
+
target: R.OPEN_SELECTOR
|
55
55
|
});
|
56
|
-
}, [l,
|
57
|
-
const C =
|
58
|
-
|
59
|
-
type:
|
56
|
+
}, [l, o]);
|
57
|
+
const C = d((t) => {
|
58
|
+
c(!1), w({
|
59
|
+
type: st.SET_SELECTED_AGENT,
|
60
60
|
id: t.id
|
61
|
-
}),
|
62
|
-
...
|
63
|
-
action:
|
64
|
-
target:
|
61
|
+
}), o && o({
|
62
|
+
...S,
|
63
|
+
action: T,
|
64
|
+
target: R.SELECT_AGENT
|
65
65
|
});
|
66
|
-
}, [w,
|
67
|
-
|
68
|
-
...
|
69
|
-
action:
|
70
|
-
target:
|
66
|
+
}, [w, o]), Q = d(() => {
|
67
|
+
c(!1), b(), o && o({
|
68
|
+
...S,
|
69
|
+
action: T,
|
70
|
+
target: R.RETRY_LOADING_AGENTS
|
71
71
|
});
|
72
|
-
}, [
|
73
|
-
if (t.key === "Escape" && (
|
74
|
-
const
|
75
|
-
if (
|
76
|
-
const H =
|
77
|
-
|
72
|
+
}, [b, o]), V = d((t) => {
|
73
|
+
if (t.key === "Escape" && (c(!1), t.stopPropagation()), t.key === " ") {
|
74
|
+
const x = t.target;
|
75
|
+
if (x) {
|
76
|
+
const H = x.getAttribute("data-key"), B = h.find((J) => J.id === H);
|
77
|
+
B && C(B);
|
78
78
|
}
|
79
79
|
}
|
80
|
-
}, [
|
81
|
-
t && N && N(),
|
82
|
-
},
|
80
|
+
}, [h, C]), W = d((t) => L(n && n && !l && t ? t : !1), [n, l]), Y = (t) => {
|
81
|
+
t && N && N(), c(t);
|
82
|
+
}, E = v === "sidebar" && a.sidebar, z = (t) => {
|
83
83
|
(t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") && t.stopPropagation();
|
84
84
|
};
|
85
|
-
return /* @__PURE__ */ e(
|
86
|
-
className:
|
85
|
+
return /* @__PURE__ */ e(p.Group, {
|
86
|
+
className: f(a.agentSelector, K, E),
|
87
87
|
name: G,
|
88
|
-
onKeyDown:
|
88
|
+
onKeyDown: z,
|
89
89
|
type: "multiple",
|
90
|
-
children: /* @__PURE__ */
|
90
|
+
children: /* @__PURE__ */ y(m.Root, {
|
91
91
|
modal: !1,
|
92
|
-
onOpenChange:
|
92
|
+
onOpenChange: Y,
|
93
93
|
open: l,
|
94
94
|
children: [/* @__PURE__ */ e(Z, {
|
95
|
-
content:
|
96
|
-
onOpenChange:
|
97
|
-
open:
|
95
|
+
content: r(i.errorTooltip),
|
96
|
+
onOpenChange: W,
|
97
|
+
open: M,
|
98
98
|
side: "bottom",
|
99
99
|
variant: "error",
|
100
|
-
children: /* @__PURE__ */ e(
|
101
|
-
disabled:
|
102
|
-
children: /* @__PURE__ */
|
100
|
+
children: /* @__PURE__ */ e(m.Trigger, {
|
101
|
+
disabled: D || u,
|
102
|
+
children: /* @__PURE__ */ y(p.TriggerChip, {
|
103
103
|
className: a.triggerChip,
|
104
104
|
"data-target-id": "FilterChip.TriggerChip-agentSelectorTrigger",
|
105
105
|
value: "trigger-chip",
|
106
106
|
children: [/* @__PURE__ */ e($, {
|
107
107
|
className: a.agentStatus,
|
108
108
|
colorIndex: 0,
|
109
|
-
text:
|
109
|
+
text: r(i.agent)
|
110
110
|
}), u && /* @__PURE__ */ e(q, {
|
111
|
-
"aria-label":
|
111
|
+
"aria-label": r(i.loadingMessage),
|
112
112
|
className: a.agentLoader,
|
113
113
|
variant: "default"
|
114
114
|
}), n && /* @__PURE__ */ e(at, {
|
@@ -116,38 +116,38 @@ function At({
|
|
116
116
|
height: "1rem",
|
117
117
|
role: "presentation",
|
118
118
|
width: "1rem"
|
119
|
-
}), /* @__PURE__ */ e(
|
120
|
-
...
|
121
|
-
children: /* @__PURE__ */ e(
|
122
|
-
ref:
|
119
|
+
}), /* @__PURE__ */ e(U, {
|
120
|
+
...j,
|
121
|
+
children: /* @__PURE__ */ e(p.Label, {
|
122
|
+
ref: A,
|
123
123
|
className: a.agentLabel,
|
124
124
|
children: g
|
125
125
|
})
|
126
126
|
}), !u && /* @__PURE__ */ e("div", {
|
127
127
|
className: a.dropdownIndicator,
|
128
|
-
children: /* @__PURE__ */ e(
|
128
|
+
children: /* @__PURE__ */ e(p.DropdownIndicator, {})
|
129
129
|
})]
|
130
130
|
})
|
131
131
|
})
|
132
|
-
}), /* @__PURE__ */ e(
|
132
|
+
}), /* @__PURE__ */ e(m.ContentContainer, {
|
133
133
|
align: "start",
|
134
|
-
className:
|
135
|
-
onKeyDownCapture:
|
136
|
-
children: /* @__PURE__ */
|
134
|
+
className: f(a.agentListContainer, E),
|
135
|
+
onKeyDownCapture: V,
|
136
|
+
children: /* @__PURE__ */ y(m.MainContent, {
|
137
137
|
children: [O && /* @__PURE__ */ e(tt, {
|
138
|
-
"aria-label":
|
139
|
-
className:
|
140
|
-
selectedKeys: [(
|
141
|
-
children:
|
138
|
+
"aria-label": r(i.agentList),
|
139
|
+
className: f([a.agentList, k]),
|
140
|
+
selectedKeys: [(s == null ? void 0 : s.id) || ""],
|
141
|
+
children: h.map((t) => /* @__PURE__ */ e(it, {
|
142
142
|
agent: t,
|
143
143
|
onAction: () => C(t)
|
144
144
|
}, t.id))
|
145
145
|
}), n && /* @__PURE__ */ e(et, {
|
146
|
-
className:
|
147
|
-
onClick:
|
146
|
+
className: f(a.agentListRetryButton, E),
|
147
|
+
onClick: Q,
|
148
148
|
variant: "tertiary",
|
149
149
|
"data-target-id": "Button-errorMessage",
|
150
|
-
children:
|
150
|
+
children: r(i.errorMessage)
|
151
151
|
})]
|
152
152
|
})
|
153
153
|
})]
|
@@ -155,6 +155,6 @@ function At({
|
|
155
155
|
});
|
156
156
|
}
|
157
157
|
export {
|
158
|
-
|
159
|
-
|
158
|
+
xt as BoxAiAgentSelector,
|
159
|
+
xt as default
|
160
160
|
};
|
@@ -1 +1 @@
|
|
1
|
-
.
|
1
|
+
._agentSelector_hcmlf_1{margin-inline-start:.75rem}._agentSelector_hcmlf_1 ._agentStatus_hcmlf_4{margin-inline-start:.5rem}._agentSelector_hcmlf_1 ._agentStatus_hcmlf_4>span{background:linear-gradient(#f4f4f4 0,#f4f4f4 0) padding-box,linear-gradient(135deg,#fe01da,#2486fc) border-box;border:.0625rem solid rgba(0,0,0,0)}._agentSelector_hcmlf_1 ._agentStatus_hcmlf_4>span span{color:transparent;text-transform:uppercase;background:linear-gradient(135deg,#fe01da,#2486fc);-webkit-background-clip:text;background-clip:text}._agentSelector_hcmlf_1 ._agentLoader_hcmlf_17{position:inherit}._agentSelector_hcmlf_1 ._agentError_hcmlf_20 path{fill:#d5324e}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23{display:flex;max-width:376px;text-align:start;background-color:#faf5fe}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23 ._agentLabel_hcmlf_29{flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23 ._dropdownIndicator_hcmlf_35{flex-shrink:0;margin-inline-start:0}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23 ._dropdownIndicator_hcmlf_35 svg{margin-inline-start:0}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23:disabled ._dropdownIndicator_hcmlf_35{opacity:.3}@media (max-width: 374px){._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23{width:100%}}._agentSelector_hcmlf_1._sidebar_hcmlf_50{margin:0 .25rem 0 0;margin-inline-start:0}@media (max-width: 767px){._agentSelector_hcmlf_1._sidebar_hcmlf_50{width:100%}}._agentSelector_hcmlf_1._sidebar_hcmlf_50 ._triggerChip_hcmlf_23{max-width:246px}._agentListItemIcon_hcmlf_63{width:2rem;height:2rem}._agentListContainer_hcmlf_68{min-width:320px;max-width:376px;width:360px}@media (max-width: 376px){._agentListContainer_hcmlf_68{max-width:320px}}._agentListContainer_hcmlf_68>div{padding:var(--space-3)}._agentListContainer_hcmlf_68._sidebar_hcmlf_50{min-width:320px;max-width:360px;transform:translate(-6px)}@media (max-width: 360px){._agentListContainer_hcmlf_68._sidebar_hcmlf_50{max-width:320px}}@media (max-width: 767px){._agentListContainer_hcmlf_68._sidebar_hcmlf_50{max-width:unset;width:auto}}._agentListRetryButton_hcmlf_98{max-width:320px;margin:.25rem;text-wrap:wrap}._agentListRetryButton_hcmlf_98._sidebar_hcmlf_50{max-width:184px}
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import { BoxAiAgentSelectorWithApiProps } from '../../index';
|
2
|
+
import { REQUEST_STATE } from '../types';
|
2
3
|
export declare const defaultBoxAiAgentSelectorProps: {
|
3
4
|
fetcher: () => Promise<{
|
4
5
|
agents: import('../types').AgentType[];
|
5
6
|
}>;
|
6
7
|
};
|
7
8
|
export declare const DefaultBoxAiAgentSelectorWithApiContainer: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
|
9
|
+
export declare const BoxAiAgentSelectorWithApiContainerWithChangedRequestState: ({ changeTimeout, newRequestState, ...args }: BoxAiAgentSelectorWithApiProps & {
|
10
|
+
changeTimeout: number;
|
11
|
+
newRequestState: REQUEST_STATE;
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
8
13
|
export declare const BoxAiAgentSelectorWithProvider: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/box-ai-agent-selector",
|
3
|
-
"version": "0.33.
|
3
|
+
"version": "0.33.3",
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
5
5
|
"peerDependencies": {
|
6
6
|
"@box/blueprint-web": "^7.31.1",
|
@@ -11,8 +11,8 @@
|
|
11
11
|
},
|
12
12
|
"devDependencies": {
|
13
13
|
"@box/babel-plugin-target-attributes": "1.3.0",
|
14
|
-
"@box/blueprint-web": "^9.19.
|
15
|
-
"@box/blueprint-web-assets": "^4.37.
|
14
|
+
"@box/blueprint-web": "^9.19.2",
|
15
|
+
"@box/blueprint-web-assets": "^4.37.2",
|
16
16
|
"@box/eslint-plugin-blueprint": "^1.0.3",
|
17
17
|
"@box/storybook-utils": "^0.8.3",
|
18
18
|
"react-intl": "^6.4.2"
|