json-renderers-build 1.3.4 → 1.3.6
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.
- package/docs/dist/v3/min.js +57 -43
- package/package.json +2 -2
- package/src/v3/index.js +1 -2
package/docs/dist/v3/min.js
CHANGED
|
@@ -7,18 +7,18 @@ const d = {
|
|
|
7
7
|
meta: d,
|
|
8
8
|
renderToDom: t
|
|
9
9
|
}));
|
|
10
|
-
},
|
|
10
|
+
}, y = {
|
|
11
11
|
version: "v32",
|
|
12
12
|
description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
|
|
13
|
-
},
|
|
13
|
+
}, b = ({ inFuncDefinition: t } = {}) => {
|
|
14
14
|
if (typeof globalThis > "u" || !t) return;
|
|
15
15
|
globalThis.ks ?? (globalThis.ks = {});
|
|
16
16
|
const e = {
|
|
17
|
-
meta:
|
|
17
|
+
meta: y,
|
|
18
18
|
buildSpecElement: t
|
|
19
19
|
};
|
|
20
20
|
globalThis.ks.jsonToSpec = e;
|
|
21
|
-
}, g = (t, e) => n(t, e),
|
|
21
|
+
}, g = (t, e) => n(t, e), i = (t, e) => Array.isArray(t) ? t.map((r) => g(r, e)).flat(1 / 0).filter(Boolean) : [], h = (t, e) => {
|
|
22
22
|
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
23
23
|
const r = e[t == null ? void 0 : t.source];
|
|
24
24
|
if (Array.isArray(r))
|
|
@@ -28,20 +28,20 @@ const d = {
|
|
|
28
28
|
return n(o, a);
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
},
|
|
31
|
+
}, A = (t, e) => {
|
|
32
32
|
let r = [];
|
|
33
33
|
for (const [l, a] of Object.entries(e)) {
|
|
34
34
|
const o = t == null ? void 0 : t.template;
|
|
35
35
|
if (o) {
|
|
36
|
-
const
|
|
36
|
+
const s = n(o, {
|
|
37
37
|
key: l,
|
|
38
38
|
value: a
|
|
39
39
|
});
|
|
40
|
-
r.push(
|
|
40
|
+
r.push(s);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
return r;
|
|
44
|
-
},
|
|
44
|
+
}, v = (t, e) => {
|
|
45
45
|
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
46
46
|
const r = e[t == null ? void 0 : t.source];
|
|
47
47
|
if (Array.isArray(r))
|
|
@@ -51,14 +51,14 @@ const d = {
|
|
|
51
51
|
return n(o, a);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
},
|
|
54
|
+
}, $ = (t, e) => {
|
|
55
55
|
if ("operation" in t) {
|
|
56
56
|
if (t.operation === "loopArray")
|
|
57
57
|
return h(t, e);
|
|
58
58
|
if (t.operation === "loopObject")
|
|
59
|
-
return v(t, e);
|
|
60
|
-
if (t.operation === "loopCollection")
|
|
61
59
|
return A(t, e);
|
|
60
|
+
if (t.operation === "loopCollection")
|
|
61
|
+
return v(t, e);
|
|
62
62
|
}
|
|
63
63
|
}, f = (t, e) => {
|
|
64
64
|
if (typeof e == "string") return e;
|
|
@@ -71,46 +71,42 @@ const d = {
|
|
|
71
71
|
return (e == null ? void 0 : e[l]) ?? "";
|
|
72
72
|
}
|
|
73
73
|
return t;
|
|
74
|
-
},
|
|
74
|
+
}, j = (t, e) => {
|
|
75
75
|
let r = {};
|
|
76
76
|
for (const [l, a] of Object.entries(t)) {
|
|
77
77
|
const o = f(a, e);
|
|
78
78
|
r[l] = o;
|
|
79
79
|
}
|
|
80
80
|
return r;
|
|
81
|
-
},
|
|
81
|
+
}, p = (t, e) => {
|
|
82
82
|
if ("tagName" in t) {
|
|
83
83
|
if ("textContent" in t) {
|
|
84
84
|
const r = f(t.textContent, e);
|
|
85
85
|
t.textContent = r;
|
|
86
86
|
}
|
|
87
87
|
if ("attributes" in t) {
|
|
88
|
-
const r =
|
|
88
|
+
const r = j(t.attributes, e);
|
|
89
89
|
t.attributes = r;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, N = (t, e) => {
|
|
93
93
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
94
94
|
const r = structuredClone(t);
|
|
95
95
|
if (!r) return null;
|
|
96
|
-
if ("tagName" in r &&
|
|
97
|
-
const l = r == null ? void 0 : r.jsonToSpec, a =
|
|
96
|
+
if ("tagName" in r && p(r, e), "jsonToSpec" in r) {
|
|
97
|
+
const l = r == null ? void 0 : r.jsonToSpec, a = $(l, e);
|
|
98
98
|
Array.isArray(a) ? r.children = a : r.children = [a], delete r.jsonToSpec;
|
|
99
99
|
}
|
|
100
100
|
if (Array.isArray(r == null ? void 0 : r.children)) {
|
|
101
|
-
const l =
|
|
101
|
+
const l = i(r == null ? void 0 : r.children, e);
|
|
102
102
|
r.children = l;
|
|
103
103
|
}
|
|
104
104
|
return r;
|
|
105
|
-
}, n = (t, e) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? c(t, e) : typeof t == "object" ? p(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t;
|
|
109
|
-
}, s = (t, e) => n(t, e);
|
|
110
|
-
y({
|
|
111
|
-
inFuncDefinition: s
|
|
105
|
+
}, n = (t, e) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? i(t, e) : typeof t == "object" ? N(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t, u = (t, e) => n(t, e);
|
|
106
|
+
b({
|
|
107
|
+
inFuncDefinition: u
|
|
112
108
|
});
|
|
113
|
-
const
|
|
109
|
+
const D = {
|
|
114
110
|
default: {
|
|
115
111
|
tagName: "table",
|
|
116
112
|
attributes: {
|
|
@@ -156,16 +152,16 @@ const C = {
|
|
|
156
152
|
}
|
|
157
153
|
]
|
|
158
154
|
}
|
|
159
|
-
},
|
|
155
|
+
}, O = ({
|
|
160
156
|
inColumns: t,
|
|
161
157
|
inData: e
|
|
162
158
|
} = {}) => {
|
|
163
159
|
const r = e ?? [], l = t;
|
|
164
|
-
return
|
|
160
|
+
return u(D.default, {
|
|
165
161
|
columns: l,
|
|
166
162
|
data: r
|
|
167
163
|
});
|
|
168
|
-
},
|
|
164
|
+
}, C = "select", k = {
|
|
169
165
|
id: "LedgerName"
|
|
170
166
|
}, F = {
|
|
171
167
|
operation: "loopArray",
|
|
@@ -177,32 +173,50 @@ const C = {
|
|
|
177
173
|
},
|
|
178
174
|
textContent: "${}"
|
|
179
175
|
}
|
|
180
|
-
}, R = [],
|
|
181
|
-
tagName:
|
|
182
|
-
attributes:
|
|
176
|
+
}, R = [], x = {
|
|
177
|
+
tagName: C,
|
|
178
|
+
attributes: k,
|
|
183
179
|
jsonToSpec: F,
|
|
184
180
|
children: R
|
|
185
|
-
},
|
|
181
|
+
}, E = ({
|
|
186
182
|
inData: t
|
|
187
|
-
} = {}) =>
|
|
183
|
+
} = {}) => u(x, {
|
|
188
184
|
arrayOfStrings: t ?? []
|
|
189
|
-
}),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
}), w = {
|
|
186
|
+
operation: "loopArray",
|
|
187
|
+
source: "arrayOfStrings",
|
|
188
|
+
template: {
|
|
189
|
+
tagName: "option",
|
|
190
|
+
attributes: {
|
|
191
|
+
value: "${}"
|
|
192
|
+
},
|
|
193
|
+
textContent: "${}"
|
|
194
|
+
}
|
|
195
|
+
}, M = [], B = {
|
|
196
|
+
jsonToSpec: w,
|
|
197
|
+
children: M
|
|
198
|
+
}, G = ({
|
|
199
|
+
inData: t
|
|
200
|
+
} = {}) => u(B, {
|
|
201
|
+
arrayOfStrings: t ?? []
|
|
202
|
+
}), c = {
|
|
203
|
+
table: O,
|
|
204
|
+
select: E,
|
|
205
|
+
selectOptionsOnly: G
|
|
206
|
+
}, z = ({
|
|
193
207
|
type: t = "table",
|
|
194
208
|
data: e,
|
|
195
209
|
columns: r
|
|
196
210
|
} = {}) => {
|
|
197
|
-
const l = t, a =
|
|
198
|
-
return
|
|
211
|
+
const l = t, a = c[l];
|
|
212
|
+
return a ? a({
|
|
199
213
|
inColumns: r,
|
|
200
214
|
inData: e
|
|
201
215
|
}) : (console.error(
|
|
202
|
-
`[Renderer] Unknown renderer type "${l}". Available types: ${Object.keys(
|
|
216
|
+
`[Renderer] Unknown renderer type "${l}". Available types: ${Object.keys(c).join(", ")}`
|
|
203
217
|
), null);
|
|
204
218
|
};
|
|
205
|
-
m(
|
|
219
|
+
m(z);
|
|
206
220
|
export {
|
|
207
|
-
|
|
221
|
+
z as default
|
|
208
222
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-renderers-build",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Standalone, config-driven Table renderer built on top of json-to-dom",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"vite": "^5.4.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"json-to-spec": "^32.1.
|
|
32
|
+
"json-to-spec": "^32.1.3"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/v3/index.js
CHANGED
|
@@ -16,8 +16,7 @@ const render = ({
|
|
|
16
16
|
columns
|
|
17
17
|
} = {}) => {
|
|
18
18
|
const rawType = type;
|
|
19
|
-
const
|
|
20
|
-
const renderer = RENDERER_MAP[resolvedType];
|
|
19
|
+
const renderer = RENDERER_MAP[rawType];
|
|
21
20
|
|
|
22
21
|
if (!renderer) {
|
|
23
22
|
console.error(
|