@box/box-ai-agent-selector 0.12.3 → 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/index.js CHANGED
@@ -1,12 +1,16 @@
1
- import { BoxAiAgentSelectorWithApiContainer as t } from "./lib/box-ai-agent-selector-with-api-container.js";
2
- import { ACTIONS as A } from "./lib/contexts/actions.js";
3
- import { AgentsProvider as i, useAgents as n, useAgentsDispatch as p } from "./lib/contexts/context.js";
4
- import { R as g } from "../chunks/types.js";
1
+ import { BoxAiAgentSelector as t } from "./lib/box-ai-agent-selector.js";
2
+ import { BoxAiAgentSelectorWithApi as A } from "./lib/box-ai-agent-selector-with-api.js";
3
+ import { BoxAiAgentSelectorWithApiContainer as p } from "./lib/box-ai-agent-selector-with-api-container.js";
4
+ import { ACTIONS as n } from "./lib/contexts/actions.js";
5
+ import { AgentsProvider as f, useAgents as g, useAgentsDispatch as m } from "./lib/contexts/context.js";
6
+ import { R as c } from "../chunks/types.js";
5
7
  export {
6
- A as ACTIONS,
7
- i as AgentsProvider,
8
+ n as ACTIONS,
9
+ f as AgentsProvider,
8
10
  t as BoxAiAgentSelector,
9
- g as REQUEST_STATE,
10
- n as useAgents,
11
- p as useAgentsDispatch
11
+ A as BoxAiAgentSelectorWithApi,
12
+ p as BoxAiAgentSelectorWithApiContainer,
13
+ c as REQUEST_STATE,
14
+ g as useAgents,
15
+ m as useAgentsDispatch
12
16
  };
@@ -1,22 +1,30 @@
1
- import { BoxAiAgentSelectorWithApi as n } from "./box-ai-agent-selector-with-api.js";
2
- import { AgentsProvider as A } from "./contexts/context.js";
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 c({
4
+ function a({
5
5
  fetcher: t,
6
- shouldHideAgentSelectorOnLoad: e = !0,
7
- hostAppName: o,
8
- recordAction: i
6
+ hostAppName: e,
7
+ onSelectAgent: o,
8
+ recordAction: i,
9
+ requestState: n,
10
+ shouldHideAgentSelectorOnLoad: A = !0,
11
+ triggerChipClassName: m,
12
+ contentClassName: p
9
13
  }) {
10
- return /* @__PURE__ */ r(A, {
11
- children: /* @__PURE__ */ r(n, {
14
+ return /* @__PURE__ */ r(c, {
15
+ children: /* @__PURE__ */ r(f, {
16
+ contentClassName: p,
12
17
  fetcher: t,
13
- hostAppName: o,
18
+ hostAppName: e,
19
+ onSelectAgent: o,
14
20
  recordAction: i,
15
- shouldHideAgentSelectorOnLoad: e
21
+ requestState: n,
22
+ shouldHideAgentSelectorOnLoad: A,
23
+ triggerChipClassName: m
16
24
  })
17
25
  });
18
26
  }
19
27
  export {
20
- c as BoxAiAgentSelectorWithApiContainer,
21
- c as default
28
+ a as BoxAiAgentSelectorWithApiContainer,
29
+ a as default
22
30
  };
@@ -1,59 +1,75 @@
1
- import { useState as _, useCallback as T, useEffect as l } from "react";
2
- import { BoxAiAgentSelector as p } from "./box-ai-agent-selector.js";
3
- import { LOGGER_BASE_CONFIG as u, LOGGER_TARGET as R } from "./constants.js";
4
- import { ACTIONS as n } from "./contexts/actions.js";
5
- import { useAgentsDispatch as G, useAgents as O } from "./contexts/context.js";
6
- import { R as S } from "../../chunks/types.js";
7
- import { jsx as h } from "react/jsx-runtime";
8
- function U({
9
- fetcher: E,
10
- shouldHideAgentSelectorOnLoad: a,
11
- hostAppName: i,
12
- recordAction: r
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
+ import { LOGGER_BASE_CONFIG as u, LOGGER_TARGET as a } from "./constants.js";
4
+ import { ACTIONS as E } from "./contexts/actions.js";
5
+ import { useAgentsDispatch as h, useAgents as I } from "./contexts/context.js";
6
+ import { R as i } from "../../chunks/types.js";
7
+ import { jsx as L } from "react/jsx-runtime";
8
+ function F({
9
+ fetcher: R,
10
+ hostAppName: _,
11
+ onSelectAgent: T,
12
+ recordAction: n,
13
+ requestState: s,
14
+ shouldHideAgentSelectorOnLoad: g,
15
+ triggerChipClassName: G,
16
+ contentClassName: l
13
17
  }) {
14
- const e = G(), {
15
- agents: A,
16
- requestState: c,
17
- selectedAgent: g
18
- } = O(), [m, f] = _(!1), s = T((t) => {
19
- r && (t.data ?? (t.data = {}), t.data.hostAppName = i, r(t));
20
- }, [i, r]), o = T(async () => {
18
+ const e = h(), {
19
+ agents: c,
20
+ requestState: S,
21
+ selectedAgent: o
22
+ } = I(), [p, C] = O(!1), r = m((t) => {
23
+ n && (t.data ?? (t.data = {}), t.data.hostAppName = _, n(t));
24
+ }, [_, n]), A = m(async () => {
21
25
  e({
22
- type: n.SET_REQUEST_STATE,
23
- requestState: S.IN_PROGRESS
26
+ type: E.SET_REQUEST_STATE,
27
+ requestState: i.IN_PROGRESS
24
28
  });
25
29
  try {
26
- const t = await E();
30
+ const t = await R();
27
31
  e({
28
- type: n.SET_AGENT_LIST,
32
+ type: E.SET_AGENT_LIST,
29
33
  agents: t.agents
30
- }), s({
34
+ }), r({
31
35
  ...u,
32
- target: R.LOADED_AGENTS
36
+ target: a.LOADED_AGENTS
33
37
  });
34
38
  } catch {
35
39
  e({
36
- type: n.SET_REQUEST_STATE,
37
- requestState: S.ERROR
38
- }), s({
40
+ type: E.SET_REQUEST_STATE,
41
+ requestState: i.ERROR
42
+ }), r({
39
43
  ...u,
40
- target: R.ERROR_LOADING_AGENTS
44
+ target: a.ERROR_LOADING_AGENTS
41
45
  });
42
46
  }
43
- }, [e, s, E]);
44
- return l(() => {
45
- o().finally(() => {
46
- f(!0);
47
+ }, [e, r, R]);
48
+ return f(() => {
49
+ A().finally(() => {
50
+ C(!0);
47
51
  });
48
- }, [o]), a && !m || c === S.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ h(p, {
49
- agents: A,
50
- onErrorAction: o,
51
- recordAction: s,
52
- requestState: c,
53
- selectedAgent: g
52
+ }, [A]), f(() => {
53
+ s && s !== S && (s !== i.SUCCESS && e({
54
+ type: E.SET_AGENT_LIST,
55
+ agents: []
56
+ }), e({
57
+ type: E.SET_REQUEST_STATE,
58
+ requestState: s
59
+ }));
60
+ }, [e, S, s]), f(() => {
61
+ T && T(o);
62
+ }, [T, o]), g && !p || S === i.SUCCESS && c.length <= 1 ? null : /* @__PURE__ */ L(N, {
63
+ agents: c,
64
+ contentClassName: l,
65
+ onErrorAction: A,
66
+ recordAction: r,
67
+ requestState: S,
68
+ selectedAgent: o,
69
+ triggerChipClassName: G
54
70
  });
55
71
  }
56
72
  export {
57
- U as BoxAiAgentSelectorWithApi,
58
- U as default
73
+ F as BoxAiAgentSelectorWithApi,
74
+ F as default
59
75
  };
@@ -1,107 +1,131 @@
1
1
  import "../../styles/box-ai-agent-selector.css";
2
- import { FilterChip as l, Popover as g, Tooltip as y, Status as j, LoadingIndicator as w, SmallList as B, Button as b } from "@box/blueprint-web";
3
- import { AlertBadge as x } from "@box/blueprint-web-assets/icons/Fill";
4
- import { useState as P, useEffect as A, useCallback as I } from "react";
5
- import { useIntl as D } from "react-intl";
6
- import { BoxAiAgent as M } from "./box-ai-agent.js";
7
- import { LOGGER_BASE_CONFIG as E, LOGGER_ACTION_CLICK as f, LOGGER_TARGET as d } from "./constants.js";
8
- import { ACTIONS as k } from "./contexts/actions.js";
9
- import { useAgentsDispatch as F } from "./contexts/context.js";
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";
8
+ import { LOGGER_BASE_CONFIG as L, LOGGER_ACTION_CLICK as f, LOGGER_TARGET as E } from "./constants.js";
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
- import { R as S } from "../../chunks/types.js";
12
- import { jsx as t, jsxs as h } from "react/jsx-runtime";
13
- const K = "_agentSelector_1vtwj_1", U = "_agentStatus_1vtwj_4", Q = "_agentLoader_1vtwj_18", Y = "_agentError_1vtwj_21", z = "_agentListItemIcon_1vtwj_25", H = "_agentListContainer_1vtwj_30", J = "_agentListRetryButton_1vtwj_35", a = {
14
- agentSelector: K,
15
- agentStatus: U,
16
- agentLoader: Q,
17
- agentError: Y,
18
- agentListItemIcon: z,
19
- agentListContainer: H,
20
- agentListRetryButton: J
12
+ import { R as h } from "../../chunks/types.js";
13
+ import { jsx as t, jsxs as u } from "react/jsx-runtime";
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
21
25
  };
22
- function it({
23
- agents: N,
24
- onErrorAction: u,
25
- requestState: m,
26
+ function ht({
27
+ agents: G,
28
+ contentClassName: O,
29
+ onErrorAction: C,
30
+ recordAction: a,
31
+ requestState: p,
26
32
  selectedAgent: n,
27
- recordAction: e
33
+ triggerChipClassName: b
28
34
  }) {
29
35
  const {
30
36
  formatMessage: o
31
- } = D(), [c, p] = P(!1), C = o(r.selectAgent), v = o(r.defaultAgent), R = F(), T = m === S.SUCCESS, _ = m === S.IN_PROGRESS, s = m === S.ERROR;
32
- let L = "";
33
- T ? L = (n == null ? void 0 : n.name) || C : s && (L = v), A(() => {
34
- c && e && e({
35
- ...E,
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;
38
+ let i = "";
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({
44
+ ref: T,
45
+ textValue: i
46
+ });
47
+ V(() => {
48
+ l && a && a({
49
+ ...L,
36
50
  action: f,
37
- target: d.OPEN_SELECTOR
51
+ target: E.OPEN_SELECTOR
38
52
  });
39
- }, [c, e]);
40
- const G = I((i) => {
41
- p(!1), R({
42
- type: k.SET_SELECTED_AGENT,
43
- id: i.id
44
- }), e && e({
45
- ...E,
53
+ }, [l, a]);
54
+ const v = N((s) => {
55
+ _(!1), I({
56
+ type: z.SET_SELECTED_AGENT,
57
+ id: s.id
58
+ }), a && a({
59
+ ...L,
46
60
  action: f,
47
- target: d.SELECT_AGENT
61
+ target: E.SELECT_AGENT
48
62
  });
49
- }, [R, e]), O = I(() => {
50
- p(!1), u(), e && e({
51
- ...E,
63
+ }, [I, a]), w = N(() => {
64
+ _(!1), C(), a && a({
65
+ ...L,
52
66
  action: f,
53
- target: d.RETRY_LOADING_AGENTS
67
+ target: E.RETRY_LOADING_AGENTS
54
68
  });
55
- }, [u, e]);
56
- return /* @__PURE__ */ t(l.Group, {
57
- className: a.agentSelector,
58
- name: C,
69
+ }, [C, a]);
70
+ return /* @__PURE__ */ t(c.Group, {
71
+ className: x([e.agentSelector, b]),
72
+ name: S,
59
73
  type: "multiple",
60
- children: /* @__PURE__ */ h(g.Root, {
74
+ children: /* @__PURE__ */ u(m.Root, {
61
75
  modal: !1,
62
- onOpenChange: p,
63
- open: c,
64
- children: [/* @__PURE__ */ t(y, {
76
+ onOpenChange: _,
77
+ open: l,
78
+ children: [/* @__PURE__ */ t(A, {
65
79
  content: o(r.errorTooltip),
66
- hidden: !s,
80
+ hidden: !g || l,
67
81
  side: "bottom",
68
82
  variant: "error",
69
- children: /* @__PURE__ */ t(g.Trigger, {
70
- disabled: _,
71
- children: /* @__PURE__ */ h(l.TriggerChip, {
83
+ children: /* @__PURE__ */ t(m.Trigger, {
84
+ disabled: d,
85
+ children: /* @__PURE__ */ u(c.TriggerChip, {
86
+ className: e.triggerChip,
72
87
  value: "trigger-chip",
73
- children: [/* @__PURE__ */ t(j, {
74
- className: a.agentStatus,
88
+ children: [/* @__PURE__ */ t(D, {
89
+ className: e.agentStatus,
75
90
  colorIndex: 0,
76
91
  text: o(r.agent)
77
- }), _ && /* @__PURE__ */ t(w, {
92
+ }), d && /* @__PURE__ */ t(M, {
78
93
  "aria-label": o(r.loadingMessage),
79
- className: a.agentLoader,
94
+ className: e.agentLoader,
80
95
  variant: "default"
81
- }), s && /* @__PURE__ */ t(x, {
82
- className: a.agentError,
96
+ }), g && /* @__PURE__ */ t(K, {
97
+ className: e.agentError,
83
98
  height: "1rem",
84
99
  role: "presentation",
85
100
  width: "1rem"
86
- }), /* @__PURE__ */ t(l.Label, {
87
- children: L
88
- }), !_ && /* @__PURE__ */ t(l.DropdownIndicator, {})]
101
+ }), /* @__PURE__ */ t(y, {
102
+ ...B,
103
+ content: i,
104
+ children: /* @__PURE__ */ t(c.Label, {
105
+ ref: T,
106
+ className: e.agentLabel,
107
+ children: i
108
+ })
109
+ }), !d && /* @__PURE__ */ t("div", {
110
+ className: e.dropdownIndicator,
111
+ children: /* @__PURE__ */ t(c.DropdownIndicator, {})
112
+ })]
89
113
  })
90
114
  })
91
- }), /* @__PURE__ */ t(g.ContentContainer, {
115
+ }), /* @__PURE__ */ t(m.ContentContainer, {
92
116
  align: "start",
93
- className: a.agentListContainer,
94
- children: /* @__PURE__ */ h(g.MainContent, {
95
- children: [T && /* @__PURE__ */ t(B, {
96
- className: a.agentList,
117
+ className: e.agentListContainer,
118
+ children: /* @__PURE__ */ u(m.MainContent, {
119
+ children: [R && /* @__PURE__ */ t(F, {
120
+ className: x([e.agentList, O]),
97
121
  selectedKeys: [(n == null ? void 0 : n.id) || ""],
98
- children: N.map((i) => /* @__PURE__ */ t(M, {
99
- agent: i,
100
- onAction: () => G(i)
101
- }, i.id))
102
- }), s && /* @__PURE__ */ t(b, {
103
- className: a.agentListRetryButton,
104
- onClick: O,
122
+ children: G.map((s) => /* @__PURE__ */ t(Y, {
123
+ agent: s,
124
+ onAction: () => v(s)
125
+ }, s.id))
126
+ }), g && /* @__PURE__ */ t(j, {
127
+ className: e.agentListRetryButton,
128
+ onClick: w,
105
129
  variant: "tertiary",
106
130
  children: o(r.errorMessage)
107
131
  })]
@@ -111,6 +135,6 @@ function it({
111
135
  });
112
136
  }
113
137
  export {
114
- it as BoxAiAgentSelector,
115
- it as default
138
+ ht as BoxAiAgentSelector,
139
+ ht as default
116
140
  };
@@ -1,52 +1,62 @@
1
1
  import "../../styles/box-ai-agent.css";
2
- import { SmallList as s, Tooltip as o, Text as r, Status as c } from "@box/blueprint-web";
3
- import { BoxAiLogo as d } from "@box/blueprint-web-assets/icons/Logo";
4
- import { SurfaceStatusSurfaceGray as u } from "@box/blueprint-web-assets/tokens/tokens";
5
- import { useIntl as f } from "react-intl";
6
- import g from "./messages.js";
7
- import { jsxs as i, jsx as t, Fragment as A } from "react/jsx-runtime";
8
- const _ = "_agentListItem_1s7vn_1", p = "_agentListItemIcon_1s7vn_1", I = "_defaultAgentHeader_1s7vn_5", L = "_defaultAgentName_1s7vn_9", S = "_defaultAgentStatus_1s7vn_15", a = {
9
- agentListItem: _,
10
- agentListItemIcon: p,
11
- defaultAgentHeader: I,
12
- defaultAgentName: L,
13
- defaultAgentStatus: S
2
+ import { useFullTextTooltip as u, SmallList as s, Text as d, Status as f } from "@box/blueprint-web";
3
+ import { BoxAiLogo as p } from "@box/blueprint-web-assets/icons/Logo";
4
+ import { SurfaceStatusSurfaceGray as g } from "@box/blueprint-web-assets/tokens/tokens";
5
+ import { useRef as A } from "react";
6
+ import { useIntl as _ } from "react-intl";
7
+ import I from "./messages.js";
8
+ import { jsxs as i, jsx as t, Fragment as L } from "react/jsx-runtime";
9
+ const S = "_agentListItem_1s7vn_1", x = "_agentListItemIcon_1s7vn_1", N = "_defaultAgentHeader_1s7vn_5", h = "_defaultAgentName_1s7vn_9", v = "_defaultAgentStatus_1s7vn_15", a = {
10
+ agentListItem: S,
11
+ agentListItemIcon: x,
12
+ defaultAgentHeader: N,
13
+ defaultAgentName: h,
14
+ defaultAgentStatus: v
14
15
  };
15
- function y({
16
+ function w({
16
17
  agent: e,
17
- onAction: m
18
+ onAction: l
18
19
  }) {
19
20
  const {
20
- formatMessage: l
21
- } = f(), n = e.isEnterpriseDefault;
21
+ formatMessage: m
22
+ } = _(), n = e.isEnterpriseDefault, r = A(null), {
23
+ Wrapper: o,
24
+ wrapperProps: c
25
+ } = u({
26
+ ref: r,
27
+ textValue: e.name,
28
+ skipOverflowCheck: !n
29
+ });
22
30
  return /* @__PURE__ */ i(s.Item, {
23
31
  className: a.agentListItem,
24
32
  id: e.id,
25
- onAction: m,
33
+ onAction: l,
26
34
  children: [/* @__PURE__ */ t(s.Thumbnail, {
27
35
  className: a.agentListItemIcon,
28
36
  children: e.imageURL ? /* @__PURE__ */ t("img", {
29
37
  "aria-label": e.name,
30
38
  src: e.imageURL
31
- }) : /* @__PURE__ */ t(d, {
39
+ }) : /* @__PURE__ */ t(p, {
32
40
  "aria-label": e.name
33
41
  })
34
42
  }), /* @__PURE__ */ t(s.Header, {
35
43
  className: n ? a.defaultAgentHeader : void 0,
36
44
  textValue: e.name,
37
- children: n ? /* @__PURE__ */ i(A, {
45
+ children: n ? /* @__PURE__ */ i(L, {
38
46
  children: [/* @__PURE__ */ t(o, {
47
+ ...c,
39
48
  content: e.name,
40
- children: /* @__PURE__ */ t(r, {
49
+ children: /* @__PURE__ */ t(d, {
50
+ ref: r,
41
51
  as: "span",
42
52
  className: a.defaultAgentName,
43
53
  variant: "bodyDefaultSemibold",
44
54
  children: e.name
45
55
  })
46
- }), /* @__PURE__ */ t(c, {
56
+ }), /* @__PURE__ */ t(f, {
47
57
  className: a.defaultAgentStatus,
48
- color: u,
49
- text: l(g.defaultStatus)
58
+ color: g,
59
+ text: m(I.defaultStatus)
50
60
  })]
51
61
  }) : e.name
52
62
  }), e.description && /* @__PURE__ */ t(s.Subtitle, {
@@ -56,6 +66,6 @@ function y({
56
66
  });
57
67
  }
58
68
  export {
59
- y as BoxAiAgent,
60
- y as default
69
+ w as BoxAiAgent,
70
+ w as default
61
71
  };
@@ -1,4 +1,4 @@
1
- const G = "click", E = "programmatic", e = "selector", t = "agentSelector", o = {
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: t
10
+ feature: G
11
11
  };
12
12
  export {
13
- G as LOGGER_ACTION_CLICK,
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
- t as LOGGER_FEATURE,
18
- o as LOGGER_TARGET
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.12.3",
3
+ "version": "0.13.1",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^7.31.1",
@@ -10,7 +10,7 @@
10
10
  "react-intl": "^6.4.2"
11
11
  },
12
12
  "devDependencies": {
13
- "@box/blueprint-web": "^8.3.0",
13
+ "@box/blueprint-web": "^8.3.1",
14
14
  "@box/blueprint-web-assets": "^4.28.0",
15
15
  "@box/eslint-plugin-blueprint": "*",
16
16
  "@box/storybook-utils": "^0.7.0",
@@ -46,5 +46,5 @@
46
46
  "sideEffects": [
47
47
  "**/*.css"
48
48
  ],
49
- "gitHead": "30a4168eff5a8500b505e86beb4dff3b527aac44"
49
+ "gitHead": "5a9d17c1a6963a9dbcde5a0a86d4f2cbcf35db53"
50
50
  }
@@ -1 +1 @@
1
- ._agentSelector_1vtwj_1{margin-inline-start:.75rem}._agentSelector_1vtwj_1 ._agentStatus_1vtwj_4{margin-inline-start:.5rem}._agentSelector_1vtwj_1 ._agentStatus_1vtwj_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_1vtwj_1 ._agentStatus_1vtwj_4>span span{background:linear-gradient(135deg,#fe01da,#2486fc);color:transparent;-webkit-background-clip:text;background-clip:text;text-transform:uppercase}._agentSelector_1vtwj_1 ._agentLoader_1vtwj_18{position:inherit}._agentSelector_1vtwj_1 ._agentError_1vtwj_21 path{fill:#d5324e}._agentListItemIcon_1vtwj_25{height:2rem;width:2rem}._agentListContainer_1vtwj_30{min-width:320px;max-width:500px}._agentListRetryButton_1vtwj_35{margin:.25rem;max-width:320px;text-wrap:wrap}
1
+ ._agentSelector_1k90x_1{margin-inline-start:.75rem}._agentSelector_1k90x_1 ._agentStatus_1k90x_4{margin-inline-start:.5rem}._agentSelector_1k90x_1 ._agentStatus_1k90x_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_1k90x_1 ._agentStatus_1k90x_4>span span{background:linear-gradient(135deg,#fe01da,#2486fc);color:transparent;-webkit-background-clip:text;background-clip:text;text-transform:uppercase}._agentSelector_1k90x_1 ._agentLoader_1k90x_18{position:inherit}._agentSelector_1k90x_1 ._agentError_1k90x_21 path{fill:#d5324e}._agentSelector_1k90x_1 ._triggerChip_1k90x_24{max-width:376px;display:flex;text-align:start}._agentSelector_1k90x_1 ._triggerChip_1k90x_24 ._agentLabel_1k90x_29{flex-grow:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._agentSelector_1k90x_1 ._triggerChip_1k90x_24 ._dropdownIndicator_1k90x_35{flex-shrink:0}@media (max-width: 374px){._agentSelector_1k90x_1 ._triggerChip_1k90x_24{width:100%}}._agentListItemIcon_1k90x_44{height:2rem;width:2rem}._agentListContainer_1k90x_49{min-width:320px;max-width:376px}@media (max-width: 376px){._agentListContainer_1k90x_49{max-width:320px}}._agentListRetryButton_1k90x_59{margin:.25rem;max-width:320px;text-wrap:wrap}
package/types/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export { BoxAiAgentSelectorWithApiContainer as BoxAiAgentSelector } from './lib/box-ai-agent-selector-with-api-container';
1
+ export * from './lib/box-ai-agent-selector';
2
+ export * from './lib/box-ai-agent-selector-with-api';
3
+ export * from './lib/box-ai-agent-selector-with-api-container';
2
4
  export * from './lib/contexts';
3
5
  export * from './lib/types';
@@ -1,25 +1,3 @@
1
- import { type AgentListResponse, type RecordActionType } from './types';
2
- export interface BoxAiAgentSelectorWithApiContainerProps {
3
- /**
4
- * Function responsible for fetching the list of agents,
5
- * typically passed from the parent component.
6
- * The function returns a promise that resolves to the agent list response.
7
- */
8
- fetcher: () => Promise<AgentListResponse>;
9
- /**
10
- * Name of the host application for resin event tracking
11
- * */
12
- hostAppName?: string;
13
- /**
14
- * Callback function to handle logging resin events
15
- * */
16
- recordAction?: (payload: RecordActionType) => void;
17
- /**
18
- * Determines whether the agent selector component should remain hidden
19
- * until the initial data fetch is complete.
20
- * @default true
21
- */
22
- shouldHideAgentSelectorOnLoad?: boolean;
23
- }
24
- export declare function BoxAiAgentSelectorWithApiContainer({ fetcher, shouldHideAgentSelectorOnLoad, hostAppName, recordAction, }: BoxAiAgentSelectorWithApiContainerProps): import("react/jsx-runtime").JSX.Element;
1
+ import { type BoxAiAgentSelectorWithApiProps } from './types';
2
+ export declare function BoxAiAgentSelectorWithApiContainer({ fetcher, hostAppName, onSelectAgent, recordAction, requestState, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element;
25
3
  export default BoxAiAgentSelectorWithApiContainer;
@@ -1,25 +1,3 @@
1
- import { type AgentListResponse, type RecordActionType } from './types';
2
- export interface BoxAiAgentSelectorWithApiProps {
3
- /**
4
- * Function responsible for fetching the list of agents,
5
- * typically passed from the parent component.
6
- * The function returns a promise that resolves to the agent list response.
7
- */
8
- fetcher: () => Promise<AgentListResponse>;
9
- /**
10
- * Name of the host application for resin event tracking
11
- * */
12
- hostAppName?: string;
13
- /**
14
- * Callback function to handle logging resin events
15
- * */
16
- recordAction?: (payload: RecordActionType) => void;
17
- /**
18
- * Determines whether the agent selector component should remain hidden
19
- * until the initial data fetch is complete.
20
- * @default true
21
- */
22
- shouldHideAgentSelectorOnLoad?: boolean;
23
- }
24
- export declare function BoxAiAgentSelectorWithApi({ fetcher, shouldHideAgentSelectorOnLoad, hostAppName, recordAction, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
1
+ import { type BoxAiAgentSelectorWithApiProps } from './types';
2
+ export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
25
3
  export default BoxAiAgentSelectorWithApi;
@@ -1,25 +1,3 @@
1
- import { REQUEST_STATE, type AgentType, type RecordActionType } from './types';
2
- export interface BoxAiAgentSelectorProps {
3
- /**
4
- * Array of available agents to select from.
5
- */
6
- agents: AgentType[];
7
- /**
8
- * Callback function triggered when an error occurs, used to retry fetching the agent list.
9
- */
10
- onErrorAction: () => void;
11
- /**
12
- * Callback function to handle logging resin events
13
- * */
14
- recordAction?: (payload: RecordActionType) => void;
15
- /**
16
- * Current state of the request to fetch agents, representing one of: Success, Error, In Progress, or Not Started.
17
- */
18
- requestState: REQUEST_STATE;
19
- /**
20
- * The currently selected agent, or null if no agent is selected.
21
- */
22
- selectedAgent: AgentType | null;
23
- }
24
- export declare function BoxAiAgentSelector({ agents, onErrorAction, requestState, selectedAgent, recordAction, }: BoxAiAgentSelectorProps): import("react/jsx-runtime").JSX.Element;
1
+ import { type BoxAiAgentSelectorProps } from './types';
2
+ export declare function BoxAiAgentSelector({ agents, contentClassName, onErrorAction, recordAction, requestState, selectedAgent, triggerChipClassName, }: BoxAiAgentSelectorProps): import("react/jsx-runtime").JSX.Element;
25
3
  export default BoxAiAgentSelector;
@@ -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";
@@ -0,0 +1,7 @@
1
+ import { type BoxAiAgentSelectorWithApiProps } from '../../index';
2
+ export declare const defaultBoxAiAgentSelectorProps: {
3
+ fetcher: () => Promise<{
4
+ agents: import("../types").AgentType[];
5
+ }>;
6
+ };
7
+ export declare const DefaultBoxAiAgentSelectorWithApiContainer: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
@@ -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,11 +31,69 @@ 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
  };
47
+ export interface BoxAiAgentSelectorWithApiProps {
48
+ contentClassName?: string;
49
+ /**
50
+ * Function responsible for fetching the list of agents,
51
+ * typically passed from the parent component.
52
+ * The function returns a promise that resolves to the agent list response.
53
+ */
54
+ fetcher: () => Promise<AgentListResponse>;
55
+ /**
56
+ * Name of the host application for resin event tracking
57
+ * */
58
+ hostAppName?: string;
59
+ /** Callback function when an agent is selected */
60
+ onSelectAgent?: (agent: AgentType | null) => void;
61
+ /**
62
+ * Callback function to handle logging resin events
63
+ * */
64
+ recordAction?: (payload: RecordActionType) => void;
65
+ /** Request state of the list fetching
66
+ */
67
+ requestState?: REQUEST_STATE | null;
68
+ /**
69
+ * Determines whether the agent selector component should remain hidden
70
+ * until the initial data fetch is complete.
71
+ * @default true
72
+ */
73
+ shouldHideAgentSelectorOnLoad?: boolean;
74
+ triggerChipClassName?: string;
75
+ }
76
+ export interface BoxAiAgentSelectorProps {
77
+ contentClassName?: string;
78
+ /**
79
+ * Array of available agents to select from.
80
+ */
81
+ agents: AgentType[];
82
+ /**
83
+ * Callback function triggered when an error occurs, used to retry fetching the agent list.
84
+ */
85
+ onErrorAction: () => void;
86
+ /**
87
+ * Callback function to handle logging resin events
88
+ * */
89
+ recordAction?: (payload: RecordActionType) => void;
90
+ /**
91
+ * Current state of the request to fetch agents, representing one of: Success, Error, In Progress, or Not Started.
92
+ */
93
+ requestState: REQUEST_STATE;
94
+ /**
95
+ * The currently selected agent, or null if no agent is selected.
96
+ */
97
+ selectedAgent: AgentType | null;
98
+ triggerChipClassName?: string;
99
+ }
@@ -1,4 +0,0 @@
1
- import { type AgentState } from '../../types';
2
- import { type AgentsProviderProps } from '../context';
3
- export declare const initialState: AgentState;
4
- export declare const DefaultContextProvider: ({ value }: AgentsProviderProps) => import("react/jsx-runtime").JSX.Element;