@ea-lab/reactive-json
Version:
A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.
29 lines (28 loc) • 1.06 kB
JavaScript
const h = (e) => {
var i, g, s, v, f, r;
const n = (i = e == null ? void 0 : e.args) == null ? void 0 : i.selector;
if (!n || typeof n != "string" || n.length === 0)
return;
const c = (g = e == null ? void 0 : e.args) == null ? void 0 : g.selectorBase;
let t;
if (typeof c > "u" ? t = document : c === "currentEventTarget" ? t = (s = e == null ? void 0 : e.event) == null ? void 0 : s.target : t = (f = (v = e == null ? void 0 : e.event) == null ? void 0 : v.target) == null ? void 0 : f.closest(c), !t)
return;
const l = (r = e == null ? void 0 : e.args) == null ? void 0 : r.eventName;
if (!l || typeof l != "string" || l.length === 0)
return;
const d = t.querySelectorAll(n), y = Object.entries(d), a = () => {
var m, b;
const u = ((b = (m = y.splice(0, 1)) == null ? void 0 : m[0]) == null ? void 0 : b[1]) ?? void 0;
if (!u)
return;
const E = new Event(l, {
bubbles: !0,
cancelable: !1
});
u.dispatchEvent(E), Promise.resolve().then(a);
};
a();
};
export {
h as triggerEvent
};