@box/box-ai-agent-selector 0.13.0 → 0.13.1
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-with-api-container.js +13 -9
- package/esm/lib/box-ai-agent-selector-with-api.js +17 -13
- package/esm/lib/box-ai-agent-selector.js +54 -51
- package/esm/lib/constants.js +6 -5
- package/package.json +2 -2
- package/types/lib/box-ai-agent-selector-with-api-container.d.ts +1 -1
- package/types/lib/box-ai-agent-selector-with-api.d.ts +1 -1
- package/types/lib/box-ai-agent-selector.d.ts +1 -1
- package/types/lib/constants.d.ts +1 -0
- package/types/lib/types.d.ts +11 -2
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { BoxAiAgentSelectorWithApi as
|
|
2
|
-
import { AgentsProvider as
|
|
1
|
+
import { BoxAiAgentSelectorWithApi as f } from "./box-ai-agent-selector-with-api.js";
|
|
2
|
+
import { AgentsProvider as c } from "./contexts/context.js";
|
|
3
3
|
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
-
function
|
|
4
|
+
function a({
|
|
5
5
|
fetcher: t,
|
|
6
6
|
hostAppName: e,
|
|
7
7
|
onSelectAgent: o,
|
|
8
8
|
recordAction: i,
|
|
9
9
|
requestState: n,
|
|
10
|
-
shouldHideAgentSelectorOnLoad: A = !0
|
|
10
|
+
shouldHideAgentSelectorOnLoad: A = !0,
|
|
11
|
+
triggerChipClassName: m,
|
|
12
|
+
contentClassName: p
|
|
11
13
|
}) {
|
|
12
|
-
return /* @__PURE__ */ r(
|
|
13
|
-
children: /* @__PURE__ */ r(
|
|
14
|
+
return /* @__PURE__ */ r(c, {
|
|
15
|
+
children: /* @__PURE__ */ r(f, {
|
|
16
|
+
contentClassName: p,
|
|
14
17
|
fetcher: t,
|
|
15
18
|
hostAppName: e,
|
|
16
19
|
onSelectAgent: o,
|
|
17
20
|
recordAction: i,
|
|
18
21
|
requestState: n,
|
|
19
|
-
shouldHideAgentSelectorOnLoad: A
|
|
22
|
+
shouldHideAgentSelectorOnLoad: A,
|
|
23
|
+
triggerChipClassName: m
|
|
20
24
|
})
|
|
21
25
|
});
|
|
22
26
|
}
|
|
23
27
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
a as BoxAiAgentSelectorWithApiContainer,
|
|
29
|
+
a as default
|
|
26
30
|
};
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { BoxAiAgentSelector as
|
|
1
|
+
import { useState as O, useCallback as m, useEffect as f } from "react";
|
|
2
|
+
import { BoxAiAgentSelector as N } from "./box-ai-agent-selector.js";
|
|
3
3
|
import { LOGGER_BASE_CONFIG as u, LOGGER_TARGET as a } from "./constants.js";
|
|
4
4
|
import { ACTIONS as E } from "./contexts/actions.js";
|
|
5
|
-
import { useAgentsDispatch as
|
|
5
|
+
import { useAgentsDispatch as h, useAgents as I } from "./contexts/context.js";
|
|
6
6
|
import { R as i } from "../../chunks/types.js";
|
|
7
|
-
import { jsx as
|
|
8
|
-
function
|
|
7
|
+
import { jsx as L } from "react/jsx-runtime";
|
|
8
|
+
function F({
|
|
9
9
|
fetcher: R,
|
|
10
10
|
hostAppName: _,
|
|
11
11
|
onSelectAgent: T,
|
|
12
12
|
recordAction: n,
|
|
13
13
|
requestState: s,
|
|
14
|
-
shouldHideAgentSelectorOnLoad: g
|
|
14
|
+
shouldHideAgentSelectorOnLoad: g,
|
|
15
|
+
triggerChipClassName: G,
|
|
16
|
+
contentClassName: l
|
|
15
17
|
}) {
|
|
16
|
-
const e =
|
|
18
|
+
const e = h(), {
|
|
17
19
|
agents: c,
|
|
18
20
|
requestState: S,
|
|
19
21
|
selectedAgent: o
|
|
20
|
-
} =
|
|
22
|
+
} = I(), [p, C] = O(!1), r = m((t) => {
|
|
21
23
|
n && (t.data ?? (t.data = {}), t.data.hostAppName = _, n(t));
|
|
22
24
|
}, [_, n]), A = m(async () => {
|
|
23
25
|
e({
|
|
@@ -45,7 +47,7 @@ function y({
|
|
|
45
47
|
}, [e, r, R]);
|
|
46
48
|
return f(() => {
|
|
47
49
|
A().finally(() => {
|
|
48
|
-
|
|
50
|
+
C(!0);
|
|
49
51
|
});
|
|
50
52
|
}, [A]), f(() => {
|
|
51
53
|
s && s !== S && (s !== i.SUCCESS && e({
|
|
@@ -57,15 +59,17 @@ function y({
|
|
|
57
59
|
}));
|
|
58
60
|
}, [e, S, s]), f(() => {
|
|
59
61
|
T && T(o);
|
|
60
|
-
}, [T, o]), g && !
|
|
62
|
+
}, [T, o]), g && !p || S === i.SUCCESS && c.length <= 1 ? null : /* @__PURE__ */ L(N, {
|
|
61
63
|
agents: c,
|
|
64
|
+
contentClassName: l,
|
|
62
65
|
onErrorAction: A,
|
|
63
66
|
recordAction: r,
|
|
64
67
|
requestState: S,
|
|
65
|
-
selectedAgent: o
|
|
68
|
+
selectedAgent: o,
|
|
69
|
+
triggerChipClassName: G
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
F as BoxAiAgentSelectorWithApi,
|
|
74
|
+
F as default
|
|
71
75
|
};
|
|
@@ -1,63 +1,66 @@
|
|
|
1
1
|
import "../../styles/box-ai-agent-selector.css";
|
|
2
|
-
import { useFullTextTooltip as
|
|
3
|
-
import { AlertBadge as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { useFullTextTooltip as P, FilterChip as c, Popover as m, Tooltip as A, Status as D, LoadingIndicator as M, SmallList as F, Button as j } from "@box/blueprint-web";
|
|
3
|
+
import { AlertBadge as K } from "@box/blueprint-web-assets/icons/Fill";
|
|
4
|
+
import x from "clsx";
|
|
5
|
+
import { useState as U, useRef as Q, useEffect as V, useCallback as N } from "react";
|
|
6
|
+
import { useIntl as W } from "react-intl";
|
|
7
|
+
import { BoxAiAgent as Y } from "./box-ai-agent.js";
|
|
7
8
|
import { LOGGER_BASE_CONFIG as L, LOGGER_ACTION_CLICK as f, LOGGER_TARGET as E } from "./constants.js";
|
|
8
|
-
import { ACTIONS as
|
|
9
|
-
import { useAgentsDispatch as
|
|
9
|
+
import { ACTIONS as z } from "./contexts/actions.js";
|
|
10
|
+
import { useAgentsDispatch as H } from "./contexts/context.js";
|
|
10
11
|
import r from "./messages.js";
|
|
11
12
|
import { R as h } from "../../chunks/types.js";
|
|
12
13
|
import { jsx as t, jsxs as u } from "react/jsx-runtime";
|
|
13
|
-
const
|
|
14
|
-
agentSelector:
|
|
15
|
-
agentStatus:
|
|
16
|
-
agentLoader:
|
|
17
|
-
agentError:
|
|
18
|
-
triggerChip:
|
|
19
|
-
agentLabel:
|
|
20
|
-
dropdownIndicator:
|
|
21
|
-
agentListItemIcon:
|
|
22
|
-
agentListContainer:
|
|
23
|
-
agentListRetryButton:
|
|
14
|
+
const J = "_agentSelector_1k90x_1", X = "_agentStatus_1k90x_4", Z = "_agentLoader_1k90x_18", $ = "_agentError_1k90x_21", q = "_triggerChip_1k90x_24", tt = "_agentLabel_1k90x_29", et = "_dropdownIndicator_1k90x_35", at = "_agentListItemIcon_1k90x_44", nt = "_agentListContainer_1k90x_49", ot = "_agentListRetryButton_1k90x_59", e = {
|
|
15
|
+
agentSelector: J,
|
|
16
|
+
agentStatus: X,
|
|
17
|
+
agentLoader: Z,
|
|
18
|
+
agentError: $,
|
|
19
|
+
triggerChip: q,
|
|
20
|
+
agentLabel: tt,
|
|
21
|
+
dropdownIndicator: et,
|
|
22
|
+
agentListItemIcon: at,
|
|
23
|
+
agentListContainer: nt,
|
|
24
|
+
agentListRetryButton: ot
|
|
24
25
|
};
|
|
25
|
-
function
|
|
26
|
-
agents:
|
|
26
|
+
function ht({
|
|
27
|
+
agents: G,
|
|
28
|
+
contentClassName: O,
|
|
27
29
|
onErrorAction: C,
|
|
28
30
|
recordAction: a,
|
|
29
|
-
requestState:
|
|
30
|
-
selectedAgent: n
|
|
31
|
+
requestState: p,
|
|
32
|
+
selectedAgent: n,
|
|
33
|
+
triggerChipClassName: b
|
|
31
34
|
}) {
|
|
32
35
|
const {
|
|
33
36
|
formatMessage: o
|
|
34
|
-
} =
|
|
37
|
+
} = W(), [l, _] = U(!1), S = o(r.selectAgent), k = o(r.defaultAgent), I = H(), R = p === h.SUCCESS, d = p === h.IN_PROGRESS, g = p === h.ERROR;
|
|
35
38
|
let i = "";
|
|
36
|
-
R ? i = (n == null ? void 0 : n.name) || S : g && (i =
|
|
37
|
-
const T =
|
|
38
|
-
Wrapper:
|
|
39
|
-
wrapperProps:
|
|
40
|
-
} =
|
|
39
|
+
R ? i = (n == null ? void 0 : n.name) || S : g && (i = k);
|
|
40
|
+
const T = Q(null), {
|
|
41
|
+
Wrapper: y,
|
|
42
|
+
wrapperProps: B
|
|
43
|
+
} = P({
|
|
41
44
|
ref: T,
|
|
42
45
|
textValue: i
|
|
43
46
|
});
|
|
44
|
-
|
|
47
|
+
V(() => {
|
|
45
48
|
l && a && a({
|
|
46
49
|
...L,
|
|
47
50
|
action: f,
|
|
48
51
|
target: E.OPEN_SELECTOR
|
|
49
52
|
});
|
|
50
53
|
}, [l, a]);
|
|
51
|
-
const
|
|
54
|
+
const v = N((s) => {
|
|
52
55
|
_(!1), I({
|
|
53
|
-
type:
|
|
56
|
+
type: z.SET_SELECTED_AGENT,
|
|
54
57
|
id: s.id
|
|
55
58
|
}), a && a({
|
|
56
59
|
...L,
|
|
57
60
|
action: f,
|
|
58
61
|
target: E.SELECT_AGENT
|
|
59
62
|
});
|
|
60
|
-
}, [I, a]),
|
|
63
|
+
}, [I, a]), w = N(() => {
|
|
61
64
|
_(!1), C(), a && a({
|
|
62
65
|
...L,
|
|
63
66
|
action: f,
|
|
@@ -65,38 +68,38 @@ function dt({
|
|
|
65
68
|
});
|
|
66
69
|
}, [C, a]);
|
|
67
70
|
return /* @__PURE__ */ t(c.Group, {
|
|
68
|
-
className: e.agentSelector,
|
|
71
|
+
className: x([e.agentSelector, b]),
|
|
69
72
|
name: S,
|
|
70
73
|
type: "multiple",
|
|
71
|
-
children: /* @__PURE__ */ u(
|
|
74
|
+
children: /* @__PURE__ */ u(m.Root, {
|
|
72
75
|
modal: !1,
|
|
73
76
|
onOpenChange: _,
|
|
74
77
|
open: l,
|
|
75
|
-
children: [/* @__PURE__ */ t(
|
|
78
|
+
children: [/* @__PURE__ */ t(A, {
|
|
76
79
|
content: o(r.errorTooltip),
|
|
77
80
|
hidden: !g || l,
|
|
78
81
|
side: "bottom",
|
|
79
82
|
variant: "error",
|
|
80
|
-
children: /* @__PURE__ */ t(
|
|
83
|
+
children: /* @__PURE__ */ t(m.Trigger, {
|
|
81
84
|
disabled: d,
|
|
82
85
|
children: /* @__PURE__ */ u(c.TriggerChip, {
|
|
83
86
|
className: e.triggerChip,
|
|
84
87
|
value: "trigger-chip",
|
|
85
|
-
children: [/* @__PURE__ */ t(
|
|
88
|
+
children: [/* @__PURE__ */ t(D, {
|
|
86
89
|
className: e.agentStatus,
|
|
87
90
|
colorIndex: 0,
|
|
88
91
|
text: o(r.agent)
|
|
89
|
-
}), d && /* @__PURE__ */ t(
|
|
92
|
+
}), d && /* @__PURE__ */ t(M, {
|
|
90
93
|
"aria-label": o(r.loadingMessage),
|
|
91
94
|
className: e.agentLoader,
|
|
92
95
|
variant: "default"
|
|
93
|
-
}), g && /* @__PURE__ */ t(
|
|
96
|
+
}), g && /* @__PURE__ */ t(K, {
|
|
94
97
|
className: e.agentError,
|
|
95
98
|
height: "1rem",
|
|
96
99
|
role: "presentation",
|
|
97
100
|
width: "1rem"
|
|
98
|
-
}), /* @__PURE__ */ t(
|
|
99
|
-
...
|
|
101
|
+
}), /* @__PURE__ */ t(y, {
|
|
102
|
+
...B,
|
|
100
103
|
content: i,
|
|
101
104
|
children: /* @__PURE__ */ t(c.Label, {
|
|
102
105
|
ref: T,
|
|
@@ -109,20 +112,20 @@ function dt({
|
|
|
109
112
|
})]
|
|
110
113
|
})
|
|
111
114
|
})
|
|
112
|
-
}), /* @__PURE__ */ t(
|
|
115
|
+
}), /* @__PURE__ */ t(m.ContentContainer, {
|
|
113
116
|
align: "start",
|
|
114
117
|
className: e.agentListContainer,
|
|
115
|
-
children: /* @__PURE__ */ u(
|
|
116
|
-
children: [R && /* @__PURE__ */ t(
|
|
117
|
-
className: e.agentList,
|
|
118
|
+
children: /* @__PURE__ */ u(m.MainContent, {
|
|
119
|
+
children: [R && /* @__PURE__ */ t(F, {
|
|
120
|
+
className: x([e.agentList, O]),
|
|
118
121
|
selectedKeys: [(n == null ? void 0 : n.id) || ""],
|
|
119
|
-
children:
|
|
122
|
+
children: G.map((s) => /* @__PURE__ */ t(Y, {
|
|
120
123
|
agent: s,
|
|
121
|
-
onAction: () =>
|
|
124
|
+
onAction: () => v(s)
|
|
122
125
|
}, s.id))
|
|
123
|
-
}), g && /* @__PURE__ */ t(
|
|
126
|
+
}), g && /* @__PURE__ */ t(j, {
|
|
124
127
|
className: e.agentListRetryButton,
|
|
125
|
-
onClick:
|
|
128
|
+
onClick: w,
|
|
126
129
|
variant: "tertiary",
|
|
127
130
|
children: o(r.errorMessage)
|
|
128
131
|
})]
|
|
@@ -132,6 +135,6 @@ function dt({
|
|
|
132
135
|
});
|
|
133
136
|
}
|
|
134
137
|
export {
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
ht as BoxAiAgentSelector,
|
|
139
|
+
ht as default
|
|
137
140
|
};
|
package/esm/lib/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t = "click", o = "keypress", E = "programmatic", e = "selector", G = "agentSelector", O = {
|
|
2
2
|
LOADED_AGENTS: "loadedAgents",
|
|
3
3
|
ERROR_LOADING_AGENTS: "errorLoadingAgents",
|
|
4
4
|
RETRY_LOADING_AGENTS: "retryLoadingAgents",
|
|
@@ -7,13 +7,14 @@ const G = "click", E = "programmatic", e = "selector", t = "agentSelector", o =
|
|
|
7
7
|
}, A = {
|
|
8
8
|
action: E,
|
|
9
9
|
component: e,
|
|
10
|
-
feature:
|
|
10
|
+
feature: G
|
|
11
11
|
};
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
t as LOGGER_ACTION_CLICK,
|
|
14
|
+
o as LOGGER_ACTION_KEYPRESS,
|
|
14
15
|
E as LOGGER_ACTION_PROGRAMMATIC,
|
|
15
16
|
A as LOGGER_BASE_CONFIG,
|
|
16
17
|
e as LOGGER_COMPONENT,
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
G as LOGGER_FEATURE,
|
|
19
|
+
O as LOGGER_TARGET
|
|
19
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/box-ai-agent-selector",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@box/blueprint-web": "^7.31.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"sideEffects": [
|
|
47
47
|
"**/*.css"
|
|
48
48
|
],
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5a9d17c1a6963a9dbcde5a0a86d4f2cbcf35db53"
|
|
50
50
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type BoxAiAgentSelectorWithApiProps } from './types';
|
|
2
|
-
export declare function BoxAiAgentSelectorWithApiContainer({ fetcher, hostAppName, onSelectAgent, recordAction, requestState, shouldHideAgentSelectorOnLoad, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function BoxAiAgentSelectorWithApiContainer({ fetcher, hostAppName, onSelectAgent, recordAction, requestState, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default BoxAiAgentSelectorWithApiContainer;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type BoxAiAgentSelectorWithApiProps } from './types';
|
|
2
|
-
export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, shouldHideAgentSelectorOnLoad, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
export default BoxAiAgentSelectorWithApi;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type BoxAiAgentSelectorProps } from './types';
|
|
2
|
-
export declare function BoxAiAgentSelector({ agents, onErrorAction, recordAction, requestState, selectedAgent, }: BoxAiAgentSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function BoxAiAgentSelector({ agents, contentClassName, onErrorAction, recordAction, requestState, selectedAgent, triggerChipClassName, }: BoxAiAgentSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default BoxAiAgentSelector;
|
package/types/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RecordActionType } from './types';
|
|
2
2
|
export declare const LOGGER_ACTION_CLICK = "click";
|
|
3
|
+
export declare const LOGGER_ACTION_KEYPRESS = "keypress";
|
|
3
4
|
export declare const LOGGER_ACTION_PROGRAMMATIC = "programmatic";
|
|
4
5
|
export declare const LOGGER_COMPONENT = "selector";
|
|
5
6
|
export declare const LOGGER_FEATURE = "agentSelector";
|
package/types/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LOGGER_ACTION_CLICK, type LOGGER_ACTION_PROGRAMMATIC } from './constants';
|
|
1
|
+
import { type LOGGER_ACTION_CLICK, type LOGGER_ACTION_KEYPRESS, type LOGGER_ACTION_PROGRAMMATIC } from './constants';
|
|
2
2
|
import { type ACTIONS } from './contexts';
|
|
3
3
|
export type AgentType = {
|
|
4
4
|
id: string;
|
|
@@ -31,15 +31,21 @@ export type AgentListResponse = {
|
|
|
31
31
|
agents: AgentType[];
|
|
32
32
|
};
|
|
33
33
|
export type RecordActionType = {
|
|
34
|
-
action: typeof LOGGER_ACTION_CLICK | typeof LOGGER_ACTION_PROGRAMMATIC;
|
|
34
|
+
action: typeof LOGGER_ACTION_CLICK | typeof LOGGER_ACTION_PROGRAMMATIC | typeof LOGGER_ACTION_KEYPRESS;
|
|
35
35
|
data?: {
|
|
36
36
|
hostAppName?: string;
|
|
37
|
+
agentSelected?: string;
|
|
38
|
+
index?: number;
|
|
39
|
+
count?: number;
|
|
40
|
+
errorType?: string;
|
|
41
|
+
selectedQuestion?: string;
|
|
37
42
|
};
|
|
38
43
|
component: string;
|
|
39
44
|
feature: string;
|
|
40
45
|
target?: string;
|
|
41
46
|
};
|
|
42
47
|
export interface BoxAiAgentSelectorWithApiProps {
|
|
48
|
+
contentClassName?: string;
|
|
43
49
|
/**
|
|
44
50
|
* Function responsible for fetching the list of agents,
|
|
45
51
|
* typically passed from the parent component.
|
|
@@ -65,8 +71,10 @@ export interface BoxAiAgentSelectorWithApiProps {
|
|
|
65
71
|
* @default true
|
|
66
72
|
*/
|
|
67
73
|
shouldHideAgentSelectorOnLoad?: boolean;
|
|
74
|
+
triggerChipClassName?: string;
|
|
68
75
|
}
|
|
69
76
|
export interface BoxAiAgentSelectorProps {
|
|
77
|
+
contentClassName?: string;
|
|
70
78
|
/**
|
|
71
79
|
* Array of available agents to select from.
|
|
72
80
|
*/
|
|
@@ -87,4 +95,5 @@ export interface BoxAiAgentSelectorProps {
|
|
|
87
95
|
* The currently selected agent, or null if no agent is selected.
|
|
88
96
|
*/
|
|
89
97
|
selectedAgent: AgentType | null;
|
|
98
|
+
triggerChipClassName?: string;
|
|
90
99
|
}
|