UNPKG

@ea-lab/reactive-json

Version:

A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.

21 lines (20 loc) 706 B
import { jsx as o } from "react/jsx-runtime"; import { memo as i } from "react"; import { EventDispatcherContext as s } from "./EventDispatcherContext.js"; const e = {}, c = (r) => { if (e.hasOwnProperty(r.type)) for (const n of e[r.type]) n(r); }, d = (r, n) => { e.hasOwnProperty(r) ? e[r].push(n) : (window.addEventListener(r, c), e[r] = [n]); }, a = (r, n) => { if (!e.hasOwnProperty(r)) return; const t = e[r].indexOf(n); t > -1 && e[r].splice(t, 1); }, p = i((r) => /* @__PURE__ */ o(s.Provider, { value: { addEventListener: d, removeEventListener: a }, children: r.children })); export { p as EventDispatcherProvider, d as addEventListener, a as removeEventListener };