@box/box-ai-agent-selector 0.41.9 → 0.41.10
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,16 +1,16 @@
|
|
1
|
-
import { useState as
|
2
|
-
import { BoxAiAgentSelector as
|
3
|
-
import { LOGGER_BASE_CONFIG as
|
4
|
-
import { ACTIONS as
|
5
|
-
import { useAgentsDispatch as
|
6
|
-
import { R as
|
1
|
+
import { useState as L, useCallback as a, useEffect as u } from "react";
|
2
|
+
import { BoxAiAgentSelector as U } from "./box-ai-agent-selector.js";
|
3
|
+
import { LOGGER_BASE_CONFIG as g, LOGGER_TARGET as l } from "./constants.js";
|
4
|
+
import { ACTIONS as S } from "./contexts/actions.js";
|
5
|
+
import { useAgentsDispatch as d, useAgents as x } from "./contexts/context.js";
|
6
|
+
import { R as r } from "../../chunks/types.js";
|
7
7
|
import { jsx as D } from "react/jsx-runtime";
|
8
8
|
function k({
|
9
|
-
fetcher:
|
10
|
-
hostAppName:
|
11
|
-
onSelectAgent:
|
9
|
+
fetcher: R,
|
10
|
+
hostAppName: _,
|
11
|
+
onSelectAgent: n,
|
12
12
|
recordAction: T,
|
13
|
-
requestState:
|
13
|
+
requestState: E,
|
14
14
|
disabled: G,
|
15
15
|
onAgentsListOpen: C,
|
16
16
|
shouldHideAgentSelectorOnLoad: h,
|
@@ -18,59 +18,59 @@ function k({
|
|
18
18
|
contentClassName: O,
|
19
19
|
variant: N = "modal"
|
20
20
|
}) {
|
21
|
-
const e =
|
21
|
+
const e = d(), {
|
22
22
|
agents: A,
|
23
|
-
requestState:
|
24
|
-
selectedAgent:
|
25
|
-
} = x(), [
|
26
|
-
T && (t.data ?? (t.data = {}), t.data.hostAppName =
|
27
|
-
}, [
|
23
|
+
requestState: i,
|
24
|
+
selectedAgent: s
|
25
|
+
} = x(), [I, c] = L(!1), o = a((t) => {
|
26
|
+
T && (t.data ?? (t.data = {}), t.data.hostAppName = _, T(t));
|
27
|
+
}, [_, T]), f = a(async () => {
|
28
28
|
e({
|
29
|
-
type:
|
30
|
-
requestState:
|
29
|
+
type: S.SET_REQUEST_STATE,
|
30
|
+
requestState: r.IN_PROGRESS
|
31
31
|
});
|
32
32
|
try {
|
33
|
-
const t = await
|
33
|
+
const t = await R();
|
34
34
|
e({
|
35
|
-
type:
|
35
|
+
type: S.SET_AGENT_LIST,
|
36
36
|
agents: t.agents
|
37
37
|
}), o({
|
38
|
-
...
|
38
|
+
...g,
|
39
39
|
target: l.LOADED_AGENTS
|
40
40
|
});
|
41
41
|
} catch {
|
42
42
|
e({
|
43
|
-
type:
|
44
|
-
requestState:
|
43
|
+
type: S.SET_REQUEST_STATE,
|
44
|
+
requestState: r.ERROR
|
45
45
|
}), o({
|
46
|
-
...
|
46
|
+
...g,
|
47
47
|
target: l.ERROR_LOADING_AGENTS
|
48
48
|
});
|
49
49
|
}
|
50
|
-
}, [e, o,
|
51
|
-
return
|
52
|
-
|
53
|
-
|
54
|
-
}) :
|
55
|
-
}, [
|
56
|
-
|
57
|
-
type:
|
50
|
+
}, [e, o, R]), m = i !== r.SUCCESS || !A.length || !s;
|
51
|
+
return u(() => {
|
52
|
+
m ? f().finally(() => {
|
53
|
+
c(!0);
|
54
|
+
}) : c(!0);
|
55
|
+
}, [f, m]), u(() => {
|
56
|
+
E && E !== i && (E !== r.SUCCESS && e({
|
57
|
+
type: S.SET_AGENT_LIST,
|
58
58
|
agents: []
|
59
59
|
}), e({
|
60
|
-
type:
|
61
|
-
requestState:
|
60
|
+
type: S.SET_REQUEST_STATE,
|
61
|
+
requestState: E
|
62
62
|
}));
|
63
|
-
}, [e,
|
64
|
-
|
65
|
-
}, [
|
63
|
+
}, [e, E]), u(() => {
|
64
|
+
n && n(s);
|
65
|
+
}, [n, s == null ? void 0 : s.id]), h && !I || i === r.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(U, {
|
66
66
|
agents: A,
|
67
67
|
contentClassName: O,
|
68
68
|
disabled: G,
|
69
69
|
onAgentsListOpen: C,
|
70
|
-
onErrorAction:
|
70
|
+
onErrorAction: f,
|
71
71
|
recordAction: o,
|
72
|
-
requestState:
|
73
|
-
selectedAgent:
|
72
|
+
requestState: i,
|
73
|
+
selectedAgent: s,
|
74
74
|
triggerChipClassName: p,
|
75
75
|
variant: N
|
76
76
|
});
|