json-renderers 1.17.7 → 1.18.4
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/min.js +1352 -1047
- package/docs/dist/v17/min.js +85 -83
- package/docs/dist/v18/min.js +1352 -0
- package/docs/index.html +91 -2
- package/docs/subDoc/advanceDoc.html +1140 -0
- package/docs/subDoc/index.html +244 -0
- package/docs/subDoc/simpleDoc.html +476 -0
- package/package.json +3 -2
- package/src/index.js +2 -2
- package/src/v18/buildSpec/index.js +25 -0
- package/src/v18/common/deriveColumnsFromData.js +20 -0
- package/src/v18/index.js +33 -0
- package/src/v18/meta.js +6 -0
- package/src/v18/registerGlobal.js +16 -0
- package/src/v18/renderToDom/index.js +47 -0
package/docs/dist/v17/min.js
CHANGED
|
@@ -43,7 +43,7 @@ const q = {
|
|
|
43
43
|
targetHtmlId: t,
|
|
44
44
|
data: o,
|
|
45
45
|
columns: n,
|
|
46
|
-
classToApply:
|
|
46
|
+
classToApply: l = "",
|
|
47
47
|
appendPosition: r = "replace",
|
|
48
48
|
showLog: s = !1
|
|
49
49
|
} = {}) => {
|
|
@@ -52,7 +52,7 @@ const q = {
|
|
|
52
52
|
targetHtmlId: t,
|
|
53
53
|
data: o,
|
|
54
54
|
columns: n,
|
|
55
|
-
classToApply:
|
|
55
|
+
classToApply: l,
|
|
56
56
|
appendPosition: r,
|
|
57
57
|
showLog: s
|
|
58
58
|
};
|
|
@@ -108,10 +108,10 @@ const et = {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
return !0;
|
|
111
|
-
}, rt = "table",
|
|
111
|
+
}, rt = "table", lt = [], at = [], st = {}, ct = !1, h = {
|
|
112
112
|
type: rt,
|
|
113
|
-
columns:
|
|
114
|
-
data:
|
|
113
|
+
columns: lt,
|
|
114
|
+
data: at,
|
|
115
115
|
options: st,
|
|
116
116
|
showLog: ct
|
|
117
117
|
}, it = [
|
|
@@ -139,48 +139,48 @@ const et = {
|
|
|
139
139
|
data: t = f.data,
|
|
140
140
|
columns: o = f.columns,
|
|
141
141
|
options: n = f.options,
|
|
142
|
-
showLog:
|
|
142
|
+
showLog: l = f.showLog
|
|
143
143
|
} = {}) => {
|
|
144
|
-
const
|
|
144
|
+
const a = {
|
|
145
145
|
type: e,
|
|
146
146
|
data: t,
|
|
147
147
|
columns: o,
|
|
148
148
|
options: n,
|
|
149
|
-
showLog:
|
|
149
|
+
showLog: l
|
|
150
150
|
};
|
|
151
|
-
return F({ inConfig:
|
|
151
|
+
return F({ inConfig: a }), a;
|
|
152
152
|
};
|
|
153
153
|
Object.assign(x, f);
|
|
154
154
|
x.toJSON = () => structuredClone(f);
|
|
155
155
|
const pt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ft = (e, t) => {
|
|
156
156
|
if (!pt(e)) return;
|
|
157
157
|
let o = {};
|
|
158
|
-
for (const [n,
|
|
159
|
-
o[n] =
|
|
158
|
+
for (const [n, l] of Object.entries(e))
|
|
159
|
+
o[n] = g(t, l);
|
|
160
160
|
return o;
|
|
161
161
|
}, bt = (e, t) => {
|
|
162
162
|
const o = structuredClone(e);
|
|
163
|
-
return Array.isArray(o) ? o.map((
|
|
163
|
+
return Array.isArray(o) ? o.map((l) => g(t, l)) : void 0;
|
|
164
164
|
}, k = (e, t, o) => {
|
|
165
165
|
if (e === "${agg:count}" && "rowData" in t) {
|
|
166
166
|
if (Array.isArray(t == null ? void 0 : t.rowData))
|
|
167
167
|
return t == null ? void 0 : t.rowData.length;
|
|
168
168
|
} else
|
|
169
|
-
return e === "${rowValue}" && "rowData" in t ? t == null ? void 0 : t.rowData : e.replace(/\$\{(\w+)\}/g, (n,
|
|
169
|
+
return e === "${rowValue}" && "rowData" in t ? t == null ? void 0 : t.rowData : e.replace(/\$\{(\w+)\}/g, (n, l) => t[l] !== void 0 ? t[l] : n);
|
|
170
170
|
}, ht = (e, t) => k(e, t), mt = (e, t, o) => {
|
|
171
|
-
if (
|
|
171
|
+
if (t == null)
|
|
172
172
|
throw new TypeError("inTemplate is required");
|
|
173
|
-
if (typeof
|
|
173
|
+
if (typeof t != "object" && typeof t != "string")
|
|
174
174
|
throw new TypeError("inTemplate must be an object or string");
|
|
175
|
-
if (!
|
|
175
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
176
176
|
throw new TypeError("inElement must be an object");
|
|
177
177
|
return !0;
|
|
178
|
-
},
|
|
179
|
-
const n = e,
|
|
180
|
-
mt(n,
|
|
181
|
-
const r = structuredClone(
|
|
178
|
+
}, g = (e, t, o) => {
|
|
179
|
+
const n = e, l = t;
|
|
180
|
+
mt(n, l);
|
|
181
|
+
const r = structuredClone(l);
|
|
182
182
|
return typeof r == "string" ? k(r, n) : (r === null || typeof r != "object" || ("textContent" in r && (r.textContent = ht(r == null ? void 0 : r.textContent, n)), "attributes" in r && (r.attributes = ft(r == null ? void 0 : r.attributes, n)), "children" in r && (r.children = bt(r == null ? void 0 : r.children, n))), r);
|
|
183
|
-
},
|
|
183
|
+
}, wt = (e, t) => {
|
|
184
184
|
if (!Array.isArray(e))
|
|
185
185
|
throw new TypeError("inSource must be an Array");
|
|
186
186
|
if (e.length === 0)
|
|
@@ -193,64 +193,64 @@ const pt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ft =
|
|
|
193
193
|
return !0;
|
|
194
194
|
}, C = (e, t) => {
|
|
195
195
|
const o = e, n = t;
|
|
196
|
-
return
|
|
197
|
-
},
|
|
196
|
+
return wt(o, n), o.map((l) => g(l, n));
|
|
197
|
+
}, gt = (e, t) => e.map((n) => ({
|
|
198
198
|
...n,
|
|
199
199
|
rowData: t[n.columnName]
|
|
200
200
|
})), yt = (e, t, o) => {
|
|
201
|
-
var
|
|
201
|
+
var l, r, s, c, i, u;
|
|
202
202
|
if (!Array.isArray(e))
|
|
203
203
|
throw new TypeError("inColumns must be an Array");
|
|
204
204
|
if (e.length === 0)
|
|
205
205
|
throw new Error("inColumns cannot be empty");
|
|
206
|
-
for (let
|
|
207
|
-
const d = e[
|
|
206
|
+
for (let a = 0; a < e.length; a++) {
|
|
207
|
+
const d = e[a];
|
|
208
208
|
if (!d || typeof d != "object")
|
|
209
|
-
throw new TypeError(`inColumns[${
|
|
209
|
+
throw new TypeError(`inColumns[${a}] must be an object`);
|
|
210
210
|
if (typeof d.columnName != "string" || !d.columnName.trim())
|
|
211
|
-
throw new TypeError(`inColumns[${
|
|
211
|
+
throw new TypeError(`inColumns[${a}].columnName must be a non-empty string`);
|
|
212
212
|
}
|
|
213
213
|
if (!Array.isArray(t))
|
|
214
214
|
throw new TypeError("inData must be an Array");
|
|
215
|
-
for (let
|
|
216
|
-
const d = t[
|
|
215
|
+
for (let a = 0; a < t.length; a++) {
|
|
216
|
+
const d = t[a];
|
|
217
217
|
if (!d || typeof d != "object")
|
|
218
|
-
throw new TypeError(`inData[${
|
|
218
|
+
throw new TypeError(`inData[${a}] must be an object`);
|
|
219
219
|
}
|
|
220
220
|
if (!o || typeof o != "object" || Array.isArray(o))
|
|
221
221
|
throw new TypeError("inSpec must be an object");
|
|
222
|
-
const n = ((s = (r = (
|
|
222
|
+
const n = ((s = (r = (l = e[0]) == null ? void 0 : l.template) == null ? void 0 : r.body) == null ? void 0 : s.tr) || "buildBodyTr";
|
|
223
223
|
if (!(n in o))
|
|
224
224
|
throw new Error(`Row template "${n}" not found in inSpec`);
|
|
225
|
-
for (let
|
|
226
|
-
const d = e[
|
|
225
|
+
for (let a = 0; a < e.length; a++) {
|
|
226
|
+
const d = e[a], p = ((i = (c = d.template) == null ? void 0 : c.body) == null ? void 0 : i.cell) || ((u = d.template) == null ? void 0 : u.bodyCell) || "buildBodyCell";
|
|
227
227
|
if (!(p in o))
|
|
228
228
|
throw new Error(`Cell template "${p}" for column "${d.columnName}" not found in inSpec`);
|
|
229
229
|
}
|
|
230
230
|
return !0;
|
|
231
231
|
}, Tt = (e, t) => e.map((n) => {
|
|
232
232
|
var c, i, u;
|
|
233
|
-
const
|
|
234
|
-
return
|
|
233
|
+
const l = ((i = (c = n.template) == null ? void 0 : c.body) == null ? void 0 : i.cell) || ((u = n.template) == null ? void 0 : u.bodyCell) || "buildBodyCell", r = t[l];
|
|
234
|
+
return g(n, r);
|
|
235
235
|
}), Ct = (e, t, o) => {
|
|
236
|
-
var u,
|
|
236
|
+
var u, a, d;
|
|
237
237
|
yt(e, t, o);
|
|
238
|
-
const n = e,
|
|
239
|
-
return
|
|
240
|
-
const A =
|
|
238
|
+
const n = e, l = t, r = o, s = ((d = (a = (u = n[0]) == null ? void 0 : u.template) == null ? void 0 : a.body) == null ? void 0 : d.tr) || "buildBodyTr", c = r[s];
|
|
239
|
+
return l.map((p) => {
|
|
240
|
+
const A = g(p, c), y = gt(n, p), z = Tt(y, r);
|
|
241
241
|
return A.children = z, A;
|
|
242
242
|
});
|
|
243
243
|
}, S = (e, t) => {
|
|
244
244
|
var o;
|
|
245
245
|
if (((o = e == null ? void 0 : e.attributes) == null ? void 0 : o["data-role"]) === t) return e;
|
|
246
246
|
for (const n of (e == null ? void 0 : e.children) ?? []) {
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
247
|
+
const l = S(n, t);
|
|
248
|
+
if (l) return l;
|
|
249
249
|
}
|
|
250
250
|
return null;
|
|
251
251
|
}, At = (e, t) => {
|
|
252
252
|
const o = e[t.fileName], n = t.dataRole ? S(o, t.dataRole) : o;
|
|
253
|
-
return (t.filePath ?? []).reduce((
|
|
253
|
+
return (t.filePath ?? []).reduce((l, r) => l[r], n);
|
|
254
254
|
}, Nt = {
|
|
255
255
|
tagName: "tr",
|
|
256
256
|
attributes: {
|
|
@@ -464,13 +464,13 @@ const pt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ft =
|
|
|
464
464
|
});
|
|
465
465
|
},
|
|
466
466
|
unshiftSerialToRows: (e, t, o) => {
|
|
467
|
-
e[t].forEach((n,
|
|
467
|
+
e[t].forEach((n, l) => {
|
|
468
468
|
const r = structuredClone(o);
|
|
469
|
-
r.textContent =
|
|
469
|
+
r.textContent = l + 1, n.children.unshift(r);
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
472
|
}, R = (e, t, o) => {
|
|
473
|
-
const n = t.dataRole ? S(e[t.fileName], t.dataRole) : e[t.fileName],
|
|
473
|
+
const n = t.dataRole ? S(e[t.fileName], t.dataRole) : e[t.fileName], l = [...t.filePath ?? []], r = l.pop(), s = l.reduce((i, u) => i[u], n);
|
|
474
474
|
(L[t.action] || L.set)(s, r, o);
|
|
475
475
|
}, m = { data: {}, base: I, spec: j }, v = {
|
|
476
476
|
fromCollection: C,
|
|
@@ -519,23 +519,25 @@ const pt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ft =
|
|
|
519
519
|
"data-name": "${columnName}"
|
|
520
520
|
},
|
|
521
521
|
children: []
|
|
522
|
-
},
|
|
522
|
+
}, w = {
|
|
523
523
|
buildOption: Mt,
|
|
524
524
|
buildSelect: Gt,
|
|
525
525
|
buildDataList: Kt
|
|
526
526
|
}, zt = ({ inData: e = [] } = {}) => {
|
|
527
527
|
const t = (e ?? []).map(
|
|
528
528
|
(n) => typeof n == "object" && n !== null ? n : { rowValue: n }
|
|
529
|
-
), o = structuredClone(
|
|
530
|
-
return o.children = C(t,
|
|
529
|
+
), o = structuredClone(w.buildSelect);
|
|
530
|
+
return o.children = C(t, w.buildOption), o;
|
|
531
531
|
}, qt = ({ inData: e = [], inColumns: t = [] } = {}) => t.map((n) => {
|
|
532
|
-
const
|
|
533
|
-
|
|
532
|
+
const l = structuredClone(w.buildOption);
|
|
533
|
+
l.textContent = l.textContent.replace("rowValue", n.columnName), l.attributes.value = l.attributes.value.replace("rowValue", n.columnName);
|
|
534
|
+
const r = C(e, l);
|
|
535
|
+
return console.log("createdArray : ", r[0], l), r;
|
|
534
536
|
}), E = ({ inData: e = [] } = {}) => {
|
|
535
537
|
const t = (e ?? []).map(
|
|
536
538
|
(n) => typeof n == "object" && n !== null ? n : { rowValue: n }
|
|
537
|
-
), o = structuredClone(
|
|
538
|
-
return o.children = C(t,
|
|
539
|
+
), o = structuredClone(w.buildDataList);
|
|
540
|
+
return o.children = C(t, w.buildOption), o;
|
|
539
541
|
}, _t = {
|
|
540
542
|
table: D,
|
|
541
543
|
tableFromSpec: D,
|
|
@@ -548,25 +550,25 @@ const pt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ft =
|
|
|
548
550
|
data: t = h.data,
|
|
549
551
|
columns: o = h.columns,
|
|
550
552
|
options: n = h.options,
|
|
551
|
-
showLog:
|
|
553
|
+
showLog: l = h.showLog
|
|
552
554
|
} = {}) => {
|
|
553
|
-
const
|
|
555
|
+
const a = {
|
|
554
556
|
type: e,
|
|
555
557
|
data: t,
|
|
556
558
|
columns: o,
|
|
557
559
|
options: n,
|
|
558
|
-
showLog:
|
|
560
|
+
showLog: l
|
|
559
561
|
};
|
|
560
|
-
F({ inConfig:
|
|
561
|
-
const d = _t[
|
|
562
|
+
F({ inConfig: a });
|
|
563
|
+
const d = _t[a.type];
|
|
562
564
|
if (!d)
|
|
563
|
-
throw new Error(`Renderer for type "${
|
|
565
|
+
throw new Error(`Renderer for type "${a.type}" not found.`);
|
|
564
566
|
const p = d({
|
|
565
|
-
inColumns:
|
|
566
|
-
inData:
|
|
567
|
-
options:
|
|
567
|
+
inColumns: a.columns,
|
|
568
|
+
inData: a.data,
|
|
569
|
+
options: a.options
|
|
568
570
|
});
|
|
569
|
-
return
|
|
571
|
+
return a.showLog && console.log("json-renderers-build output:", p), p;
|
|
570
572
|
};
|
|
571
573
|
ot({ render: H, getSpec: x, spec: f });
|
|
572
574
|
const V = ({
|
|
@@ -630,16 +632,16 @@ const V = ({
|
|
|
630
632
|
const o = e, n = t;
|
|
631
633
|
if (!o || !n || typeof n != "object")
|
|
632
634
|
return o;
|
|
633
|
-
const
|
|
635
|
+
const l = typeof SVGElement < "u" ? o instanceof SVGElement : o.namespaceURI === "http://www.w3.org/2000/svg";
|
|
634
636
|
return Object.entries(n).forEach(([r, s]) => {
|
|
635
637
|
if (r === "class") {
|
|
636
|
-
|
|
638
|
+
l ? o.setAttribute("class", String(s)) : o.className = s;
|
|
637
639
|
return;
|
|
638
640
|
}
|
|
639
641
|
if (r === "xlink:href" || r === "href") {
|
|
640
642
|
if (s != null) {
|
|
641
643
|
const c = String(s);
|
|
642
|
-
if (
|
|
644
|
+
if (l)
|
|
643
645
|
try {
|
|
644
646
|
o.setAttributeNS(oe, "href", c);
|
|
645
647
|
} catch {
|
|
@@ -658,7 +660,7 @@ const V = ({
|
|
|
658
660
|
if (!e || !t) return e;
|
|
659
661
|
const o = typeof t == "string" ? t.split(/\s+/).filter(Boolean) : Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim()) : [];
|
|
660
662
|
return o.length && e.classList.add(...o), e;
|
|
661
|
-
},
|
|
663
|
+
}, le = (e) => {
|
|
662
664
|
if (!e || typeof e != "object" || Array.isArray(e) || !e.tagName) return null;
|
|
663
665
|
const t = Zt({ inTagName: e.tagName });
|
|
664
666
|
if (!t) return null;
|
|
@@ -680,7 +682,7 @@ const V = ({
|
|
|
680
682
|
o.length && t.append(...o);
|
|
681
683
|
}
|
|
682
684
|
return t;
|
|
683
|
-
}, M = (e) => e == null ? null : typeof Node < "u" && e instanceof Node ? e : Array.isArray(e) ? B(e) : typeof e == "object" ?
|
|
685
|
+
}, M = (e) => e == null ? null : typeof Node < "u" && e instanceof Node ? e : Array.isArray(e) ? B(e) : typeof e == "object" ? le(e) : typeof e == "string" || typeof e == "number" ? document.createTextNode(String(e)) : null, ae = "./tags.schema.json", se = {
|
|
684
686
|
allowsTextContent: !1,
|
|
685
687
|
allowsChildren: !0,
|
|
686
688
|
allowedAttributes: [
|
|
@@ -772,12 +774,12 @@ const V = ({
|
|
|
772
774
|
allowsChildren: !0,
|
|
773
775
|
allowedAttributes: [],
|
|
774
776
|
childTags: []
|
|
775
|
-
},
|
|
777
|
+
}, we = {
|
|
776
778
|
allowsTextContent: !0,
|
|
777
779
|
allowsChildren: !0,
|
|
778
780
|
allowedAttributes: [],
|
|
779
781
|
childTags: []
|
|
780
|
-
},
|
|
782
|
+
}, ge = {
|
|
781
783
|
allowsTextContent: !0,
|
|
782
784
|
allowsChildren: !0,
|
|
783
785
|
allowedAttributes: [],
|
|
@@ -931,7 +933,7 @@ const V = ({
|
|
|
931
933
|
allowsChildren: !1,
|
|
932
934
|
allowedAttributes: []
|
|
933
935
|
}, ve = {
|
|
934
|
-
$schema:
|
|
936
|
+
$schema: ae,
|
|
935
937
|
div: se,
|
|
936
938
|
input: ce,
|
|
937
939
|
checkbox: ie,
|
|
@@ -942,8 +944,8 @@ const V = ({
|
|
|
942
944
|
select: be,
|
|
943
945
|
p: he,
|
|
944
946
|
h1: me,
|
|
945
|
-
h2:
|
|
946
|
-
span:
|
|
947
|
+
h2: we,
|
|
948
|
+
span: ge,
|
|
947
949
|
img: ye,
|
|
948
950
|
button: Te,
|
|
949
951
|
table: Ce,
|
|
@@ -970,15 +972,15 @@ const V = ({
|
|
|
970
972
|
if (typeof t != "object") return [];
|
|
971
973
|
const o = [];
|
|
972
974
|
return typeof t.tagName == "string" && t.tagName.trim().length > 0 && o.push(t.tagName.toLowerCase()), Array.isArray(t.children) && t.children.length > 0 && t.children.forEach((n) => {
|
|
973
|
-
const
|
|
974
|
-
o.push(...
|
|
975
|
+
const l = $({ inSpec: n });
|
|
976
|
+
o.push(...l);
|
|
975
977
|
}), o;
|
|
976
978
|
}, He = ({ inTagsFound: e, inAllowedTags: t }) => {
|
|
977
|
-
const o = e ?? [], n = t ?? {},
|
|
978
|
-
Object.keys(n).filter((
|
|
979
|
+
const o = e ?? [], n = t ?? {}, l = new Set(
|
|
980
|
+
Object.keys(n).filter((a) => a !== "$schema").map((a) => a.toLowerCase())
|
|
979
981
|
), r = {}, s = [], c = [];
|
|
980
|
-
o.forEach((
|
|
981
|
-
r[
|
|
982
|
+
o.forEach((a) => {
|
|
983
|
+
r[a] = (r[a] || 0) + 1, l.has(a) ? s.includes(a) || s.push(a) : c.includes(a) || c.push(a);
|
|
982
984
|
});
|
|
983
985
|
const i = o.length, u = c.length === 0;
|
|
984
986
|
return {
|
|
@@ -990,8 +992,8 @@ const V = ({
|
|
|
990
992
|
areAllTagsPresent: u
|
|
991
993
|
};
|
|
992
994
|
}, Ve = ({ inSpec: e, inTags: t = ve } = {}) => {
|
|
993
|
-
const o = e, n = t,
|
|
994
|
-
inTagsFound:
|
|
995
|
+
const o = e, n = t, l = $({ inSpec: o }), r = He({
|
|
996
|
+
inTagsFound: l,
|
|
995
997
|
inAllowedTags: n
|
|
996
998
|
});
|
|
997
999
|
return {
|
|
@@ -1016,13 +1018,13 @@ const K = ({
|
|
|
1016
1018
|
inAppendPosition: o,
|
|
1017
1019
|
inShowLog: n = !1
|
|
1018
1020
|
} = {}) => {
|
|
1019
|
-
const
|
|
1021
|
+
const l = e, r = t, s = o, c = n, i = G(l);
|
|
1020
1022
|
c && console.log("renderToDom 1 (content):", i);
|
|
1021
1023
|
const u = document.getElementById(r);
|
|
1022
1024
|
return u ? (Array.isArray(i) || i instanceof NodeList || i instanceof HTMLCollection ? s === "prepend" ? u.prepend(...i) : u.append(...i) : s === "prepend" ? u.prepend(i) : (u.innerHTML = "", u.append(i)), c && console.log("renderToDom 2 (mounted):", u), u) : null;
|
|
1023
1025
|
}, Be = (e = {}) => {
|
|
1024
1026
|
const t = O(e);
|
|
1025
|
-
(t == null ? void 0 : t.showLog) && console.log("first : ", t == null ? void 0 : t.columns, t == null ? void 0 : t.data);
|
|
1027
|
+
(t == null ? void 0 : t.showLog) && console.log("first : ", t == null ? void 0 : t.columns, t == null ? void 0 : t.data, t == null ? void 0 : t.appendPosition);
|
|
1026
1028
|
const n = V({
|
|
1027
1029
|
inColumns: t.columns,
|
|
1028
1030
|
inData: t.data,
|