json-renderers-build 1.3.4 → 1.5.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.
- package/README.md +374 -0
- package/docs/dist/min.js +320 -0
- package/docs/dist/v3/min.js +222 -208
- package/docs/dist/v4/min.js +320 -0
- package/docs/index.html +832 -0
- package/package.json +20 -7
- package/src/index.js +2 -2
- package/src/v3/index.js +1 -2
- package/src/v4/common/deriveColumnsFromData.js +20 -0
- package/src/v4/index.js +40 -0
- package/src/v4/meta.js +6 -0
- package/src/v4/registerGlobal.js +14 -0
- package/src/v4/select/index.js +20 -0
- package/src/v4/select/skeleton.json +7 -0
- package/src/v4/selectOptionsOnly/index.js +19 -0
- package/src/v4/selectOptionsOnly/skeleton.json +17 -0
- package/src/v4/table/index.js +20 -0
- package/src/v4/table/skeleton.json +47 -0
- package/src/v5/common/deriveColumnsFromData.js +20 -0
- package/src/v5/index.js +40 -0
- package/src/v5/meta.js +6 -0
- package/src/v5/registerGlobal.js +14 -0
- package/src/v5/select/index.js +20 -0
- package/src/v5/select/skeleton.json +7 -0
- package/src/v5/selectOptionsOnly/index.js +19 -0
- package/src/v5/selectOptionsOnly/skeleton.json +17 -0
- package/src/v5/table/index.js +20 -0
- package/src/v5/table/skeleton.json +47 -0
package/docs/dist/v3/min.js
CHANGED
|
@@ -1,208 +1,222 @@
|
|
|
1
|
-
const d = {
|
|
2
|
-
version: "v3.0.0",
|
|
3
|
-
description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
|
|
4
|
-
}, m = (t) => {
|
|
5
|
-
var e;
|
|
6
|
-
typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
|
|
7
|
-
meta: d,
|
|
8
|
-
renderToDom: t
|
|
9
|
-
}));
|
|
10
|
-
},
|
|
11
|
-
version: "v32",
|
|
12
|
-
description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
|
|
13
|
-
},
|
|
14
|
-
if (typeof globalThis > "u" || !t) return;
|
|
15
|
-
globalThis.ks ?? (globalThis.ks = {});
|
|
16
|
-
const e = {
|
|
17
|
-
meta:
|
|
18
|
-
buildSpecElement: t
|
|
19
|
-
};
|
|
20
|
-
globalThis.ks.jsonToSpec = e;
|
|
21
|
-
}, g = (t, e) => n(t, e),
|
|
22
|
-
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
23
|
-
const r = e[t == null ? void 0 : t.source];
|
|
24
|
-
if (Array.isArray(r))
|
|
25
|
-
return r.map((a) => {
|
|
26
|
-
const o = t == null ? void 0 : t.template;
|
|
27
|
-
if (o)
|
|
28
|
-
return n(o, a);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
let r = [];
|
|
33
|
-
for (const [l, a] of Object.entries(e)) {
|
|
34
|
-
const o = t == null ? void 0 : t.template;
|
|
35
|
-
if (o) {
|
|
36
|
-
const
|
|
37
|
-
key: l,
|
|
38
|
-
value: a
|
|
39
|
-
});
|
|
40
|
-
r.push(
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return r;
|
|
44
|
-
},
|
|
45
|
-
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
46
|
-
const r = e[t == null ? void 0 : t.source];
|
|
47
|
-
if (Array.isArray(r))
|
|
48
|
-
return r.map((a) => {
|
|
49
|
-
const o = t == null ? void 0 : t.template;
|
|
50
|
-
if (o)
|
|
51
|
-
return n(o, a);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
if ("operation" in t) {
|
|
56
|
-
if (t.operation === "loopArray")
|
|
57
|
-
return h(t, e);
|
|
58
|
-
if (t.operation === "loopObject")
|
|
59
|
-
return
|
|
60
|
-
if (t.operation === "loopCollection")
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
}, f = (t, e) => {
|
|
64
|
-
if (typeof e == "string") return e;
|
|
65
|
-
if (typeof t != "string") return t;
|
|
66
|
-
if (t === "${value}")
|
|
67
|
-
return e.value;
|
|
68
|
-
const r = t.match(/^\$\{(.+?)\}$/);
|
|
69
|
-
if (r) {
|
|
70
|
-
const l = r[1];
|
|
71
|
-
return (e == null ? void 0 : e[l]) ?? "";
|
|
72
|
-
}
|
|
73
|
-
return t;
|
|
74
|
-
},
|
|
75
|
-
let r = {};
|
|
76
|
-
for (const [l, a] of Object.entries(t)) {
|
|
77
|
-
const o = f(a, e);
|
|
78
|
-
r[l] = o;
|
|
79
|
-
}
|
|
80
|
-
return r;
|
|
81
|
-
},
|
|
82
|
-
if ("tagName" in t) {
|
|
83
|
-
if ("textContent" in t) {
|
|
84
|
-
const r = f(t.textContent, e);
|
|
85
|
-
t.textContent = r;
|
|
86
|
-
}
|
|
87
|
-
if ("attributes" in t) {
|
|
88
|
-
const r =
|
|
89
|
-
t.attributes = r;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
94
|
-
const r = structuredClone(t);
|
|
95
|
-
if (!r) return null;
|
|
96
|
-
if ("tagName" in r &&
|
|
97
|
-
const l = r == null ? void 0 : r.jsonToSpec, a =
|
|
98
|
-
Array.isArray(a) ? r.children = a : r.children = [a], delete r.jsonToSpec;
|
|
99
|
-
}
|
|
100
|
-
if (Array.isArray(r == null ? void 0 : r.children)) {
|
|
101
|
-
const l =
|
|
102
|
-
r.children = l;
|
|
103
|
-
}
|
|
104
|
-
return r;
|
|
105
|
-
}, n = (t, e) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
1
|
+
const d = {
|
|
2
|
+
version: "v3.0.0",
|
|
3
|
+
description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
|
|
4
|
+
}, m = (t) => {
|
|
5
|
+
var e;
|
|
6
|
+
typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
|
|
7
|
+
meta: d,
|
|
8
|
+
renderToDom: t
|
|
9
|
+
}));
|
|
10
|
+
}, y = {
|
|
11
|
+
version: "v32",
|
|
12
|
+
description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
|
|
13
|
+
}, b = ({ inFuncDefinition: t } = {}) => {
|
|
14
|
+
if (typeof globalThis > "u" || !t) return;
|
|
15
|
+
globalThis.ks ?? (globalThis.ks = {});
|
|
16
|
+
const e = {
|
|
17
|
+
meta: y,
|
|
18
|
+
buildSpecElement: t
|
|
19
|
+
};
|
|
20
|
+
globalThis.ks.jsonToSpec = 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
|
+
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
23
|
+
const r = e[t == null ? void 0 : t.source];
|
|
24
|
+
if (Array.isArray(r))
|
|
25
|
+
return r.map((a) => {
|
|
26
|
+
const o = t == null ? void 0 : t.template;
|
|
27
|
+
if (o)
|
|
28
|
+
return n(o, a);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}, A = (t, e) => {
|
|
32
|
+
let r = [];
|
|
33
|
+
for (const [l, a] of Object.entries(e)) {
|
|
34
|
+
const o = t == null ? void 0 : t.template;
|
|
35
|
+
if (o) {
|
|
36
|
+
const s = n(o, {
|
|
37
|
+
key: l,
|
|
38
|
+
value: a
|
|
39
|
+
});
|
|
40
|
+
r.push(s);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return r;
|
|
44
|
+
}, v = (t, e) => {
|
|
45
|
+
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
46
|
+
const r = e[t == null ? void 0 : t.source];
|
|
47
|
+
if (Array.isArray(r))
|
|
48
|
+
return r.map((a) => {
|
|
49
|
+
const o = t == null ? void 0 : t.template;
|
|
50
|
+
if (o)
|
|
51
|
+
return n(o, a);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, $ = (t, e) => {
|
|
55
|
+
if ("operation" in t) {
|
|
56
|
+
if (t.operation === "loopArray")
|
|
57
|
+
return h(t, e);
|
|
58
|
+
if (t.operation === "loopObject")
|
|
59
|
+
return A(t, e);
|
|
60
|
+
if (t.operation === "loopCollection")
|
|
61
|
+
return v(t, e);
|
|
62
|
+
}
|
|
63
|
+
}, f = (t, e) => {
|
|
64
|
+
if (typeof e == "string") return e;
|
|
65
|
+
if (typeof t != "string") return t;
|
|
66
|
+
if (t === "${value}")
|
|
67
|
+
return e.value;
|
|
68
|
+
const r = t.match(/^\$\{(.+?)\}$/);
|
|
69
|
+
if (r) {
|
|
70
|
+
const l = r[1];
|
|
71
|
+
return (e == null ? void 0 : e[l]) ?? "";
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
74
|
+
}, j = (t, e) => {
|
|
75
|
+
let r = {};
|
|
76
|
+
for (const [l, a] of Object.entries(t)) {
|
|
77
|
+
const o = f(a, e);
|
|
78
|
+
r[l] = o;
|
|
79
|
+
}
|
|
80
|
+
return r;
|
|
81
|
+
}, p = (t, e) => {
|
|
82
|
+
if ("tagName" in t) {
|
|
83
|
+
if ("textContent" in t) {
|
|
84
|
+
const r = f(t.textContent, e);
|
|
85
|
+
t.textContent = r;
|
|
86
|
+
}
|
|
87
|
+
if ("attributes" in t) {
|
|
88
|
+
const r = j(t.attributes, e);
|
|
89
|
+
t.attributes = r;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, N = (t, e) => {
|
|
93
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
94
|
+
const r = structuredClone(t);
|
|
95
|
+
if (!r) return null;
|
|
96
|
+
if ("tagName" in r && p(r, e), "jsonToSpec" in r) {
|
|
97
|
+
const l = r == null ? void 0 : r.jsonToSpec, a = $(l, e);
|
|
98
|
+
Array.isArray(a) ? r.children = a : r.children = [a], delete r.jsonToSpec;
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(r == null ? void 0 : r.children)) {
|
|
101
|
+
const l = i(r == null ? void 0 : r.children, e);
|
|
102
|
+
r.children = l;
|
|
103
|
+
}
|
|
104
|
+
return r;
|
|
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
|
|
108
|
+
});
|
|
109
|
+
const D = {
|
|
110
|
+
default: {
|
|
111
|
+
tagName: "table",
|
|
112
|
+
attributes: {
|
|
113
|
+
class: "table table-hover table-striped mb-0"
|
|
114
|
+
},
|
|
115
|
+
children: [
|
|
116
|
+
{
|
|
117
|
+
tagName: "thead",
|
|
118
|
+
children: [
|
|
119
|
+
{
|
|
120
|
+
tagName: "tr",
|
|
121
|
+
jsonToSpec: {
|
|
122
|
+
operation: "loopCollection",
|
|
123
|
+
source: "columns",
|
|
124
|
+
template: {
|
|
125
|
+
tagName: "th",
|
|
126
|
+
textContent: "${title}"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
children: []
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
tagName: "tbody",
|
|
135
|
+
jsonToSpec: {
|
|
136
|
+
operation: "loopCollection",
|
|
137
|
+
source: "data",
|
|
138
|
+
template: {
|
|
139
|
+
tagName: "tr",
|
|
140
|
+
jsonToSpec: {
|
|
141
|
+
operation: "loopObject",
|
|
142
|
+
source: "data",
|
|
143
|
+
template: {
|
|
144
|
+
tagName: "td",
|
|
145
|
+
textContent: "${value}"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
children: []
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
children: []
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}, O = ({
|
|
156
|
+
inColumns: t,
|
|
157
|
+
inData: e
|
|
158
|
+
} = {}) => {
|
|
159
|
+
const r = e ?? [], l = t;
|
|
160
|
+
return u(D.default, {
|
|
161
|
+
columns: l,
|
|
162
|
+
data: r
|
|
163
|
+
});
|
|
164
|
+
}, C = "select", k = {
|
|
165
|
+
id: "LedgerName"
|
|
166
|
+
}, F = {
|
|
167
|
+
operation: "loopArray",
|
|
168
|
+
source: "arrayOfStrings",
|
|
169
|
+
template: {
|
|
170
|
+
tagName: "option",
|
|
171
|
+
attributes: {
|
|
172
|
+
value: "${}"
|
|
173
|
+
},
|
|
174
|
+
textContent: "${}"
|
|
175
|
+
}
|
|
176
|
+
}, R = [], x = {
|
|
177
|
+
tagName: C,
|
|
178
|
+
attributes: k,
|
|
179
|
+
jsonToSpec: F,
|
|
180
|
+
children: R
|
|
181
|
+
}, E = ({
|
|
182
|
+
inData: t
|
|
183
|
+
} = {}) => u(x, {
|
|
184
|
+
arrayOfStrings: t ?? []
|
|
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 = ({
|
|
207
|
+
type: t = "table",
|
|
208
|
+
data: e,
|
|
209
|
+
columns: r
|
|
210
|
+
} = {}) => {
|
|
211
|
+
const l = t, a = c[l];
|
|
212
|
+
return a ? a({
|
|
213
|
+
inColumns: r,
|
|
214
|
+
inData: e
|
|
215
|
+
}) : (console.error(
|
|
216
|
+
`[Renderer] Unknown renderer type "${l}". Available types: ${Object.keys(c).join(", ")}`
|
|
217
|
+
), null);
|
|
218
|
+
};
|
|
219
|
+
m(z);
|
|
220
|
+
export {
|
|
221
|
+
z as default
|
|
222
|
+
};
|