json-renderers-build 1.6.1 → 1.9.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.
Files changed (120) hide show
  1. package/README.md +8 -4
  2. package/docs/dist/min.js +541 -266
  3. package/docs/dist/v4/min.js +320 -320
  4. package/docs/dist/v5/min.js +312 -312
  5. package/docs/dist/v7/min.js +272 -0
  6. package/docs/dist/v8/min.js +268 -0
  7. package/docs/dist/v9/min.js +587 -0
  8. package/docs/index.html +2 -2
  9. package/package.json +2 -2
  10. package/src/index.js +2 -2
  11. package/src/v7/common/deriveColumnsFromData.js +20 -0
  12. package/src/v7/index.js +47 -0
  13. package/src/v7/meta.js +6 -0
  14. package/src/v7/registerGlobal.js +14 -0
  15. package/src/v7/select/index.js +21 -0
  16. package/src/v7/select/options/index.js +17 -0
  17. package/src/v7/select/options/skeleton.json +17 -0
  18. package/src/v7/select/skeleton.json +7 -0
  19. package/src/v7/table/body/cells/index.js +23 -0
  20. package/src/v7/table/body/cells/skeleton.json +17 -0
  21. package/src/v7/table/body/index.js +15 -0
  22. package/src/v7/table/body/rows/index.js +36 -0
  23. package/src/v7/table/body/rows/skeleton.json +4 -0
  24. package/src/v7/table/body/skeleton.json +4 -0
  25. package/src/v7/table/head/cells/index.js +23 -0
  26. package/src/v7/table/head/cells/skeleton.json +17 -0
  27. package/src/v7/table/head/index.js +15 -0
  28. package/src/v7/table/head/row/index.js +15 -0
  29. package/src/v7/table/head/row/skeleton.json +4 -0
  30. package/src/v7/table/head/skeleton.json +4 -0
  31. package/src/v7/table/index.js +26 -0
  32. package/src/v7/table/skeleton.json +7 -0
  33. package/src/v8/common/deriveColumnsFromData.js +20 -0
  34. package/src/v8/index.js +40 -0
  35. package/src/v8/meta.js +6 -0
  36. package/src/v8/registerGlobal.js +14 -0
  37. package/src/v8/select/index.js +21 -0
  38. package/src/v8/select/options/index.js +17 -0
  39. package/src/v8/select/options/skeleton.json +17 -0
  40. package/src/v8/select/skeleton.json +7 -0
  41. package/src/v8/table/body/cells/index.js +17 -0
  42. package/src/v8/table/body/cells/skeleton.json +17 -0
  43. package/src/v8/table/body/index.js +20 -0
  44. package/src/v8/table/body/rows/index.js +23 -0
  45. package/src/v8/table/body/rows/skeleton.json +4 -0
  46. package/src/v8/table/body/skeleton.json +4 -0
  47. package/src/v8/table/head/cells/index.js +17 -0
  48. package/src/v8/table/head/cells/skeleton.json +17 -0
  49. package/src/v8/table/head/index.js +15 -0
  50. package/src/v8/table/head/row/index.js +15 -0
  51. package/src/v8/table/head/row/skeleton.json +4 -0
  52. package/src/v8/table/head/skeleton.json +4 -0
  53. package/src/v8/table/index.js +26 -0
  54. package/src/v8/table/skeleton.json +7 -0
  55. package/src/v9/common/deriveColumnsFromData.js +20 -0
  56. package/src/v9/index.js +36 -0
  57. package/src/v9/meta.js +6 -0
  58. package/src/v9/registerGlobal.js +14 -0
  59. package/src/v9/select/index.js +21 -0
  60. package/src/v9/select/options/index.js +17 -0
  61. package/src/v9/select/options/skeleton.json +17 -0
  62. package/src/v9/select/skeleton.json +7 -0
  63. package/src/v9/table/footer/empty/cell/index.js +5 -0
  64. package/src/v9/table/footer/empty/cell/tag.json +6 -0
  65. package/src/v9/table/footer/empty/index.js +6 -0
  66. package/src/v9/table/footer/empty/row/index.js +10 -0
  67. package/src/v9/table/footer/empty/row/tag.json +7 -0
  68. package/src/v9/table/footer/index.js +28 -0
  69. package/src/v9/table/footer/inputs/cell/index.js +15 -0
  70. package/src/v9/table/footer/inputs/cell/tag.json +7 -0
  71. package/src/v9/table/footer/inputs/index.js +6 -0
  72. package/src/v9/table/footer/inputs/input/tag.json +9 -0
  73. package/src/v9/table/footer/inputs/row/index.js +10 -0
  74. package/src/v9/table/footer/inputs/row/tag.json +7 -0
  75. package/src/v9/table/footer/inputsWithSave/button/tag.json +8 -0
  76. package/src/v9/table/footer/inputsWithSave/cell/index.js +20 -0
  77. package/src/v9/table/footer/inputsWithSave/cell/tag.json +7 -0
  78. package/src/v9/table/footer/inputsWithSave/index.js +6 -0
  79. package/src/v9/table/footer/inputsWithSave/input/tag.json +9 -0
  80. package/src/v9/table/footer/inputsWithSave/row/index.js +13 -0
  81. package/src/v9/table/footer/inputsWithSave/row/tag.json +7 -0
  82. package/src/v9/table/footer/tag.json +7 -0
  83. package/src/v9/table/footer/totals/cell/index.js +21 -0
  84. package/src/v9/table/footer/totals/cell/tag.json +7 -0
  85. package/src/v9/table/footer/totals/index.js +6 -0
  86. package/src/v9/table/footer/totals/row/index.js +12 -0
  87. package/src/v9/table/footer/totals/row/tag.json +7 -0
  88. package/src/v9/table/index.js +33 -0
  89. package/src/v9/table/options/index.js +18 -0
  90. package/src/v9/table/options/showOptions/index.js +39 -0
  91. package/src/v9/table/options/showSerial/index.js +19 -0
  92. package/src/v9/table/render-requests.json +107 -0
  93. package/src/v9/table/table/body/cell/index.js +12 -0
  94. package/src/v9/table/table/body/cell/tag.json +7 -0
  95. package/src/v9/table/table/body/index.js +17 -0
  96. package/src/v9/table/table/body/row/index.js +18 -0
  97. package/src/v9/table/table/body/row/tag.json +4 -0
  98. package/src/v9/table/table/body/tag.json +4 -0
  99. package/src/v9/table/table/head/cell/index.js +12 -0
  100. package/src/v9/table/table/head/cell/tag.json +7 -0
  101. package/src/v9/table/table/head/index.js +16 -0
  102. package/src/v9/table/table/head/row/index.js +14 -0
  103. package/src/v9/table/table/head/row/tag.json +4 -0
  104. package/src/v9/table/table/head/tag.json +4 -0
  105. package/src/v9/table/table/index.js +36 -0
  106. package/src/v9/table/table/tag.json +7 -0
  107. package/src/v9/table_10oct/body/cells/index.js +17 -0
  108. package/src/v9/table_10oct/body/cells/skeleton.json +17 -0
  109. package/src/v9/table_10oct/body/index.js +20 -0
  110. package/src/v9/table_10oct/body/rows/index.js +23 -0
  111. package/src/v9/table_10oct/body/rows/skeleton.json +4 -0
  112. package/src/v9/table_10oct/body/skeleton.json +4 -0
  113. package/src/v9/table_10oct/head/cells/index.js +17 -0
  114. package/src/v9/table_10oct/head/cells/skeleton.json +17 -0
  115. package/src/v9/table_10oct/head/index.js +15 -0
  116. package/src/v9/table_10oct/head/row/index.js +15 -0
  117. package/src/v9/table_10oct/head/row/skeleton.json +4 -0
  118. package/src/v9/table_10oct/head/skeleton.json +4 -0
  119. package/src/v9/table_10oct/index.js +26 -0
  120. package/src/v9/table_10oct/skeleton.json +7 -0
@@ -0,0 +1,587 @@
1
+ const $ = {
2
+ version: "v9.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, N = (t) => {
5
+ var e;
6
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
7
+ meta: $,
8
+ renderToDom: t
9
+ }));
10
+ }, C = "table", S = {
11
+ class: "table table-hover table-striped mb-0"
12
+ }, x = [], A = {
13
+ tagName: C,
14
+ attributes: S,
15
+ children: x
16
+ }, E = "thead", w = [], U = {
17
+ tagName: E,
18
+ children: w
19
+ }, v = "tr", T = [], J = {
20
+ tagName: v,
21
+ children: T
22
+ }, W = "th", R = {
23
+ value: ""
24
+ }, k = "", F = {
25
+ tagName: W,
26
+ attributes: R,
27
+ textContent: k
28
+ }, O = ({ inColumn: t } = {}) => {
29
+ const e = structuredClone(F);
30
+ return e.attributes.value = t, e.textContent = t, e;
31
+ }, D = ({ inColumns: t = [] } = {}) => {
32
+ const e = structuredClone(J), n = t.map((o) => O({ inColumn: o }));
33
+ return e.children = n, e;
34
+ }, B = ({ inColumns: t = [] } = {}) => {
35
+ const e = structuredClone(U), n = [
36
+ D({ inColumns: t })
37
+ ];
38
+ return e.children = n, e;
39
+ }, j = "tbody", V = [], I = {
40
+ tagName: j,
41
+ children: V
42
+ }, H = "tr", K = [], M = {
43
+ tagName: H,
44
+ children: K
45
+ }, q = "td", G = {
46
+ value: ""
47
+ }, L = "", P = {
48
+ tagName: q,
49
+ attributes: G,
50
+ textContent: L
51
+ }, _ = ({ inValue: t } = {}) => {
52
+ const e = structuredClone(P);
53
+ return e.attributes.value = t, e.textContent = t, e;
54
+ }, z = ({ inRow: t, inColumns: e = [] } = {}) => {
55
+ const n = structuredClone(M), o = e.map((a) => {
56
+ const s = Array.isArray(t) ? t[a] : t == null ? void 0 : t[a];
57
+ return _({ inValue: s });
58
+ });
59
+ return n.children = o, n;
60
+ }, Q = ({ inData: t = [], inColumns: e = [] } = {}) => {
61
+ const n = structuredClone(I), o = t.map((a) => z({
62
+ inRow: a,
63
+ inColumns: e
64
+ }));
65
+ return n.children = o, n;
66
+ }, X = "tfoot", Y = {
67
+ class: "table-light"
68
+ }, Z = [], tt = {
69
+ tagName: X,
70
+ attributes: Y,
71
+ children: Z
72
+ }, et = "tr", nt = {
73
+ class: "align-middle"
74
+ }, ot = [], at = {
75
+ tagName: et,
76
+ attributes: nt,
77
+ children: ot
78
+ }, st = "td", rt = {
79
+ class: "align-middle py-2"
80
+ }, ct = [], lt = {
81
+ tagName: st,
82
+ attributes: rt,
83
+ children: ct
84
+ }, it = "input", ut = {
85
+ type: "text",
86
+ name: "",
87
+ placeholder: "",
88
+ class: "form-control form-control-sm"
89
+ }, dt = {
90
+ tagName: it,
91
+ attributes: ut
92
+ }, mt = ({ inColumn: t } = {}) => {
93
+ const e = structuredClone(lt), n = structuredClone(dt);
94
+ return n.attributes.name = t, n.attributes.placeholder = t, e.children.push(n), e;
95
+ }, bt = ({ inColumns: t = [] } = {}) => {
96
+ const e = structuredClone(at);
97
+ return e.children = t.map((n) => mt({ inColumn: n })), e;
98
+ }, pt = ({ inColumns: t = [] } = {}) => bt({ inColumns: t }), ht = "tr", gt = {
99
+ class: "align-middle"
100
+ }, yt = [], ft = {
101
+ tagName: ht,
102
+ attributes: gt,
103
+ children: yt
104
+ }, $t = "td", Nt = {
105
+ class: "align-middle py-2"
106
+ }, Ct = [], St = {
107
+ tagName: $t,
108
+ attributes: Nt,
109
+ children: Ct
110
+ }, xt = "input", At = {
111
+ type: "text",
112
+ name: "",
113
+ placeholder: "",
114
+ class: "form-control form-control-sm"
115
+ }, Et = {
116
+ tagName: xt,
117
+ attributes: At
118
+ }, wt = "button", Ut = {
119
+ type: "button",
120
+ class: "btn btn-primary btn-sm ms-2"
121
+ }, vt = "Save", Tt = {
122
+ tagName: wt,
123
+ attributes: Ut,
124
+ textContent: vt
125
+ }, Jt = ({ inColumn: t, inSave: e = !1 } = {}) => {
126
+ const n = structuredClone(St), o = structuredClone(Et);
127
+ return o.attributes.name = t, o.attributes.placeholder = t, n.children.push(o), e && n.children.push(structuredClone(Tt)), n;
128
+ }, Wt = ({ inColumns: t = [] } = {}) => {
129
+ const e = structuredClone(ft);
130
+ return e.children = t.map((n, o) => Jt({
131
+ inColumn: n,
132
+ inSave: o === t.length - 1
133
+ })), e;
134
+ }, Rt = ({ inColumns: t = [] } = {}) => Wt({ inColumns: t }), kt = "tr", Ft = {
135
+ class: "fw-semibold align-middle"
136
+ }, Ot = [], Dt = {
137
+ tagName: kt,
138
+ attributes: Ft,
139
+ children: Ot
140
+ }, Bt = "td", jt = {
141
+ class: "align-middle py-2"
142
+ }, Vt = "", It = {
143
+ tagName: Bt,
144
+ attributes: jt,
145
+ textContent: Vt
146
+ }, Ht = (t, e) => Array.isArray(t) ? t[e] : t == null ? void 0 : t[e], Kt = ({ inColumn: t, inIndex: e, inData: n = [] } = {}) => {
147
+ const o = structuredClone(It), a = n.map((s) => Ht(s, t)).filter((s) => s != null && String(s).trim() !== "").map(Number).filter(Number.isFinite);
148
+ return o.textContent = a.length ? String(a.reduce((s, r) => s + r, 0)) : e === 0 ? "Total" : "", o;
149
+ }, Mt = ({ inColumns: t = [], inData: e = [] } = {}) => {
150
+ const n = structuredClone(Dt);
151
+ return n.children = t.map(
152
+ (o, a) => Kt({ inColumn: o, inIndex: a, inData: e })
153
+ ), n;
154
+ }, qt = ({ inColumns: t = [], inData: e = [] } = {}) => Mt({ inColumns: t, inData: e }), Gt = "tr", Lt = {
155
+ class: "align-middle"
156
+ }, Pt = [], _t = {
157
+ tagName: Gt,
158
+ attributes: Lt,
159
+ children: Pt
160
+ }, zt = "td", Qt = {
161
+ class: "align-middle py-2"
162
+ }, Xt = {
163
+ tagName: zt,
164
+ attributes: Qt
165
+ }, Yt = () => structuredClone(Xt), Zt = ({ inColumns: t = [] } = {}) => {
166
+ const e = structuredClone(_t);
167
+ return e.children = t.map(() => Yt()), e;
168
+ }, te = ({ inColumns: t = [] } = {}) => Zt({ inColumns: t }), b = {
169
+ inputs: pt,
170
+ inputsWithSave: Rt,
171
+ totals: qt,
172
+ empty: te
173
+ }, ee = ({ inFooter: t = [], inColumns: e = [], inData: n = [] } = {}) => {
174
+ const o = structuredClone(tt);
175
+ return o.children = t.map((a) => {
176
+ if (!Object.hasOwn(b, a))
177
+ throw new Error(`Unknown footer "${a}".`);
178
+ return b[a]({ inColumns: e, inData: n });
179
+ }), o;
180
+ }, ne = ({
181
+ inColumns: t = [],
182
+ inData: e = [],
183
+ inFooter: n = []
184
+ } = {}) => {
185
+ const o = structuredClone(A), a = [
186
+ B({ inColumns: t }),
187
+ Q({ inData: e, inColumns: t })
188
+ ];
189
+ if (!Array.isArray(n))
190
+ throw new TypeError("The footer property must be an array of footer names.");
191
+ return n.length > 0 && a.push(ee({
192
+ inFooter: n,
193
+ inColumns: t,
194
+ inData: e
195
+ })), o.children = a, o;
196
+ }, oe = (t) => {
197
+ const [e, n] = t.children;
198
+ e.children[0].children.unshift({
199
+ tagName: "th",
200
+ textContent: "#"
201
+ }), n.children.forEach((o, a) => {
202
+ o.children.unshift({
203
+ tagName: "td",
204
+ textContent: String(a + 1)
205
+ });
206
+ });
207
+ }, ae = (t) => t === !0 ? [{ label: "Apply", type: "button" }] : Array.isArray(t) ? t : [], se = (t, e) => {
208
+ const n = ae(e);
209
+ if (n.length === 0) return;
210
+ const [o, a] = t.children;
211
+ o.children[0].children.push({
212
+ tagName: "th",
213
+ textContent: "Actions"
214
+ }), a.children.forEach((s) => {
215
+ s.children.push({
216
+ tagName: "td",
217
+ children: n.map((r) => ({
218
+ tagName: "button",
219
+ attributes: { type: r.type || "button" },
220
+ textContent: r.label
221
+ }))
222
+ });
223
+ });
224
+ }, re = (t, e = {}) => (e.showSerial && oe(t), e.showOptions && se(t, e.showOptions), t), ce = {
225
+ type: "table",
226
+ data: [
227
+ {
228
+ itemName: "0.09/30mm",
229
+ baseUnit: "kgs"
230
+ }
231
+ ],
232
+ columns: [
233
+ "itemName",
234
+ "baseUnit"
235
+ ],
236
+ options: {}
237
+ }, le = {
238
+ type: "table",
239
+ data: [
240
+ {
241
+ itemName: "0.09/30mm",
242
+ baseUnit: "kgs"
243
+ }
244
+ ],
245
+ columns: [
246
+ "itemName",
247
+ "baseUnit"
248
+ ],
249
+ options: {
250
+ showSerial: !0
251
+ }
252
+ }, ie = {
253
+ type: "table",
254
+ data: [
255
+ {
256
+ itemName: "0.09/30mm",
257
+ baseUnit: "kgs"
258
+ }
259
+ ],
260
+ columns: [
261
+ "itemName",
262
+ "baseUnit"
263
+ ],
264
+ options: {
265
+ showOptions: !0
266
+ }
267
+ }, ue = {
268
+ type: "table",
269
+ data: [
270
+ {
271
+ itemName: "0.09/30mm",
272
+ baseUnit: "kgs"
273
+ }
274
+ ],
275
+ columns: [
276
+ "itemName",
277
+ "baseUnit"
278
+ ],
279
+ options: {
280
+ showOptions: [
281
+ {
282
+ label: "Show",
283
+ type: "button"
284
+ },
285
+ {
286
+ label: "Edit",
287
+ type: "button"
288
+ }
289
+ ]
290
+ }
291
+ }, de = {
292
+ type: "table",
293
+ data: [
294
+ {
295
+ itemName: "0.09/30mm",
296
+ baseUnit: "kgs"
297
+ }
298
+ ],
299
+ columns: [
300
+ "itemName",
301
+ "baseUnit"
302
+ ],
303
+ options: {
304
+ showSerial: !0,
305
+ showOptions: [
306
+ {
307
+ label: "Show",
308
+ type: "button"
309
+ }
310
+ ]
311
+ }
312
+ }, me = {
313
+ type: "table",
314
+ data: [
315
+ {
316
+ itemName: "0.09/30mm",
317
+ baseUnit: "kgs"
318
+ }
319
+ ],
320
+ columns: [
321
+ "itemName",
322
+ "baseUnit"
323
+ ],
324
+ footer: [
325
+ "inputs"
326
+ ],
327
+ options: {}
328
+ }, be = {
329
+ type: "table",
330
+ data: [
331
+ {
332
+ itemName: "0.09/30mm",
333
+ baseUnit: "kgs"
334
+ }
335
+ ],
336
+ columns: [
337
+ "itemName",
338
+ "baseUnit"
339
+ ],
340
+ footer: [
341
+ "inputsWithSave"
342
+ ],
343
+ options: {}
344
+ }, pe = {
345
+ type: "table",
346
+ data: [
347
+ {
348
+ itemName: "0.09/30mm",
349
+ baseUnit: "2"
350
+ },
351
+ {
352
+ itemName: "0.11-25",
353
+ baseUnit: "3"
354
+ }
355
+ ],
356
+ columns: [
357
+ "itemName",
358
+ "baseUnit"
359
+ ],
360
+ footer: [
361
+ "totals"
362
+ ],
363
+ options: {}
364
+ }, he = {
365
+ type: "table",
366
+ data: [
367
+ {
368
+ itemName: "0.09/30mm",
369
+ baseUnit: "2"
370
+ }
371
+ ],
372
+ columns: [
373
+ "itemName",
374
+ "baseUnit"
375
+ ],
376
+ footer: [
377
+ "inputs",
378
+ "totals",
379
+ "inputsWithSave",
380
+ "empty"
381
+ ],
382
+ options: {}
383
+ }, ge = {
384
+ type: "tableHead",
385
+ data: [],
386
+ columns: [
387
+ "itemName",
388
+ "baseUnit"
389
+ ],
390
+ options: {}
391
+ }, ye = {
392
+ type: "tableBody",
393
+ data: [
394
+ {
395
+ itemName: "0.09/30mm",
396
+ baseUnit: "kgs"
397
+ }
398
+ ],
399
+ columns: [
400
+ "itemName",
401
+ "baseUnit"
402
+ ],
403
+ options: {}
404
+ }, fe = {
405
+ table: ce,
406
+ tableWithSerial: le,
407
+ tableWithDefaultAction: ie,
408
+ tableWithCustomActions: ue,
409
+ tableWithSerialAndActions: de,
410
+ tableWithFooter: me,
411
+ tableWithFooterSave: be,
412
+ tableWithTotals: pe,
413
+ tableWithMultipleFooters: he,
414
+ tableHead: ge,
415
+ tableBody: ye
416
+ }, p = ({
417
+ type: t = "table",
418
+ inData: e,
419
+ inColumns: n,
420
+ footer: o = [],
421
+ options: a = {}
422
+ } = {}) => {
423
+ if (t === "table") {
424
+ const s = ne({
425
+ inColumns: n,
426
+ inData: e,
427
+ inFooter: o
428
+ });
429
+ return re(s, a);
430
+ }
431
+ throw new Error(`Unknown table renderer type "${t}".`);
432
+ };
433
+ p.requests = fe;
434
+ const h = ({ inItems: t, inRecipe: e, inExecute: n }) => {
435
+ const o = t, a = e, s = n;
436
+ return o.map((r) => m({
437
+ inSource: r,
438
+ inRecipe: a,
439
+ inExecute: s
440
+ })).flat(1 / 0).filter(Boolean);
441
+ }, $e = ({ inSource: t, inRecipe: e, inExecute: n }) => {
442
+ const o = t, a = e, s = n;
443
+ let r = o;
444
+ typeof s == "function" && (r = s({
445
+ inSource: o,
446
+ inRecipe: a
447
+ }));
448
+ for (const [c, u] of Object.entries(r))
449
+ Array.isArray(u) && a && c in a && (r[c] = h({
450
+ inItems: u,
451
+ inRecipe: a[c],
452
+ inExecute: s
453
+ }));
454
+ return r;
455
+ }, m = ({ inSource: t, inRecipe: e, inExecute: n }) => {
456
+ const o = t, a = e, s = n;
457
+ return Array.isArray(o) ? h({
458
+ inItems: o,
459
+ inRecipe: a,
460
+ inExecute: s
461
+ }) : typeof o == "object" && o !== null ? $e({
462
+ inSource: o,
463
+ inRecipe: a,
464
+ inExecute: s
465
+ }) : o;
466
+ }, Ne = ({ inKey: t, inDirective: e }) => {
467
+ const n = t, o = e;
468
+ return (o == null ? void 0 : o.alterKey) || n;
469
+ }, Ce = ({ inValue: t, inDirective: e, inExecute: n }) => {
470
+ const o = t, a = e, s = n;
471
+ return a && "transform" in a ? m({
472
+ inSource: o,
473
+ inRecipe: a,
474
+ inExecute: s
475
+ }) : o;
476
+ }, Se = ({ inValue: t, inDirective: e }) => {
477
+ const n = t, o = e;
478
+ return (o == null ? void 0 : o.valueType) === "array" && !Array.isArray(n) ? [n] : n;
479
+ }, xe = ({ inValue: t, inDirective: e }) => {
480
+ const n = t, o = e;
481
+ return o != null && o.valueKey && n && typeof n == "object" ? n[o.valueKey] : n;
482
+ }, Ae = ({ inSource: t, inTransform: e, inExecute: n }) => {
483
+ const o = t, a = e, s = n, r = {};
484
+ for (const [c, u] of Object.entries(o)) {
485
+ if (!(c in a))
486
+ continue;
487
+ const l = a[c], f = Ne({ inKey: c, inDirective: l });
488
+ let i = u;
489
+ i = Ce({
490
+ inValue: i,
491
+ inDirective: l,
492
+ inExecute: s
493
+ }), i = Se({ inValue: i, inDirective: l }), i = xe({ inValue: i, inDirective: l }), r[f] = i;
494
+ }
495
+ return r;
496
+ };
497
+ function g(t, e) {
498
+ for (const n in t)
499
+ typeof t[n] == "object" && t[n] !== null ? g(t[n], e) : typeof t[n] == "string" && t[n] === "${}" && (t[n] = e);
500
+ return t;
501
+ }
502
+ const Ee = ({ inSource: t, inOperation: e, inExecute: n }) => {
503
+ const o = t, a = e;
504
+ for (const [s, r] of Object.entries(a))
505
+ if ("operationType" in r && r.operationType === "loopArray" && s in o) {
506
+ const c = o[s].map((u) => {
507
+ const l = structuredClone(r == null ? void 0 : r.template);
508
+ return g(l, u), l;
509
+ });
510
+ o[s] = c;
511
+ }
512
+ return o;
513
+ }, d = ({ inSource: t, inRecipe: e }) => {
514
+ let n = t;
515
+ const o = e;
516
+ return o && typeof o == "object" && "transform" in o && (n = Ae({
517
+ inSource: n,
518
+ inTransform: o.transform,
519
+ inExecute: d
520
+ })), o && typeof o == "object" && "operation" in o && (n = Ee({
521
+ inSource: n,
522
+ inOperation: o.operation,
523
+ inExecute: d
524
+ })), n;
525
+ }, we = (t, e) => m({
526
+ inSource: t,
527
+ inRecipe: e,
528
+ inExecute: d
529
+ }), Ue = {
530
+ children: ""
531
+ }, ve = {
532
+ children: {
533
+ operationType: "loopArray",
534
+ template: {
535
+ tagName: "option",
536
+ attributes: {
537
+ value: "${}"
538
+ },
539
+ textContent: "${}"
540
+ }
541
+ }
542
+ }, Te = {
543
+ transform: Ue,
544
+ operation: ve
545
+ }, y = ({
546
+ inData: t
547
+ }) => {
548
+ let n = we({
549
+ children: t
550
+ }, Te);
551
+ return n == null ? void 0 : n.children;
552
+ }, Je = "select", We = {
553
+ id: "LedgerName"
554
+ }, Re = [], ke = {
555
+ tagName: Je,
556
+ attributes: We,
557
+ children: Re
558
+ }, Fe = ({
559
+ inData: t
560
+ }) => {
561
+ let n = y({
562
+ inData: t
563
+ });
564
+ const o = structuredClone(ke);
565
+ return o.children = n, o;
566
+ }, Oe = {
567
+ table: p,
568
+ select: Fe,
569
+ selectOptionsOnly: y
570
+ }, De = ({
571
+ type: t = "table",
572
+ data: e,
573
+ columns: n
574
+ }) => {
575
+ const a = Oe[t];
576
+ return a({
577
+ inColumns: n,
578
+ inData: e
579
+ });
580
+ };
581
+ N(De);
582
+ export {
583
+ De as default,
584
+ Fe as renderSelect,
585
+ y as renderSelectOptions,
586
+ p as renderTable
587
+ };
package/docs/index.html CHANGED
@@ -111,8 +111,8 @@
111
111
  Build Declarative UI Specifications <br class="hidden sm:inline" />
112
112
  <span class="text-transparent bg-clip-text bg-gradient-to-r from-indigo-400 via-purple-300 to-pink-400">Headless, Pure, and Config-Driven</span>
113
113
  </h2>
114
- <p class="max-w-3xl mx-auto text-slate-400 text-sm sm:text-base leading-relaxed">
115
- <strong class="text-slate-200">json-renderers-build</strong> transforms raw data arrays and column definitions into comprehensive DOM specification ASTs (<code class="text-indigo-300 font-mono">specAsJsonToDom</code>). It decouples UI structure generation from DOM rendering, letting downstream runtimes like <code class="text-indigo-300 font-mono">json-renderers</code> handle the DOM mounting.
114
+ <p class="max-w-4xl mx-auto text-slate-400 text-sm sm:text-base leading-relaxed">
115
+ <strong class="text-slate-200">json-renderers-build</strong> transforms raw data arrays and column definitions into a pure DOM specification AST (<code class="text-indigo-300 font-mono">specAsJsonToDom</code>). This repo does not live in the browser DOM layer. It is the headless spec generator, while the actual DOM creation is handled by <code class="text-emerald-300 font-mono">@keshavsoft/json-to-tag</code> and the runtime mount step is performed by <code class="text-indigo-300 font-mono">json-renderers</code>.
116
116
  </p>
117
117
 
118
118
  <div class="flex flex-wrap items-center justify-center gap-3 pt-2">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-renderers-build",
3
- "version": "1.6.1",
3
+ "version": "1.9.1",
4
4
  "description": "Headless component specification builder for json-renderers, compiling UI skeletons and data into JSON-to-DOM specs using json-to-spec",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -41,7 +41,7 @@
41
41
  "vite": "^5.4.2"
42
42
  },
43
43
  "dependencies": {
44
- "@keshavsoft/json-transformer": "^1.13.2",
44
+ "@keshavsoft/json-transformer": "^1.14.0",
45
45
  "json-to-spec": "^32.1.3"
46
46
  }
47
47
  }
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./v6/index.js";
2
- export { default } from "./v6/index.js";
1
+ export * from "./v8/index.js";
2
+ export { default } from "./v8/index.js";
@@ -0,0 +1,20 @@
1
+ const deriveColumnsFromData = ({ inData = [] } = {}) => {
2
+ const localData = inData;
3
+
4
+ if (!Array.isArray(localData) || localData.length === 0) {
5
+ return [];
6
+ }
7
+
8
+ const firstRow = localData[0];
9
+ if (!firstRow || typeof firstRow !== "object") {
10
+ return [];
11
+ }
12
+
13
+ return Object.keys(firstRow).map(key => ({
14
+ key,
15
+ label: key
16
+ }));
17
+ };
18
+
19
+ export { deriveColumnsFromData };
20
+ export default deriveColumnsFromData;
@@ -0,0 +1,47 @@
1
+ import registerGlobal from "./registerGlobal.js";
2
+
3
+ import renderTable, { renderTableHead, renderTableBody } from "./table/index.js";
4
+ import renderSelect, { renderSelectOptions } from "./select/index.js";
5
+
6
+ const RENDERER_MAP = {
7
+ table: renderTable,
8
+ select: renderSelect,
9
+ selectOptionsOnly: renderSelectOptions,
10
+ tableHead: renderTableHead,
11
+ tableBody: renderTableBody
12
+ };
13
+
14
+ const render = ({
15
+ type = "table",
16
+ data,
17
+ columns
18
+ } = {}) => {
19
+ const rawType = type;
20
+ const renderer = RENDERER_MAP[rawType];
21
+
22
+ if (!renderer) {
23
+ console.error(
24
+ `[Renderer] Unknown renderer type "${rawType}". Available types: ${Object.keys(RENDERER_MAP).join(", ")}`
25
+ );
26
+ return null;
27
+ }
28
+
29
+ const localData = data;
30
+ const localColumns = columns;
31
+
32
+ return renderer({
33
+ inColumns: localColumns,
34
+ inData: localData
35
+ });
36
+ };
37
+
38
+ registerGlobal(render);
39
+
40
+ export {
41
+ renderTable,
42
+ renderTableHead,
43
+ renderTableBody,
44
+ renderSelect,
45
+ renderSelectOptions
46
+ };
47
+ export default render;
package/src/v7/meta.js ADDED
@@ -0,0 +1,6 @@
1
+ export const meta = {
2
+ version: "v4.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ };
5
+
6
+ export default meta;
@@ -0,0 +1,14 @@
1
+ import meta from "./meta.js";
2
+
3
+ export const registerGlobal = (inFuncDefinition) => {
4
+ if (typeof globalThis === "undefined" || !inFuncDefinition) return;
5
+
6
+ globalThis.ks ??= {};
7
+
8
+ globalThis.ks.jsonRenderersBuild ??= {
9
+ meta,
10
+ renderToDom: inFuncDefinition
11
+ };
12
+ };
13
+
14
+ export default registerGlobal;