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