@box/box-ai-agent-selector 0.33.1 → 0.33.2

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,9 +1,9 @@
1
1
  import { useState as I, useCallback as m, useEffect as f } from "react";
2
2
  import { BoxAiAgentSelector as L } from "./box-ai-agent-selector.js";
3
3
  import { LOGGER_BASE_CONFIG as a, LOGGER_TARGET as l } from "./constants.js";
4
- import { ACTIONS as S } from "./contexts/actions.js";
4
+ import { ACTIONS as E } from "./contexts/actions.js";
5
5
  import { useAgentsDispatch as U, useAgents as x } from "./contexts/context.js";
6
- import { R as r } from "../../chunks/types.js";
6
+ import { R as S } from "../../chunks/types.js";
7
7
  import { jsx as D } from "react/jsx-runtime";
8
8
  function k({
9
9
  fetcher: u,
@@ -20,19 +20,19 @@ function k({
20
20
  }) {
21
21
  const e = U(), {
22
22
  agents: A,
23
- requestState: E,
23
+ requestState: r,
24
24
  selectedAgent: n
25
25
  } = x(), [d, _] = I(!1), o = m((t) => {
26
26
  T && (t.data ?? (t.data = {}), t.data.hostAppName = R, T(t));
27
27
  }, [R, T]), c = m(async () => {
28
28
  e({
29
- type: S.SET_REQUEST_STATE,
30
- requestState: r.IN_PROGRESS
29
+ type: E.SET_REQUEST_STATE,
30
+ requestState: S.IN_PROGRESS
31
31
  });
32
32
  try {
33
33
  const t = await u();
34
34
  e({
35
- type: S.SET_AGENT_LIST,
35
+ type: E.SET_AGENT_LIST,
36
36
  agents: t.agents
37
37
  }), o({
38
38
  ...a,
@@ -40,36 +40,36 @@ function k({
40
40
  });
41
41
  } catch {
42
42
  e({
43
- type: S.SET_REQUEST_STATE,
44
- requestState: r.ERROR
43
+ type: E.SET_REQUEST_STATE,
44
+ requestState: S.ERROR
45
45
  }), o({
46
46
  ...a,
47
47
  target: l.ERROR_LOADING_AGENTS
48
48
  });
49
49
  }
50
- }, [e, o, u]), g = E !== r.SUCCESS || !A.length || !n;
50
+ }, [e, o, u]), g = r !== S.SUCCESS || !A.length || !n;
51
51
  return f(() => {
52
52
  g ? c().finally(() => {
53
53
  _(!0);
54
54
  }) : _(!0);
55
55
  }, [c, g]), f(() => {
56
- s && s !== E && (s !== r.SUCCESS && e({
57
- type: S.SET_AGENT_LIST,
56
+ s && s !== r && (s !== S.SUCCESS && e({
57
+ type: E.SET_AGENT_LIST,
58
58
  agents: []
59
59
  }), e({
60
- type: S.SET_REQUEST_STATE,
60
+ type: E.SET_REQUEST_STATE,
61
61
  requestState: s
62
62
  }));
63
- }, [e, E, s]), f(() => {
63
+ }, [e, s]), f(() => {
64
64
  i && i(n);
65
- }, [i, n]), h && !d || E === r.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(L, {
65
+ }, [i, n]), h && !d || r === S.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(L, {
66
66
  agents: A,
67
67
  contentClassName: O,
68
68
  disabled: G,
69
69
  onAgentsListOpen: C,
70
70
  onErrorAction: c,
71
71
  recordAction: o,
72
- requestState: E,
72
+ requestState: r,
73
73
  selectedAgent: n,
74
74
  triggerChipClassName: p,
75
75
  variant: N
@@ -1,114 +1,114 @@
1
- import { useFullTextTooltip as X, FilterChip as c, Popover as d, Tooltip as Z, Status as $, LoadingIndicator as q, SmallList as tt, Button as et } from "@box/blueprint-web";
1
+ import { useFullTextTooltip as X, FilterChip as p, Popover as m, Tooltip as Z, Status as $, LoadingIndicator as q, SmallList as tt, Button as et } from "@box/blueprint-web";
2
2
  import { AlertBadge as at } from "@box/blueprint-web-assets/icons/Fill";
3
- import m from "clsx";
4
- import { useState as B, useRef as rt, useEffect as ot, useCallback as f } from "react";
3
+ import f from "clsx";
4
+ import { useState as P, useRef as ot, useEffect as rt, useCallback as d } from "react";
5
5
  import { useIntl as nt } from "react-intl";
6
- import { BoxAiAgent as st } from "./box-ai-agent.js";
7
- import { LOGGER_BASE_CONFIG as E, LOGGER_ACTION_CLICK as S, LOGGER_TARGET as T } from "./constants.js";
8
- import { ACTIONS as it } from "./contexts/actions.js";
6
+ import { BoxAiAgent as it } from "./box-ai-agent.js";
7
+ import { LOGGER_BASE_CONFIG as S, LOGGER_ACTION_CLICK as T, LOGGER_TARGET as R } from "./constants.js";
8
+ import { ACTIONS as st } from "./contexts/actions.js";
9
9
  import { useAgentsDispatch as lt } from "./contexts/context.js";
10
- import s from "./messages.js";
11
- import { R } from "../../chunks/types.js";
12
- import { jsx as e, jsxs as I } from "react/jsx-runtime";
13
- import '../../styles/box-ai-agent-selector.css';const pt = "_agentSelector_prbzs_1", gt = "_agentStatus_prbzs_4", ct = "_agentLoader_prbzs_18", dt = "_agentError_prbzs_21", mt = "_triggerChip_prbzs_24", ft = "_agentLabel_prbzs_30", _t = "_dropdownIndicator_prbzs_36", Lt = "_sidebar_prbzs_51", ht = "_agentListItemIcon_prbzs_64", ut = "_agentListContainer_prbzs_69", Ct = "_agentListRetryButton_prbzs_99", a = {
14
- agentSelector: pt,
10
+ import i from "./messages.js";
11
+ import { R as I } from "../../chunks/types.js";
12
+ import { jsx as e, jsxs as y } from "react/jsx-runtime";
13
+ import '../../styles/box-ai-agent-selector.css';const ct = "_agentSelector_hcmlf_1", gt = "_agentStatus_hcmlf_4", pt = "_agentLoader_hcmlf_17", mt = "_agentError_hcmlf_20", ft = "_triggerChip_hcmlf_23", dt = "_agentLabel_hcmlf_29", ht = "_dropdownIndicator_hcmlf_35", _t = "_sidebar_hcmlf_50", Lt = "_agentListItemIcon_hcmlf_63", ut = "_agentListContainer_hcmlf_68", Ct = "_agentListRetryButton_hcmlf_98", a = {
14
+ agentSelector: ct,
15
15
  agentStatus: gt,
16
- agentLoader: ct,
17
- agentError: dt,
18
- triggerChip: mt,
19
- agentLabel: ft,
20
- dropdownIndicator: _t,
21
- sidebar: Lt,
22
- agentListItemIcon: ht,
16
+ agentLoader: pt,
17
+ agentError: mt,
18
+ triggerChip: ft,
19
+ agentLabel: dt,
20
+ dropdownIndicator: ht,
21
+ sidebar: _t,
22
+ agentListItemIcon: Lt,
23
23
  agentListContainer: ut,
24
24
  agentListRetryButton: Ct
25
25
  };
26
- function At({
27
- agents: _,
28
- contentClassName: P,
29
- onErrorAction: y,
30
- recordAction: r,
31
- requestState: L,
32
- disabled: k,
26
+ function xt({
27
+ agents: h,
28
+ contentClassName: k,
29
+ onErrorAction: b,
30
+ recordAction: o,
31
+ requestState: _,
32
+ disabled: D,
33
33
  onAgentsListOpen: N,
34
- selectedAgent: i,
35
- triggerChipClassName: D,
36
- variant: K = "modal"
34
+ selectedAgent: s,
35
+ triggerChipClassName: K,
36
+ variant: v = "modal"
37
37
  }) {
38
38
  const {
39
- formatMessage: o
40
- } = nt(), [l, p] = B(!1), n = L === R.ERROR, [v, h] = B(n), w = lt(), O = L === R.SUCCESS, u = L === R.IN_PROGRESS, G = o(s.selectAgent), M = o(s.defaultAgent);
39
+ formatMessage: r
40
+ } = nt(), [l, c] = P(!1), n = _ === I.ERROR, [M, L] = P(n), w = lt(), O = _ === I.SUCCESS, u = _ === I.IN_PROGRESS, G = r(i.selectAgent), F = r(i.defaultAgent);
41
41
  let g = "";
42
- O ? g = (i == null ? void 0 : i.name) || G : n && (g = M);
43
- const z = rt(null), {
44
- Wrapper: F,
45
- wrapperProps: U
42
+ O ? g = (s == null ? void 0 : s.name) || G : n && (g = F);
43
+ const A = ot(null), {
44
+ Wrapper: U,
45
+ wrapperProps: j
46
46
  } = X({
47
- ref: z,
47
+ ref: A,
48
48
  textValue: g
49
49
  });
50
- ot(() => {
51
- l && r && r({
52
- ...E,
53
- action: S,
54
- target: T.OPEN_SELECTOR
50
+ rt(() => {
51
+ l && o && o({
52
+ ...S,
53
+ action: T,
54
+ target: R.OPEN_SELECTOR
55
55
  });
56
- }, [l, r]);
57
- const C = f((t) => {
58
- p(!1), w({
59
- type: it.SET_SELECTED_AGENT,
56
+ }, [l, o]);
57
+ const C = d((t) => {
58
+ c(!1), w({
59
+ type: st.SET_SELECTED_AGENT,
60
60
  id: t.id
61
- }), r && r({
62
- ...E,
63
- action: S,
64
- target: T.SELECT_AGENT
61
+ }), o && o({
62
+ ...S,
63
+ action: T,
64
+ target: R.SELECT_AGENT
65
65
  });
66
- }, [w, r]), j = f(() => {
67
- p(!1), y(), r && r({
68
- ...E,
69
- action: S,
70
- target: T.RETRY_LOADING_AGENTS
66
+ }, [w, o]), Q = d(() => {
67
+ c(!1), b(), o && o({
68
+ ...S,
69
+ action: T,
70
+ target: R.RETRY_LOADING_AGENTS
71
71
  });
72
- }, [y, r]), Q = f((t) => {
73
- if (t.key === "Escape" && (p(!1), t.stopPropagation()), t.key === " ") {
74
- const A = t.target;
75
- if (A) {
76
- const H = A.getAttribute("data-key"), x = _.find((J) => J.id === H);
77
- x && C(x);
72
+ }, [b, o]), V = d((t) => {
73
+ if (t.key === "Escape" && (c(!1), t.stopPropagation()), t.key === " ") {
74
+ const x = t.target;
75
+ if (x) {
76
+ const H = x.getAttribute("data-key"), B = h.find((J) => J.id === H);
77
+ B && C(B);
78
78
  }
79
79
  }
80
- }, [_, C]), V = f((t) => h(n && n && !l && t ? t : !1), [n, l]), W = (t) => {
81
- t && N && N(), p(t);
82
- }, b = K === "sidebar" && a.sidebar, Y = (t) => {
80
+ }, [h, C]), W = d((t) => L(n && n && !l && t ? t : !1), [n, l]), Y = (t) => {
81
+ t && N && N(), c(t);
82
+ }, E = v === "sidebar" && a.sidebar, z = (t) => {
83
83
  (t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") && t.stopPropagation();
84
84
  };
85
- return /* @__PURE__ */ e(c.Group, {
86
- className: m(a.agentSelector, D, b),
85
+ return /* @__PURE__ */ e(p.Group, {
86
+ className: f(a.agentSelector, K, E),
87
87
  name: G,
88
- onKeyDown: Y,
88
+ onKeyDown: z,
89
89
  type: "multiple",
90
- children: /* @__PURE__ */ I(d.Root, {
90
+ children: /* @__PURE__ */ y(m.Root, {
91
91
  modal: !1,
92
- onOpenChange: W,
92
+ onOpenChange: Y,
93
93
  open: l,
94
94
  children: [/* @__PURE__ */ e(Z, {
95
- content: o(s.errorTooltip),
96
- onOpenChange: V,
97
- open: v,
95
+ content: r(i.errorTooltip),
96
+ onOpenChange: W,
97
+ open: M,
98
98
  side: "bottom",
99
99
  variant: "error",
100
- children: /* @__PURE__ */ e(d.Trigger, {
101
- disabled: k || u,
102
- children: /* @__PURE__ */ I(c.TriggerChip, {
100
+ children: /* @__PURE__ */ e(m.Trigger, {
101
+ disabled: D || u,
102
+ children: /* @__PURE__ */ y(p.TriggerChip, {
103
103
  className: a.triggerChip,
104
104
  "data-target-id": "FilterChip.TriggerChip-agentSelectorTrigger",
105
105
  value: "trigger-chip",
106
106
  children: [/* @__PURE__ */ e($, {
107
107
  className: a.agentStatus,
108
108
  colorIndex: 0,
109
- text: o(s.agent)
109
+ text: r(i.agent)
110
110
  }), u && /* @__PURE__ */ e(q, {
111
- "aria-label": o(s.loadingMessage),
111
+ "aria-label": r(i.loadingMessage),
112
112
  className: a.agentLoader,
113
113
  variant: "default"
114
114
  }), n && /* @__PURE__ */ e(at, {
@@ -116,38 +116,38 @@ function At({
116
116
  height: "1rem",
117
117
  role: "presentation",
118
118
  width: "1rem"
119
- }), /* @__PURE__ */ e(F, {
120
- ...U,
121
- children: /* @__PURE__ */ e(c.Label, {
122
- ref: z,
119
+ }), /* @__PURE__ */ e(U, {
120
+ ...j,
121
+ children: /* @__PURE__ */ e(p.Label, {
122
+ ref: A,
123
123
  className: a.agentLabel,
124
124
  children: g
125
125
  })
126
126
  }), !u && /* @__PURE__ */ e("div", {
127
127
  className: a.dropdownIndicator,
128
- children: /* @__PURE__ */ e(c.DropdownIndicator, {})
128
+ children: /* @__PURE__ */ e(p.DropdownIndicator, {})
129
129
  })]
130
130
  })
131
131
  })
132
- }), /* @__PURE__ */ e(d.ContentContainer, {
132
+ }), /* @__PURE__ */ e(m.ContentContainer, {
133
133
  align: "start",
134
- className: m(a.agentListContainer, b),
135
- onKeyDownCapture: Q,
136
- children: /* @__PURE__ */ I(d.MainContent, {
134
+ className: f(a.agentListContainer, E),
135
+ onKeyDownCapture: V,
136
+ children: /* @__PURE__ */ y(m.MainContent, {
137
137
  children: [O && /* @__PURE__ */ e(tt, {
138
- "aria-label": o(s.agentList),
139
- className: m([a.agentList, P]),
140
- selectedKeys: [(i == null ? void 0 : i.id) || ""],
141
- children: _.map((t) => /* @__PURE__ */ e(st, {
138
+ "aria-label": r(i.agentList),
139
+ className: f([a.agentList, k]),
140
+ selectedKeys: [(s == null ? void 0 : s.id) || ""],
141
+ children: h.map((t) => /* @__PURE__ */ e(it, {
142
142
  agent: t,
143
143
  onAction: () => C(t)
144
144
  }, t.id))
145
145
  }), n && /* @__PURE__ */ e(et, {
146
- className: m(a.agentListRetryButton, b),
147
- onClick: j,
146
+ className: f(a.agentListRetryButton, E),
147
+ onClick: Q,
148
148
  variant: "tertiary",
149
149
  "data-target-id": "Button-errorMessage",
150
- children: o(s.errorMessage)
150
+ children: r(i.errorMessage)
151
151
  })]
152
152
  })
153
153
  })]
@@ -155,6 +155,6 @@ function At({
155
155
  });
156
156
  }
157
157
  export {
158
- At as BoxAiAgentSelector,
159
- At as default
158
+ xt as BoxAiAgentSelector,
159
+ xt as default
160
160
  };
@@ -1 +1 @@
1
- ._agentSelector_prbzs_1{margin-inline-start:.75rem}._agentSelector_prbzs_1 ._agentStatus_prbzs_4{margin-inline-start:.5rem}._agentSelector_prbzs_1 ._agentStatus_prbzs_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_prbzs_1 ._agentStatus_prbzs_4>span span{color:transparent;text-transform:uppercase;background:linear-gradient(135deg,#fe01da,#2486fc);-webkit-background-clip:text;background-clip:text}._agentSelector_prbzs_1 ._agentLoader_prbzs_18{position:inherit}._agentSelector_prbzs_1 ._agentError_prbzs_21 path{fill:#d5324e}._agentSelector_prbzs_1 ._triggerChip_prbzs_24{display:flex;max-width:376px;text-align:start;background-color:#faf5fe}._agentSelector_prbzs_1 ._triggerChip_prbzs_24 ._agentLabel_prbzs_30{flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}._agentSelector_prbzs_1 ._triggerChip_prbzs_24 ._dropdownIndicator_prbzs_36{flex-shrink:0;margin-inline-start:0}._agentSelector_prbzs_1 ._triggerChip_prbzs_24 ._dropdownIndicator_prbzs_36 svg{margin-inline-start:0}._agentSelector_prbzs_1 ._triggerChip_prbzs_24:disabled ._dropdownIndicator_prbzs_36{opacity:.3}@media (max-width: 374px){._agentSelector_prbzs_1 ._triggerChip_prbzs_24{width:100%}}._agentSelector_prbzs_1._sidebar_prbzs_51{margin:0 .25rem 0 0;margin-inline-start:0}@media (max-width: 767px){._agentSelector_prbzs_1._sidebar_prbzs_51{width:100%}}._agentSelector_prbzs_1._sidebar_prbzs_51 ._triggerChip_prbzs_24{max-width:246px}._agentListItemIcon_prbzs_64{width:2rem;height:2rem}._agentListContainer_prbzs_69{min-width:320px;max-width:376px;width:360px}@media (max-width: 376px){._agentListContainer_prbzs_69{max-width:320px}}._agentListContainer_prbzs_69>div{padding:var(--space-3)}._agentListContainer_prbzs_69._sidebar_prbzs_51{min-width:320px;max-width:360px;transform:translate(-6px)}@media (max-width: 360px){._agentListContainer_prbzs_69._sidebar_prbzs_51{max-width:320px}}@media (max-width: 767px){._agentListContainer_prbzs_69._sidebar_prbzs_51{max-width:unset;width:auto}}._agentListRetryButton_prbzs_99{max-width:320px;margin:.25rem;text-wrap:wrap}._agentListRetryButton_prbzs_99._sidebar_prbzs_51{max-width:184px}
1
+ ._agentSelector_hcmlf_1{margin-inline-start:.75rem}._agentSelector_hcmlf_1 ._agentStatus_hcmlf_4{margin-inline-start:.5rem}._agentSelector_hcmlf_1 ._agentStatus_hcmlf_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_hcmlf_1 ._agentStatus_hcmlf_4>span span{color:transparent;text-transform:uppercase;background:linear-gradient(135deg,#fe01da,#2486fc);-webkit-background-clip:text;background-clip:text}._agentSelector_hcmlf_1 ._agentLoader_hcmlf_17{position:inherit}._agentSelector_hcmlf_1 ._agentError_hcmlf_20 path{fill:#d5324e}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23{display:flex;max-width:376px;text-align:start;background-color:#faf5fe}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23 ._agentLabel_hcmlf_29{flex-grow:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23 ._dropdownIndicator_hcmlf_35{flex-shrink:0;margin-inline-start:0}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23 ._dropdownIndicator_hcmlf_35 svg{margin-inline-start:0}._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23:disabled ._dropdownIndicator_hcmlf_35{opacity:.3}@media (max-width: 374px){._agentSelector_hcmlf_1 ._triggerChip_hcmlf_23{width:100%}}._agentSelector_hcmlf_1._sidebar_hcmlf_50{margin:0 .25rem 0 0;margin-inline-start:0}@media (max-width: 767px){._agentSelector_hcmlf_1._sidebar_hcmlf_50{width:100%}}._agentSelector_hcmlf_1._sidebar_hcmlf_50 ._triggerChip_hcmlf_23{max-width:246px}._agentListItemIcon_hcmlf_63{width:2rem;height:2rem}._agentListContainer_hcmlf_68{min-width:320px;max-width:376px;width:360px}@media (max-width: 376px){._agentListContainer_hcmlf_68{max-width:320px}}._agentListContainer_hcmlf_68>div{padding:var(--space-3)}._agentListContainer_hcmlf_68._sidebar_hcmlf_50{min-width:320px;max-width:360px;transform:translate(-6px)}@media (max-width: 360px){._agentListContainer_hcmlf_68._sidebar_hcmlf_50{max-width:320px}}@media (max-width: 767px){._agentListContainer_hcmlf_68._sidebar_hcmlf_50{max-width:unset;width:auto}}._agentListRetryButton_hcmlf_98{max-width:320px;margin:.25rem;text-wrap:wrap}._agentListRetryButton_hcmlf_98._sidebar_hcmlf_50{max-width:184px}
@@ -1,8 +1,13 @@
1
1
  import { BoxAiAgentSelectorWithApiProps } from '../../index';
2
+ import { REQUEST_STATE } from '../types';
2
3
  export declare const defaultBoxAiAgentSelectorProps: {
3
4
  fetcher: () => Promise<{
4
5
  agents: import('../types').AgentType[];
5
6
  }>;
6
7
  };
7
8
  export declare const DefaultBoxAiAgentSelectorWithApiContainer: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const BoxAiAgentSelectorWithApiContainerWithChangedRequestState: ({ changeTimeout, newRequestState, ...args }: BoxAiAgentSelectorWithApiProps & {
10
+ changeTimeout: number;
11
+ newRequestState: REQUEST_STATE;
12
+ }) => import("react/jsx-runtime").JSX.Element;
8
13
  export declare const BoxAiAgentSelectorWithProvider: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-agent-selector",
3
- "version": "0.33.1",
3
+ "version": "0.33.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^7.31.1",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "devDependencies": {
13
13
  "@box/babel-plugin-target-attributes": "1.3.0",
14
- "@box/blueprint-web": "^9.19.0",
14
+ "@box/blueprint-web": "^9.19.1",
15
15
  "@box/blueprint-web-assets": "^4.37.1",
16
16
  "@box/eslint-plugin-blueprint": "^1.0.3",
17
17
  "@box/storybook-utils": "^0.8.3",