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

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