@ea-lab/reactive-json 1.0.0-alpha.4 → 1.0.0-alpha.5

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.
@@ -1,29 +1,29 @@
1
1
  import { jsx as o, jsxs as d, Fragment as u } from "react/jsx-runtime";
2
- import { useContext as b, useRef as A } from "react";
3
- import { ActionDependant as C } from "../../../engine/Actions.js";
4
- import { GlobalDataContext as T } from "../../../engine/GlobalDataContext.js";
2
+ import { useContext as b, useRef as k } from "react";
3
+ import { ActionDependant as A } from "../../../engine/Actions.js";
4
+ import { GlobalDataContext as C } from "../../../engine/GlobalDataContext.js";
5
5
  import { normalizeAttributesForReactJsx as g } from "../../../engine/utility/reactJsxHelpers.js";
6
- import { TemplateContext as j } from "../../../engine/TemplateContext.js";
7
- import { evaluateAttributes as k } from "../../../engine/TemplateSystem.js";
8
- import { View as c } from "../../../engine/View.js";
9
- const N = ({ props: e, currentData: m, datafield: v, path: x }) => {
10
- const h = b(T), p = b(j), i = A(null), l = `${e.tag}`, r = e.extra ?? {}, n = g(e.attributes), a = g(m.attributes);
11
- for (const t of Object.keys(a)) {
12
- if (t.charAt(0) === "+") {
13
- const s = t.substring(1);
14
- n[s] = (n[s] ?? "").length > 0 ? (
6
+ import { TemplateContext as T } from "../../../engine/TemplateContext.js";
7
+ import { evaluateAttributes as j } from "../../../engine/TemplateSystem.js";
8
+ import { View as l } from "../../../engine/View.js";
9
+ const N = ({ props: t, currentData: m, datafield: p, path: x }) => {
10
+ const h = b(C), v = b(T), c = k(null), f = `${t.tag}`, n = t.extra ?? {}, r = g(t.attributes), i = g(m.attributes);
11
+ for (const e of Object.keys(i)) {
12
+ if (e.charAt(0) === "+") {
13
+ const s = e.substring(1);
14
+ r[s] = (r[s] ?? "").length > 0 ? (
15
15
  // Append using a space.
16
- " " + a[t]
16
+ " " + i[e]
17
17
  ) : (
18
18
  // Set directly.
19
- a[t]
19
+ i[e]
20
20
  );
21
21
  continue;
22
22
  }
23
- n[t] = a[t];
23
+ r[e] = i[e];
24
24
  }
25
- const f = k({ attrs: n, globalDataContext: h, templateContext: p });
26
- return /* @__PURE__ */ o(C, { ...e, attributesHolderRef: i, children: ((t) => t && [
25
+ const a = j({ attrs: r, globalDataContext: h, templateContext: v });
26
+ return (t.tag === "input" || t.tag === "textarea" || t.tag === "select") && (a.value === void 0 && (a.value = ""), t.tag === "input" && (a.type === "checkbox" || a.type === "radio") && a.checked === void 0 && (a.checked = !1)), /* @__PURE__ */ o(A, { ...t, attributesHolderRef: c, children: ((e) => e && [
27
27
  "area",
28
28
  "base",
29
29
  "br",
@@ -38,20 +38,20 @@ const N = ({ props: e, currentData: m, datafield: v, path: x }) => {
38
38
  "source",
39
39
  "track",
40
40
  "wbr"
41
- ].indexOf(t) !== -1)(e.tag) ? /* @__PURE__ */ d(u, { children: [
42
- /* @__PURE__ */ o(l, { ref: i, ...f }),
43
- Object.keys(r).length ? /* @__PURE__ */ o(c, { props: r }) : ""
41
+ ].indexOf(e) !== -1)(t.tag) ? /* @__PURE__ */ d(u, { children: [
42
+ /* @__PURE__ */ o(f, { ref: c, ...a }),
43
+ Object.keys(n).length ? /* @__PURE__ */ o(l, { props: n }) : ""
44
44
  ] }) : /* @__PURE__ */ d(u, { children: [
45
- /* @__PURE__ */ o(l, { ref: i, ...f, children: e.content && /* @__PURE__ */ o(
46
- c,
45
+ /* @__PURE__ */ o(f, { ref: c, ...a, children: t.content && /* @__PURE__ */ o(
46
+ l,
47
47
  {
48
48
  currentData: m.content ?? void 0,
49
49
  datafield: "content",
50
50
  path: x + ".content",
51
- props: e.content
51
+ props: t.content
52
52
  }
53
53
  ) }),
54
- Object.keys(r).length ? /* @__PURE__ */ o(c, { props: r }) : ""
54
+ Object.keys(n).length ? /* @__PURE__ */ o(l, { props: n }) : ""
55
55
  ] }) });
56
56
  };
57
57
  export {
@@ -53,7 +53,7 @@ const A = ({ dataLocation: r, currentPath: t, globalDataContext: e, templateCont
53
53
  return;
54
54
  const f = r.split(".");
55
55
  for (f.shift(); f.length; )
56
- if (typeof s != "object" || (s = s[f.shift()], s === void 0))
56
+ if (typeof s != "object" || s === null || (s = s[f.shift()], s === void 0))
57
57
  return;
58
58
  return s;
59
59
  }, u = ({
@@ -65,7 +65,7 @@ const A = ({ dataLocation: r, currentPath: t, globalDataContext: e, templateCont
65
65
  if (s === 0 || s <= -20)
66
66
  return r;
67
67
  let i;
68
- if (typeof r == "object") {
68
+ if (typeof r == "object" && r !== null) {
69
69
  i = Array.isArray(r) ? [] : {};
70
70
  for (const [h, m] of Object.entries(r)) {
71
71
  const n = W({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ea-lab/reactive-json",
3
3
  "private": false,
4
- "version": "1.0.0-alpha.4",
4
+ "version": "1.0.0-alpha.5",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",