json-renderers 1.13.2 → 1.13.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/v13/min.js +179 -168
- package/package.json +3 -3
- package/src/v13/buildSpec/index.js +38 -0
- package/src/v13/index.js +37 -25
- package/src/v13/meta.js +1 -1
- package/src/v13/select/index.js +0 -32
- package/src/v13/select/skeleton.json +0 -18
- package/src/v13/table/index.js +0 -39
- package/src/v13/table/skeleton.json +0 -47
package/docs/dist/v13/min.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
const
|
|
2
|
-
version: "
|
|
1
|
+
const x = {
|
|
2
|
+
version: "v13.1.0",
|
|
3
3
|
description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
|
|
4
|
-
},
|
|
4
|
+
}, j = (t) => {
|
|
5
5
|
var e;
|
|
6
6
|
typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderers ?? (e.jsonRenderers = {
|
|
7
|
-
meta:
|
|
7
|
+
meta: x,
|
|
8
8
|
renderToDom: t
|
|
9
9
|
}));
|
|
10
|
-
},
|
|
11
|
-
version: "
|
|
10
|
+
}, v = {
|
|
11
|
+
version: "v3.0.0",
|
|
12
12
|
description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
|
|
13
|
-
},
|
|
13
|
+
}, N = (t) => {
|
|
14
14
|
var e;
|
|
15
15
|
typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
|
|
16
|
-
meta:
|
|
16
|
+
meta: v,
|
|
17
17
|
renderToDom: t
|
|
18
18
|
}));
|
|
19
|
-
},
|
|
19
|
+
}, $ = {
|
|
20
20
|
version: "v32",
|
|
21
21
|
description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
|
|
22
|
-
},
|
|
22
|
+
}, k = ({ inFuncDefinition: t } = {}) => {
|
|
23
23
|
if (typeof globalThis > "u" || !t) return;
|
|
24
24
|
globalThis.ks ?? (globalThis.ks = {});
|
|
25
25
|
const e = {
|
|
26
|
-
meta:
|
|
26
|
+
meta: $,
|
|
27
27
|
buildSpecElement: t
|
|
28
28
|
};
|
|
29
29
|
globalThis.ks.jsonToSpec = e;
|
|
30
|
-
},
|
|
30
|
+
}, D = (t, e) => g(t, e), m = (t, e) => Array.isArray(t) ? t.map((l) => D(l, e)).flat(1 / 0).filter(Boolean) : [], O = (t, e) => {
|
|
31
31
|
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
32
32
|
const l = e[t == null ? void 0 : t.source];
|
|
33
33
|
if (Array.isArray(l))
|
|
34
34
|
return l.map((n) => {
|
|
35
35
|
const r = t == null ? void 0 : t.template;
|
|
36
36
|
if (r)
|
|
37
|
-
return
|
|
37
|
+
return g(r, n);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
},
|
|
40
|
+
}, E = (t, e) => {
|
|
41
41
|
let l = [];
|
|
42
42
|
for (const [o, n] of Object.entries(e)) {
|
|
43
43
|
const r = t == null ? void 0 : t.template;
|
|
44
44
|
if (r) {
|
|
45
|
-
const a =
|
|
45
|
+
const a = g(r, {
|
|
46
46
|
key: o,
|
|
47
47
|
value: n
|
|
48
48
|
});
|
|
@@ -50,26 +50,26 @@ const R = {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return l;
|
|
53
|
-
},
|
|
53
|
+
}, S = (t, e) => {
|
|
54
54
|
if ("source" in t && (t == null ? void 0 : t.source) in e) {
|
|
55
55
|
const l = e[t == null ? void 0 : t.source];
|
|
56
56
|
if (Array.isArray(l))
|
|
57
57
|
return l.map((n) => {
|
|
58
58
|
const r = t == null ? void 0 : t.template;
|
|
59
59
|
if (r)
|
|
60
|
-
return
|
|
60
|
+
return g(r, n);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
},
|
|
63
|
+
}, L = (t, e) => {
|
|
64
64
|
if ("operation" in t) {
|
|
65
65
|
if (t.operation === "loopArray")
|
|
66
|
-
return
|
|
66
|
+
return O(t, e);
|
|
67
67
|
if (t.operation === "loopObject")
|
|
68
|
-
return
|
|
68
|
+
return E(t, e);
|
|
69
69
|
if (t.operation === "loopCollection")
|
|
70
|
-
return
|
|
70
|
+
return S(t, e);
|
|
71
71
|
}
|
|
72
|
-
},
|
|
72
|
+
}, p = (t, e) => {
|
|
73
73
|
if (typeof e == "string") return e;
|
|
74
74
|
if (typeof t != "string") return t;
|
|
75
75
|
if (t === "${value}")
|
|
@@ -80,46 +80,42 @@ const R = {
|
|
|
80
80
|
return (e == null ? void 0 : e[o]) ?? "";
|
|
81
81
|
}
|
|
82
82
|
return t;
|
|
83
|
-
},
|
|
83
|
+
}, F = (t, e) => {
|
|
84
84
|
let l = {};
|
|
85
85
|
for (const [o, n] of Object.entries(t)) {
|
|
86
|
-
const r =
|
|
86
|
+
const r = p(n, e);
|
|
87
87
|
l[o] = r;
|
|
88
88
|
}
|
|
89
89
|
return l;
|
|
90
|
-
},
|
|
90
|
+
}, G = (t, e) => {
|
|
91
91
|
if ("tagName" in t) {
|
|
92
92
|
if ("textContent" in t) {
|
|
93
|
-
const l =
|
|
93
|
+
const l = p(t.textContent, e);
|
|
94
94
|
t.textContent = l;
|
|
95
95
|
}
|
|
96
96
|
if ("attributes" in t) {
|
|
97
|
-
const l =
|
|
97
|
+
const l = F(t.attributes, e);
|
|
98
98
|
t.attributes = l;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
},
|
|
101
|
+
}, M = (t, e) => {
|
|
102
102
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
103
103
|
const l = structuredClone(t);
|
|
104
104
|
if (!l) return null;
|
|
105
|
-
if ("tagName" in l &&
|
|
106
|
-
const o = l == null ? void 0 : l.jsonToSpec, n =
|
|
105
|
+
if ("tagName" in l && G(l, e), "jsonToSpec" in l) {
|
|
106
|
+
const o = l == null ? void 0 : l.jsonToSpec, n = L(o, e);
|
|
107
107
|
Array.isArray(n) ? l.children = n : l.children = [n], delete l.jsonToSpec;
|
|
108
108
|
}
|
|
109
109
|
if (Array.isArray(l == null ? void 0 : l.children)) {
|
|
110
|
-
const o =
|
|
110
|
+
const o = m(l == null ? void 0 : l.children, e);
|
|
111
111
|
l.children = o;
|
|
112
112
|
}
|
|
113
113
|
return l;
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? C(t, e) : typeof t == "object" ? U(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t;
|
|
118
|
-
}, x = (t, e) => d(t, e);
|
|
119
|
-
L({
|
|
120
|
-
inFuncDefinition: x
|
|
114
|
+
}, g = (t, e) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? m(t, e) : typeof t == "object" ? M(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t, h = (t, e) => g(t, e);
|
|
115
|
+
k({
|
|
116
|
+
inFuncDefinition: h
|
|
121
117
|
});
|
|
122
|
-
const
|
|
118
|
+
const R = {
|
|
123
119
|
default: {
|
|
124
120
|
tagName: "table",
|
|
125
121
|
attributes: {
|
|
@@ -165,55 +161,71 @@ const K = {
|
|
|
165
161
|
}
|
|
166
162
|
]
|
|
167
163
|
}
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
inColumns: l,
|
|
172
|
-
inData: o
|
|
164
|
+
}, z = ({
|
|
165
|
+
inColumns: t,
|
|
166
|
+
inData: e
|
|
173
167
|
} = {}) => {
|
|
174
|
-
const
|
|
175
|
-
return
|
|
176
|
-
columns:
|
|
177
|
-
data:
|
|
168
|
+
const l = e ?? [], o = t;
|
|
169
|
+
return h(R.default, {
|
|
170
|
+
columns: o,
|
|
171
|
+
data: l
|
|
178
172
|
});
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
},
|
|
173
|
+
}, I = "select", V = {
|
|
174
|
+
id: "LedgerName"
|
|
175
|
+
}, q = {
|
|
176
|
+
operation: "loopArray",
|
|
177
|
+
source: "arrayOfStrings",
|
|
178
|
+
template: {
|
|
179
|
+
tagName: "option",
|
|
180
|
+
attributes: {
|
|
181
|
+
value: "${}"
|
|
182
|
+
},
|
|
183
|
+
textContent: "${}"
|
|
184
|
+
}
|
|
185
|
+
}, B = [], P = {
|
|
186
|
+
tagName: I,
|
|
187
|
+
attributes: V,
|
|
188
|
+
jsonToSpec: q,
|
|
189
|
+
children: B
|
|
190
|
+
}, H = ({
|
|
191
|
+
inData: t
|
|
192
|
+
} = {}) => h(P, {
|
|
193
|
+
arrayOfStrings: t ?? []
|
|
194
|
+
}), _ = {
|
|
195
|
+
operation: "loopArray",
|
|
196
|
+
source: "arrayOfStrings",
|
|
197
|
+
template: {
|
|
198
|
+
tagName: "option",
|
|
199
|
+
attributes: {
|
|
200
|
+
value: "${}"
|
|
201
|
+
},
|
|
202
|
+
textContent: "${}"
|
|
203
|
+
}
|
|
204
|
+
}, U = [], K = {
|
|
205
|
+
jsonToSpec: _,
|
|
206
|
+
children: U
|
|
207
|
+
}, X = ({
|
|
208
|
+
inData: t
|
|
209
|
+
} = {}) => h(K, {
|
|
210
|
+
arrayOfStrings: t ?? []
|
|
211
|
+
}), w = {
|
|
212
|
+
table: z,
|
|
213
|
+
select: H,
|
|
214
|
+
selectOptionsOnly: X
|
|
215
|
+
}, y = ({
|
|
182
216
|
type: t = "table",
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
classToApply: o,
|
|
186
|
-
inTargetHtmlId: n,
|
|
187
|
-
inData: r,
|
|
188
|
-
columns: a,
|
|
189
|
-
inColumns: s,
|
|
190
|
-
colGroup: u,
|
|
191
|
-
inColGroup: c,
|
|
192
|
-
footerData: i,
|
|
193
|
-
inFooterData: f,
|
|
194
|
-
config: b,
|
|
195
|
-
inConfig: w,
|
|
196
|
-
variant: m,
|
|
197
|
-
skeletonType: $,
|
|
198
|
-
inSkeletonType: E,
|
|
199
|
-
showLog: D = !1,
|
|
200
|
-
inShowLog: O
|
|
217
|
+
data: e,
|
|
218
|
+
columns: l
|
|
201
219
|
} = {}) => {
|
|
202
|
-
const
|
|
203
|
-
return
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
inData: r ?? l,
|
|
207
|
-
inColGroup: c ?? u,
|
|
208
|
-
inFooterData: f ?? i ?? [],
|
|
209
|
-
inConfig: w ?? b ?? {},
|
|
210
|
-
inSkeletonType: E ?? $ ?? m ?? "default",
|
|
211
|
-
inShowLog: O ?? D ?? !1
|
|
220
|
+
const o = t, n = w[o];
|
|
221
|
+
return n ? n({
|
|
222
|
+
inColumns: l,
|
|
223
|
+
inData: e
|
|
212
224
|
}) : (console.error(
|
|
213
|
-
`[Renderer] Unknown renderer type "${
|
|
225
|
+
`[Renderer] Unknown renderer type "${o}". Available types: ${Object.keys(w).join(", ")}`
|
|
214
226
|
), null);
|
|
215
227
|
};
|
|
216
|
-
|
|
228
|
+
N(y);
|
|
217
229
|
const Q = {
|
|
218
230
|
version: "v9",
|
|
219
231
|
description: "JSON-to-DOM engine with SVG namespace support, mixed text content, and centralized traversal"
|
|
@@ -226,7 +238,7 @@ const Q = {
|
|
|
226
238
|
reviewSpec: e
|
|
227
239
|
};
|
|
228
240
|
globalThis.ks["json-to-tag"] = l, globalThis.ks.jsonToTag = l;
|
|
229
|
-
}, Y = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : typeof t == "object" && (t.nodeType === 3 || t.tagName === "#text" || !t.tagName && (t.textContent !== void 0 || t.text !== void 0)) ? document.createTextNode(t.textContent ?? t.text ?? "") :
|
|
241
|
+
}, Y = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : typeof t == "object" && (t.nodeType === 3 || t.tagName === "#text" || !t.tagName && (t.textContent !== void 0 || t.text !== void 0)) ? document.createTextNode(t.textContent ?? t.text ?? "") : C(t), T = (t) => Array.isArray(t) ? t.map(Y).flat(1 / 0).filter(Boolean) : [], Z = (t) => (t == null, t), J = "http://www.w3.org/2000/svg", tt = /* @__PURE__ */ new Set([
|
|
230
242
|
"svg",
|
|
231
243
|
"path",
|
|
232
244
|
"symbol",
|
|
@@ -261,7 +273,7 @@ const Q = {
|
|
|
261
273
|
return l.type = "checkbox", l;
|
|
262
274
|
}
|
|
263
275
|
return tt.has(e) ? document.createElementNS(J, e) : document.createElement(e);
|
|
264
|
-
}, lt = ({ inElement: t, inTextContent: e }) => (!t || e === void 0 || e === null || (t.textContent = e), t),
|
|
276
|
+
}, lt = ({ inElement: t, inTextContent: e }) => (!t || e === void 0 || e === null || (t.textContent = e), t), ot = ({ inElement: t, inProperties: e }) => (t && e && typeof e == "object" && Object.assign(t, e), t), rt = "http://www.w3.org/1999/xlink", nt = ({ inElement: t, inAttributes: e }) => {
|
|
265
277
|
const l = t, o = e;
|
|
266
278
|
if (!l || !o || typeof o != "object")
|
|
267
279
|
return l;
|
|
@@ -273,13 +285,13 @@ const Q = {
|
|
|
273
285
|
}
|
|
274
286
|
if (r === "xlink:href" || r === "href") {
|
|
275
287
|
if (a != null) {
|
|
276
|
-
const
|
|
288
|
+
const i = String(a);
|
|
277
289
|
if (n)
|
|
278
290
|
try {
|
|
279
|
-
l.setAttributeNS(
|
|
291
|
+
l.setAttributeNS(rt, "href", i);
|
|
280
292
|
} catch {
|
|
281
293
|
}
|
|
282
|
-
l.setAttribute("href",
|
|
294
|
+
l.setAttribute("href", i), l.setAttribute("xlink:href", i);
|
|
283
295
|
}
|
|
284
296
|
return;
|
|
285
297
|
}
|
|
@@ -301,7 +313,7 @@ const Q = {
|
|
|
301
313
|
inElement: e,
|
|
302
314
|
inTextContent: Z(t.textContent),
|
|
303
315
|
inTagName: t.tagName
|
|
304
|
-
}),
|
|
316
|
+
}), ot({
|
|
305
317
|
inElement: e,
|
|
306
318
|
inProperties: t.properties
|
|
307
319
|
}), nt({
|
|
@@ -311,11 +323,11 @@ const Q = {
|
|
|
311
323
|
inElement: e,
|
|
312
324
|
inClassList: t.classList
|
|
313
325
|
}), Array.isArray(t.children)) {
|
|
314
|
-
const l =
|
|
326
|
+
const l = T(t.children);
|
|
315
327
|
l.length && e.append(...l);
|
|
316
328
|
}
|
|
317
329
|
return e;
|
|
318
|
-
},
|
|
330
|
+
}, C = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? T(t) : typeof t == "object" ? st(t) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : null, it = "./tags.schema.json", ct = {
|
|
319
331
|
allowsTextContent: !1,
|
|
320
332
|
allowsChildren: !0,
|
|
321
333
|
allowedAttributes: [
|
|
@@ -323,7 +335,7 @@ const Q = {
|
|
|
323
335
|
"role"
|
|
324
336
|
],
|
|
325
337
|
childTags: []
|
|
326
|
-
},
|
|
338
|
+
}, ut = {
|
|
327
339
|
allowsTextContent: !1,
|
|
328
340
|
allowsChildren: !1,
|
|
329
341
|
allowedAttributes: [
|
|
@@ -453,14 +465,14 @@ const Q = {
|
|
|
453
465
|
"tfoot",
|
|
454
466
|
"tr"
|
|
455
467
|
]
|
|
456
|
-
},
|
|
468
|
+
}, jt = {
|
|
457
469
|
allowsTextContent: !1,
|
|
458
470
|
allowsChildren: !0,
|
|
459
471
|
allowedAttributes: [],
|
|
460
472
|
childTags: [
|
|
461
473
|
"tr"
|
|
462
474
|
]
|
|
463
|
-
},
|
|
475
|
+
}, vt = {
|
|
464
476
|
allowsTextContent: !1,
|
|
465
477
|
allowsChildren: !0,
|
|
466
478
|
allowedAttributes: [],
|
|
@@ -474,7 +486,7 @@ const Q = {
|
|
|
474
486
|
childTags: [
|
|
475
487
|
"tr"
|
|
476
488
|
]
|
|
477
|
-
},
|
|
489
|
+
}, $t = {
|
|
478
490
|
allowsTextContent: !1,
|
|
479
491
|
allowsChildren: !0,
|
|
480
492
|
allowedAttributes: [],
|
|
@@ -482,7 +494,7 @@ const Q = {
|
|
|
482
494
|
"td",
|
|
483
495
|
"th"
|
|
484
496
|
]
|
|
485
|
-
},
|
|
497
|
+
}, kt = {
|
|
486
498
|
allowsTextContent: !0,
|
|
487
499
|
allowsChildren: !0,
|
|
488
500
|
allowedAttributes: [
|
|
@@ -491,7 +503,7 @@ const Q = {
|
|
|
491
503
|
"rowspan"
|
|
492
504
|
],
|
|
493
505
|
childTags: []
|
|
494
|
-
},
|
|
506
|
+
}, Dt = {
|
|
495
507
|
allowsTextContent: !0,
|
|
496
508
|
allowsChildren: !0,
|
|
497
509
|
allowedAttributes: [
|
|
@@ -499,14 +511,14 @@ const Q = {
|
|
|
499
511
|
"rowspan"
|
|
500
512
|
],
|
|
501
513
|
childTags: []
|
|
502
|
-
},
|
|
514
|
+
}, Ot = {
|
|
503
515
|
allowsTextContent: !1,
|
|
504
516
|
allowsChildren: !0,
|
|
505
517
|
allowedAttributes: [],
|
|
506
518
|
childTags: [
|
|
507
519
|
"option"
|
|
508
520
|
]
|
|
509
|
-
},
|
|
521
|
+
}, Et = {
|
|
510
522
|
allowsTextContent: !0,
|
|
511
523
|
allowsChildren: !1,
|
|
512
524
|
allowedAttributes: [
|
|
@@ -515,14 +527,14 @@ const Q = {
|
|
|
515
527
|
"selected",
|
|
516
528
|
"disabled"
|
|
517
529
|
]
|
|
518
|
-
},
|
|
530
|
+
}, St = {
|
|
519
531
|
allowsTextContent: !1,
|
|
520
532
|
allowsChildren: !0,
|
|
521
533
|
allowedAttributes: [
|
|
522
534
|
"role"
|
|
523
535
|
],
|
|
524
536
|
childTags: []
|
|
525
|
-
},
|
|
537
|
+
}, Lt = {
|
|
526
538
|
allowsTextContent: !0,
|
|
527
539
|
allowsChildren: !0,
|
|
528
540
|
allowedAttributes: [
|
|
@@ -545,7 +557,7 @@ const Q = {
|
|
|
545
557
|
allowsChildren: !0,
|
|
546
558
|
allowedAttributes: [],
|
|
547
559
|
childTags: []
|
|
548
|
-
},
|
|
560
|
+
}, Mt = {
|
|
549
561
|
allowsTextContent: !1,
|
|
550
562
|
allowsChildren: !0,
|
|
551
563
|
allowedAttributes: [
|
|
@@ -554,21 +566,21 @@ const Q = {
|
|
|
554
566
|
childTags: [
|
|
555
567
|
"li"
|
|
556
568
|
]
|
|
557
|
-
},
|
|
569
|
+
}, Rt = {
|
|
558
570
|
allowsTextContent: !0,
|
|
559
571
|
allowsChildren: !0,
|
|
560
572
|
allowedAttributes: [
|
|
561
573
|
"value"
|
|
562
574
|
],
|
|
563
575
|
childTags: []
|
|
564
|
-
},
|
|
576
|
+
}, zt = {
|
|
565
577
|
allowsTextContent: !1,
|
|
566
578
|
allowsChildren: !1,
|
|
567
579
|
allowedAttributes: []
|
|
568
|
-
},
|
|
580
|
+
}, It = {
|
|
569
581
|
$schema: it,
|
|
570
|
-
div:
|
|
571
|
-
input:
|
|
582
|
+
div: ct,
|
|
583
|
+
input: ut,
|
|
572
584
|
checkbox: dt,
|
|
573
585
|
colgroup: ft,
|
|
574
586
|
col: gt,
|
|
@@ -582,50 +594,50 @@ const Q = {
|
|
|
582
594
|
img: Ct,
|
|
583
595
|
button: At,
|
|
584
596
|
table: xt,
|
|
585
|
-
thead:
|
|
586
|
-
tbody:
|
|
597
|
+
thead: jt,
|
|
598
|
+
tbody: vt,
|
|
587
599
|
tfoot: Nt,
|
|
588
|
-
tr:
|
|
589
|
-
th:
|
|
590
|
-
td:
|
|
591
|
-
datalist:
|
|
592
|
-
option:
|
|
593
|
-
header:
|
|
594
|
-
a:
|
|
600
|
+
tr: $t,
|
|
601
|
+
th: kt,
|
|
602
|
+
td: Dt,
|
|
603
|
+
datalist: Ot,
|
|
604
|
+
option: Et,
|
|
605
|
+
header: St,
|
|
606
|
+
a: Lt,
|
|
595
607
|
i: Ft,
|
|
596
608
|
small: Gt,
|
|
597
|
-
ul:
|
|
598
|
-
li:
|
|
599
|
-
hr:
|
|
600
|
-
},
|
|
609
|
+
ul: Mt,
|
|
610
|
+
li: Rt,
|
|
611
|
+
hr: zt
|
|
612
|
+
}, b = ({ inSpec: t }) => {
|
|
601
613
|
const e = t;
|
|
602
614
|
if (!e) return [];
|
|
603
615
|
if (Array.isArray(e))
|
|
604
|
-
return e.flatMap((o) =>
|
|
616
|
+
return e.flatMap((o) => b({ inSpec: o }));
|
|
605
617
|
if (typeof e != "object") return [];
|
|
606
618
|
const l = [];
|
|
607
619
|
return typeof e.tagName == "string" && e.tagName.trim().length > 0 && l.push(e.tagName.toLowerCase()), Array.isArray(e.children) && e.children.length > 0 && e.children.forEach((o) => {
|
|
608
|
-
const n =
|
|
620
|
+
const n = b({ inSpec: o });
|
|
609
621
|
l.push(...n);
|
|
610
622
|
}), l;
|
|
611
|
-
},
|
|
623
|
+
}, Vt = ({ inTagsFound: t, inAllowedTags: e }) => {
|
|
612
624
|
const l = t ?? [], o = e ?? {}, n = new Set(
|
|
613
|
-
Object.keys(o).filter((
|
|
614
|
-
), r = {}, a = [],
|
|
615
|
-
l.forEach((
|
|
616
|
-
r[
|
|
625
|
+
Object.keys(o).filter((s) => s !== "$schema").map((s) => s.toLowerCase())
|
|
626
|
+
), r = {}, a = [], i = [];
|
|
627
|
+
l.forEach((s) => {
|
|
628
|
+
r[s] = (r[s] || 0) + 1, n.has(s) ? a.includes(s) || a.push(s) : i.includes(s) || i.push(s);
|
|
617
629
|
});
|
|
618
|
-
const
|
|
630
|
+
const c = l.length, f = i.length === 0;
|
|
619
631
|
return {
|
|
620
|
-
totalTags:
|
|
632
|
+
totalTags: c,
|
|
621
633
|
tagCounts: r,
|
|
622
634
|
uniqueTags: Object.keys(r),
|
|
623
635
|
recognizedTags: a,
|
|
624
|
-
unrecognizedTags:
|
|
625
|
-
areAllTagsPresent:
|
|
636
|
+
unrecognizedTags: i,
|
|
637
|
+
areAllTagsPresent: f
|
|
626
638
|
};
|
|
627
|
-
},
|
|
628
|
-
const l = t, o = e, n =
|
|
639
|
+
}, qt = ({ inSpec: t, inTags: e = It } = {}) => {
|
|
640
|
+
const l = t, o = e, n = b({ inSpec: l }), r = Vt({
|
|
629
641
|
inTagsFound: n,
|
|
630
642
|
inAllowedTags: o
|
|
631
643
|
});
|
|
@@ -637,55 +649,54 @@ const Q = {
|
|
|
637
649
|
recognizedTags: r.recognizedTags,
|
|
638
650
|
unrecognizedTags: r.unrecognizedTags
|
|
639
651
|
};
|
|
640
|
-
},
|
|
652
|
+
}, A = (t = {}) => {
|
|
641
653
|
const e = (t == null ? void 0 : t.spec) ?? (t == null ? void 0 : t.inSpec) ?? t;
|
|
642
|
-
return
|
|
654
|
+
return C(e);
|
|
643
655
|
};
|
|
644
656
|
W({
|
|
645
|
-
inFuncDefinition:
|
|
646
|
-
inReviewSpec:
|
|
657
|
+
inFuncDefinition: A,
|
|
658
|
+
inReviewSpec: qt
|
|
647
659
|
});
|
|
648
|
-
const
|
|
660
|
+
const Bt = ({
|
|
649
661
|
inTargetHtmlId: t,
|
|
650
662
|
inColumns: e,
|
|
651
|
-
|
|
652
|
-
|
|
663
|
+
type: l,
|
|
664
|
+
inData: o,
|
|
665
|
+
showLog: n
|
|
653
666
|
} = {}) => {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
let
|
|
657
|
-
type:
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}, T = {
|
|
666
|
-
table: Vt
|
|
667
|
-
}, qt = ({
|
|
667
|
+
const r = t, a = o ?? [], i = e;
|
|
668
|
+
console.log("buildSpec 1 :", r, a.localColumns);
|
|
669
|
+
let c = y({
|
|
670
|
+
type: l,
|
|
671
|
+
data: a,
|
|
672
|
+
columns: i
|
|
673
|
+
}), f = c;
|
|
674
|
+
!("tagName" in c) && "children" in c && (f = c.children);
|
|
675
|
+
const s = A(f);
|
|
676
|
+
return console.log("buildSpec 3 :", s), s;
|
|
677
|
+
}, Pt = ({
|
|
668
678
|
type: t = "table",
|
|
669
679
|
targetHtmlId: e,
|
|
670
680
|
data: l,
|
|
671
681
|
classToApply: o,
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
inColumns: s,
|
|
676
|
-
appendPosition: u
|
|
682
|
+
columns: n,
|
|
683
|
+
appendPosition: r,
|
|
684
|
+
showLog: a = !1
|
|
677
685
|
} = {}) => {
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
)
|
|
686
|
+
const i = t, c = e, f = l, s = n;
|
|
687
|
+
console.log("showLog 1 :", i, e, l, o, n, r);
|
|
688
|
+
const u = Bt({
|
|
689
|
+
inTargetHtmlId: c,
|
|
690
|
+
inColumns: s,
|
|
691
|
+
showLog: a,
|
|
692
|
+
inData: f,
|
|
693
|
+
type: i
|
|
694
|
+
});
|
|
695
|
+
console.log("showLog 2 :", u);
|
|
696
|
+
const d = document.getElementById(c);
|
|
697
|
+
return console.log("showLog 3 :", d), r === "prepend" ? d.prepend(u) : (d && (d.innerHTML = ""), console.log("showLog 4:1 :", u instanceof Node), console.log("showLog 4:2 :", u instanceof NodeList), console.log("showLog 4:3 :", u instanceof HTMLCollection), u != null && typeof u[Symbol.iterator] == "function" ? d.append(...u) : d.append(u)), console.log("showLog 5 :", d), d;
|
|
687
698
|
};
|
|
688
|
-
|
|
699
|
+
j(Pt);
|
|
689
700
|
export {
|
|
690
|
-
|
|
701
|
+
Pt as default
|
|
691
702
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-renderers",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.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",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@keshavsoft/json-to-tag": "^1.9.3",
|
|
33
|
-
"json-renderers-build": "^1.
|
|
33
|
+
"json-renderers-build": "^1.3.6"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import jsonRenderBuild from "json-renderers-build";
|
|
2
|
+
import jsonToTag from "@keshavsoft/json-to-tag";
|
|
3
|
+
|
|
4
|
+
// --- Story of Table Render ---
|
|
5
|
+
const startFunc = ({
|
|
6
|
+
inTargetHtmlId,
|
|
7
|
+
inColumns, type,
|
|
8
|
+
inData, showLog
|
|
9
|
+
} = {}) => {
|
|
10
|
+
// debugger
|
|
11
|
+
const localTargetHtmlId = inTargetHtmlId;
|
|
12
|
+
const localData = inData ?? [];
|
|
13
|
+
const localColumns = inColumns;
|
|
14
|
+
|
|
15
|
+
console.log("buildSpec 1 :", localTargetHtmlId, localData.localColumns);
|
|
16
|
+
|
|
17
|
+
let specAsJsonToDom = jsonRenderBuild({
|
|
18
|
+
type,
|
|
19
|
+
targetHtmlId: localTargetHtmlId,
|
|
20
|
+
data: localData,
|
|
21
|
+
columns: localColumns
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
let jsonToSend = specAsJsonToDom;
|
|
25
|
+
// console.log("buildSpec 2 :", specAsJsonToDom);
|
|
26
|
+
|
|
27
|
+
if (!("tagName" in specAsJsonToDom) && "children" in specAsJsonToDom) {
|
|
28
|
+
jsonToSend = specAsJsonToDom.children;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const content = jsonToTag(jsonToSend);
|
|
32
|
+
|
|
33
|
+
console.log("buildSpec 3 :", content);
|
|
34
|
+
|
|
35
|
+
return content;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default startFunc;
|
package/src/v13/index.js
CHANGED
|
@@ -1,44 +1,56 @@
|
|
|
1
1
|
import registerGlobal from "./registerGlobal.js";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const RENDERER_MAP = {
|
|
6
|
-
table: renderTable
|
|
7
|
-
};
|
|
3
|
+
import buildSpec from "./buildSpec/index.js";
|
|
8
4
|
|
|
9
5
|
const render = ({
|
|
10
6
|
type = "table",
|
|
11
7
|
targetHtmlId,
|
|
12
8
|
data,
|
|
13
9
|
classToApply,
|
|
14
|
-
inTargetHtmlId,
|
|
15
|
-
inData,
|
|
16
10
|
columns,
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
appendPosition,
|
|
12
|
+
showLog = false
|
|
19
13
|
} = {}) => {
|
|
20
14
|
const rawType = type;
|
|
21
|
-
const resolvedType = typeof rawType === "string" ? rawType.toLowerCase() : "table";
|
|
22
|
-
const renderer = RENDERER_MAP[resolvedType];
|
|
23
|
-
|
|
24
|
-
if (!renderer) {
|
|
25
|
-
console.error(
|
|
26
|
-
`[Renderer] Unknown renderer type "${rawType}". Available types: ${Object.keys(RENDERER_MAP).join(", ")}`
|
|
27
|
-
);
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
15
|
|
|
31
|
-
const localTargetHtmlId =
|
|
32
|
-
const localData =
|
|
33
|
-
const localColumns =
|
|
16
|
+
const localTargetHtmlId = targetHtmlId;
|
|
17
|
+
const localData = data;
|
|
18
|
+
const localColumns = columns;
|
|
19
|
+
console.log("showLog 1 :", rawType, targetHtmlId, data, classToApply, columns, appendPosition);
|
|
34
20
|
|
|
35
21
|
// Default to table renderer
|
|
36
|
-
|
|
22
|
+
const content = buildSpec({
|
|
37
23
|
inTargetHtmlId: localTargetHtmlId,
|
|
38
|
-
inColumns: localColumns,
|
|
39
|
-
inData: localData,
|
|
40
|
-
inAppendPosition: appendPosition
|
|
24
|
+
inColumns: localColumns, showLog,
|
|
25
|
+
inData: localData, type: rawType
|
|
41
26
|
});
|
|
27
|
+
console.log("showLog 2 :", content);
|
|
28
|
+
const container = document.getElementById(localTargetHtmlId);
|
|
29
|
+
console.log("showLog 3 :", container);
|
|
30
|
+
if (appendPosition === "prepend") {
|
|
31
|
+
container.prepend(content);
|
|
32
|
+
} else {
|
|
33
|
+
if (container) container.innerHTML = "";
|
|
34
|
+
|
|
35
|
+
console.log("showLog 4:1 :", content instanceof Node);
|
|
36
|
+
console.log("showLog 4:2 :", content instanceof NodeList);
|
|
37
|
+
console.log("showLog 4:3 :", content instanceof HTMLCollection);
|
|
38
|
+
|
|
39
|
+
if (content != null && typeof content[Symbol.iterator] === "function") {
|
|
40
|
+
container.append(...content);
|
|
41
|
+
} else {
|
|
42
|
+
container.append(content);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// if (content instanceof Node) {
|
|
46
|
+
// container.append(content);
|
|
47
|
+
// } else if (content instanceof NodeList || content instanceof HTMLCollection) {
|
|
48
|
+
// container.append(...content);
|
|
49
|
+
// };
|
|
50
|
+
// container.append(...content);
|
|
51
|
+
};
|
|
52
|
+
console.log("showLog 5 :", container);
|
|
53
|
+
return container;
|
|
42
54
|
};
|
|
43
55
|
|
|
44
56
|
registerGlobal(render);
|
package/src/v13/meta.js
CHANGED
package/src/v13/select/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import jsonToSpec from "json-to-spec";
|
|
2
|
-
import jsonToTag from "@keshavsoft/json-to-tag";
|
|
3
|
-
|
|
4
|
-
import skeletonJson from './skeleton.json' with { type: 'json' };
|
|
5
|
-
|
|
6
|
-
// --- Story of Table Render ---
|
|
7
|
-
const startFunc = ({
|
|
8
|
-
inTargetHtmlId,
|
|
9
|
-
inData
|
|
10
|
-
} = {}) => {
|
|
11
|
-
const localTargetHtmlId = inTargetHtmlId ?? targetHtmlId;
|
|
12
|
-
const localData = inData ?? [];
|
|
13
|
-
const localColumns = inColumns;
|
|
14
|
-
|
|
15
|
-
let specAsJsonToDom = jsonToSpec(skeletonJson, {
|
|
16
|
-
arrayOfStrings: localData
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if (!("tagName" in specAsJsonToDom)) {
|
|
20
|
-
specAsJsonToDom = specAsJsonToDom.children;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const container = document.getElementById(localTargetHtmlId);
|
|
24
|
-
|
|
25
|
-
if (container) container.innerHTML = "";
|
|
26
|
-
|
|
27
|
-
const content = jsonToTag(specAsJsonToDom);
|
|
28
|
-
|
|
29
|
-
container.append(content);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default startFunc;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "select",
|
|
3
|
-
"attributes": {
|
|
4
|
-
"id": "arrayOfStrings"
|
|
5
|
-
},
|
|
6
|
-
"jsonToSpec": {
|
|
7
|
-
"operation": "loopArray",
|
|
8
|
-
"source": "arrayOfStrings",
|
|
9
|
-
"template": {
|
|
10
|
-
"tagName": "option",
|
|
11
|
-
"attributes": {
|
|
12
|
-
"value": "${}"
|
|
13
|
-
},
|
|
14
|
-
"textContent": "${}"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"children": []
|
|
18
|
-
}
|
package/src/v13/table/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import jsonRenderBuild from "json-renderers-build";
|
|
2
|
-
import jsonToTag from "@keshavsoft/json-to-tag";
|
|
3
|
-
|
|
4
|
-
import skeletonJson from './skeleton.json' with { type: 'json' };
|
|
5
|
-
|
|
6
|
-
// --- Story of Table Render ---
|
|
7
|
-
const startFunc = ({
|
|
8
|
-
inTargetHtmlId,
|
|
9
|
-
inColumns,
|
|
10
|
-
inData, inAppendPosition
|
|
11
|
-
} = {}) => {
|
|
12
|
-
debugger
|
|
13
|
-
const localTargetHtmlId = inTargetHtmlId;
|
|
14
|
-
const localData = inData ?? [];
|
|
15
|
-
const localColumns = inColumns;
|
|
16
|
-
|
|
17
|
-
let specAsJsonToDom = jsonRenderBuild({
|
|
18
|
-
type: "table",
|
|
19
|
-
targetHtmlId: localTargetHtmlId,
|
|
20
|
-
data: localData,
|
|
21
|
-
columns: localColumns
|
|
22
|
-
});
|
|
23
|
-
console.log("specAsJsonToDom : ", inAppendPosition, specAsJsonToDom);
|
|
24
|
-
|
|
25
|
-
const container = document.getElementById(localTargetHtmlId);
|
|
26
|
-
|
|
27
|
-
const content = jsonToTag(specAsJsonToDom);
|
|
28
|
-
|
|
29
|
-
if (inAppendPosition === "prepend") {
|
|
30
|
-
container.prepend(content);
|
|
31
|
-
} else {
|
|
32
|
-
|
|
33
|
-
if (container) container.innerHTML = "";
|
|
34
|
-
|
|
35
|
-
container.append(content);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default startFunc;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"default": {
|
|
3
|
-
"tagName": "table",
|
|
4
|
-
"attributes": {
|
|
5
|
-
"class": "table table-hover table-striped mb-0"
|
|
6
|
-
},
|
|
7
|
-
"children": [
|
|
8
|
-
{
|
|
9
|
-
"tagName": "thead",
|
|
10
|
-
"children": [
|
|
11
|
-
{
|
|
12
|
-
"tagName": "tr",
|
|
13
|
-
"jsonToSpec": {
|
|
14
|
-
"operation": "loopCollection",
|
|
15
|
-
"source": "columns",
|
|
16
|
-
"template": {
|
|
17
|
-
"tagName": "th",
|
|
18
|
-
"textContent": "${title}"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"children": []
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"tagName": "tbody",
|
|
27
|
-
"jsonToSpec": {
|
|
28
|
-
"operation": "loopCollection",
|
|
29
|
-
"source": "data",
|
|
30
|
-
"template": {
|
|
31
|
-
"tagName": "tr",
|
|
32
|
-
"jsonToSpec": {
|
|
33
|
-
"operation": "loopObject",
|
|
34
|
-
"source": "data",
|
|
35
|
-
"template": {
|
|
36
|
-
"tagName": "td",
|
|
37
|
-
"textContent": "${value}"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"children": []
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"children": []
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
}
|