mongodb-chatbot-ui
Version:
UI React components for the MongoDB Assistant
21 lines (20 loc) • 573 B
JavaScript
import { useEffect as s } from "react";
import { useChatbotContext as m } from "./useChatbotContext.js";
import { u } from "./HotkeyContext.js";
import "./ChatbotProvider.js";
import "react/jsx-runtime";
function y({ onKey: t }) {
const { open: o, openChat: n } = m(), e = u();
return s(() => {
e.setHotkey(t);
const r = (i) => {
i.key === t && n();
};
return o || window.addEventListener("keydown", r), () => {
window.removeEventListener("keydown", r), e.setHotkey(null);
};
}, [e, t, o, n]), null;
}
export {
y as HotkeyTrigger
};