@ea-lab/reactive-json 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ import { useContext as l, useEffect as v } from "react";
2
+ import { GlobalDataContext as C } from "../../engine/GlobalDataContext.js";
3
+ import { TemplateContext as x } from "../../engine/TemplateContext.js";
4
+ import "react/jsx-runtime";
5
+ import "../../jsonpath-B9kE9k9e.js";
6
+ import "../../lodash-CYNxjS-I.js";
7
+ import "../../engine/EventDispatcherContext.js";
8
+ import "../../engine/EventDispatcherProvider.js";
9
+ import "../../engine/PaginationContext.js";
10
+ import "../../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
11
+ import "../../index-NNBvIV0S.js";
12
+ import { replaceEventPlaceholders as E } from "../../engine/utility/eventPlaceholderSystem.js";
13
+ import "../../js-yaml-Bw0KO4XO.js";
14
+ import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
15
+ const j = (o) => {
16
+ const e = l(C), i = l(x), d = o.attributesHolderRef, n = e.plugins ?? {}, f = (n == null ? void 0 : n.reaction) ?? {}, t = (o == null ? void 0 : o.actionProps) ?? void 0;
17
+ return v(() => {
18
+ const p = t ?? void 0, m = (t == null ? void 0 : t.what) ?? void 0, c = (a) => {
19
+ const s = m && (f[m] ?? void 0);
20
+ if (s) {
21
+ const u = E(p, a);
22
+ s({ args: u, event: a, globalDataContext: e, templateContext: i });
23
+ }
24
+ }, r = d.current;
25
+ if (r)
26
+ return r.addEventListener(t.on, c), () => {
27
+ r.removeEventListener(t.on, c);
28
+ };
29
+ }, [e, t, i]), o.children;
30
+ };
31
+ export {
32
+ j as CustomEventListener
33
+ };
@@ -1,66 +1,46 @@
1
- import { jsx as A, Fragment as C } from "react/jsx-runtime";
2
- import { useContext as E, Children as d, Fragment as h, isValidElement as j, cloneElement as k } from "react";
3
- import { GlobalDataContext as R } from "../../engine/GlobalDataContext.js";
4
- import { TemplateContext as L } from "../../engine/TemplateContext.js";
5
- const w = (s) => {
6
- const f = E(R), g = E(L), a = f.plugins ?? {}, P = (a == null ? void 0 : a.reaction) ?? {}, { actionProps: y } = s, p = {}, u = "<reactive-json:event>", v = "<reactive-json:event-new-value>", F = (e) => {
7
- if (e && e.target) {
8
- const r = e.target;
9
- if (r.type === "checkbox")
10
- return r.checked;
11
- if (r.type === "radio")
12
- return r.checked ? r.value : void 0;
13
- if (typeof r.value < "u")
14
- return r.value;
15
- if (typeof r.checked < "u")
16
- return r.checked;
17
- }
18
- }, b = (e, r) => {
19
- if (e === v)
20
- return F(r);
21
- if (typeof e != "string" || !e.startsWith(u))
22
- return e;
23
- let t = e.slice(u.length);
24
- if (t.startsWith(".") && (t = t.slice(1)), !!t)
25
- return t.split(".").reduce((n, o) => n ? n[o] : void 0, r);
26
- }, i = (e, r) => {
27
- if (Array.isArray(e))
28
- return e.map((t) => i(t, r));
29
- if (e && typeof e == "object") {
30
- const t = {};
31
- for (const [n, o] of Object.entries(e))
32
- t[n] = i(o, r);
33
- return t;
34
- }
35
- return b(e, r);
36
- };
37
- for (const [e, r] of Object.entries(y))
38
- p[e] = (t) => {
39
- let n = !0;
40
- for (const o of r) {
41
- if (!o)
1
+ import { jsx as C, Fragment as b } from "react/jsx-runtime";
2
+ import { useContext as f, Children as l, Fragment as v, isValidElement as y, cloneElement as A } from "react";
3
+ import { GlobalDataContext as E } from "../../engine/GlobalDataContext.js";
4
+ import "../../jsonpath-B9kE9k9e.js";
5
+ import "../../lodash-CYNxjS-I.js";
6
+ import { TemplateContext as j } from "../../engine/TemplateContext.js";
7
+ import "../../engine/EventDispatcherContext.js";
8
+ import "../../engine/EventDispatcherProvider.js";
9
+ import "../../engine/PaginationContext.js";
10
+ import "../../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
11
+ import "../../index-NNBvIV0S.js";
12
+ import { replaceEventPlaceholders as R } from "../../engine/utility/eventPlaceholderSystem.js";
13
+ import "../../js-yaml-Bw0KO4XO.js";
14
+ import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
15
+ const H = (p) => {
16
+ const s = f(E), g = f(j), e = s.plugins ?? {}, P = (e == null ? void 0 : e.reaction) ?? {}, { actionProps: F } = p, c = {};
17
+ for (const [o, a] of Object.entries(F))
18
+ c[o] = (t) => {
19
+ let r = !0;
20
+ for (const n of a) {
21
+ if (!n)
42
22
  continue;
43
- const m = o.what && (P[o.what] ?? null);
44
- if (!m)
23
+ const u = n.what && (P[n.what] ?? null);
24
+ if (!u)
45
25
  continue;
46
- const c = i(o, t);
47
- if (m({ args: c, event: t, globalDataContext: f, templateContext: g }), c.stopPropagation === !0)
26
+ const i = R(n, t);
27
+ if (u({ args: i, event: t, globalDataContext: s, templateContext: g }), i.stopPropagation === !0)
48
28
  break;
49
- n = c.stopPropagation ?? !0;
29
+ r = i.stopPropagation ?? !0;
50
30
  }
51
- n !== !1 && t.stopPropagation();
31
+ r !== !1 && t.stopPropagation();
52
32
  };
53
- const l = (e) => {
54
- if (!e)
55
- return e;
56
- const r = d.toArray(e);
57
- return d.map(r, (t) => {
58
- var n;
59
- return t.type === h ? l((n = t == null ? void 0 : t.props) == null ? void 0 : n.children) : typeof t != "object" || !j(t) ? t : k(t, p);
33
+ const m = (o) => {
34
+ if (!o)
35
+ return o;
36
+ const a = l.toArray(o);
37
+ return l.map(a, (t) => {
38
+ var r;
39
+ return t.type === v ? m((r = t == null ? void 0 : t.props) == null ? void 0 : r.children) : typeof t != "object" || !y(t) ? t : A(t, c);
60
40
  });
61
- }, x = l(s.children);
62
- return /* @__PURE__ */ A(C, { children: x });
41
+ }, x = m(p.children);
42
+ return /* @__PURE__ */ C(b, { children: x });
63
43
  };
64
44
  export {
65
- w as ReactOnEvent
45
+ H as ReactOnEvent
66
46
  };
@@ -1,22 +1,24 @@
1
- import { HashChangeListener as r } from "./HashChangeListener.js";
2
- import { Hide as f } from "./Hide.js";
3
- import { MessageListener as m } from "./MessageListener.js";
4
- import { ReactOnEvent as x } from "./ReactOnEvent.js";
5
- import { Redirect as s } from "./Redirect.js";
6
- import { SetAttributeValue as n } from "./SetAttributeValue.js";
7
- import { ToggleAttributeValue as b } from "./ToggleAttributeValue.js";
8
- import { UnsetAttribute as A } from "./UnsetAttribute.js";
9
- import { UnsetAttributeValue as d } from "./UnsetAttributeValue.js";
10
- import { VisuallyHide as c } from "./VisuallyHide.js";
1
+ import { CustomEventListener as r } from "./CustomEventListener.js";
2
+ import { HashChangeListener as m } from "./HashChangeListener.js";
3
+ import { Hide as i } from "./Hide.js";
4
+ import { MessageListener as x } from "./MessageListener.js";
5
+ import { ReactOnEvent as n } from "./ReactOnEvent.js";
6
+ import { Redirect as a } from "./Redirect.js";
7
+ import { SetAttributeValue as b } from "./SetAttributeValue.js";
8
+ import { ToggleAttributeValue as A } from "./ToggleAttributeValue.js";
9
+ import { UnsetAttribute as d } from "./UnsetAttribute.js";
10
+ import { UnsetAttributeValue as L } from "./UnsetAttributeValue.js";
11
+ import { VisuallyHide as h } from "./VisuallyHide.js";
11
12
  export {
12
- r as HashChangeListener,
13
- f as Hide,
14
- m as MessageListener,
15
- x as ReactOnEvent,
16
- s as Redirect,
17
- n as SetAttributeValue,
18
- b as ToggleAttributeValue,
19
- A as UnsetAttribute,
20
- d as UnsetAttributeValue,
21
- c as VisuallyHide
13
+ r as CustomEventListener,
14
+ m as HashChangeListener,
15
+ i as Hide,
16
+ x as MessageListener,
17
+ n as ReactOnEvent,
18
+ a as Redirect,
19
+ b as SetAttributeValue,
20
+ A as ToggleAttributeValue,
21
+ d as UnsetAttribute,
22
+ L as UnsetAttributeValue,
23
+ h as VisuallyHide
22
24
  };
@@ -10,27 +10,26 @@ import "../../engine/EventDispatcherProvider.js";
10
10
  import "../../engine/PaginationContext.js";
11
11
  import "../../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
12
12
  import { normalizeAttributeNameForReactJsx as d } from "../../engine/utility/reactJsxHelpers.js";
13
- import '../../assets/reset.css';/* empty css */
14
13
  import "../../index-NNBvIV0S.js";
15
14
  import "../../js-yaml-Bw0KO4XO.js";
16
15
  import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
17
- const q = ({ attributes: e, globalDataContext: a, singleTransformProps: i, templateContext: l }) => {
16
+ const k = ({ attributes: e, globalDataContext: p, singleTransformProps: i, templateContext: l }) => {
18
17
  const { name: n, mode: u = "append", value: c, preventDuplicateValues: s = !0, separator: r = " " } = i, t = v({
19
18
  valueToEvaluate: c,
20
- globalDataContext: a,
19
+ globalDataContext: p,
21
20
  templateContext: l
22
21
  }), o = d(n);
23
22
  if (u === "replace")
24
23
  e[o] = t;
25
24
  else {
26
- const m = e[o] || "", p = m ? m.split(r) : [];
27
- if (!s || !p.includes(t)) {
28
- const V = [...p, t];
25
+ const a = e[o] || "", m = a ? a.split(r) : [];
26
+ if (!s || !m.includes(t)) {
27
+ const V = [...m, t];
29
28
  e[o] = V.join(r);
30
29
  }
31
30
  }
32
31
  return e;
33
32
  };
34
33
  export {
35
- q as setAttributeValue
34
+ k as setAttributeValue
36
35
  };
@@ -10,38 +10,37 @@ import "../../engine/EventDispatcherProvider.js";
10
10
  import "../../engine/PaginationContext.js";
11
11
  import "../../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
12
12
  import { normalizeAttributeNameForReactJsx as A } from "../../engine/utility/reactJsxHelpers.js";
13
- import '../../assets/reset.css';/* empty css */
14
13
  import "../../index-NNBvIV0S.js";
15
14
  import "../../js-yaml-Bw0KO4XO.js";
16
15
  import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
17
- const B = ({ attributes: o, globalDataContext: V, singleTransformProps: x, templateContext: g }) => {
18
- const { name: p, value: m, separator: u = " ", keepAttributeWhenEmpty: h = !1 } = x || {};
19
- if (!p || m === void 0)
16
+ const q = ({ attributes: o, globalDataContext: V, singleTransformProps: x, templateContext: g }) => {
17
+ const { name: p, value: u, separator: m = " ", keepAttributeWhenEmpty: h = !1 } = x || {};
18
+ if (!p || u === void 0)
20
19
  return o;
21
20
  const s = v({
22
- valueToEvaluate: m,
21
+ valueToEvaluate: u,
23
22
  globalDataContext: V,
24
23
  templateContext: g
25
- }), n = A(p), f = o[n] || "";
26
- let l = [...f ? f.split(u).filter((e) => e.trim() !== "") : []];
24
+ }), i = A(p), f = o[i] || "";
25
+ let l = [...f ? f.split(m).filter((e) => e.trim() !== "") : []];
27
26
  if (Array.isArray(s)) {
28
27
  const e = s.map((t) => String(t));
29
28
  if (e.length === 0)
30
29
  return o;
31
30
  if (e.length === 1) {
32
- const t = e[0], i = l.indexOf(t);
33
- i > -1 ? l.splice(i, 1) : t !== "" && l.push(t);
31
+ const t = e[0], n = l.indexOf(t);
32
+ n > -1 ? l.splice(n, 1) : t !== "" && l.push(t);
34
33
  } else {
35
- let t = -1, i = -1;
34
+ let t = -1, n = -1;
36
35
  for (let r = 0; r < e.length; r++) {
37
36
  const a = e[r], d = l.indexOf(a);
38
37
  if (d > -1) {
39
- t = d, i = r;
38
+ t = d, n = r;
40
39
  break;
41
40
  }
42
41
  }
43
42
  if (t > -1) {
44
- const r = (i + 1) % e.length, a = e[r];
43
+ const r = (n + 1) % e.length, a = e[r];
45
44
  l.splice(t, 1), a !== "" && l.push(a);
46
45
  } else {
47
46
  const r = e[0];
@@ -52,9 +51,9 @@ const B = ({ attributes: o, globalDataContext: V, singleTransformProps: x, templ
52
51
  const e = String(s), t = l.indexOf(e);
53
52
  t > -1 ? l.splice(t, 1) : l.push(e);
54
53
  }
55
- const c = l.join(u);
56
- return c.trim() === "" ? h ? o[n] = "" : delete o[n] : o[n] = c, o;
54
+ const c = l.join(m);
55
+ return c.trim() === "" ? h ? o[i] = "" : delete o[i] : o[i] = c, o;
57
56
  };
58
57
  export {
59
- B as toggleAttributeValue
58
+ q as toggleAttributeValue
60
59
  };
@@ -10,12 +10,11 @@ import "../../engine/EventDispatcherProvider.js";
10
10
  import "../../engine/PaginationContext.js";
11
11
  import "../../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
12
12
  import { normalizeAttributeNameForReactJsx as w } from "../../engine/utility/reactJsxHelpers.js";
13
- import '../../assets/reset.css';/* empty css */
14
13
  import "../../index-NNBvIV0S.js";
15
14
  import "../../js-yaml-Bw0KO4XO.js";
16
15
  import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
17
- const B = ({ attributes: t, globalDataContext: l, singleTransformProps: A, templateContext: a }) => {
18
- const { name: s, value: m, separator: p = " ", unsetAllOccurrences: C, unsetCount: c } = A || {};
16
+ const y = ({ attributes: t, globalDataContext: l, singleTransformProps: A, templateContext: a }) => {
17
+ const { name: s, value: m, separator: c = " ", unsetAllOccurrences: C, unsetCount: p } = A || {};
19
18
  if (!s || m === void 0)
20
19
  return t;
21
20
  const n = String(
@@ -24,14 +23,14 @@ const B = ({ attributes: t, globalDataContext: l, singleTransformProps: A, templ
24
23
  globalDataContext: l,
25
24
  templateContext: a
26
25
  })
27
- ), u = c !== void 0 ? V({
28
- valueToEvaluate: c,
26
+ ), u = p !== void 0 ? V({
27
+ valueToEvaluate: p,
29
28
  globalDataContext: l,
30
29
  templateContext: a
31
30
  }) : void 0, i = w(s), f = t[i] || "";
32
31
  if (!f)
33
32
  return t;
34
- let e = [...f.split(p)];
33
+ let e = [...f.split(c)];
35
34
  (() => {
36
35
  if (C === !0) {
37
36
  e = e.filter((r) => r !== n);
@@ -53,9 +52,9 @@ const B = ({ attributes: t, globalDataContext: l, singleTransformProps: A, templ
53
52
  let d = 0;
54
53
  e = e.reverse().filter((r) => r === n && d < N ? (d++, !1) : !0).reverse();
55
54
  })();
56
- const v = e.join(p);
55
+ const v = e.join(c);
57
56
  return v.trim() === "" ? delete t[i] : t[i] = v, t;
58
57
  };
59
58
  export {
60
- B as unsetAttributeValue
59
+ y as unsetAttributeValue
61
60
  };
@@ -12,12 +12,11 @@ import "../../../../index-NNBvIV0S.js";
12
12
  import "../../../../jsonpath-B9kE9k9e.js";
13
13
  import "../../../../js-yaml-Bw0KO4XO.js";
14
14
  import "../../../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
15
- import { DebugMode as r } from "./DebugMode.enum.js";
15
+ import { DebugMode as c } from "./DebugMode.enum.js";
16
16
  import R from "./ModeDisplay/DebugList/DebugList.js";
17
17
  import D from "./ModeDisplay/DebugJson/DebugJson.js";
18
- import '../../../../assets/reset.css';import '../../../../assets/VariablesDebug.css';/* empty css */
19
18
  import { flattenObject as J } from "./utils.js";
20
- const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_34", T = "_header_1ny7q_39", I = "_actions_1ny7q_45", P = "_btn_1ny7q_50", M = "_active_1ny7q_58", w = "_path_1ny7q_62", A = "_value_1ny7q_66", H = "_copyBtn_1ny7q_70", V = "_copyBtnSuccess_1ny7q_74", F = "_copyBtnError_1ny7q_78", W = "_info_1ny7q_82", n = {
19
+ import '../../../../assets/VariablesDebug.css';const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_34", T = "_header_1ny7q_39", I = "_actions_1ny7q_45", P = "_btn_1ny7q_50", M = "_active_1ny7q_58", w = "_path_1ny7q_62", A = "_value_1ny7q_66", H = "_copyBtn_1ny7q_70", V = "_copyBtnSuccess_1ny7q_74", F = "_copyBtnError_1ny7q_78", W = "_info_1ny7q_82", n = {
21
20
  debugRoot: O,
22
21
  container: j,
23
22
  expanded: k,
@@ -31,8 +30,8 @@ const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_
31
30
  copyBtnSuccess: V,
32
31
  copyBtnError: F,
33
32
  info: W
34
- }, pt = ({ props: v }) => {
35
- const [c, u] = p(!1), [i, _] = p(r.LIST), o = B($), d = g(null), [y, S] = p(null), f = g(null);
33
+ }, dt = ({ props: v }) => {
34
+ const [r, u] = p(!1), [i, _] = p(c.LIST), o = B($), d = g(null), [y, S] = p(null), f = g(null);
36
35
  q(() => {
37
36
  if (typeof document > "u") return;
38
37
  let t = document.getElementById("rj-debug-root");
@@ -42,7 +41,7 @@ const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_
42
41
  const t = d.current;
43
42
  try {
44
43
  if (await navigator.clipboard.writeText(
45
- i === r.JSON ? b : h.map((s) => `${s.path}: ${JSON.stringify(s.value)}`).join(`
44
+ i === c.JSON ? b : h.map((s) => `${s.path}: ${JSON.stringify(s.value)}`).join(`
46
45
  `)
47
46
  ), !t) return;
48
47
  t.classList.add(n.copyBtnSuccess), t.textContent = "Copied!", setTimeout(() => {
@@ -57,7 +56,7 @@ const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_
57
56
  }, N = /* @__PURE__ */ e(L, { ...v, attributesHolderRef: f, children: /* @__PURE__ */ a(
58
57
  "div",
59
58
  {
60
- className: `${n.container} ${c ? n.expanded : ""}`,
59
+ className: `${n.container} ${r ? n.expanded : ""}`,
61
60
  onClick: () => u((t) => !t),
62
61
  role: "button",
63
62
  ref: f,
@@ -68,20 +67,20 @@ const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_
68
67
  /* @__PURE__ */ e("code", { children: o.templatePath })
69
68
  ] }),
70
69
  /* @__PURE__ */ a("div", { className: n.actions, onClick: (t) => t.stopPropagation(), children: [
71
- c && /* @__PURE__ */ a(x, { children: [
70
+ r && /* @__PURE__ */ a(x, { children: [
72
71
  /* @__PURE__ */ e(
73
72
  "button",
74
73
  {
75
- className: `${n.btn} ${i === r.LIST ? n.active : ""}`,
76
- onClick: () => _(r.LIST),
74
+ className: `${n.btn} ${i === c.LIST ? n.active : ""}`,
75
+ onClick: () => _(c.LIST),
77
76
  children: "List"
78
77
  }
79
78
  ),
80
79
  /* @__PURE__ */ e(
81
80
  "button",
82
81
  {
83
- className: `${n.btn} ${i === r.JSON ? n.active : ""}`,
84
- onClick: () => _(r.JSON),
82
+ className: `${n.btn} ${i === c.JSON ? n.active : ""}`,
83
+ onClick: () => _(c.JSON),
85
84
  children: "JSON"
86
85
  }
87
86
  )
@@ -91,10 +90,10 @@ const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_
91
90
  {
92
91
  className: n.btn,
93
92
  onClick: () => u((t) => !t),
94
- children: c ? "Collapse" : "Expand"
93
+ children: r ? "Collapse" : "Expand"
95
94
  }
96
95
  ),
97
- c && /* @__PURE__ */ e(
96
+ r && /* @__PURE__ */ e(
98
97
  "button",
99
98
  {
100
99
  className: `${n.btn} ${n.copyBtn}`,
@@ -105,12 +104,12 @@ const O = "_debugRoot_1ny7q_1", j = "_container_1ny7q_16", k = "_expanded_1ny7q_
105
104
  )
106
105
  ] })
107
106
  ] }),
108
- c && /* @__PURE__ */ e("div", { className: n.info, onClick: (t) => t.stopPropagation(), children: i === r.JSON ? /* @__PURE__ */ e(D, { jsonString: b }) : /* @__PURE__ */ e(R, { flatRows: h }) })
107
+ r && /* @__PURE__ */ e("div", { className: n.info, onClick: (t) => t.stopPropagation(), children: i === c.JSON ? /* @__PURE__ */ e(D, { jsonString: b }) : /* @__PURE__ */ e(R, { flatRows: h }) })
109
108
  ]
110
109
  }
111
110
  ) });
112
111
  return y ? E.createPortal(N, y) : null;
113
112
  };
114
113
  export {
115
- pt as VariablesDebug
114
+ dt as VariablesDebug
116
115
  };