@ea-lab/reactive-json 1.2.0 → 1.3.0
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.
|
@@ -4,7 +4,7 @@ import "../../lodash-CYNxjS-I.js";
|
|
|
4
4
|
import "react";
|
|
5
5
|
import "../../engine/GlobalDataContext.js";
|
|
6
6
|
import "../../engine/TemplateContext.js";
|
|
7
|
-
import { evaluateTemplateValue as
|
|
7
|
+
import { evaluateTemplateValue as V } from "../../engine/TemplateSystem.js";
|
|
8
8
|
import "../../engine/EventDispatcherContext.js";
|
|
9
9
|
import "../../engine/EventDispatcherProvider.js";
|
|
10
10
|
import "../../engine/PaginationContext.js";
|
|
@@ -13,23 +13,58 @@ import { normalizeAttributeNameForReactJsx as d } from "../../engine/utility/rea
|
|
|
13
13
|
import "../../index-NNBvIV0S.js";
|
|
14
14
|
import "../../js-yaml-Bw0KO4XO.js";
|
|
15
15
|
import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const f = (e, p, u, a) => {
|
|
17
|
+
const l = { ...e };
|
|
18
|
+
for (const r in p)
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(p, r)) {
|
|
20
|
+
const n = p[r], t = l[r];
|
|
21
|
+
if (n !== null && typeof n == "object" && !Array.isArray(n))
|
|
22
|
+
t !== null && typeof t == "object" && !Array.isArray(t) ? l[r] = f(t, n, u, a) : l[r] = n;
|
|
23
|
+
else if (typeof t == "string" && typeof n == "string") {
|
|
24
|
+
const s = t ? t.split(a) : [];
|
|
25
|
+
if (!u || !s.includes(n)) {
|
|
26
|
+
const o = [...s, n];
|
|
27
|
+
l[r] = o.join(a);
|
|
28
|
+
} else
|
|
29
|
+
l[r] = t;
|
|
30
|
+
} else
|
|
31
|
+
l[r] = n;
|
|
32
|
+
}
|
|
33
|
+
return l;
|
|
34
|
+
}, P = ({ attributes: e, globalDataContext: p, singleTransformProps: u, templateContext: a }) => {
|
|
35
|
+
const { name: l, mode: r = "append", value: n, preventDuplicateValues: t = !0, separator: s = " " } = u, o = V({
|
|
36
|
+
valueToEvaluate: n,
|
|
19
37
|
globalDataContext: p,
|
|
20
|
-
templateContext:
|
|
21
|
-
}),
|
|
22
|
-
if (
|
|
23
|
-
e[
|
|
38
|
+
templateContext: a
|
|
39
|
+
}), i = d(l);
|
|
40
|
+
if (o === void 0)
|
|
41
|
+
return r === "append" || (e[i] = void 0), e;
|
|
42
|
+
if (o !== null && typeof o == "object" && !Array.isArray(o))
|
|
43
|
+
if (r === "replace")
|
|
44
|
+
e[i] = o;
|
|
45
|
+
else {
|
|
46
|
+
const c = e[i] || {}, m = typeof c == "object" && !Array.isArray(c) ? c : {};
|
|
47
|
+
e[i] = f(
|
|
48
|
+
m,
|
|
49
|
+
o,
|
|
50
|
+
t,
|
|
51
|
+
s
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
else if (r === "replace")
|
|
55
|
+
e[i] = o;
|
|
24
56
|
else {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
57
|
+
const c = e[i] || "";
|
|
58
|
+
if (typeof c != "string")
|
|
59
|
+
return e[i] = o, e;
|
|
60
|
+
const m = c ? c.split(s) : [];
|
|
61
|
+
if (!t || !m.includes(o)) {
|
|
62
|
+
const y = [...m, o];
|
|
63
|
+
e[i] = y.join(s);
|
|
29
64
|
}
|
|
30
65
|
}
|
|
31
66
|
return e;
|
|
32
67
|
};
|
|
33
68
|
export {
|
|
34
|
-
|
|
69
|
+
P as setAttributeValue
|
|
35
70
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ea-lab/reactive-json",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"lint": "eslint .",
|
|
36
36
|
"prepublishOnly": "npm run build",
|
|
37
37
|
"preview": "vite preview",
|
|
38
|
-
"test": "
|
|
38
|
+
"test": "jest"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"axios": "^1.8.4",
|
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
"react-dom": "^19.1.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
+
"@babel/preset-env": "^7.28.5",
|
|
53
|
+
"@babel/preset-react": "^7.28.5",
|
|
54
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
52
55
|
"@ea-lab/reactive-json-docs": "^0.1.6",
|
|
53
56
|
"@eslint/js": "^9.25.0",
|
|
54
57
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -58,14 +61,17 @@
|
|
|
58
61
|
"@types/react-dom": "^19.1.2",
|
|
59
62
|
"@vitejs/plugin-react": "^4.4.1",
|
|
60
63
|
"axios": "^1.8.4",
|
|
64
|
+
"babel-jest": "^30.2.0",
|
|
61
65
|
"clsx": "^2.1.1",
|
|
62
66
|
"dnd-kit-sortable-tree": "^0.1.73",
|
|
67
|
+
"esbuild-jest": "^0.5.0",
|
|
63
68
|
"eslint": "^9.25.0",
|
|
64
69
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
65
70
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
66
71
|
"glob": "^11.0.2",
|
|
67
72
|
"globals": "^16.0.0",
|
|
68
73
|
"html-react-parser": "^5.2.3",
|
|
74
|
+
"identity-obj-proxy": "^3.0.0",
|
|
69
75
|
"jest": "^30.0.5",
|
|
70
76
|
"js-yaml": "^4.1.0",
|
|
71
77
|
"jsonpath": "^1.1.1",
|