@box/box-ai-agent-selector 0.21.0 → 0.22.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,79 +1,79 @@
1
- import { useState as h, useCallback as m, useEffect as f } from "react";
1
+ import { useState as d, useCallback as m, useEffect as f } from "react";
2
2
  import { BoxAiAgentSelector as I } from "./box-ai-agent-selector.js";
3
- import { LOGGER_BASE_CONFIG as a, LOGGER_TARGET as u } from "./constants.js";
4
- import { ACTIONS as E } from "./contexts/actions.js";
5
- import { useAgentsDispatch as L, useAgents as d } from "./contexts/context.js";
6
- import { R as i } from "../../chunks/types.js";
7
- import { jsx as U } from "react/jsx-runtime";
8
- function b({
9
- fetcher: R,
10
- hostAppName: _,
11
- onSelectAgent: o,
3
+ import { LOGGER_BASE_CONFIG as a, LOGGER_TARGET as l } from "./constants.js";
4
+ import { ACTIONS as S } from "./contexts/actions.js";
5
+ import { useAgentsDispatch as L, useAgents as U } from "./contexts/context.js";
6
+ import { R as r } from "../../chunks/types.js";
7
+ import { jsx as x } from "react/jsx-runtime";
8
+ function j({
9
+ fetcher: u,
10
+ hostAppName: R,
11
+ onSelectAgent: i,
12
12
  recordAction: T,
13
13
  requestState: s,
14
- disabled: g,
15
- shouldHideAgentSelectorOnLoad: l,
16
- triggerChipClassName: G,
14
+ disabled: G,
15
+ shouldHideAgentSelectorOnLoad: C,
16
+ triggerChipClassName: h,
17
17
  contentClassName: p,
18
- variant: C = "modal"
18
+ variant: O = "modal"
19
19
  }) {
20
20
  const e = L(), {
21
- agents: c,
22
- requestState: S,
21
+ agents: A,
22
+ requestState: E,
23
23
  selectedAgent: n
24
- } = d(), [O, N] = h(!1), r = m((t) => {
25
- T && (t.data ?? (t.data = {}), t.data.hostAppName = _, T(t));
26
- }, [_, T]), A = m(async () => {
24
+ } = U(), [N, _] = d(!1), o = m((t) => {
25
+ T && (t.data ?? (t.data = {}), t.data.hostAppName = R, T(t));
26
+ }, [R, T]), c = m(async () => {
27
27
  e({
28
- type: E.SET_REQUEST_STATE,
29
- requestState: i.IN_PROGRESS
28
+ type: S.SET_REQUEST_STATE,
29
+ requestState: r.IN_PROGRESS
30
30
  });
31
31
  try {
32
- const t = await R();
32
+ const t = await u();
33
33
  e({
34
- type: E.SET_AGENT_LIST,
34
+ type: S.SET_AGENT_LIST,
35
35
  agents: t.agents
36
- }), r({
36
+ }), o({
37
37
  ...a,
38
- target: u.LOADED_AGENTS
38
+ target: l.LOADED_AGENTS
39
39
  });
40
40
  } catch {
41
41
  e({
42
- type: E.SET_REQUEST_STATE,
43
- requestState: i.ERROR
44
- }), r({
42
+ type: S.SET_REQUEST_STATE,
43
+ requestState: r.ERROR
44
+ }), o({
45
45
  ...a,
46
- target: u.ERROR_LOADING_AGENTS
46
+ target: l.ERROR_LOADING_AGENTS
47
47
  });
48
48
  }
49
- }, [e, r, R]);
49
+ }, [e, o, u]), g = E !== r.SUCCESS || !A.length || !n;
50
50
  return f(() => {
51
- A().finally(() => {
52
- N(!0);
53
- });
54
- }, [A]), f(() => {
55
- s && s !== S && (s !== i.SUCCESS && e({
56
- type: E.SET_AGENT_LIST,
51
+ g ? c().finally(() => {
52
+ _(!0);
53
+ }) : _(!0);
54
+ }, [c, g]), f(() => {
55
+ s && s !== E && (s !== r.SUCCESS && e({
56
+ type: S.SET_AGENT_LIST,
57
57
  agents: []
58
58
  }), e({
59
- type: E.SET_REQUEST_STATE,
59
+ type: S.SET_REQUEST_STATE,
60
60
  requestState: s
61
61
  }));
62
- }, [e, S, s]), f(() => {
63
- o && o(n);
64
- }, [o, n]), l && !O || S === i.SUCCESS && c.length <= 1 ? null : /* @__PURE__ */ U(I, {
65
- agents: c,
62
+ }, [e, E, s]), f(() => {
63
+ i && i(n);
64
+ }, [i, n]), C && !N || E === r.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ x(I, {
65
+ agents: A,
66
66
  contentClassName: p,
67
- disabled: g,
68
- onErrorAction: A,
69
- recordAction: r,
70
- requestState: S,
67
+ disabled: G,
68
+ onErrorAction: c,
69
+ recordAction: o,
70
+ requestState: E,
71
71
  selectedAgent: n,
72
- triggerChipClassName: G,
73
- variant: C
72
+ triggerChipClassName: h,
73
+ variant: O
74
74
  });
75
75
  }
76
76
  export {
77
- b as BoxAiAgentSelectorWithApi,
78
- b as default
77
+ j as BoxAiAgentSelectorWithApi,
78
+ j as default
79
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-agent-selector",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
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": "^9.13.2",
13
+ "@box/blueprint-web": "^9.14.0",
14
14
  "@box/blueprint-web-assets": "^4.31.1",
15
15
  "@box/eslint-plugin-blueprint": "^1.0.3",
16
16
  "@box/storybook-utils": "^0.8.1",
@@ -46,5 +46,5 @@
46
46
  "sideEffects": [
47
47
  "**/*.css"
48
48
  ],
49
- "gitHead": "fc8fa2b3620bb3eff349a4b17dc7d71cc88d9690"
49
+ "gitHead": "f4624bdc366a4e8bcbb5dcefbeaf06ff0224163f"
50
50
  }
@@ -5,3 +5,4 @@ export declare const defaultBoxAiAgentSelectorProps: {
5
5
  }>;
6
6
  };
7
7
  export declare const DefaultBoxAiAgentSelectorWithApiContainer: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const BoxAiAgentSelectorWithProvider: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
- import { type AgentType } from '../types';
1
+ import { type AgentState, type AgentType } from '../types';
2
2
  export declare const mockAgents: AgentType[];
3
3
  export declare const mockAgentsWithLongNamesAndDescriptions: AgentType[];
4
+ export declare const mockAgentProviderState: AgentState;