@box/box-ai-agent-selector 0.26.1 → 0.26.3

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,148 +1,151 @@
1
- import { useFullTextTooltip as z, FilterChip as p, Popover as d, Tooltip as H, Status as J, LoadingIndicator as X, SmallList as Z, Button as $ } from "@box/blueprint-web";
2
- import { AlertBadge as q } from "@box/blueprint-web-assets/icons/Fill";
1
+ import { useFullTextTooltip as H, FilterChip as c, Popover as d, Tooltip as J, Status as X, LoadingIndicator as Z, SmallList as $, Button as q } from "@box/blueprint-web";
2
+ import { AlertBadge as tt } from "@box/blueprint-web-assets/icons/Fill";
3
3
  import m from "clsx";
4
- import { useState as w, useRef as tt, useEffect as et, useCallback as _ } from "react";
5
- import { useIntl as at } from "react-intl";
6
- import { BoxAiAgent as nt } from "./box-ai-agent.js";
7
- import { LOGGER_BASE_CONFIG as S, LOGGER_ACTION_CLICK as y, LOGGER_TARGET as T } from "./constants.js";
8
- import { ACTIONS as ot } from "./contexts/actions.js";
9
- import { useAgentsDispatch as rt } from "./contexts/context.js";
4
+ import { useState as B, useRef as et, useEffect as at, useCallback as f } from "react";
5
+ import { useIntl as ot } from "react-intl";
6
+ import { BoxAiAgent as rt } 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 nt } from "./contexts/actions.js";
9
+ import { useAgentsDispatch as it } from "./contexts/context.js";
10
10
  import s from "./messages.js";
11
- import { R as I } from "../../chunks/types.js";
12
- import { jsx as e, jsxs as R } from "react/jsx-runtime";
13
- import '../../styles/box-ai-agent-selector.css';const it = "_agentSelector_1y96v_1", st = "_agentStatus_1y96v_4", lt = "_agentLoader_1y96v_18", gt = "_agentError_1y96v_21", ct = "_triggerChip_1y96v_24", pt = "_agentLabel_1y96v_30", dt = "_dropdownIndicator_1y96v_36", mt = "_sidebar_1y96v_51", _t = "_agentListItemIcon_1y96v_70", ft = "_agentListContainer_1y96v_75", Lt = "_agentListRetryButton_1y96v_105", a = {
14
- agentSelector: it,
15
- agentStatus: st,
16
- agentLoader: lt,
17
- agentError: gt,
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 st = "_agentSelector_1y96v_1", lt = "_agentStatus_1y96v_4", gt = "_agentLoader_1y96v_18", pt = "_agentError_1y96v_21", ct = "_triggerChip_1y96v_24", dt = "_agentLabel_1y96v_30", mt = "_dropdownIndicator_1y96v_36", ft = "_sidebar_1y96v_51", _t = "_agentListItemIcon_1y96v_70", Lt = "_agentListContainer_1y96v_75", ut = "_agentListRetryButton_1y96v_105", a = {
14
+ agentSelector: st,
15
+ agentStatus: lt,
16
+ agentLoader: gt,
17
+ agentError: pt,
18
18
  triggerChip: ct,
19
- agentLabel: pt,
20
- dropdownIndicator: dt,
21
- sidebar: mt,
19
+ agentLabel: dt,
20
+ dropdownIndicator: mt,
21
+ sidebar: ft,
22
22
  agentListItemIcon: _t,
23
- agentListContainer: ft,
24
- agentListRetryButton: Lt
23
+ agentListContainer: Lt,
24
+ agentListRetryButton: ut
25
25
  };
26
- function Ot({
27
- agents: f,
28
- contentClassName: P,
26
+ function vt({
27
+ agents: _,
28
+ contentClassName: k,
29
29
  onErrorAction: b,
30
- recordAction: n,
30
+ recordAction: o,
31
31
  requestState: L,
32
32
  disabled: D,
33
- selectedAgent: o,
34
- triggerChipClassName: k,
35
- variant: M = "modal"
33
+ selectedAgent: r,
34
+ triggerChipClassName: P,
35
+ variant: A = "modal"
36
36
  }) {
37
37
  const {
38
- formatMessage: r
39
- } = at(), [l, g] = w(!1), i = L === I.ERROR, [F, u] = w(i), N = rt(), v = L === I.SUCCESS, h = L === I.IN_PROGRESS, O = r(s.selectAgent), K = r(s.defaultAgent);
40
- let c = "";
41
- v ? c = (o == null ? void 0 : o.name) || O : i && (c = K);
42
- const G = tt(null), {
43
- Wrapper: j,
44
- wrapperProps: A
45
- } = z({
46
- ref: G,
47
- textValue: c
38
+ formatMessage: n
39
+ } = ot(), [l, g] = B(!1), i = L === R.ERROR, [K, u] = B(i), N = it(), O = L === R.SUCCESS, h = L === R.IN_PROGRESS, w = n(s.selectAgent), M = n(s.defaultAgent);
40
+ let p = "";
41
+ O ? p = (r == null ? void 0 : r.name) || w : i && (p = M);
42
+ const v = et(null), {
43
+ Wrapper: F,
44
+ wrapperProps: U
45
+ } = H({
46
+ ref: v,
47
+ textValue: p
48
48
  });
49
- et(() => {
50
- l && n && n({
51
- ...S,
52
- action: y,
49
+ at(() => {
50
+ l && o && o({
51
+ ...E,
52
+ action: S,
53
53
  target: T.OPEN_SELECTOR
54
54
  });
55
- }, [l, n]);
56
- const C = _((t) => {
55
+ }, [l, o]);
56
+ const y = f((t) => {
57
57
  g(!1), N({
58
- type: ot.SET_SELECTED_AGENT,
58
+ type: nt.SET_SELECTED_AGENT,
59
59
  id: t.id
60
- }), n && n({
61
- ...S,
62
- action: y,
60
+ }), o && o({
61
+ ...E,
62
+ action: S,
63
63
  target: T.SELECT_AGENT
64
64
  });
65
- }, [N, n]), U = _(() => {
66
- g(!1), b(), n && n({
67
- ...S,
68
- action: y,
65
+ }, [N, o]), j = f(() => {
66
+ g(!1), b(), o && o({
67
+ ...E,
68
+ action: S,
69
69
  target: T.RETRY_LOADING_AGENTS
70
70
  });
71
- }, [b, n]), Q = _((t) => {
71
+ }, [b, o]), Q = f((t) => {
72
72
  if (t.key === "Escape" && (g(!1), t.stopPropagation()), t.key === " ") {
73
- const x = t.target;
74
- if (x) {
75
- const W = x.getAttribute("data-key"), B = f.find((Y) => Y.id === W);
76
- B && C(B);
73
+ const G = t.target;
74
+ if (G) {
75
+ const Y = G.getAttribute("data-key"), x = _.find((z) => z.id === Y);
76
+ x && y(x);
77
77
  }
78
78
  }
79
- }, [f, C]), V = _((t) => u(i && i && !l && t ? t : !1), [i, l]), E = M === "sidebar" && a.sidebar;
80
- return /* @__PURE__ */ e(p.Group, {
81
- className: m(a.agentSelector, k, E),
82
- name: O,
79
+ }, [_, y]), V = f((t) => u(i && i && !l && t ? t : !1), [i, l]), C = A === "sidebar" && a.sidebar, W = (t) => {
80
+ (t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") && t.stopPropagation();
81
+ };
82
+ return /* @__PURE__ */ e(c.Group, {
83
+ className: m(a.agentSelector, P, C),
84
+ name: w,
85
+ onKeyDown: W,
83
86
  type: "multiple",
84
- children: /* @__PURE__ */ R(d.Root, {
87
+ children: /* @__PURE__ */ I(d.Root, {
85
88
  modal: !1,
86
89
  onOpenChange: g,
87
90
  open: l,
88
- children: [/* @__PURE__ */ e(H, {
89
- content: r(s.errorTooltip),
91
+ children: [/* @__PURE__ */ e(J, {
92
+ content: n(s.errorTooltip),
90
93
  onOpenChange: V,
91
- open: F,
94
+ open: K,
92
95
  side: "bottom",
93
96
  variant: "error",
94
97
  children: /* @__PURE__ */ e(d.Trigger, {
95
98
  disabled: D || h,
96
- children: /* @__PURE__ */ R(p.TriggerChip, {
99
+ children: /* @__PURE__ */ I(c.TriggerChip, {
97
100
  className: a.triggerChip,
98
101
  "data-target-id": "FilterChip.TriggerChip-agentSelectorTrigger",
99
102
  value: "trigger-chip",
100
- children: [/* @__PURE__ */ e(J, {
103
+ children: [/* @__PURE__ */ e(X, {
101
104
  className: a.agentStatus,
102
105
  colorIndex: 0,
103
- text: r(s.agent)
104
- }), h && /* @__PURE__ */ e(X, {
105
- "aria-label": r(s.loadingMessage),
106
+ text: n(s.agent)
107
+ }), h && /* @__PURE__ */ e(Z, {
108
+ "aria-label": n(s.loadingMessage),
106
109
  className: a.agentLoader,
107
110
  variant: "default"
108
- }), i && /* @__PURE__ */ e(q, {
111
+ }), i && /* @__PURE__ */ e(tt, {
109
112
  className: a.agentError,
110
113
  height: "1rem",
111
114
  role: "presentation",
112
115
  width: "1rem"
113
- }), /* @__PURE__ */ e(j, {
114
- ...A,
115
- children: /* @__PURE__ */ e(p.Label, {
116
- ref: G,
116
+ }), /* @__PURE__ */ e(F, {
117
+ ...U,
118
+ children: /* @__PURE__ */ e(c.Label, {
119
+ ref: v,
117
120
  className: a.agentLabel,
118
- children: c
121
+ children: p
119
122
  })
120
123
  }), !h && /* @__PURE__ */ e("div", {
121
124
  className: a.dropdownIndicator,
122
- children: /* @__PURE__ */ e(p.DropdownIndicator, {})
125
+ children: /* @__PURE__ */ e(c.DropdownIndicator, {})
123
126
  })]
124
127
  })
125
128
  })
126
129
  }), /* @__PURE__ */ e(d.ContentContainer, {
127
130
  align: "start",
128
- className: m(a.agentListContainer, E),
131
+ className: m(a.agentListContainer, C),
129
132
  onKeyDownCapture: Q,
130
- children: /* @__PURE__ */ R(d.MainContent, {
131
- children: [v && /* @__PURE__ */ e(Z, {
132
- "aria-label": r(s.agentList),
133
- className: m([a.agentList, P]),
134
- selectedKeys: [(o == null ? void 0 : o.id) || ""],
135
- children: f.map((t) => /* @__PURE__ */ e(nt, {
133
+ children: /* @__PURE__ */ I(d.MainContent, {
134
+ children: [O && /* @__PURE__ */ e($, {
135
+ "aria-label": n(s.agentList),
136
+ className: m([a.agentList, k]),
137
+ selectedKeys: [(r == null ? void 0 : r.id) || ""],
138
+ children: _.map((t) => /* @__PURE__ */ e(rt, {
136
139
  agent: t,
137
- isSelected: (o == null ? void 0 : o.id) === t.id,
138
- onAction: () => C(t)
140
+ isSelected: (r == null ? void 0 : r.id) === t.id,
141
+ onAction: () => y(t)
139
142
  }, t.id))
140
- }), i && /* @__PURE__ */ e($, {
141
- className: m(a.agentListRetryButton, E),
142
- onClick: U,
143
+ }), i && /* @__PURE__ */ e(q, {
144
+ className: m(a.agentListRetryButton, C),
145
+ onClick: j,
143
146
  variant: "tertiary",
144
147
  "data-target-id": "Button-errorMessage",
145
- children: r(s.errorMessage)
148
+ children: n(s.errorMessage)
146
149
  })]
147
150
  })
148
151
  })]
@@ -150,6 +153,6 @@ function Ot({
150
153
  });
151
154
  }
152
155
  export {
153
- Ot as BoxAiAgentSelector,
154
- Ot as default
156
+ vt as BoxAiAgentSelector,
157
+ vt as default
155
158
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-agent-selector",
3
- "version": "0.26.1",
3
+ "version": "0.26.3",
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.18.0",
14
+ "@box/blueprint-web": "^9.18.1",
15
15
  "@box/blueprint-web-assets": "^4.33.1",
16
16
  "@box/eslint-plugin-blueprint": "^1.0.3",
17
17
  "@box/storybook-utils": "^0.8.3",
@@ -47,5 +47,5 @@
47
47
  "sideEffects": [
48
48
  "**/*.css"
49
49
  ],
50
- "gitHead": "a2056d2f579edc055a85156efe0e93414840445e"
50
+ "gitHead": "f58975e6ef79aaa7ede93cd503cc8412f68fac44"
51
51
  }