@box/box-ai-agent-selector 1.15.4 → 1.16.0

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,8 +1,8 @@
1
- let t = /* @__PURE__ */ function(e) {
1
+ let t = /* @__PURE__ */ (function(e) {
2
2
  return e.NOT_STARTED = "not_started", e.IN_PROGRESS = "in_progress", e.SUCCESS = "success", e.ERROR = "error", e.CANCELLED = "cancelled", e;
3
- }({}), r = /* @__PURE__ */ function(e) {
3
+ })({}), r = /* @__PURE__ */ (function(e) {
4
4
  return e.LEFT = "left", e.OFFSET_FROM_LEFT = "offset_from_left", e;
5
- }({});
5
+ })({});
6
6
  export {
7
7
  t as R,
8
8
  r as S
package/dist/esm/index.js CHANGED
@@ -3,19 +3,19 @@ import { BoxAiAgentSelectorWithApi as A } from "./lib/box-ai-agent-selector-with
3
3
  import { BoxAiAgentSelectorWithApiContainer as s } from "./lib/box-ai-agent-selector-with-api-container.js";
4
4
  import { AI_AGENTS_LOCAL_STORAGE_KEY as S } from "./lib/constants.js";
5
5
  import { R as f, S as n } from "../chunks/types.js";
6
- import { ACTIONS as a } from "./lib/contexts/actions.js";
7
- import { AgentsProvider as m, useAgents as T, useAgentsDispatch as _ } from "./lib/contexts/context.js";
8
- import { default as l } from "./lib/hooks/useLocalStorageAIAgents.js";
6
+ import { default as a } from "./lib/hooks/useLocalStorageAIAgents.js";
7
+ import { ACTIONS as m } from "./lib/contexts/actions.js";
8
+ import { AgentsProvider as _, useAgents as c, useAgentsDispatch as l } from "./lib/contexts/context.js";
9
9
  export {
10
- a as ACTIONS,
10
+ m as ACTIONS,
11
11
  S as AI_AGENTS_LOCAL_STORAGE_KEY,
12
- m as AgentsProvider,
12
+ _ as AgentsProvider,
13
13
  t as BoxAiAgentSelector,
14
14
  A as BoxAiAgentSelectorWithApi,
15
15
  s as BoxAiAgentSelectorWithApiContainer,
16
16
  f as REQUEST_STATE,
17
17
  n as SELECTOR_ALIGNMENT,
18
- T as useAgents,
19
- _ as useAgentsDispatch,
20
- l as useLocalStorageAIAgents
18
+ c as useAgents,
19
+ l as useAgentsDispatch,
20
+ a as useLocalStorageAIAgents
21
21
  };
@@ -4,8 +4,8 @@ import { S } from "../../chunks/types.js";
4
4
  import { jsx as r } from "react/jsx-runtime";
5
5
  import { AgentsProvider as c } from "./contexts/context.js";
6
6
  import "./constants.js";
7
- import "./contexts/actions.js";
8
7
  import "./hooks/useLocalStorageAIAgents.js";
8
+ import "./contexts/actions.js";
9
9
  function O({
10
10
  fetcher: t,
11
11
  hostAppName: o,
@@ -1,86 +1,86 @@
1
- import { useState as x, useCallback as O, useEffect as o } from "react";
2
- import { BoxAiAgentSelector as D } from "./box-ai-agent-selector.js";
3
- import { LOGGER_BASE_CONFIG as c, LOGGER_TARGET as g } from "./constants.js";
1
+ import { useState as y, useCallback as g, useEffect as T } from "react";
2
+ import { BoxAiAgentSelector as U } from "./box-ai-agent-selector.js";
3
+ import { LOGGER_TARGET as l, LOGGER_BASE_CONFIG as p } from "./constants.js";
4
4
  import { ACTIONS as S } from "./contexts/actions.js";
5
- import { useAgentsDispatch as Q, useAgents as d } from "./contexts/context.js";
6
- import { R as r, S as q } from "../../chunks/types.js";
7
- import { jsx as y } from "react/jsx-runtime";
5
+ import { useAgentsDispatch as x, useAgents as D } from "./contexts/context.js";
6
+ import { R as r, S as Q } from "../../chunks/types.js";
7
+ import { jsx as q } from "react/jsx-runtime";
8
8
  function J({
9
- fetcher: A,
10
- hostAppName: m,
11
- onSelectAgent: f,
12
- onSelectedAgentCallback: _,
13
- recordAction: n,
14
- requestState: e,
15
- disabled: h,
16
- onAgentsListOpen: C,
17
- selectorAlignment: L = q.OFFSET_FROM_LEFT,
18
- shouldHideAgentSelectorOnLoad: N,
19
- triggerChipClassName: p,
20
- contentClassName: F,
21
- useAgentLocalStorage: I = !1,
9
+ fetcher: R,
10
+ hostAppName: u,
11
+ onSelectAgent: n,
12
+ onSelectedAgentCallback: a,
13
+ recordAction: A,
14
+ requestState: E,
15
+ disabled: G,
16
+ onAgentsListOpen: O,
17
+ selectorAlignment: d = Q.OFFSET_FROM_LEFT,
18
+ shouldHideAgentSelectorOnLoad: h,
19
+ triggerChipClassName: C,
20
+ contentClassName: L,
21
+ useAgentLocalStorage: N = !1,
22
22
  // All non-Box AI Q&A experiences should pass in false
23
- variant: U = "modal"
23
+ variant: F = "modal"
24
24
  }) {
25
- const E = Q(), {
26
- agents: R,
25
+ const t = x(), {
26
+ agents: f,
27
27
  requestState: i,
28
- selectedAgent: t
29
- } = d(), [l, a] = x(!1), T = O((s) => {
30
- n && (s.data ?? (s.data = {}), s.data.hostAppName = m, n(s));
31
- }, [m, n]), u = O(async () => {
32
- E({
28
+ selectedAgent: e
29
+ } = D(), [I, m] = y(!1), o = g((s) => {
30
+ A && (s.data ??= {}, s.data.hostAppName = u, A(s));
31
+ }, [u, A]), _ = g(async () => {
32
+ t({
33
33
  type: S.SET_REQUEST_STATE,
34
34
  requestState: r.IN_PROGRESS
35
35
  });
36
36
  try {
37
- const s = await A();
38
- E({
37
+ const s = await R();
38
+ t({
39
39
  type: S.SET_AGENT_LIST,
40
40
  agents: s.agents
41
- }), T({
42
- ...c,
43
- target: g.LOADED_AGENTS
41
+ }), o({
42
+ ...p,
43
+ target: l.LOADED_AGENTS
44
44
  });
45
45
  } catch {
46
- E({
46
+ t({
47
47
  type: S.SET_REQUEST_STATE,
48
48
  requestState: r.ERROR
49
- }), T({
50
- ...c,
51
- target: g.ERROR_LOADING_AGENTS
49
+ }), o({
50
+ ...p,
51
+ target: l.ERROR_LOADING_AGENTS
52
52
  });
53
53
  }
54
- }, [E, T, A]), G = i !== r.SUCCESS || !R.length || !t;
55
- return o(() => {
56
- G ? u().finally(() => {
57
- a(!0);
58
- }) : a(!0);
59
- }, [u, G]), o(() => {
60
- e && e !== i && (e !== r.SUCCESS && E({
54
+ }, [t, o, R]), c = i !== r.SUCCESS || !f.length || !e;
55
+ return T(() => {
56
+ c ? _().finally(() => {
57
+ m(!0);
58
+ }) : m(!0);
59
+ }, [_, c]), T(() => {
60
+ E && E !== i && (E !== r.SUCCESS && t({
61
61
  type: S.SET_AGENT_LIST,
62
62
  agents: []
63
- }), E({
63
+ }), t({
64
64
  type: S.SET_REQUEST_STATE,
65
- requestState: e
65
+ requestState: E
66
66
  }));
67
- }, [E, e]), o(() => {
68
- f && f(t);
69
- }, [f, t == null ? void 0 : t.id]), o(() => {
70
- _ && _(t);
71
- }, [_, t == null ? void 0 : t.id]), N && !l || i === r.SUCCESS && R.length <= 1 ? null : /* @__PURE__ */ y(D, {
72
- agents: R,
73
- contentClassName: F,
74
- disabled: h,
75
- onAgentsListOpen: C,
76
- onErrorAction: u,
77
- recordAction: T,
67
+ }, [t, E]), T(() => {
68
+ n && n(e);
69
+ }, [n, e?.id]), T(() => {
70
+ a && a(e);
71
+ }, [a, e?.id]), h && !I || i === r.SUCCESS && f.length <= 1 ? null : /* @__PURE__ */ q(U, {
72
+ agents: f,
73
+ contentClassName: L,
74
+ disabled: G,
75
+ onAgentsListOpen: O,
76
+ onErrorAction: _,
77
+ recordAction: o,
78
78
  requestState: i,
79
- selectedAgent: t,
80
- selectorAlignment: L,
81
- triggerChipClassName: p,
82
- useAgentLocalStorage: I,
83
- variant: U
79
+ selectedAgent: e,
80
+ selectorAlignment: d,
81
+ triggerChipClassName: C,
82
+ useAgentLocalStorage: N,
83
+ variant: F
84
84
  });
85
85
  }
86
86
  export {