@box/box-ai-agent-selector 0.17.12 → 0.17.14

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,27 +1,28 @@
1
- import { useState as O, useCallback as m, useEffect as f } from "react";
2
- import { BoxAiAgentSelector as N } from "./box-ai-agent-selector.js";
3
- import { LOGGER_BASE_CONFIG as u, LOGGER_TARGET as a } from "./constants.js";
1
+ import { useState as N, useCallback as m, useEffect as f } from "react";
2
+ import { BoxAiAgentSelector as h } from "./box-ai-agent-selector.js";
3
+ import { LOGGER_BASE_CONFIG as a, LOGGER_TARGET as u } from "./constants.js";
4
4
  import { ACTIONS as E } from "./contexts/actions.js";
5
- import { useAgentsDispatch as h, useAgents as I } from "./contexts/context.js";
5
+ import { useAgentsDispatch as I, useAgents as L } from "./contexts/context.js";
6
6
  import { R as i } from "../../chunks/types.js";
7
- import { jsx as L } from "react/jsx-runtime";
8
- function F({
7
+ import { jsx as d } from "react/jsx-runtime";
8
+ function H({
9
9
  fetcher: R,
10
10
  hostAppName: _,
11
- onSelectAgent: T,
12
- recordAction: n,
11
+ onSelectAgent: o,
12
+ recordAction: T,
13
13
  requestState: s,
14
14
  shouldHideAgentSelectorOnLoad: g,
15
- triggerChipClassName: G,
16
- contentClassName: l
15
+ triggerChipClassName: l,
16
+ contentClassName: G,
17
+ variant: p = "modal"
17
18
  }) {
18
- const e = h(), {
19
+ const e = I(), {
19
20
  agents: c,
20
21
  requestState: S,
21
- selectedAgent: o
22
- } = I(), [p, C] = O(!1), r = m((t) => {
23
- n && (t.data ?? (t.data = {}), t.data.hostAppName = _, n(t));
24
- }, [_, n]), A = m(async () => {
22
+ selectedAgent: n
23
+ } = L(), [C, O] = N(!1), r = m((t) => {
24
+ T && (t.data ?? (t.data = {}), t.data.hostAppName = _, T(t));
25
+ }, [_, T]), A = m(async () => {
25
26
  e({
26
27
  type: E.SET_REQUEST_STATE,
27
28
  requestState: i.IN_PROGRESS
@@ -32,22 +33,22 @@ function F({
32
33
  type: E.SET_AGENT_LIST,
33
34
  agents: t.agents
34
35
  }), r({
35
- ...u,
36
- target: a.LOADED_AGENTS
36
+ ...a,
37
+ target: u.LOADED_AGENTS
37
38
  });
38
39
  } catch {
39
40
  e({
40
41
  type: E.SET_REQUEST_STATE,
41
42
  requestState: i.ERROR
42
43
  }), r({
43
- ...u,
44
- target: a.ERROR_LOADING_AGENTS
44
+ ...a,
45
+ target: u.ERROR_LOADING_AGENTS
45
46
  });
46
47
  }
47
48
  }, [e, r, R]);
48
49
  return f(() => {
49
50
  A().finally(() => {
50
- C(!0);
51
+ O(!0);
51
52
  });
52
53
  }, [A]), f(() => {
53
54
  s && s !== S && (s !== i.SUCCESS && e({
@@ -58,18 +59,19 @@ function F({
58
59
  requestState: s
59
60
  }));
60
61
  }, [e, S, s]), f(() => {
61
- T && T(o);
62
- }, [T, o]), g && !p || S === i.SUCCESS && c.length <= 1 ? null : /* @__PURE__ */ L(N, {
62
+ o && o(n);
63
+ }, [o, n]), g && !C || S === i.SUCCESS && c.length <= 1 ? null : /* @__PURE__ */ d(h, {
63
64
  agents: c,
64
- contentClassName: l,
65
+ contentClassName: G,
65
66
  onErrorAction: A,
66
67
  recordAction: r,
67
68
  requestState: S,
68
- selectedAgent: o,
69
- triggerChipClassName: G
69
+ selectedAgent: n,
70
+ triggerChipClassName: l,
71
+ variant: p
70
72
  });
71
73
  }
72
74
  export {
73
- F as BoxAiAgentSelectorWithApi,
74
- F as default
75
+ H as BoxAiAgentSelectorWithApi,
76
+ H as default
75
77
  };
@@ -1,119 +1,119 @@
1
1
  import "../../styles/box-ai-agent-selector.css";
2
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 H } from "@box/blueprint-web-assets/icons/Fill";
4
- import f from "clsx";
5
- import { useState as J, useRef as X, useEffect as Z, useCallback as E } from "react";
6
- import { useIntl as $ } from "react-intl";
7
- import { BoxAiAgent as q } from "./box-ai-agent.js";
8
- import { LOGGER_BASE_CONFIG as h, LOGGER_ACTION_CLICK as C, LOGGER_TARGET as S } from "./constants.js";
3
+ import { AlertBadge as z } from "@box/blueprint-web-assets/icons/Fill";
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
9
  import { ACTIONS as tt } from "./contexts/actions.js";
10
10
  import { useAgentsDispatch as et } from "./contexts/context.js";
11
- import r from "./messages.js";
12
- import { R } from "../../chunks/types.js";
13
- import { jsx as t, jsxs as I } from "react/jsx-runtime";
14
- const at = "_agentSelector_zvgbf_1", nt = "_agentStatus_zvgbf_4", ot = "_agentLoader_zvgbf_18", rt = "_agentError_zvgbf_21", it = "_triggerChip_zvgbf_24", st = "_agentLabel_zvgbf_29", lt = "_dropdownIndicator_zvgbf_35", gt = "_sidebar_zvgbf_47", ct = "_agentListItemIcon_zvgbf_58", dt = "_agentListContainer_zvgbf_63", pt = "_agentListRetryButton_zvgbf_82", e = {
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
15
  agentSelector: at,
16
16
  agentStatus: nt,
17
17
  agentLoader: ot,
18
- agentError: rt,
19
- triggerChip: it,
18
+ agentError: it,
19
+ triggerChip: rt,
20
20
  agentLabel: st,
21
21
  dropdownIndicator: lt,
22
- sidebar: gt,
23
- agentListItemIcon: ct,
22
+ sidebar: ct,
23
+ agentListItemIcon: gt,
24
24
  agentListContainer: dt,
25
25
  agentListRetryButton: pt
26
26
  };
27
27
  function Nt({
28
- agents: m,
29
- contentClassName: x,
30
- onErrorAction: T,
28
+ agents: _,
29
+ contentClassName: q,
30
+ onErrorAction: b,
31
31
  recordAction: n,
32
- requestState: _,
33
- selectedAgent: i,
32
+ requestState: f,
33
+ selectedAgent: r,
34
34
  triggerChipClassName: w,
35
35
  variant: B = "modal"
36
36
  }) {
37
37
  const {
38
38
  formatMessage: o
39
- } = $(), [s, l] = J(!1), N = o(r.selectAgent), A = o(r.defaultAgent), v = et(), y = _ === R.SUCCESS, L = _ === R.IN_PROGRESS, g = _ === R.ERROR;
40
- let c = "";
41
- y ? c = (i == null ? void 0 : i.name) || N : g && (c = A);
42
- const G = X(null), {
43
- Wrapper: P,
44
- wrapperProps: D
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;
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
45
  } = j({
46
46
  ref: G,
47
- textValue: c
47
+ textValue: g
48
48
  });
49
- Z(() => {
49
+ X(() => {
50
50
  s && n && n({
51
- ...h,
52
- action: C,
53
- target: S.OPEN_SELECTOR
51
+ ...C,
52
+ action: S,
53
+ target: R.OPEN_SELECTOR
54
54
  });
55
55
  }, [s, n]);
56
- const b = E((a) => {
57
- l(!1), v({
56
+ const u = h((a) => {
57
+ l(!1), k({
58
58
  type: tt.SET_SELECTED_AGENT,
59
59
  id: a.id
60
60
  }), n && n({
61
- ...h,
62
- action: C,
63
- target: S.SELECT_AGENT
61
+ ...C,
62
+ action: S,
63
+ target: R.SELECT_AGENT
64
64
  });
65
- }, [v, n]), k = E(() => {
66
- l(!1), T(), n && n({
67
- ...h,
68
- action: C,
69
- target: S.RETRY_LOADING_AGENTS
65
+ }, [k, n]), D = h(() => {
66
+ l(!1), b(), n && n({
67
+ ...C,
68
+ action: S,
69
+ target: R.RETRY_LOADING_AGENTS
70
70
  });
71
- }, [T, n]), K = E((a) => {
71
+ }, [b, n]), K = h((a) => {
72
72
  if (a.key === "Escape" && (l(!1), a.stopPropagation()), a.key === " ") {
73
73
  const O = a.target;
74
74
  if (O) {
75
- const M = O.getAttribute("data-key"), z = m.find((F) => F.id === M);
76
- z && b(z);
75
+ const M = O.getAttribute("data-key"), x = _.find((F) => F.id === M);
76
+ x && u(x);
77
77
  }
78
78
  }
79
- }, [m, b]), u = B === "sidebar" && e.sidebar;
79
+ }, [_, u]), E = B === "sidebar" && e.sidebar;
80
80
  return /* @__PURE__ */ t(d.Group, {
81
- className: f(e.agentSelector, w, u),
81
+ className: m(e.agentSelector, w, E),
82
82
  name: N,
83
83
  type: "multiple",
84
- children: /* @__PURE__ */ I(p.Root, {
84
+ children: /* @__PURE__ */ T(p.Root, {
85
85
  modal: !1,
86
86
  onOpenChange: l,
87
87
  open: s,
88
88
  children: [/* @__PURE__ */ t(U, {
89
- content: o(r.errorTooltip),
90
- hidden: !g || s,
89
+ content: o(i.errorTooltip),
90
+ hidden: !c || s,
91
91
  side: "bottom",
92
92
  variant: "error",
93
93
  children: /* @__PURE__ */ t(p.Trigger, {
94
94
  disabled: L,
95
- children: /* @__PURE__ */ I(d.TriggerChip, {
95
+ children: /* @__PURE__ */ T(d.TriggerChip, {
96
96
  className: e.triggerChip,
97
97
  value: "trigger-chip",
98
98
  children: [/* @__PURE__ */ t(Q, {
99
99
  className: e.agentStatus,
100
100
  colorIndex: 0,
101
- text: o(r.agent)
101
+ text: o(i.agent)
102
102
  }), L && /* @__PURE__ */ t(V, {
103
- "aria-label": o(r.loadingMessage),
103
+ "aria-label": o(i.loadingMessage),
104
104
  className: e.agentLoader,
105
105
  variant: "default"
106
- }), g && /* @__PURE__ */ t(H, {
106
+ }), c && /* @__PURE__ */ t(z, {
107
107
  className: e.agentError,
108
108
  height: "1rem",
109
109
  role: "presentation",
110
110
  width: "1rem"
111
- }), /* @__PURE__ */ t(P, {
112
- ...D,
111
+ }), /* @__PURE__ */ t(A, {
112
+ ...P,
113
113
  children: /* @__PURE__ */ t(d.Label, {
114
114
  ref: G,
115
115
  className: e.agentLabel,
116
- children: c
116
+ children: g
117
117
  })
118
118
  }), !L && /* @__PURE__ */ t("div", {
119
119
  className: e.dropdownIndicator,
@@ -123,22 +123,22 @@ function Nt({
123
123
  })
124
124
  }), /* @__PURE__ */ t(p.ContentContainer, {
125
125
  align: "start",
126
- className: f(e.agentListContainer, u),
126
+ className: m(e.agentListContainer, E),
127
127
  onKeyDownCapture: K,
128
- children: /* @__PURE__ */ I(p.MainContent, {
128
+ children: /* @__PURE__ */ T(p.MainContent, {
129
129
  children: [y && /* @__PURE__ */ t(W, {
130
- "aria-label": o(r.agentList),
131
- className: f([e.agentList, x]),
132
- selectedKeys: [(i == null ? void 0 : i.id) || ""],
133
- children: m.map((a) => /* @__PURE__ */ t(q, {
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
134
  agent: a,
135
- onAction: () => b(a)
135
+ onAction: () => u(a)
136
136
  }, a.id))
137
- }), g && /* @__PURE__ */ t(Y, {
138
- className: f(e.agentListRetryButton, u),
139
- onClick: k,
137
+ }), c && /* @__PURE__ */ t(Y, {
138
+ className: m(e.agentListRetryButton, E),
139
+ onClick: D,
140
140
  variant: "tertiary",
141
- children: o(r.errorMessage)
141
+ children: o(i.errorMessage)
142
142
  })]
143
143
  })
144
144
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-agent-selector",
3
- "version": "0.17.12",
3
+ "version": "0.17.14",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^7.31.1",
@@ -46,5 +46,5 @@
46
46
  "sideEffects": [
47
47
  "**/*.css"
48
48
  ],
49
- "gitHead": "3ca9db9ebc750eda29f3a1c71326fedd318dde5c"
49
+ "gitHead": "a5de5c04371f4e8fcf9ea7471aba3e6aaa05f704"
50
50
  }
@@ -1 +1 @@
1
- ._agentSelector_zvgbf_1{margin-inline-start:.75rem}._agentSelector_zvgbf_1 ._agentStatus_zvgbf_4{margin-inline-start:.5rem}._agentSelector_zvgbf_1 ._agentStatus_zvgbf_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_zvgbf_1 ._agentStatus_zvgbf_4>span span{background:linear-gradient(135deg,#fe01da,#2486fc);color:transparent;-webkit-background-clip:text;background-clip:text;text-transform:uppercase}._agentSelector_zvgbf_1 ._agentLoader_zvgbf_18{position:inherit}._agentSelector_zvgbf_1 ._agentError_zvgbf_21 path{fill:#d5324e}._agentSelector_zvgbf_1 ._triggerChip_zvgbf_24{max-width:376px;display:flex;text-align:start}._agentSelector_zvgbf_1 ._triggerChip_zvgbf_24 ._agentLabel_zvgbf_29{flex-grow:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._agentSelector_zvgbf_1 ._triggerChip_zvgbf_24 ._dropdownIndicator_zvgbf_35{flex-shrink:0;margin-inline-start:0}._agentSelector_zvgbf_1 ._triggerChip_zvgbf_24 ._dropdownIndicator_zvgbf_35 svg{margin-inline-start:0}@media (max-width: 374px){._agentSelector_zvgbf_1 ._triggerChip_zvgbf_24{width:100%}}._agentSelector_zvgbf_1._sidebar_zvgbf_47{margin:0;margin-inline-start:0;min-width:72px;max-width:246px}._agentSelector_zvgbf_1._sidebar_zvgbf_47 ._triggerChip_zvgbf_24{min-width:72px;max-width:246px}._agentListItemIcon_zvgbf_58{height:2rem;width:2rem}._agentListContainer_zvgbf_63{min-width:320px;max-width:376px}@media (max-width: 376px){._agentListContainer_zvgbf_63{max-width:320px}}._agentListContainer_zvgbf_63._sidebar_zvgbf_47{min-width:184px;max-width:252px}@media (max-width: 252px){._agentListContainer_zvgbf_63._sidebar_zvgbf_47{max-width:184px}}._agentListRetryButton_zvgbf_82{margin:.25rem;max-width:320px;text-wrap:wrap}._agentListRetryButton_zvgbf_82._sidebar_zvgbf_47{max-width:184px}
1
+ ._agentSelector_ak9iq_1{margin-inline-start:.75rem}._agentSelector_ak9iq_1 ._agentStatus_ak9iq_4{margin-inline-start:.5rem}._agentSelector_ak9iq_1 ._agentStatus_ak9iq_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_ak9iq_1 ._agentStatus_ak9iq_4>span span{background:linear-gradient(135deg,#fe01da,#2486fc);color:transparent;-webkit-background-clip:text;background-clip:text;text-transform:uppercase}._agentSelector_ak9iq_1 ._agentLoader_ak9iq_18{position:inherit}._agentSelector_ak9iq_1 ._agentError_ak9iq_21 path{fill:#d5324e}._agentSelector_ak9iq_1 ._triggerChip_ak9iq_24{max-width:376px;display:flex;text-align:start}._agentSelector_ak9iq_1 ._triggerChip_ak9iq_24 ._agentLabel_ak9iq_29{flex-grow:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._agentSelector_ak9iq_1 ._triggerChip_ak9iq_24 ._dropdownIndicator_ak9iq_35{flex-shrink:0;margin-inline-start:0}._agentSelector_ak9iq_1 ._triggerChip_ak9iq_24 ._dropdownIndicator_ak9iq_35 svg{margin-inline-start:0}@media (max-width: 374px){._agentSelector_ak9iq_1 ._triggerChip_ak9iq_24{width:100%}}._agentSelector_ak9iq_1._sidebar_ak9iq_47{margin:0 .25rem 0 0;margin-inline-start:0}@media (max-width: 767px){._agentSelector_ak9iq_1._sidebar_ak9iq_47{width:100%}}._agentSelector_ak9iq_1._sidebar_ak9iq_47 ._triggerChip_ak9iq_24{width:246px}@media (max-width: 767px){._agentSelector_ak9iq_1._sidebar_ak9iq_47 ._triggerChip_ak9iq_24{width:100%;max-width:100%}}._agentListItemIcon_ak9iq_66{height:2rem;width:2rem}._agentListContainer_ak9iq_71{min-width:320px;max-width:376px}@media (max-width: 376px){._agentListContainer_ak9iq_71{max-width:320px}}._agentListContainer_ak9iq_71._sidebar_ak9iq_47{min-width:184px;max-width:252px}@media (max-width: 252px){._agentListContainer_ak9iq_71._sidebar_ak9iq_47{max-width:184px}}._agentListRetryButton_ak9iq_90{margin:.25rem;max-width:320px;text-wrap:wrap}._agentListRetryButton_ak9iq_90._sidebar_ak9iq_47{max-width:184px}
@@ -1,3 +1,3 @@
1
1
  import { type BoxAiAgentSelectorWithApiProps } from './types';
2
- export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
2
+ export declare function BoxAiAgentSelectorWithApi({ fetcher, hostAppName, onSelectAgent, recordAction, requestState: requestStateProp, shouldHideAgentSelectorOnLoad, triggerChipClassName, contentClassName, variant, }: BoxAiAgentSelectorWithApiProps): import("react/jsx-runtime").JSX.Element | null;
3
3
  export default BoxAiAgentSelectorWithApi;
@@ -73,6 +73,10 @@ export interface BoxAiAgentSelectorWithApiProps {
73
73
  */
74
74
  shouldHideAgentSelectorOnLoad?: boolean;
75
75
  triggerChipClassName?: string;
76
+ /**
77
+ * Styling variant of agent selector
78
+ * */
79
+ variant?: StyleVariant;
76
80
  }
77
81
  export interface BoxAiAgentSelectorProps {
78
82
  contentClassName?: string;