@box/box-ai-agent-selector
Advanced tools
Comparing version
import { useState as I, useCallback as m, useEffect as f } from "react"; | ||
import { BoxAiAgentSelector as L } from "./box-ai-agent-selector.js"; | ||
import { LOGGER_BASE_CONFIG as a, LOGGER_TARGET as l } from "./constants.js"; | ||
import { ACTIONS as S } from "./contexts/actions.js"; | ||
import { ACTIONS as E } from "./contexts/actions.js"; | ||
import { useAgentsDispatch as U, useAgents as x } from "./contexts/context.js"; | ||
import { R as r } from "../../chunks/types.js"; | ||
import { R as S } from "../../chunks/types.js"; | ||
import { jsx as D } from "react/jsx-runtime"; | ||
@@ -23,3 +23,3 @@ function k({ | ||
agents: A, | ||
requestState: E, | ||
requestState: r, | ||
selectedAgent: n | ||
@@ -30,4 +30,4 @@ } = x(), [d, _] = I(!1), o = m((t) => { | ||
e({ | ||
type: S.SET_REQUEST_STATE, | ||
requestState: r.IN_PROGRESS | ||
type: E.SET_REQUEST_STATE, | ||
requestState: S.IN_PROGRESS | ||
}); | ||
@@ -37,3 +37,3 @@ try { | ||
e({ | ||
type: S.SET_AGENT_LIST, | ||
type: E.SET_AGENT_LIST, | ||
agents: t.agents | ||
@@ -46,4 +46,4 @@ }), o({ | ||
e({ | ||
type: S.SET_REQUEST_STATE, | ||
requestState: r.ERROR | ||
type: E.SET_REQUEST_STATE, | ||
requestState: S.ERROR | ||
}), o({ | ||
@@ -54,3 +54,3 @@ ...a, | ||
} | ||
}, [e, o, u]), g = E !== r.SUCCESS || !A.length || !n; | ||
}, [e, o, u]), g = r !== S.SUCCESS || !A.length || !n; | ||
return f(() => { | ||
@@ -61,12 +61,12 @@ g ? c().finally(() => { | ||
}, [c, g]), f(() => { | ||
s && s !== E && (s !== r.SUCCESS && e({ | ||
type: S.SET_AGENT_LIST, | ||
s && s !== r && (s !== S.SUCCESS && e({ | ||
type: E.SET_AGENT_LIST, | ||
agents: [] | ||
}), e({ | ||
type: S.SET_REQUEST_STATE, | ||
type: E.SET_REQUEST_STATE, | ||
requestState: s | ||
})); | ||
}, [e, E, s]), f(() => { | ||
}, [e, s]), f(() => { | ||
i && i(n); | ||
}, [i, n]), h && !d || E === r.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(L, { | ||
}, [i, n]), h && !d || r === S.SUCCESS && A.length <= 1 ? null : /* @__PURE__ */ D(L, { | ||
agents: A, | ||
@@ -78,3 +78,3 @@ contentClassName: O, | ||
recordAction: o, | ||
requestState: E, | ||
requestState: r, | ||
selectedAgent: n, | ||
@@ -81,0 +81,0 @@ triggerChipClassName: p, |
@@ -1,103 +0,103 @@ | ||
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"; | ||
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"; | ||
import { AlertBadge as at } from "@box/blueprint-web-assets/icons/Fill"; | ||
import m from "clsx"; | ||
import { useState as B, useRef as rt, useEffect as ot, useCallback as f } from "react"; | ||
import f from "clsx"; | ||
import { useState as P, useRef as ot, useEffect as rt, useCallback as d } from "react"; | ||
import { useIntl as nt } from "react-intl"; | ||
import { BoxAiAgent as st } from "./box-ai-agent.js"; | ||
import { LOGGER_BASE_CONFIG as E, LOGGER_ACTION_CLICK as S, LOGGER_TARGET as T } from "./constants.js"; | ||
import { ACTIONS as it } from "./contexts/actions.js"; | ||
import { BoxAiAgent as it } from "./box-ai-agent.js"; | ||
import { LOGGER_BASE_CONFIG as S, LOGGER_ACTION_CLICK as T, LOGGER_TARGET as R } from "./constants.js"; | ||
import { ACTIONS as st } from "./contexts/actions.js"; | ||
import { useAgentsDispatch as lt } from "./contexts/context.js"; | ||
import s from "./messages.js"; | ||
import { R } from "../../chunks/types.js"; | ||
import { jsx as e, jsxs as I } from "react/jsx-runtime"; | ||
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 = { | ||
agentSelector: pt, | ||
import i from "./messages.js"; | ||
import { R as I } from "../../chunks/types.js"; | ||
import { jsx as e, jsxs as y } from "react/jsx-runtime"; | ||
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 = { | ||
agentSelector: ct, | ||
agentStatus: gt, | ||
agentLoader: ct, | ||
agentError: dt, | ||
triggerChip: mt, | ||
agentLabel: ft, | ||
dropdownIndicator: _t, | ||
sidebar: Lt, | ||
agentListItemIcon: ht, | ||
agentLoader: pt, | ||
agentError: mt, | ||
triggerChip: ft, | ||
agentLabel: dt, | ||
dropdownIndicator: ht, | ||
sidebar: _t, | ||
agentListItemIcon: Lt, | ||
agentListContainer: ut, | ||
agentListRetryButton: Ct | ||
}; | ||
function At({ | ||
agents: _, | ||
contentClassName: P, | ||
onErrorAction: y, | ||
recordAction: r, | ||
requestState: L, | ||
disabled: k, | ||
function xt({ | ||
agents: h, | ||
contentClassName: k, | ||
onErrorAction: b, | ||
recordAction: o, | ||
requestState: _, | ||
disabled: D, | ||
onAgentsListOpen: N, | ||
selectedAgent: i, | ||
triggerChipClassName: D, | ||
variant: K = "modal" | ||
selectedAgent: s, | ||
triggerChipClassName: K, | ||
variant: v = "modal" | ||
}) { | ||
const { | ||
formatMessage: o | ||
} = 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); | ||
formatMessage: r | ||
} = 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); | ||
let g = ""; | ||
O ? g = (i == null ? void 0 : i.name) || G : n && (g = M); | ||
const z = rt(null), { | ||
Wrapper: F, | ||
wrapperProps: U | ||
O ? g = (s == null ? void 0 : s.name) || G : n && (g = F); | ||
const A = ot(null), { | ||
Wrapper: U, | ||
wrapperProps: j | ||
} = X({ | ||
ref: z, | ||
ref: A, | ||
textValue: g | ||
}); | ||
ot(() => { | ||
l && r && r({ | ||
...E, | ||
action: S, | ||
target: T.OPEN_SELECTOR | ||
rt(() => { | ||
l && o && o({ | ||
...S, | ||
action: T, | ||
target: R.OPEN_SELECTOR | ||
}); | ||
}, [l, r]); | ||
const C = f((t) => { | ||
p(!1), w({ | ||
type: it.SET_SELECTED_AGENT, | ||
}, [l, o]); | ||
const C = d((t) => { | ||
c(!1), w({ | ||
type: st.SET_SELECTED_AGENT, | ||
id: t.id | ||
}), r && r({ | ||
...E, | ||
action: S, | ||
target: T.SELECT_AGENT | ||
}), o && o({ | ||
...S, | ||
action: T, | ||
target: R.SELECT_AGENT | ||
}); | ||
}, [w, r]), j = f(() => { | ||
p(!1), y(), r && r({ | ||
...E, | ||
action: S, | ||
target: T.RETRY_LOADING_AGENTS | ||
}, [w, o]), Q = d(() => { | ||
c(!1), b(), o && o({ | ||
...S, | ||
action: T, | ||
target: R.RETRY_LOADING_AGENTS | ||
}); | ||
}, [y, r]), Q = f((t) => { | ||
if (t.key === "Escape" && (p(!1), t.stopPropagation()), t.key === " ") { | ||
const A = t.target; | ||
if (A) { | ||
const H = A.getAttribute("data-key"), x = _.find((J) => J.id === H); | ||
x && C(x); | ||
}, [b, o]), V = d((t) => { | ||
if (t.key === "Escape" && (c(!1), t.stopPropagation()), t.key === " ") { | ||
const x = t.target; | ||
if (x) { | ||
const H = x.getAttribute("data-key"), B = h.find((J) => J.id === H); | ||
B && C(B); | ||
} | ||
} | ||
}, [_, C]), V = f((t) => h(n && n && !l && t ? t : !1), [n, l]), W = (t) => { | ||
t && N && N(), p(t); | ||
}, b = K === "sidebar" && a.sidebar, Y = (t) => { | ||
}, [h, C]), W = d((t) => L(n && n && !l && t ? t : !1), [n, l]), Y = (t) => { | ||
t && N && N(), c(t); | ||
}, E = v === "sidebar" && a.sidebar, z = (t) => { | ||
(t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") && t.stopPropagation(); | ||
}; | ||
return /* @__PURE__ */ e(c.Group, { | ||
className: m(a.agentSelector, D, b), | ||
return /* @__PURE__ */ e(p.Group, { | ||
className: f(a.agentSelector, K, E), | ||
name: G, | ||
onKeyDown: Y, | ||
onKeyDown: z, | ||
type: "multiple", | ||
children: /* @__PURE__ */ I(d.Root, { | ||
children: /* @__PURE__ */ y(m.Root, { | ||
modal: !1, | ||
onOpenChange: W, | ||
onOpenChange: Y, | ||
open: l, | ||
children: [/* @__PURE__ */ e(Z, { | ||
content: o(s.errorTooltip), | ||
onOpenChange: V, | ||
open: v, | ||
content: r(i.errorTooltip), | ||
onOpenChange: W, | ||
open: M, | ||
side: "bottom", | ||
variant: "error", | ||
children: /* @__PURE__ */ e(d.Trigger, { | ||
disabled: k || u, | ||
children: /* @__PURE__ */ I(c.TriggerChip, { | ||
children: /* @__PURE__ */ e(m.Trigger, { | ||
disabled: D || u, | ||
children: /* @__PURE__ */ y(p.TriggerChip, { | ||
className: a.triggerChip, | ||
@@ -109,5 +109,5 @@ "data-target-id": "FilterChip.TriggerChip-agentSelectorTrigger", | ||
colorIndex: 0, | ||
text: o(s.agent) | ||
text: r(i.agent) | ||
}), u && /* @__PURE__ */ e(q, { | ||
"aria-label": o(s.loadingMessage), | ||
"aria-label": r(i.loadingMessage), | ||
className: a.agentLoader, | ||
@@ -120,6 +120,6 @@ variant: "default" | ||
width: "1rem" | ||
}), /* @__PURE__ */ e(F, { | ||
...U, | ||
children: /* @__PURE__ */ e(c.Label, { | ||
ref: z, | ||
}), /* @__PURE__ */ e(U, { | ||
...j, | ||
children: /* @__PURE__ */ e(p.Label, { | ||
ref: A, | ||
className: a.agentLabel, | ||
@@ -130,16 +130,16 @@ children: g | ||
className: a.dropdownIndicator, | ||
children: /* @__PURE__ */ e(c.DropdownIndicator, {}) | ||
children: /* @__PURE__ */ e(p.DropdownIndicator, {}) | ||
})] | ||
}) | ||
}) | ||
}), /* @__PURE__ */ e(d.ContentContainer, { | ||
}), /* @__PURE__ */ e(m.ContentContainer, { | ||
align: "start", | ||
className: m(a.agentListContainer, b), | ||
onKeyDownCapture: Q, | ||
children: /* @__PURE__ */ I(d.MainContent, { | ||
className: f(a.agentListContainer, E), | ||
onKeyDownCapture: V, | ||
children: /* @__PURE__ */ y(m.MainContent, { | ||
children: [O && /* @__PURE__ */ e(tt, { | ||
"aria-label": o(s.agentList), | ||
className: m([a.agentList, P]), | ||
selectedKeys: [(i == null ? void 0 : i.id) || ""], | ||
children: _.map((t) => /* @__PURE__ */ e(st, { | ||
"aria-label": r(i.agentList), | ||
className: f([a.agentList, k]), | ||
selectedKeys: [(s == null ? void 0 : s.id) || ""], | ||
children: h.map((t) => /* @__PURE__ */ e(it, { | ||
agent: t, | ||
@@ -149,7 +149,7 @@ onAction: () => C(t) | ||
}), n && /* @__PURE__ */ e(et, { | ||
className: m(a.agentListRetryButton, b), | ||
onClick: j, | ||
className: f(a.agentListRetryButton, E), | ||
onClick: Q, | ||
variant: "tertiary", | ||
"data-target-id": "Button-errorMessage", | ||
children: o(s.errorMessage) | ||
children: r(i.errorMessage) | ||
})] | ||
@@ -162,4 +162,4 @@ }) | ||
export { | ||
At as BoxAiAgentSelector, | ||
At as default | ||
xt as BoxAiAgentSelector, | ||
xt as default | ||
}; |
import { BoxAiAgentSelectorWithApiProps } from '../../index'; | ||
import { REQUEST_STATE } from '../types'; | ||
export declare const defaultBoxAiAgentSelectorProps: { | ||
@@ -8,2 +9,6 @@ fetcher: () => Promise<{ | ||
export declare const DefaultBoxAiAgentSelectorWithApiContainer: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element; | ||
export declare const BoxAiAgentSelectorWithApiContainerWithChangedRequestState: ({ changeTimeout, newRequestState, ...args }: BoxAiAgentSelectorWithApiProps & { | ||
changeTimeout: number; | ||
newRequestState: REQUEST_STATE; | ||
}) => import("react/jsx-runtime").JSX.Element; | ||
export declare const BoxAiAgentSelectorWithProvider: (props: BoxAiAgentSelectorWithApiProps) => import("react/jsx-runtime").JSX.Element; |
{ | ||
"name": "@box/box-ai-agent-selector", | ||
"version": "0.33.1", | ||
"version": "0.33.2", | ||
"license": "SEE LICENSE IN LICENSE", | ||
@@ -14,3 +14,3 @@ "peerDependencies": { | ||
"@box/babel-plugin-target-attributes": "1.3.0", | ||
"@box/blueprint-web": "^9.19.0", | ||
"@box/blueprint-web": "^9.19.1", | ||
"@box/blueprint-web-assets": "^4.37.1", | ||
@@ -17,0 +17,0 @@ "@box/eslint-plugin-blueprint": "^1.0.3", |
Sorry, the diff of this file is not supported yet
106764
0.3%885
126.34%1046
0.48%115
-1.71%52
-3.7%3
-40%115
-1.71%