UNPKG

@forbespro/lead-agent-hook

Version:
24 lines (23 loc) 744 B
import { jsx as u } from "react/jsx-runtime"; import { createContext as g, useState as l, useCallback as o, useContext as p } from "react"; const r = g(void 0); r.displayName = "LeadAgentContext"; const v = function({ children: a, defaultOpen: s = !1 }) { const [t, n] = l(s), d = o(() => n(!0), []), i = o(() => n(!1), []), c = o(() => n(!t), [t]); return /* @__PURE__ */ u(r.Provider, { value: { isOpen: t, openChat: d, closeChat: i, toggleChat: c }, children: a }); }; v.displayName = "LeadAgentProvider"; function L() { const e = p(r); if (e === void 0) throw new Error("useLeadAgent must be used within a LeadAgentProvider"); return e; } export { r as LeadAgentContext, v as LeadAgentProvider, L as useLeadAgent };