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.
@@ -1,48 +1,48 @@
1
- const R = {
2
- version: "v12.0.0",
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
- }, F = (t) => {
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: R,
7
+ meta: x,
8
8
  renderToDom: t
9
9
  }));
10
- }, G = {
11
- version: "v2.0.0",
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
- }, H = (t) => {
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: G,
16
+ meta: v,
17
17
  renderToDom: t
18
18
  }));
19
- }, S = {
19
+ }, $ = {
20
20
  version: "v32",
21
21
  description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
22
- }, L = ({ inFuncDefinition: t } = {}) => {
22
+ }, k = ({ inFuncDefinition: t } = {}) => {
23
23
  if (typeof globalThis > "u" || !t) return;
24
24
  globalThis.ks ?? (globalThis.ks = {});
25
25
  const e = {
26
- meta: S,
26
+ meta: $,
27
27
  buildSpecElement: t
28
28
  };
29
29
  globalThis.ks.jsonToSpec = e;
30
- }, M = (t, e) => d(t, e), C = (t, e) => Array.isArray(t) ? t.map((l) => M(l, e)).flat(1 / 0).filter(Boolean) : [], z = (t, e) => {
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 d(r, n);
37
+ return g(r, n);
38
38
  });
39
39
  }
40
- }, P = (t, e) => {
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 = d(r, {
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
- }, V = (t, e) => {
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 d(r, n);
60
+ return g(r, n);
61
61
  });
62
62
  }
63
- }, q = (t, e) => {
63
+ }, L = (t, e) => {
64
64
  if ("operation" in t) {
65
65
  if (t.operation === "loopArray")
66
- return z(t, e);
66
+ return O(t, e);
67
67
  if (t.operation === "loopObject")
68
- return P(t, e);
68
+ return E(t, e);
69
69
  if (t.operation === "loopCollection")
70
- return V(t, e);
70
+ return S(t, e);
71
71
  }
72
- }, A = (t, e) => {
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
- }, B = (t, e) => {
83
+ }, F = (t, e) => {
84
84
  let l = {};
85
85
  for (const [o, n] of Object.entries(t)) {
86
- const r = A(n, e);
86
+ const r = p(n, e);
87
87
  l[o] = r;
88
88
  }
89
89
  return l;
90
- }, _ = (t, e) => {
90
+ }, G = (t, e) => {
91
91
  if ("tagName" in t) {
92
92
  if ("textContent" in t) {
93
- const l = A(t.textContent, e);
93
+ const l = p(t.textContent, e);
94
94
  t.textContent = l;
95
95
  }
96
96
  if ("attributes" in t) {
97
- const l = B(t.attributes, e);
97
+ const l = F(t.attributes, e);
98
98
  t.attributes = l;
99
99
  }
100
100
  }
101
- }, U = (t, e) => {
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 && _(l, e), "jsonToSpec" in l) {
106
- const o = l == null ? void 0 : l.jsonToSpec, n = q(o, e);
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 = C(l == null ? void 0 : l.children, e);
110
+ const o = m(l == null ? void 0 : l.children, e);
111
111
  l.children = o;
112
112
  }
113
113
  return l;
114
- }, d = (t, e) => {
115
- if (t == null) return null;
116
- debugger;
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 K = {
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
- }, X = ({
169
- targetHtmlId: t,
170
- inTargetHtmlId: e,
171
- inColumns: l,
172
- inData: o
164
+ }, z = ({
165
+ inColumns: t,
166
+ inData: e
173
167
  } = {}) => {
174
- const n = o ?? [], r = l;
175
- return x(K.default, {
176
- columns: r,
177
- data: n
168
+ const l = e ?? [], o = t;
169
+ return h(R.default, {
170
+ columns: o,
171
+ data: l
178
172
  });
179
- }, y = {
180
- table: X
181
- }, v = ({
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
- targetHtmlId: e,
184
- data: l,
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 g = t, I = typeof g == "string" ? g.toLowerCase() : "table", p = y[I];
203
- return p ? p({
204
- targetHtmlId: n ?? e,
205
- inColumns: s ?? a,
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 "${g}". Available types: ${Object.keys(y).join(", ")}`
225
+ `[Renderer] Unknown renderer type "${o}". Available types: ${Object.keys(w).join(", ")}`
214
226
  ), null);
215
227
  };
216
- H(v);
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 ?? "") : N(t), j = (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([
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), rt = ({ inElement: t, inProperties: e }) => (t && e && typeof e == "object" && Object.assign(t, e), t), ot = "http://www.w3.org/1999/xlink", nt = ({ inElement: t, inAttributes: e }) => {
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 s = String(a);
288
+ const i = String(a);
277
289
  if (n)
278
290
  try {
279
- l.setAttributeNS(ot, "href", s);
291
+ l.setAttributeNS(rt, "href", i);
280
292
  } catch {
281
293
  }
282
- l.setAttribute("href", s), l.setAttribute("xlink:href", s);
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
- }), rt({
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 = j(t.children);
326
+ const l = T(t.children);
315
327
  l.length && e.append(...l);
316
328
  }
317
329
  return e;
318
- }, N = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? j(t) : typeof t == "object" ? st(t) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : null, it = "./tags.schema.json", ut = {
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
- }, ct = {
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
- }, vt = {
468
+ }, jt = {
457
469
  allowsTextContent: !1,
458
470
  allowsChildren: !0,
459
471
  allowedAttributes: [],
460
472
  childTags: [
461
473
  "tr"
462
474
  ]
463
- }, jt = {
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
- }, kt = {
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
- }, $t = {
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
- }, Et = {
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
- }, Dt = {
514
+ }, Ot = {
503
515
  allowsTextContent: !1,
504
516
  allowsChildren: !0,
505
517
  allowedAttributes: [],
506
518
  childTags: [
507
519
  "option"
508
520
  ]
509
- }, Ot = {
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
- }, It = {
530
+ }, St = {
519
531
  allowsTextContent: !1,
520
532
  allowsChildren: !0,
521
533
  allowedAttributes: [
522
534
  "role"
523
535
  ],
524
536
  childTags: []
525
- }, Rt = {
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
- }, Ht = {
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
- }, St = {
569
+ }, Rt = {
558
570
  allowsTextContent: !0,
559
571
  allowsChildren: !0,
560
572
  allowedAttributes: [
561
573
  "value"
562
574
  ],
563
575
  childTags: []
564
- }, Lt = {
576
+ }, zt = {
565
577
  allowsTextContent: !1,
566
578
  allowsChildren: !1,
567
579
  allowedAttributes: []
568
- }, Mt = {
580
+ }, It = {
569
581
  $schema: it,
570
- div: ut,
571
- input: ct,
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: vt,
586
- tbody: jt,
597
+ thead: jt,
598
+ tbody: vt,
587
599
  tfoot: Nt,
588
- tr: kt,
589
- th: $t,
590
- td: Et,
591
- datalist: Dt,
592
- option: Ot,
593
- header: It,
594
- a: Rt,
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: Ht,
598
- li: St,
599
- hr: Lt
600
- }, h = ({ inSpec: t }) => {
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) => h({ inSpec: 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 = h({ inSpec: o });
620
+ const n = b({ inSpec: o });
609
621
  l.push(...n);
610
622
  }), l;
611
- }, zt = ({ inTagsFound: t, inAllowedTags: e }) => {
623
+ }, Vt = ({ inTagsFound: t, inAllowedTags: e }) => {
612
624
  const l = t ?? [], o = e ?? {}, n = new Set(
613
- Object.keys(o).filter((i) => i !== "$schema").map((i) => i.toLowerCase())
614
- ), r = {}, a = [], s = [];
615
- l.forEach((i) => {
616
- r[i] = (r[i] || 0) + 1, n.has(i) ? a.includes(i) || a.push(i) : s.includes(i) || s.push(i);
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 u = l.length, c = s.length === 0;
630
+ const c = l.length, f = i.length === 0;
619
631
  return {
620
- totalTags: u,
632
+ totalTags: c,
621
633
  tagCounts: r,
622
634
  uniqueTags: Object.keys(r),
623
635
  recognizedTags: a,
624
- unrecognizedTags: s,
625
- areAllTagsPresent: c
636
+ unrecognizedTags: i,
637
+ areAllTagsPresent: f
626
638
  };
627
- }, Pt = ({ inSpec: t, inTags: e = Mt } = {}) => {
628
- const l = t, o = e, n = h({ inSpec: l }), r = zt({
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
- }, k = (t = {}) => {
652
+ }, A = (t = {}) => {
641
653
  const e = (t == null ? void 0 : t.spec) ?? (t == null ? void 0 : t.inSpec) ?? t;
642
- return N(e);
654
+ return C(e);
643
655
  };
644
656
  W({
645
- inFuncDefinition: k,
646
- inReviewSpec: Pt
657
+ inFuncDefinition: A,
658
+ inReviewSpec: qt
647
659
  });
648
- const Vt = ({
660
+ const Bt = ({
649
661
  inTargetHtmlId: t,
650
662
  inColumns: e,
651
- inData: l,
652
- inAppendPosition: o
663
+ type: l,
664
+ inData: o,
665
+ showLog: n
653
666
  } = {}) => {
654
- debugger;
655
- const n = t;
656
- let s = v({
657
- type: "table",
658
- targetHtmlId: n,
659
- data: l ?? [],
660
- columns: e
661
- });
662
- console.log("specAsJsonToDom : ", o, s);
663
- const u = document.getElementById(n), c = k(s);
664
- o === "prepend" ? u.prepend(c) : (u && (u.innerHTML = ""), u.append(c));
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
- inTargetHtmlId: n,
673
- inData: r,
674
- columns: a,
675
- inColumns: s,
676
- appendPosition: u
682
+ columns: n,
683
+ appendPosition: r,
684
+ showLog: a = !1
677
685
  } = {}) => {
678
- const c = t, i = typeof c == "string" ? c.toLowerCase() : "table", f = T[i];
679
- return f ? f({
680
- inTargetHtmlId: n ?? e,
681
- inColumns: s ?? a,
682
- inData: r ?? l,
683
- inAppendPosition: u
684
- }) : (console.error(
685
- `[Renderer] Unknown renderer type "${c}". Available types: ${Object.keys(T).join(", ")}`
686
- ), null);
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
- F(qt);
699
+ j(Pt);
689
700
  export {
690
- qt as default
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.2",
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.2.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 renderTable from "./table/index.js";
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
- inColumns,
18
- appendPosition
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 = inTargetHtmlId ?? targetHtmlId;
32
- const localData = inData ?? data;
33
- const localColumns = inColumns ?? columns;
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
- return renderer({
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
@@ -1,5 +1,5 @@
1
1
  export const meta = {
2
- version: "v12.0.0",
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
  };
5
5
 
@@ -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
- }
@@ -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
- }