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 CHANGED
@@ -1,1047 +1,1352 @@
1
- const q = {
2
- version: "v17.0.0",
3
- description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
- }, _ = (e) => {
5
- const t = e;
6
- if (typeof globalThis > "u" || !t) return;
7
- globalThis.ks ?? (globalThis.ks = {});
8
- const o = typeof t == "function" ? t : t.render, n = typeof t == "object" ? t.getSpec : void 0;
9
- globalThis.ks.jsonRenderers = {
10
- meta: q,
11
- ...typeof t == "object" ? t : {},
12
- render: o,
13
- renderToDom: o,
14
- domMount: t == null ? void 0 : t.renderToDom,
15
- ...n ? { getSpec: n } : {}
16
- };
17
- }, J = "table", Y = "", U = [], X = [], Q = "", W = "replace", Z = !1, b = {
18
- type: J,
19
- targetHtmlId: Y,
20
- data: U,
21
- columns: X,
22
- classToApply: Q,
23
- appendPosition: W,
24
- showLog: Z
25
- }, tt = ({ inConfig: e } = {}) => {
26
- const t = e;
27
- if (!t || typeof t != "object")
28
- throw console.error("Config must be an object"), new TypeError("Config must be an object");
29
- for (const o of Object.keys(b)) {
30
- if (!(o in t) || t[o] === void 0)
31
- throw console.error(`Missing compulsory key: "${o}"`), new Error(`Missing compulsory key: "${o}"`);
32
- if (Array.isArray(b[o])) {
33
- if (!Array.isArray(t[o]))
34
- throw console.error(`${o} must be an Array`), new TypeError(`${o} must be an Array`);
35
- } else if (typeof t[o] != typeof b[o])
36
- throw console.error(`${o} must be of type ${typeof b[o]}`), new TypeError(`${o} must be of type ${typeof b[o]}`);
37
- }
38
- if (typeof t.targetHtmlId == "string" && !t.targetHtmlId.trim())
39
- throw console.error("targetHtmlId must be a non-empty string"), new TypeError("targetHtmlId must be a non-empty string");
40
- return !0;
41
- }, O = ({
42
- type: e = "table",
43
- targetHtmlId: t,
44
- data: o,
45
- columns: n,
46
- classToApply: a = "",
47
- appendPosition: r = "replace",
48
- showLog: s = !1
49
- } = {}) => {
50
- const y = {
51
- type: e,
52
- targetHtmlId: t,
53
- data: o,
54
- columns: n,
55
- classToApply: a,
56
- appendPosition: r,
57
- showLog: s
58
- };
59
- return tt({ inConfig: y }), y;
60
- }, P = () => ({ ...b });
61
- Object.assign(P, b);
62
- const et = {
63
- version: "1.15.0",
64
- name: "json-renderers-build"
65
- }, ot = (e) => {
66
- const t = e;
67
- if (typeof globalThis > "u" || !t) return;
68
- globalThis.ks ?? (globalThis.ks = {});
69
- const o = typeof t == "function" ? t : t.render, n = typeof t == "object" ? t.getSpec : void 0;
70
- globalThis.ks.jsonRenderersBuild = {
71
- meta: et,
72
- renderToDom: o,
73
- render: o,
74
- ...n ? { getSpec: n } : {},
75
- ...typeof t == "object" ? t : {}
76
- };
77
- }, N = ["table", "tableFromSpec", "select", "selectOptionsOnly", "dataList", "datalist"], nt = ["table", "tableFromSpec"], F = ({ inConfig: e } = {}) => {
78
- const t = e;
79
- if (!t || typeof t != "object")
80
- throw console.error("Config must be an object"), new TypeError("Config must be an object");
81
- if (typeof t.type != "string" || !N.includes(t.type))
82
- throw console.error(`type must be one of: ${N.join(", ")}`), new Error(`type must be one of: ${N.join(", ")}`);
83
- if (t.showLog !== void 0 && typeof t.showLog != "boolean")
84
- throw console.error("showLog must be a boolean"), new TypeError("showLog must be a boolean");
85
- if (!Array.isArray(t.data))
86
- throw console.error("data must be an Array"), new TypeError("data must be an Array");
87
- if (nt.includes(t.type)) {
88
- if (!Array.isArray(t.columns))
89
- throw console.error("columns must be an array for table rendering"), new TypeError("columns must be an array for table rendering");
90
- for (let o = 0; o < t.columns.length; o++) {
91
- const n = t.columns[o];
92
- if (!n || typeof n != "object")
93
- throw console.error(`columns[${o}] must be an object`), new TypeError(`columns[${o}] must be an object`);
94
- if (typeof n.columnName != "string" || !n.columnName.trim())
95
- throw console.error(`columns[${o}].columnName must be a non-empty string`), new TypeError(`columns[${o}].columnName must be a non-empty string`);
96
- }
97
- for (let o = 0; o < t.data.length; o++) {
98
- const n = t.data[o];
99
- if (!n || typeof n != "object")
100
- throw console.error(`data[${o}] must be an object`), new TypeError(`data[${o}] must be an object`);
101
- }
102
- if (t.columns.length > 0 && t.data.length > 0) {
103
- const o = t.columns.map((r) => r.columnName), n = Object.keys(t.data[0]);
104
- if (!o.some((r) => n.includes(r))) {
105
- const r = `Data alignment error: None of the columns [${o.join(", ")}] match any keys in data rows [${n.join(", ")}]`;
106
- throw console.error(r), new Error(r);
107
- }
108
- }
109
- }
110
- return !0;
111
- }, rt = "table", at = [], lt = [], st = {}, ct = !1, h = {
112
- type: rt,
113
- columns: at,
114
- data: lt,
115
- options: st,
116
- showLog: ct
117
- }, it = [
118
- {
119
- columnName: "Name",
120
- width: "150px"
121
- },
122
- {
123
- columnName: "Designation",
124
- width: "100px"
125
- }
126
- ], ut = [
127
- {
128
- Name: "Keshav",
129
- Designation: "Founder"
130
- }
131
- ], dt = {
132
- columns: it,
133
- data: ut
134
- }, f = {
135
- ...h,
136
- ...dt
137
- }, x = ({
138
- type: e = f.type,
139
- data: t = f.data,
140
- columns: o = f.columns,
141
- options: n = f.options,
142
- showLog: a = f.showLog
143
- } = {}) => {
144
- const l = {
145
- type: e,
146
- data: t,
147
- columns: o,
148
- options: n,
149
- showLog: a
150
- };
151
- return F({ inConfig: l }), l;
152
- };
153
- Object.assign(x, f);
154
- x.toJSON = () => structuredClone(f);
155
- const pt = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ft = (e, t) => {
156
- if (!pt(e)) return;
157
- let o = {};
158
- for (const [n, a] of Object.entries(e))
159
- o[n] = w(a, t);
160
- return o;
161
- }, bt = (e, t) => {
162
- const o = structuredClone(e);
163
- return Array.isArray(o) ? o.map((a) => w(t, a)) : void 0;
164
- }, k = (e, t, o) => {
165
- if (e === "${agg:count}" && "rowData" in t) {
166
- if (Array.isArray(t == null ? void 0 : t.rowData))
167
- return t == null ? void 0 : t.rowData.length;
168
- } else
169
- return e === "${rowValue}" && "rowData" in t ? t == null ? void 0 : t.rowData : e.replace(/\$\{(\w+)\}/g, (n, a) => t[a] !== void 0 ? t[a] : n);
170
- }, ht = (e, t) => k(e, t), mt = (e, t, o) => {
171
- if (e == null)
172
- throw new TypeError("inTemplate is required");
173
- if (typeof e != "object" && typeof e != "string")
174
- throw new TypeError("inTemplate must be an object or string");
175
- if (!t || typeof t != "object" || Array.isArray(t))
176
- throw new TypeError("inElement must be an object");
177
- return !0;
178
- }, w = (e, t, o) => {
179
- const n = e, a = t;
180
- mt(n, a);
181
- const r = structuredClone(a);
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
- }, gt = (e, t) => {
184
- if (!Array.isArray(e))
185
- throw new TypeError("inSource must be an Array");
186
- if (e.length === 0)
187
- throw new Error("inSource cannot be empty");
188
- for (let o = 0; o < e.length; o++)
189
- if (!e[o] || typeof e[o] != "object")
190
- throw new TypeError(`inSource[${o}] must be an object`);
191
- if (!t || typeof t != "object" && typeof t != "string")
192
- throw new TypeError("inTemplate must be an object or string");
193
- return !0;
194
- }, C = (e, t) => {
195
- const o = e, n = t;
196
- return gt(o, n), o.map((a) => w(a, n));
197
- }, wt = (e, t) => e.map((n) => ({
198
- ...n,
199
- rowData: t[n.columnName]
200
- })), yt = (e, t, o) => {
201
- var a, r, s, c, i, u;
202
- if (!Array.isArray(e))
203
- throw new TypeError("inColumns must be an Array");
204
- if (e.length === 0)
205
- throw new Error("inColumns cannot be empty");
206
- for (let l = 0; l < e.length; l++) {
207
- const d = e[l];
208
- if (!d || typeof d != "object")
209
- throw new TypeError(`inColumns[${l}] must be an object`);
210
- if (typeof d.columnName != "string" || !d.columnName.trim())
211
- throw new TypeError(`inColumns[${l}].columnName must be a non-empty string`);
212
- }
213
- if (!Array.isArray(t))
214
- throw new TypeError("inData must be an Array");
215
- for (let l = 0; l < t.length; l++) {
216
- const d = t[l];
217
- if (!d || typeof d != "object")
218
- throw new TypeError(`inData[${l}] must be an object`);
219
- }
220
- if (!o || typeof o != "object" || Array.isArray(o))
221
- throw new TypeError("inSpec must be an object");
222
- const n = ((s = (r = (a = e[0]) == null ? void 0 : a.template) == null ? void 0 : r.body) == null ? void 0 : s.tr) || "buildBodyTr";
223
- if (!(n in o))
224
- throw new Error(`Row template "${n}" not found in inSpec`);
225
- for (let l = 0; l < e.length; l++) {
226
- const d = e[l], 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
- if (!(p in o))
228
- throw new Error(`Cell template "${p}" for column "${d.columnName}" not found in inSpec`);
229
- }
230
- return !0;
231
- }, Tt = (e, t) => e.map((n) => {
232
- var c, i, u;
233
- const a = ((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[a];
234
- return w(n, r);
235
- }), Ct = (e, t, o) => {
236
- var u, l, d;
237
- yt(e, t, o);
238
- const n = e, a = t, r = o, s = ((d = (l = (u = n[0]) == null ? void 0 : u.template) == null ? void 0 : l.body) == null ? void 0 : d.tr) || "buildBodyTr", c = r[s];
239
- return a.map((p) => {
240
- const A = w(p, c), y = wt(n, p), z = Tt(y, r);
241
- return A.children = z, A;
242
- });
243
- }, S = (e, t) => {
244
- var o;
245
- if (((o = e == null ? void 0 : e.attributes) == null ? void 0 : o["data-role"]) === t) return e;
246
- for (const n of (e == null ? void 0 : e.children) ?? []) {
247
- const a = S(n, t);
248
- if (a) return a;
249
- }
250
- return null;
251
- }, At = (e, t) => {
252
- const o = e[t.fileName], n = t.dataRole ? S(o, t.dataRole) : o;
253
- return (t.filePath ?? []).reduce((a, r) => a[r], n);
254
- }, Nt = {
255
- tagName: "tr",
256
- attributes: {
257
- class: "align-middle"
258
- },
259
- children: []
260
- }, $t = {
261
- tagName: "col",
262
- attributes: {
263
- width: "${width}"
264
- }
265
- }, xt = {
266
- tagName: "th",
267
- textContent: "${columnName}",
268
- attributes: {
269
- class: "py-3 px-3 fw-semibold text-uppercase small"
270
- }
271
- }, St = {
272
- tagName: "td",
273
- children: [
274
- {
275
- tagName: "input",
276
- attributes: {
277
- type: "text",
278
- placeholder: "enter ${columnName}",
279
- name: "${columnName}",
280
- class: "form-control"
281
- }
282
- }
283
- ]
284
- }, jt = {
285
- tagName: "td",
286
- textContent: "${rowValue}",
287
- attributes: {
288
- class: "py-3 px-3 text-secondary"
289
- }
290
- }, Lt = {
291
- tagName: "button",
292
- textContent: "${columnName}",
293
- attributes: {
294
- class: "btn btn-primary btn-sm"
295
- }
296
- }, Dt = {
297
- tagName: "td",
298
- attributes: {
299
- class: "py-2 px-3 text-center"
300
- },
301
- children: [
302
- {
303
- tagName: "button",
304
- textContent: "${agg:count}",
305
- attributes: {
306
- class: "btn btn-primary btn-sm"
307
- }
308
- }
309
- ]
310
- }, Et = {
311
- tagName: "option",
312
- textContent: "${rowValue}",
313
- attributes: {
314
- value: "${rowValue}"
315
- }
316
- }, Ot = {
317
- tagName: "select",
318
- attributes: {
319
- id: "LedgerName"
320
- },
321
- children: []
322
- }, Pt = {
323
- tagName: "datalist",
324
- attributes: {
325
- "data-name": "${columnName}"
326
- },
327
- children: []
328
- }, j = {
329
- buildBodyTr: Nt,
330
- buildColGroup: $t,
331
- buildHeader: xt,
332
- buildFooter: St,
333
- buildBodyCell: jt,
334
- button: Lt,
335
- buttonCell: Dt,
336
- buildOption: Et,
337
- buildSelect: Ot,
338
- buildDataList: Pt
339
- }, Ft = "table", kt = {
340
- class: "table table-hover table-striped align-middle border mb-0"
341
- }, It = [
342
- {
343
- tagName: "colgroup",
344
- attributes: {
345
- "data-role": "table-colgroup"
346
- },
347
- children: []
348
- },
349
- {
350
- tagName: "thead",
351
- attributes: {
352
- class: "table-dark",
353
- "data-role": "table-header"
354
- },
355
- children: [
356
- {
357
- tagName: "tr",
358
- attributes: {
359
- "data-role": "table-header-row"
360
- },
361
- children: []
362
- }
363
- ]
364
- },
365
- {
366
- tagName: "tbody",
367
- attributes: {
368
- "data-role": "table-body"
369
- },
370
- children: []
371
- },
372
- {
373
- tagName: "tfoot",
374
- attributes: {
375
- "data-role": "table-footer"
376
- },
377
- children: [
378
- {
379
- tagName: "tr",
380
- attributes: {
381
- "data-role": "table-footer-row"
382
- },
383
- children: []
384
- }
385
- ]
386
- }
387
- ], I = {
388
- tagName: Ft,
389
- attributes: kt,
390
- children: It
391
- }, Rt = [
392
- {
393
- narration: "Build the column widths for the table using the configured columns.",
394
- destinationPath: {
395
- fileName: "base",
396
- dataRole: "table-colgroup",
397
- filePath: [
398
- "children"
399
- ]
400
- },
401
- sourcePath: {
402
- fileName: "data",
403
- filePath: [
404
- "columns"
405
- ]
406
- },
407
- templateKey: "buildColGroup",
408
- func: "fromCollection"
409
- },
410
- {
411
- narration: "Build the header row for the table using the configured columns.",
412
- destinationPath: {
413
- fileName: "base",
414
- dataRole: "table-header-row",
415
- filePath: [
416
- "children"
417
- ]
418
- },
419
- sourcePath: {
420
- fileName: "data",
421
- filePath: [
422
- "columns"
423
- ]
424
- },
425
- templateKey: "buildHeader",
426
- func: "fromCollection"
427
- }
428
- ], vt = [
429
- {
430
- narration: "Build the table body rows for the table using the configured columns and data.",
431
- destinationPath: {
432
- fileName: "base",
433
- dataRole: "table-body",
434
- filePath: [
435
- "children"
436
- ]
437
- },
438
- sourcePath: {
439
- fileName: "data",
440
- filePath: [
441
- "columns"
442
- ]
443
- },
444
- func: "twoDimensional"
445
- }
446
- ], T = (e) => Array.isArray(e) ? e : [e], L = {
447
- set: (e, t, o) => {
448
- e[t] = o;
449
- },
450
- push: (e, t, o) => {
451
- e[t].push(...T(o));
452
- },
453
- unshift: (e, t, o) => {
454
- e[t].unshift(...T(o));
455
- },
456
- pushToRows: (e, t, o) => {
457
- e[t].forEach((n) => {
458
- n.children.push(...structuredClone(T(o)));
459
- });
460
- },
461
- unshiftToRows: (e, t, o) => {
462
- e[t].forEach((n) => {
463
- n.children.unshift(...structuredClone(T(o)));
464
- });
465
- },
466
- unshiftSerialToRows: (e, t, o) => {
467
- e[t].forEach((n, a) => {
468
- const r = structuredClone(o);
469
- r.textContent = a + 1, n.children.unshift(r);
470
- });
471
- }
472
- }, R = (e, t, o) => {
473
- const n = t.dataRole ? S(e[t.fileName], t.dataRole) : e[t.fileName], a = [...t.filePath ?? []], r = a.pop(), s = a.reduce((i, u) => i[u], n);
474
- (L[t.action] || L.set)(s, r, o);
475
- }, m = { data: {}, base: I, spec: j }, v = {
476
- fromCollection: C,
477
- twoDimensional: Ct
478
- }, Ht = (e) => {
479
- e.forEach((t) => {
480
- const o = At(m, t.sourcePath);
481
- if (o) {
482
- const n = v[t.func](o, j[t.templateKey]);
483
- R(m, t.destinationPath, n);
484
- } else
485
- console.log(" !instruction : ", t), console.log(" !source : ", o);
486
- });
487
- }, Vt = (e) => {
488
- e.forEach((t) => {
489
- const o = v[t.func](
490
- m.data.columns,
491
- m.data.data,
492
- j
493
- );
494
- R(m, t.destinationPath, o);
495
- });
496
- }, Bt = (e) => (m.data = e, Ht(Rt), Vt(vt), I), D = ({
497
- inData: e,
498
- inColumns: t,
499
- footer: o = [],
500
- options: n
501
- } = {}) => Bt({
502
- columns: t,
503
- data: e
504
- }), Mt = {
505
- tagName: "option",
506
- textContent: "${rowValue}",
507
- attributes: {
508
- value: "${rowValue}"
509
- }
510
- }, Gt = {
511
- tagName: "select",
512
- attributes: {
513
- id: "LedgerName"
514
- },
515
- children: []
516
- }, Kt = {
517
- tagName: "datalist",
518
- attributes: {
519
- "data-name": "${columnName}"
520
- },
521
- children: []
522
- }, g = {
523
- buildOption: Mt,
524
- buildSelect: Gt,
525
- buildDataList: Kt
526
- }, zt = ({ inData: e = [] } = {}) => {
527
- const t = (e ?? []).map(
528
- (n) => typeof n == "object" && n !== null ? n : { rowValue: n }
529
- ), o = structuredClone(g.buildSelect);
530
- return o.children = C(t, g.buildOption), o;
531
- }, qt = ({ inData: e = [], inColumns: t = [] } = {}) => t.map((n) => {
532
- const a = structuredClone(g.buildOption);
533
- return a.textContent = a.textContent.replace("rowValue", n.columnName), a.attributes.value = a.attributes.value.replace("rowValue", n.columnName), C(e, a);
534
- }), E = ({ inData: e = [] } = {}) => {
535
- const t = (e ?? []).map(
536
- (n) => typeof n == "object" && n !== null ? n : { rowValue: n }
537
- ), o = structuredClone(g.buildDataList);
538
- return o.children = C(t, g.buildOption), o;
539
- }, _t = {
540
- table: D,
541
- tableFromSpec: D,
542
- select: zt,
543
- selectOptionsOnly: qt,
544
- dataList: E,
545
- datalist: E
546
- }, H = ({
547
- type: e = h.type,
548
- data: t = h.data,
549
- columns: o = h.columns,
550
- options: n = h.options,
551
- showLog: a = h.showLog
552
- } = {}) => {
553
- const l = {
554
- type: e,
555
- data: t,
556
- columns: o,
557
- options: n,
558
- showLog: a
559
- };
560
- F({ inConfig: l });
561
- const d = _t[l.type];
562
- if (!d)
563
- throw new Error(`Renderer for type "${l.type}" not found.`);
564
- const p = d({
565
- inColumns: l.columns,
566
- inData: l.data,
567
- options: l.options
568
- });
569
- return l.showLog && console.log("json-renderers-build output:", p), p;
570
- };
571
- ot({ render: H, getSpec: x, spec: f });
572
- const V = ({
573
- inColumns: e,
574
- inType: t = "table",
575
- inData: o,
576
- inShowLog: n = !1
577
- } = {}) => H({
578
- type: t,
579
- data: o ?? [],
580
- columns: e,
581
- showLog: n
582
- }), Jt = {
583
- version: "v9",
584
- description: "JSON-to-DOM engine with SVG namespace support, mixed text content, and centralized traversal"
585
- }, Yt = ({ inFuncDefinition: e, inReviewSpec: t } = {}) => {
586
- if (typeof globalThis > "u" || !e) return;
587
- globalThis.ks ?? (globalThis.ks = {});
588
- const o = {
589
- meta: Jt,
590
- buildSpecElement: e,
591
- reviewSpec: t
592
- };
593
- globalThis.ks["json-to-tag"] = o, globalThis.ks.jsonToTag = o;
594
- }, Ut = (e) => e == null ? null : typeof Node < "u" && e instanceof Node ? e : typeof e == "string" || typeof e == "number" ? document.createTextNode(String(e)) : typeof e == "object" && (e.nodeType === 3 || e.tagName === "#text" || !e.tagName && (e.textContent !== void 0 || e.text !== void 0)) ? document.createTextNode(e.textContent ?? e.text ?? "") : M(e), B = (e) => Array.isArray(e) ? e.map(Ut).flat(1 / 0).filter(Boolean) : [], Xt = (e) => (e == null, e), Qt = "http://www.w3.org/2000/svg", Wt = /* @__PURE__ */ new Set([
595
- "svg",
596
- "path",
597
- "symbol",
598
- "use",
599
- "g",
600
- "circle",
601
- "ellipse",
602
- "rect",
603
- "line",
604
- "polyline",
605
- "polygon",
606
- "text",
607
- "tspan",
608
- "defs",
609
- "clippath",
610
- "mask",
611
- "pattern",
612
- "marker",
613
- "lineargradient",
614
- "radialgradient",
615
- "stop",
616
- "image",
617
- "filter",
618
- "fegaussianblur",
619
- "femerge",
620
- "femergenode"
621
- ]), Zt = ({ inTagName: e }) => {
622
- const t = e == null ? void 0 : e.toLowerCase();
623
- if (!t) return null;
624
- if (t === "checkbox") {
625
- const o = document.createElement("input");
626
- return o.type = "checkbox", o;
627
- }
628
- return Wt.has(t) ? document.createElementNS(Qt, t) : document.createElement(t);
629
- }, te = ({ inElement: e, inTextContent: t }) => (!e || t === void 0 || t === null || (e.textContent = t), e), ee = ({ inElement: e, inProperties: t }) => (e && t && typeof t == "object" && Object.assign(e, t), e), oe = "http://www.w3.org/1999/xlink", ne = ({ inElement: e, inAttributes: t }) => {
630
- const o = e, n = t;
631
- if (!o || !n || typeof n != "object")
632
- return o;
633
- const a = typeof SVGElement < "u" ? o instanceof SVGElement : o.namespaceURI === "http://www.w3.org/2000/svg";
634
- return Object.entries(n).forEach(([r, s]) => {
635
- if (r === "class") {
636
- a ? o.setAttribute("class", String(s)) : o.className = s;
637
- return;
638
- }
639
- if (r === "xlink:href" || r === "href") {
640
- if (s != null) {
641
- const c = String(s);
642
- if (a)
643
- try {
644
- o.setAttributeNS(oe, "href", c);
645
- } catch {
646
- }
647
- o.setAttribute("href", c), o.setAttribute("xlink:href", c);
648
- }
649
- return;
650
- }
651
- if (typeof s == "boolean") {
652
- s ? o.setAttribute(r, "") : o.removeAttribute(r);
653
- return;
654
- }
655
- s != null && o.setAttribute(r, String(s));
656
- }), o;
657
- }, re = ({ inElement: e, inClassList: t }) => {
658
- if (!e || !t) return e;
659
- const o = typeof t == "string" ? t.split(/\s+/).filter(Boolean) : Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim()) : [];
660
- return o.length && e.classList.add(...o), e;
661
- }, ae = (e) => {
662
- if (!e || typeof e != "object" || Array.isArray(e) || !e.tagName) return null;
663
- const t = Zt({ inTagName: e.tagName });
664
- if (!t) return null;
665
- if (te({
666
- inElement: t,
667
- inTextContent: Xt(e.textContent),
668
- inTagName: e.tagName
669
- }), ee({
670
- inElement: t,
671
- inProperties: e.properties
672
- }), ne({
673
- inElement: t,
674
- inAttributes: e.attributes
675
- }), re({
676
- inElement: t,
677
- inClassList: e.classList
678
- }), Array.isArray(e.children)) {
679
- const o = B(e.children);
680
- o.length && t.append(...o);
681
- }
682
- return t;
683
- }, M = (e) => e == null ? null : typeof Node < "u" && e instanceof Node ? e : Array.isArray(e) ? B(e) : typeof e == "object" ? ae(e) : typeof e == "string" || typeof e == "number" ? document.createTextNode(String(e)) : null, le = "./tags.schema.json", se = {
684
- allowsTextContent: !1,
685
- allowsChildren: !0,
686
- allowedAttributes: [
687
- "title",
688
- "role"
689
- ],
690
- childTags: []
691
- }, ce = {
692
- allowsTextContent: !1,
693
- allowsChildren: !1,
694
- allowedAttributes: [
695
- "type",
696
- "placeholder",
697
- "value",
698
- "name",
699
- "disabled",
700
- "readonly",
701
- "required",
702
- "list"
703
- ]
704
- }, ie = {
705
- allowsTextContent: !1,
706
- allowsChildren: !1,
707
- allowedAttributes: [
708
- "type",
709
- "checked",
710
- "name",
711
- "value",
712
- "disabled",
713
- "required"
714
- ]
715
- }, ue = {
716
- allowsTextContent: !1,
717
- allowsChildren: !0,
718
- allowedAttributes: [
719
- "span"
720
- ],
721
- childTags: [
722
- "col"
723
- ]
724
- }, de = {
725
- allowsTextContent: !1,
726
- allowsChildren: !1,
727
- allowedAttributes: [
728
- "span",
729
- "style",
730
- "width"
731
- ]
732
- }, pe = {
733
- allowsTextContent: !0,
734
- allowsChildren: !0,
735
- allowedAttributes: [
736
- "for"
737
- ],
738
- childTags: []
739
- }, fe = {
740
- allowsTextContent: !1,
741
- allowsChildren: !0,
742
- allowedAttributes: [
743
- "action",
744
- "method",
745
- "autocomplete",
746
- "enctype",
747
- "name",
748
- "novalidate",
749
- "target"
750
- ],
751
- childTags: []
752
- }, be = {
753
- allowsTextContent: !1,
754
- allowsChildren: !0,
755
- allowedAttributes: [
756
- "name",
757
- "disabled",
758
- "required",
759
- "multiple",
760
- "size"
761
- ],
762
- childTags: [
763
- "option"
764
- ]
765
- }, he = {
766
- allowsTextContent: !0,
767
- allowsChildren: !0,
768
- allowedAttributes: [],
769
- childTags: []
770
- }, me = {
771
- allowsTextContent: !0,
772
- allowsChildren: !0,
773
- allowedAttributes: [],
774
- childTags: []
775
- }, ge = {
776
- allowsTextContent: !0,
777
- allowsChildren: !0,
778
- allowedAttributes: [],
779
- childTags: []
780
- }, we = {
781
- allowsTextContent: !0,
782
- allowsChildren: !0,
783
- allowedAttributes: [],
784
- childTags: []
785
- }, ye = {
786
- allowsTextContent: !1,
787
- allowsChildren: !1,
788
- allowedAttributes: [
789
- "src",
790
- "alt",
791
- "width",
792
- "height",
793
- "loading"
794
- ]
795
- }, Te = {
796
- allowsTextContent: !0,
797
- allowsChildren: !0,
798
- allowedAttributes: [
799
- "type",
800
- "disabled",
801
- "name",
802
- "value"
803
- ],
804
- childTags: []
805
- }, Ce = {
806
- allowsTextContent: !1,
807
- allowsChildren: !0,
808
- allowedAttributes: [
809
- "border",
810
- "cellpadding",
811
- "cellspacing"
812
- ],
813
- childTags: [
814
- "caption",
815
- "colgroup",
816
- "thead",
817
- "tbody",
818
- "tfoot",
819
- "tr"
820
- ]
821
- }, Ae = {
822
- allowsTextContent: !1,
823
- allowsChildren: !0,
824
- allowedAttributes: [],
825
- childTags: [
826
- "tr"
827
- ]
828
- }, Ne = {
829
- allowsTextContent: !1,
830
- allowsChildren: !0,
831
- allowedAttributes: [],
832
- childTags: [
833
- "tr"
834
- ]
835
- }, $e = {
836
- allowsTextContent: !1,
837
- allowsChildren: !0,
838
- allowedAttributes: [],
839
- childTags: [
840
- "tr"
841
- ]
842
- }, xe = {
843
- allowsTextContent: !1,
844
- allowsChildren: !0,
845
- allowedAttributes: [],
846
- childTags: [
847
- "td",
848
- "th"
849
- ]
850
- }, Se = {
851
- allowsTextContent: !0,
852
- allowsChildren: !0,
853
- allowedAttributes: [
854
- "scope",
855
- "colspan",
856
- "rowspan"
857
- ],
858
- childTags: []
859
- }, je = {
860
- allowsTextContent: !0,
861
- allowsChildren: !0,
862
- allowedAttributes: [
863
- "colspan",
864
- "rowspan"
865
- ],
866
- childTags: []
867
- }, Le = {
868
- allowsTextContent: !1,
869
- allowsChildren: !0,
870
- allowedAttributes: [],
871
- childTags: [
872
- "option"
873
- ]
874
- }, De = {
875
- allowsTextContent: !0,
876
- allowsChildren: !1,
877
- allowedAttributes: [
878
- "value",
879
- "label",
880
- "selected",
881
- "disabled"
882
- ]
883
- }, Ee = {
884
- allowsTextContent: !1,
885
- allowsChildren: !0,
886
- allowedAttributes: [
887
- "role"
888
- ],
889
- childTags: []
890
- }, Oe = {
891
- allowsTextContent: !0,
892
- allowsChildren: !0,
893
- allowedAttributes: [
894
- "href",
895
- "target",
896
- "rel",
897
- "title",
898
- "download"
899
- ],
900
- childTags: []
901
- }, Pe = {
902
- allowsTextContent: !0,
903
- allowsChildren: !0,
904
- allowedAttributes: [
905
- "aria-hidden"
906
- ],
907
- childTags: []
908
- }, Fe = {
909
- allowsTextContent: !0,
910
- allowsChildren: !0,
911
- allowedAttributes: [],
912
- childTags: []
913
- }, ke = {
914
- allowsTextContent: !1,
915
- allowsChildren: !0,
916
- allowedAttributes: [
917
- "type"
918
- ],
919
- childTags: [
920
- "li"
921
- ]
922
- }, Ie = {
923
- allowsTextContent: !0,
924
- allowsChildren: !0,
925
- allowedAttributes: [
926
- "value"
927
- ],
928
- childTags: []
929
- }, Re = {
930
- allowsTextContent: !1,
931
- allowsChildren: !1,
932
- allowedAttributes: []
933
- }, ve = {
934
- $schema: le,
935
- div: se,
936
- input: ce,
937
- checkbox: ie,
938
- colgroup: ue,
939
- col: de,
940
- label: pe,
941
- form: fe,
942
- select: be,
943
- p: he,
944
- h1: me,
945
- h2: ge,
946
- span: we,
947
- img: ye,
948
- button: Te,
949
- table: Ce,
950
- thead: Ae,
951
- tbody: Ne,
952
- tfoot: $e,
953
- tr: xe,
954
- th: Se,
955
- td: je,
956
- datalist: Le,
957
- option: De,
958
- header: Ee,
959
- a: Oe,
960
- i: Pe,
961
- small: Fe,
962
- ul: ke,
963
- li: Ie,
964
- hr: Re
965
- }, $ = ({ inSpec: e }) => {
966
- const t = e;
967
- if (!t) return [];
968
- if (Array.isArray(t))
969
- return t.flatMap((n) => $({ inSpec: n }));
970
- if (typeof t != "object") return [];
971
- const o = [];
972
- 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 a = $({ inSpec: n });
974
- o.push(...a);
975
- }), o;
976
- }, He = ({ inTagsFound: e, inAllowedTags: t }) => {
977
- const o = e ?? [], n = t ?? {}, a = new Set(
978
- Object.keys(n).filter((l) => l !== "$schema").map((l) => l.toLowerCase())
979
- ), r = {}, s = [], c = [];
980
- o.forEach((l) => {
981
- r[l] = (r[l] || 0) + 1, a.has(l) ? s.includes(l) || s.push(l) : c.includes(l) || c.push(l);
982
- });
983
- const i = o.length, u = c.length === 0;
984
- return {
985
- totalTags: i,
986
- tagCounts: r,
987
- uniqueTags: Object.keys(r),
988
- recognizedTags: s,
989
- unrecognizedTags: c,
990
- areAllTagsPresent: u
991
- };
992
- }, Ve = ({ inSpec: e, inTags: t = ve } = {}) => {
993
- const o = e, n = t, a = $({ inSpec: o }), r = He({
994
- inTagsFound: a,
995
- inAllowedTags: n
996
- });
997
- return {
998
- areAllTagsPresent: r.areAllTagsPresent,
999
- totalTags: r.totalTags,
1000
- tagCounts: r.tagCounts,
1001
- uniqueTags: r.uniqueTags,
1002
- recognizedTags: r.recognizedTags,
1003
- unrecognizedTags: r.unrecognizedTags
1004
- };
1005
- }, G = (e = {}) => {
1006
- const t = (e == null ? void 0 : e.spec) ?? (e == null ? void 0 : e.inSpec) ?? e;
1007
- return M(t);
1008
- };
1009
- Yt({
1010
- inFuncDefinition: G,
1011
- inReviewSpec: Ve
1012
- });
1013
- const K = ({
1014
- inSpec: e,
1015
- inTargetHtmlId: t,
1016
- inAppendPosition: o,
1017
- inShowLog: n = !1
1018
- } = {}) => {
1019
- const a = e, r = t, s = o, c = n, i = G(a);
1020
- c && console.log("renderToDom 1 (content):", i);
1021
- const u = document.getElementById(r);
1022
- 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
- }, Be = (e = {}) => {
1024
- 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);
1026
- const n = V({
1027
- inColumns: t.columns,
1028
- inData: t.data,
1029
- inType: t.type,
1030
- inShowLog: t.showLog
1031
- });
1032
- return K({
1033
- inSpec: n,
1034
- inTargetHtmlId: t.targetHtmlId,
1035
- inAppendPosition: t.appendPosition,
1036
- inShowLog: t.showLog
1037
- });
1038
- };
1039
- _({ render: Be, getSpec: P, validateConfig: O, buildSpec: V, renderToDom: K });
1040
- export {
1041
- V as buildSpec,
1042
- Be as default,
1043
- P as getSpec,
1044
- Be as render,
1045
- K as renderToDom,
1046
- O as validateConfig
1047
- };
1
+ const et = {
2
+ version: "v18.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, rt = (t) => {
5
+ const e = t;
6
+ typeof globalThis > "u" || !e || (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.jsonRenderers = {
7
+ meta: et,
8
+ render: e
9
+ });
10
+ }, st = (t) => {
11
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
12
+ if (!e || typeof e != "object")
13
+ throw new TypeError("Config must be an object");
14
+ const r = e.type;
15
+ if (r === void 0)
16
+ throw new Error('Missing compulsory key: "type"');
17
+ if (typeof r != "string")
18
+ throw new TypeError("type must be a string");
19
+ return !0;
20
+ }, nt = (t) => {
21
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
22
+ if (!e || typeof e != "object")
23
+ throw new TypeError("Config must be an object");
24
+ const r = e.data;
25
+ if (r === void 0)
26
+ throw new Error('Missing compulsory key: "data"');
27
+ if (!Array.isArray(r))
28
+ throw new TypeError("data must be an Array");
29
+ return !0;
30
+ }, ot = (t) => {
31
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
32
+ if (!e || typeof e != "object")
33
+ throw new TypeError("Config must be an object");
34
+ const r = e.columns;
35
+ if (r === void 0)
36
+ throw new Error('Missing compulsory key: "columns"');
37
+ if (!Array.isArray(r))
38
+ throw new TypeError("columns must be an Array");
39
+ return !0;
40
+ }, at = (t) => {
41
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
42
+ if (!e || typeof e != "object")
43
+ throw new TypeError("Config must be an object");
44
+ const r = e.showLog;
45
+ if (r !== void 0 && typeof r != "boolean")
46
+ throw new TypeError("showLog must be a boolean");
47
+ return !0;
48
+ }, I = (t) => {
49
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
50
+ if (!e || typeof e != "object" || Array.isArray(e))
51
+ throw new TypeError("Config must be an object");
52
+ return st(e), nt(e), ot(e), at(e), !0;
53
+ }, lt = (t) => {
54
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
55
+ if (!e || typeof e != "object")
56
+ throw new TypeError("Config must be an object");
57
+ const r = e.targetHtmlId;
58
+ if (r === void 0)
59
+ throw new Error('Missing compulsory key: "targetHtmlId"');
60
+ if (typeof r != "string")
61
+ throw new TypeError("targetHtmlId must be a string");
62
+ if (r.trim().length === 0)
63
+ throw new Error("targetHtmlId must be a non-empty string");
64
+ return !0;
65
+ }, it = (t) => {
66
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
67
+ if (!e || typeof e != "object")
68
+ throw new TypeError("Config must be an object");
69
+ const r = e.appendPosition;
70
+ if (r === void 0)
71
+ throw new Error('Missing compulsory key: "appendPosition"');
72
+ if (typeof r != "string")
73
+ throw new TypeError("appendPosition must be a string");
74
+ return !0;
75
+ }, ct = (t) => {
76
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
77
+ if (!e || typeof e != "object")
78
+ throw new TypeError("Config must be an object");
79
+ const r = e.classToApply;
80
+ if (r === void 0)
81
+ throw new Error('Missing compulsory key: "classToApply"');
82
+ if (typeof r != "string")
83
+ throw new TypeError("classToApply must be a string");
84
+ return !0;
85
+ }, K = (t) => {
86
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
87
+ if (!e || typeof e != "object" || Array.isArray(e))
88
+ throw new TypeError("Config must be an object");
89
+ return lt(e), it(e), ct(e), !0;
90
+ }, ut = "table", dt = "", bt = [], pt = [], ft = "", ht = "replace", yt = !1, w = {
91
+ type: ut,
92
+ targetHtmlId: dt,
93
+ data: bt,
94
+ columns: pt,
95
+ classToApply: ft,
96
+ appendPosition: ht,
97
+ showLog: yt
98
+ }, z = (t) => {
99
+ const e = typeof t == "object" && t !== null ? t.inKey ?? t.key : t;
100
+ return e && e in w ? w[e] : { ...w };
101
+ };
102
+ Object.assign(z, w);
103
+ const T = (t) => {
104
+ const e = (t == null ? void 0 : t.inConfig) ?? t;
105
+ if (!e || typeof e != "object" || Array.isArray(e))
106
+ throw new TypeError("Config must be an object");
107
+ return I(e), K(e), !0;
108
+ };
109
+ T.getSpec = z;
110
+ T.configSpec = w;
111
+ T.guardSpec = I;
112
+ T.guardMount = K;
113
+ const mt = {
114
+ version: "1.22.0",
115
+ name: "json-renderers-build"
116
+ }, wt = (t) => {
117
+ t && (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.jsonRenderersBuild = {
118
+ meta: mt,
119
+ render: t
120
+ });
121
+ }, gt = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Tt = (t, e) => {
122
+ if (!gt(t)) return;
123
+ let r = {};
124
+ for (const [s, a] of Object.entries(t))
125
+ r[s] = C(e, a);
126
+ return r;
127
+ }, Ct = (t, e) => {
128
+ const r = structuredClone(t);
129
+ return Array.isArray(r) ? r.map((a) => C(e, a)) : void 0;
130
+ }, W = (t, e, r) => {
131
+ if (t === "${agg:count}" && "rowData" in e) {
132
+ if (Array.isArray(e == null ? void 0 : e.rowData))
133
+ return e == null ? void 0 : e.rowData.length;
134
+ } else
135
+ return t === "${rowValue}" && "rowData" in e ? e == null ? void 0 : e.rowData : t.replace(/\$\{(\w+)\}/g, (s, a) => e[a] !== void 0 ? e[a] : s);
136
+ }, At = (t, e) => W(t, e), xt = (t, e, r) => {
137
+ if (e == null)
138
+ throw new TypeError("inTemplate is required");
139
+ if (typeof e != "object" && typeof e != "string")
140
+ throw new TypeError("inTemplate must be an object or string");
141
+ if (!t || typeof t != "object" || Array.isArray(t))
142
+ throw new TypeError("inElement must be an object");
143
+ return !0;
144
+ }, C = (t, e, r) => {
145
+ const s = t, a = e;
146
+ xt(s, a);
147
+ const n = structuredClone(a);
148
+ return typeof n == "string" ? W(n, s) : (n === null || typeof n != "object" || ("textContent" in n && (n.textContent = At(n == null ? void 0 : n.textContent, s)), "attributes" in n && (n.attributes = Tt(n == null ? void 0 : n.attributes, s)), "children" in n && (n.children = Ct(n == null ? void 0 : n.children, s))), n);
149
+ }, Nt = (t, e) => {
150
+ if (!Array.isArray(t))
151
+ throw new TypeError("inSource must be an Array");
152
+ if (t.length === 0)
153
+ throw new Error("inSource cannot be empty");
154
+ for (let r = 0; r < t.length; r++)
155
+ if (!t[r] || typeof t[r] != "object")
156
+ throw new TypeError(`inSource[${r}] must be an object`);
157
+ if (!e || typeof e != "object" && typeof e != "string")
158
+ throw new TypeError("inTemplate must be an object or string");
159
+ return !0;
160
+ }, L = (t, e) => {
161
+ const r = t, s = e;
162
+ return Nt(r, s), r.map((a) => C(a, s));
163
+ }, $t = (t, e) => t.map((s) => ({
164
+ ...s,
165
+ rowData: e[s.columnName]
166
+ })), St = (t, e, r) => {
167
+ var a, n, i, d, o, u;
168
+ if (!Array.isArray(t))
169
+ throw new TypeError("inColumns must be an Array");
170
+ if (t.length === 0)
171
+ throw new Error("inColumns cannot be empty");
172
+ for (let l = 0; l < t.length; l++) {
173
+ const c = t[l];
174
+ if (!c || typeof c != "object")
175
+ throw new TypeError(`inColumns[${l}] must be an object`);
176
+ if (typeof c.columnName != "string" || !c.columnName.trim())
177
+ throw new TypeError(`inColumns[${l}].columnName must be a non-empty string`);
178
+ }
179
+ if (!Array.isArray(e))
180
+ throw new TypeError("inData must be an Array");
181
+ for (let l = 0; l < e.length; l++) {
182
+ const c = e[l];
183
+ if (!c || typeof c != "object")
184
+ throw new TypeError(`inData[${l}] must be an object`);
185
+ }
186
+ if (!r || typeof r != "object" || Array.isArray(r))
187
+ throw new TypeError("inSpec must be an object");
188
+ const s = ((i = (n = (a = t[0]) == null ? void 0 : a.template) == null ? void 0 : n.body) == null ? void 0 : i.tr) || "buildBodyTr";
189
+ if (!(s in r))
190
+ throw new Error(`Row template "${s}" not found in inSpec`);
191
+ for (let l = 0; l < t.length; l++) {
192
+ const c = t[l], b = ((o = (d = c.template) == null ? void 0 : d.body) == null ? void 0 : o.cell) || ((u = c.template) == null ? void 0 : u.bodyCell) || "buildBodyCell";
193
+ if (!(b in r))
194
+ throw new Error(`Cell template "${b}" for column "${c.columnName}" not found in inSpec`);
195
+ }
196
+ return !0;
197
+ }, jt = (t, e) => t.map((s) => {
198
+ var d, o, u;
199
+ const a = ((o = (d = s.template) == null ? void 0 : d.body) == null ? void 0 : o.cell) || ((u = s.template) == null ? void 0 : u.bodyCell) || "buildBodyCell", n = e[a];
200
+ return C(s, n);
201
+ }), It = (t, e, r) => {
202
+ var u, l, c;
203
+ St(t, e, r);
204
+ const s = t, a = e, n = r, i = ((c = (l = (u = s[0]) == null ? void 0 : u.template) == null ? void 0 : l.body) == null ? void 0 : c.tr) || "buildBodyTr", d = n[i];
205
+ return a.map((b) => {
206
+ const f = C(b, d), x = $t(s, b), N = jt(x, n);
207
+ return f.children = N, f;
208
+ });
209
+ }, B = (t, e) => {
210
+ var r;
211
+ if (((r = t == null ? void 0 : t.attributes) == null ? void 0 : r["data-role"]) === e) return t;
212
+ for (const s of (t == null ? void 0 : t.children) ?? []) {
213
+ const a = B(s, e);
214
+ if (a) return a;
215
+ }
216
+ return null;
217
+ }, Lt = (t, e) => {
218
+ const r = t[e.fileName], s = e.dataRole ? B(r, e.dataRole) : r;
219
+ return (e.filePath ?? []).reduce((a, n) => a[n], s);
220
+ }, vt = {
221
+ tagName: "tr",
222
+ attributes: {
223
+ class: "align-middle"
224
+ },
225
+ children: []
226
+ }, kt = {
227
+ tagName: "col",
228
+ attributes: {
229
+ width: "${width}"
230
+ }
231
+ }, Et = {
232
+ tagName: "th",
233
+ textContent: "${columnName}",
234
+ attributes: {
235
+ class: "py-3 px-3 fw-semibold text-uppercase small"
236
+ }
237
+ }, Bt = {
238
+ tagName: "td",
239
+ children: [
240
+ {
241
+ tagName: "input",
242
+ attributes: {
243
+ type: "text",
244
+ placeholder: "enter ${columnName}",
245
+ name: "${columnName}",
246
+ class: "form-control"
247
+ }
248
+ }
249
+ ]
250
+ }, Pt = {
251
+ tagName: "td",
252
+ textContent: "${rowValue}",
253
+ attributes: {
254
+ class: "py-3 px-3 text-secondary"
255
+ }
256
+ }, Dt = {
257
+ tagName: "button",
258
+ textContent: "${columnName}",
259
+ attributes: {
260
+ class: "btn btn-primary btn-sm"
261
+ }
262
+ }, Rt = {
263
+ tagName: "td",
264
+ attributes: {
265
+ class: "py-2 px-3 text-center"
266
+ },
267
+ children: [
268
+ {
269
+ tagName: "button",
270
+ textContent: "${agg:count}",
271
+ attributes: {
272
+ class: "btn btn-primary btn-sm"
273
+ }
274
+ }
275
+ ]
276
+ }, Ft = {
277
+ tagName: "option",
278
+ textContent: "${rowValue}",
279
+ attributes: {
280
+ value: "${rowValue}"
281
+ }
282
+ }, Mt = {
283
+ tagName: "select",
284
+ attributes: {
285
+ id: "LedgerName"
286
+ },
287
+ children: []
288
+ }, Ht = {
289
+ tagName: "datalist",
290
+ attributes: {
291
+ "data-name": "${columnName}"
292
+ },
293
+ children: []
294
+ }, P = {
295
+ buildBodyTr: vt,
296
+ buildColGroup: kt,
297
+ buildHeader: Et,
298
+ buildFooter: Bt,
299
+ buildBodyCell: Pt,
300
+ button: Dt,
301
+ buttonCell: Rt,
302
+ buildOption: Ft,
303
+ buildSelect: Mt,
304
+ buildDataList: Ht
305
+ }, Vt = "table", Gt = {
306
+ class: "table table-hover table-striped align-middle border mb-0"
307
+ }, Kt = [
308
+ {
309
+ tagName: "colgroup",
310
+ attributes: {
311
+ "data-role": "table-colgroup"
312
+ },
313
+ children: []
314
+ },
315
+ {
316
+ tagName: "thead",
317
+ attributes: {
318
+ class: "table-dark",
319
+ "data-role": "table-header"
320
+ },
321
+ children: [
322
+ {
323
+ tagName: "tr",
324
+ attributes: {
325
+ "data-role": "table-header-row"
326
+ },
327
+ children: []
328
+ }
329
+ ]
330
+ },
331
+ {
332
+ tagName: "tbody",
333
+ attributes: {
334
+ "data-role": "table-body"
335
+ },
336
+ children: []
337
+ },
338
+ {
339
+ tagName: "tfoot",
340
+ attributes: {
341
+ "data-role": "table-footer"
342
+ },
343
+ children: [
344
+ {
345
+ tagName: "tr",
346
+ attributes: {
347
+ "data-role": "table-footer-row"
348
+ },
349
+ children: []
350
+ }
351
+ ]
352
+ }
353
+ ], _ = {
354
+ tagName: Vt,
355
+ attributes: Gt,
356
+ children: Kt
357
+ }, zt = [
358
+ {
359
+ narration: "Build the column widths for the table using the configured columns.",
360
+ destinationPath: {
361
+ fileName: "base",
362
+ dataRole: "table-colgroup",
363
+ filePath: [
364
+ "children"
365
+ ]
366
+ },
367
+ sourcePath: {
368
+ fileName: "data",
369
+ filePath: [
370
+ "columns"
371
+ ]
372
+ },
373
+ templateKey: "buildColGroup",
374
+ func: "fromCollection"
375
+ },
376
+ {
377
+ narration: "Build the header row for the table using the configured columns.",
378
+ destinationPath: {
379
+ fileName: "base",
380
+ dataRole: "table-header-row",
381
+ filePath: [
382
+ "children"
383
+ ]
384
+ },
385
+ sourcePath: {
386
+ fileName: "data",
387
+ filePath: [
388
+ "columns"
389
+ ]
390
+ },
391
+ templateKey: "buildHeader",
392
+ func: "fromCollection"
393
+ }
394
+ ], Wt = [
395
+ {
396
+ narration: "Build the table body rows for the table using the configured columns and data.",
397
+ destinationPath: {
398
+ fileName: "base",
399
+ dataRole: "table-body",
400
+ filePath: [
401
+ "children"
402
+ ]
403
+ },
404
+ sourcePath: {
405
+ fileName: "data",
406
+ filePath: [
407
+ "columns"
408
+ ]
409
+ },
410
+ func: "twoDimensional"
411
+ }
412
+ ], $ = (t) => Array.isArray(t) ? t : [t], R = {
413
+ set: (t, e, r) => {
414
+ t[e] = r;
415
+ },
416
+ push: (t, e, r) => {
417
+ t[e].push(...$(r));
418
+ },
419
+ unshift: (t, e, r) => {
420
+ t[e].unshift(...$(r));
421
+ },
422
+ pushToRows: (t, e, r) => {
423
+ t[e].forEach((s) => {
424
+ s.children.push(...structuredClone($(r)));
425
+ });
426
+ },
427
+ unshiftToRows: (t, e, r) => {
428
+ t[e].forEach((s) => {
429
+ s.children.unshift(...structuredClone($(r)));
430
+ });
431
+ },
432
+ unshiftSerialToRows: (t, e, r) => {
433
+ t[e].forEach((s, a) => {
434
+ const n = structuredClone(r);
435
+ n.textContent = a + 1, s.children.unshift(n);
436
+ });
437
+ }
438
+ }, q = (t, e, r) => {
439
+ const s = e.dataRole ? B(t[e.fileName], e.dataRole) : t[e.fileName], a = [...e.filePath ?? []], n = a.pop(), i = a.reduce((o, u) => o[u], s);
440
+ (R[e.action] || R.set)(i, n, r);
441
+ }, m = { data: {}, base: _, spec: P }, O = {
442
+ fromCollection: L,
443
+ twoDimensional: It
444
+ }, _t = (t) => {
445
+ t.forEach((e) => {
446
+ const r = Lt(m, e.sourcePath);
447
+ if (r) {
448
+ const s = O[e.func](r, P[e.templateKey]);
449
+ q(m, e.destinationPath, s);
450
+ } else
451
+ console.log(" !instruction : ", e), console.log(" !source : ", r);
452
+ });
453
+ }, qt = (t) => {
454
+ t.forEach((e) => {
455
+ const r = O[e.func](
456
+ m.data.columns,
457
+ m.data.data,
458
+ P
459
+ );
460
+ q(m, e.destinationPath, r);
461
+ });
462
+ }, Ot = (t) => (m.data = t, _t(zt), qt(Wt), _), F = ({
463
+ inData: t,
464
+ inColumns: e,
465
+ inType: r,
466
+ footer: s = [],
467
+ options: a
468
+ } = {}) => Ot({
469
+ columns: e,
470
+ data: t
471
+ }), Jt = {
472
+ tagName: "option",
473
+ textContent: "${rowValue}",
474
+ attributes: {
475
+ value: "${rowValue}"
476
+ }
477
+ }, Ut = {
478
+ tagName: "select",
479
+ attributes: {
480
+ id: "LedgerName"
481
+ },
482
+ children: []
483
+ }, Xt = {
484
+ tagName: "datalist",
485
+ attributes: {
486
+ "data-name": "${columnName}"
487
+ },
488
+ children: []
489
+ }, g = {
490
+ buildOption: Jt,
491
+ buildSelect: Ut,
492
+ buildDataList: Xt
493
+ }, Qt = ({ inData: t = [] } = {}) => {
494
+ const e = (t ?? []).map(
495
+ (s) => typeof s == "object" && s !== null ? s : { rowValue: s }
496
+ ), r = structuredClone(g.buildSelect);
497
+ return r.children = L(e, g.buildOption), r;
498
+ }, Yt = ({ inData: t = [], inColumns: e = [] } = {}) => e.map((s) => {
499
+ const a = structuredClone(g.buildOption);
500
+ a.textContent = a.textContent.replace("rowValue", s.columnName), a.attributes.value = a.attributes.value.replace("rowValue", s.columnName);
501
+ const n = L(t, a);
502
+ return console.log("createdArray : ", n[0], a), n;
503
+ }), M = ({ inData: t = [] } = {}) => {
504
+ const e = (t ?? []).map(
505
+ (s) => typeof s == "object" && s !== null ? s : { rowValue: s }
506
+ ), r = structuredClone(g.buildDataList);
507
+ return r.children = L(e, g.buildOption), r;
508
+ }, Zt = {
509
+ version: "1.2.0",
510
+ name: "json-renderers-build-input-row"
511
+ }, te = (t) => {
512
+ const e = t;
513
+ if (typeof globalThis > "u" || !e) return;
514
+ globalThis.ks ?? (globalThis.ks = {});
515
+ const r = typeof e == "function" ? e : e.render;
516
+ globalThis.ks.jsonRenderersBuildInputRow = {
517
+ meta: Zt,
518
+ render: r,
519
+ ...typeof e == "object" ? e : {}
520
+ };
521
+ }, ee = "input", re = {
522
+ type: "search",
523
+ placeholder: "Search...",
524
+ class: "form-control",
525
+ id: "searchInputId"
526
+ }, se = {
527
+ tagName: ee,
528
+ attributes: re
529
+ }, S = ({ inOptions: t = {}, options: e = {} } = {}) => {
530
+ const r = t && Object.keys(t).length > 0 ? t : e, s = structuredClone(se);
531
+ return r.placeholder && (s.attributes.placeholder = r.placeholder), r.class && (s.attributes.class = r.class), r.id && (s.attributes.id = r.id), r.name && (s.attributes.name = r.name), r.type && (s.attributes.type = r.type), r.value && (s.attributes.value = r.value), s;
532
+ }, ne = "div", oe = {
533
+ class: "d-flex align-items-center gap-2"
534
+ }, ae = [
535
+ {
536
+ tagName: "label",
537
+ textContent: "Search:",
538
+ attributes: {
539
+ class: "form-label mb-0 text-nowrap fw-semibold",
540
+ for: "searchInputId"
541
+ }
542
+ },
543
+ {
544
+ tagName: "input",
545
+ attributes: {
546
+ type: "search",
547
+ placeholder: "Search...",
548
+ class: "form-control",
549
+ id: "searchInputId"
550
+ }
551
+ }
552
+ ], le = {
553
+ tagName: ne,
554
+ attributes: oe,
555
+ children: ae
556
+ }, A = ({ inOptions: t = {}, options: e = {} } = {}) => {
557
+ const r = t && Object.keys(t).length > 0 ? t : e, s = structuredClone(le), a = s.children[0], n = s.children[1];
558
+ return r.label && (a.textContent = r.label), r.id && (a.attributes.for = r.id, n.attributes.id = r.id), r.placeholder && (n.attributes.placeholder = r.placeholder), r.class && (n.attributes.class = r.class), r.name && (n.attributes.name = r.name), r.type && (n.attributes.type = r.type), r.wrapperClass && (s.attributes.class = r.wrapperClass), r.labelClass && (a.attributes.class = r.labelClass), s;
559
+ }, ie = "div", ce = {
560
+ class: "d-flex align-items-center gap-2"
561
+ }, ue = [
562
+ {
563
+ tagName: "label",
564
+ textContent: "Search:",
565
+ attributes: {
566
+ class: "form-label mb-0 text-nowrap fw-semibold",
567
+ for: "searchInputId"
568
+ }
569
+ },
570
+ {
571
+ tagName: "input",
572
+ attributes: {
573
+ type: "search",
574
+ placeholder: "Search...",
575
+ class: "form-control",
576
+ id: "searchInputId"
577
+ }
578
+ },
579
+ {
580
+ tagName: "button",
581
+ textContent: "Search",
582
+ attributes: {
583
+ type: "button",
584
+ class: "btn btn-primary text-nowrap",
585
+ id: "searchButtonId"
586
+ }
587
+ }
588
+ ], de = {
589
+ tagName: ie,
590
+ attributes: ce,
591
+ children: ue
592
+ }, v = ({ inOptions: t = {}, options: e = {} } = {}) => {
593
+ const r = t && Object.keys(t).length > 0 ? t : e, s = structuredClone(de), a = s.children[0], n = s.children[1], i = s.children[2];
594
+ return r.label && (a.textContent = r.label), r.id && (a.attributes.for = r.id, n.attributes.id = r.id), r.placeholder && (n.attributes.placeholder = r.placeholder), r.class && (n.attributes.class = r.class), r.name && (n.attributes.name = r.name), r.type && (n.attributes.type = r.type), r.buttonText && (i.textContent = r.buttonText), r.buttonClass && (i.attributes.class = r.buttonClass), r.buttonId && (i.attributes.id = r.buttonId), r.wrapperClass && (s.attributes.class = r.wrapperClass), r.labelClass && (a.attributes.class = r.labelClass), s;
595
+ }, be = {
596
+ input: S,
597
+ inputOnly: S,
598
+ inputWithLabel: A,
599
+ inputWithLabelButton: v
600
+ }, pe = ({
601
+ type: t = "inputWithLabel",
602
+ options: e = {},
603
+ inType: r,
604
+ inOptions: s
605
+ } = {}) => {
606
+ const a = r ?? t, n = s ?? e;
607
+ return (be[a] || A)({ inOptions: n, options: n });
608
+ };
609
+ te({
610
+ render: pe,
611
+ inputOnly: S,
612
+ inputWithLabel: A,
613
+ inputWithLabelButton: v
614
+ });
615
+ const k = ({ inOptions: t = {}, options: e = {} } = {}) => {
616
+ const r = t && Object.keys(t).length > 0 ? t : e;
617
+ return (r == null ? void 0 : r.label) === !1 || (r == null ? void 0 : r.flavour) === "inputOnly" ? S({ inOptions: r }) : (r == null ? void 0 : r.flavour) === "inputWithLabelButton" || r != null && r.button || r != null && r.buttonText ? v({ inOptions: r }) : A({ inOptions: r });
618
+ }, fe = {
619
+ version: "1.2.0",
620
+ name: "json-renderers-build-form"
621
+ }, he = (t) => {
622
+ const e = t;
623
+ typeof globalThis > "u" || !e || (globalThis.ks ?? (globalThis.ks = {}), globalThis.ks.jsonRenderersBuildForm = {
624
+ meta: fe,
625
+ render: e
626
+ });
627
+ }, ye = {
628
+ tagName: "form",
629
+ attributes: {
630
+ class: "vstack gap-3",
631
+ id: "appFormId"
632
+ },
633
+ children: []
634
+ }, me = {
635
+ tagName: "div",
636
+ attributes: {
637
+ class: "mb-3"
638
+ },
639
+ children: []
640
+ }, we = {
641
+ tagName: "label",
642
+ textContent: "Label",
643
+ attributes: {
644
+ class: "form-label fw-semibold",
645
+ for: "fieldId"
646
+ }
647
+ }, ge = {
648
+ tagName: "input",
649
+ attributes: {
650
+ type: "text",
651
+ placeholder: "",
652
+ class: "form-control",
653
+ id: "fieldId",
654
+ name: "fieldName"
655
+ }
656
+ }, Te = {
657
+ tagName: "button",
658
+ textContent: "Submit",
659
+ attributes: {
660
+ type: "submit",
661
+ class: "btn btn-primary align-self-start",
662
+ id: "formSubmitBtnId"
663
+ }
664
+ }, y = {
665
+ form: ye,
666
+ fieldWrapper: me,
667
+ label: we,
668
+ input: ge,
669
+ submitButton: Te
670
+ }, Ce = ({ inColumn: t, inRow: e = {}, inIndex: r = 0 } = {}) => {
671
+ var x, N;
672
+ const s = t, a = e, n = r, i = (s == null ? void 0 : s.columnName) ?? `field_${n}`, d = (s == null ? void 0 : s.type) ?? "text", o = (s == null ? void 0 : s.label) ?? (s == null ? void 0 : s.title) ?? i, u = (s == null ? void 0 : s.id) ?? `form-${n}-${i.toLowerCase()}`, l = a[i] ?? (s == null ? void 0 : s.value), c = structuredClone(y.fieldWrapper), b = structuredClone(y.label);
673
+ if (b.textContent = o, b.attributes.for = u, d === "checkbox") {
674
+ c.attributes.class = "form-check mb-3";
675
+ const p = structuredClone(y.input);
676
+ return p.attributes.type = "checkbox", p.attributes.class = "form-check-input", p.attributes.id = u, p.attributes.name = i, p.attributes.value = "true", p.properties = { checked: !!(l ?? (s == null ? void 0 : s.checked) ?? !1) }, b.attributes.class = "form-check-label", c.children = [p, b], c;
677
+ }
678
+ if (d === "textarea") {
679
+ const p = {
680
+ tagName: "textarea",
681
+ textContent: l ? String(l) : "",
682
+ attributes: {
683
+ class: (s == null ? void 0 : s.class) ?? "form-control",
684
+ rows: String((s == null ? void 0 : s.rows) ?? 3),
685
+ id: u,
686
+ name: i,
687
+ placeholder: (s == null ? void 0 : s.placeholder) ?? ""
688
+ }
689
+ };
690
+ return c.children = [b, p], c;
691
+ }
692
+ if (d === "select") {
693
+ const p = {
694
+ tagName: "select",
695
+ attributes: {
696
+ class: (s == null ? void 0 : s.class) ?? "form-select",
697
+ id: u,
698
+ name: i
699
+ },
700
+ children: ((s == null ? void 0 : s.options) ?? []).map((h) => {
701
+ const D = String(typeof h == "object" ? h.value : h), Z = typeof h == "object" ? h.label ?? h.value : String(h), tt = l != null && String(l) === D;
702
+ return {
703
+ tagName: "option",
704
+ textContent: Z,
705
+ attributes: {
706
+ value: D,
707
+ ...tt ? { selected: !0 } : {}
708
+ }
709
+ };
710
+ })
711
+ };
712
+ return c.children = [b, p], c;
713
+ }
714
+ const f = structuredClone(y.input);
715
+ if (f.attributes.type = d, f.attributes.id = u, f.attributes.name = i, s != null && s.placeholder && (f.attributes.placeholder = s.placeholder), s != null && s.class && (f.attributes.class = s.class), l != null && (f.attributes.value = String(l)), s != null && s.buttonText || s != null && s.button) {
716
+ const p = {
717
+ tagName: "button",
718
+ textContent: s.buttonText ?? ((x = s.button) == null ? void 0 : x.text) ?? "Action",
719
+ attributes: {
720
+ type: "button",
721
+ class: s.buttonClass ?? ((N = s.button) == null ? void 0 : N.class) ?? "btn btn-success",
722
+ id: s.buttonId ?? `${u}-btn`
723
+ }
724
+ };
725
+ return c.children = [b, f, p], c;
726
+ }
727
+ return c.children = [b, f], c;
728
+ }, j = ({ inColumns: t = [], inData: e = [], inOptions: r = {}, columns: s, data: a, options: n } = {}) => {
729
+ const i = Array.isArray(t) && t.length > 0 ? t : Array.isArray(s) ? s : [], d = Array.isArray(e) && e.length > 0 ? e : Array.isArray(a) ? a : [], o = r && Object.keys(r).length > 0 ? r : n ?? {}, u = d[0] ?? {}, l = structuredClone(y.form);
730
+ if (o != null && o.formId && (l.attributes.id = o.formId), o != null && o.className && (l.attributes.class = o.className), l.children = i.map(
731
+ (c, b) => Ce({ inColumn: c, inRow: u, inIndex: b })
732
+ ), (o == null ? void 0 : o.showSubmit) !== !1 && (o == null ? void 0 : o.submitButton) !== !1) {
733
+ const c = structuredClone(y.submitButton);
734
+ o != null && o.submitLabel && (c.textContent = o.submitLabel), o != null && o.submitClass && (c.attributes.class = o.submitClass), l.children.push(c);
735
+ }
736
+ return l;
737
+ }, Ae = {
738
+ tagName: "form",
739
+ attributes: {
740
+ class: "vstack gap-3",
741
+ id: "inlineFormId"
742
+ },
743
+ children: []
744
+ }, xe = {
745
+ tagName: "button",
746
+ textContent: "Submit",
747
+ attributes: {
748
+ type: "submit",
749
+ class: "btn btn-primary align-self-start",
750
+ id: "formSubmitBtnId"
751
+ }
752
+ }, H = {
753
+ form: Ae,
754
+ submitButton: xe
755
+ }, Ne = ({ inColumn: t, inRow: e = {}, inIndex: r = 0 } = {}) => {
756
+ var c, b;
757
+ const s = t, a = e, n = r, i = (s == null ? void 0 : s.columnName) ?? `field_${n}`, d = (s == null ? void 0 : s.type) ?? "text", o = (s == null ? void 0 : s.label) ?? (s == null ? void 0 : s.title) ?? i, u = (s == null ? void 0 : s.id) ?? `form-${n}-${i.toLowerCase()}`, l = a[i] ?? (s == null ? void 0 : s.value);
758
+ return s != null && s.buttonText || s != null && s.button ? v({
759
+ inOptions: {
760
+ label: o,
761
+ type: d,
762
+ id: u,
763
+ name: i,
764
+ placeholder: (s == null ? void 0 : s.placeholder) ?? "",
765
+ class: (s == null ? void 0 : s.class) ?? "form-control",
766
+ value: l != null ? String(l) : void 0,
767
+ buttonText: s.buttonText ?? ((c = s.button) == null ? void 0 : c.text) ?? "Action",
768
+ buttonClass: s.buttonClass ?? ((b = s.button) == null ? void 0 : b.class) ?? "btn btn-outline-primary",
769
+ buttonId: s.buttonId ?? `${u}-btn`,
770
+ wrapperClass: "d-flex align-items-center gap-2 mb-3",
771
+ labelClass: "form-label mb-0 text-nowrap fw-semibold"
772
+ }
773
+ }) : A({
774
+ inOptions: {
775
+ label: o,
776
+ type: d,
777
+ id: u,
778
+ name: i,
779
+ placeholder: (s == null ? void 0 : s.placeholder) ?? "",
780
+ class: (s == null ? void 0 : s.class) ?? "form-control",
781
+ value: l != null ? String(l) : void 0,
782
+ wrapperClass: "d-flex align-items-center gap-2 mb-3",
783
+ labelClass: "form-label mb-0 text-nowrap fw-semibold"
784
+ }
785
+ });
786
+ }, V = ({ inColumns: t = [], inData: e = [], inOptions: r = {}, columns: s, data: a, options: n } = {}) => {
787
+ const i = Array.isArray(t) && t.length > 0 ? t : Array.isArray(s) ? s : [], d = Array.isArray(e) && e.length > 0 ? e : Array.isArray(a) ? a : [], o = r && Object.keys(r).length > 0 ? r : n ?? {}, u = d[0] ?? {}, l = structuredClone(H.form);
788
+ if (o != null && o.formId && (l.attributes.id = o.formId), o != null && o.className && (l.attributes.class = o.className), l.children = i.map(
789
+ (c, b) => Ne({ inColumn: c, inRow: u, inIndex: b })
790
+ ), (o == null ? void 0 : o.showSubmit) !== !1 && (o == null ? void 0 : o.submitButton) !== !1) {
791
+ const c = structuredClone(H.submitButton);
792
+ o != null && o.submitLabel && (c.textContent = o.submitLabel), o != null && o.submitClass && (c.attributes.class = o.submitClass), l.children.push(c);
793
+ }
794
+ return l;
795
+ }, $e = {
796
+ tagName: "div",
797
+ attributes: {
798
+ class: "d-flex align-items-center gap-2 mt-3"
799
+ },
800
+ children: [
801
+ {
802
+ tagName: "button",
803
+ textContent: "Submit",
804
+ attributes: {
805
+ type: "submit",
806
+ class: "btn btn-primary",
807
+ id: "submitBtnId"
808
+ }
809
+ },
810
+ {
811
+ tagName: "button",
812
+ textContent: "Cancel",
813
+ attributes: {
814
+ type: "button",
815
+ class: "btn btn-secondary",
816
+ id: "cancelBtnId"
817
+ }
818
+ }
819
+ ]
820
+ }, Se = {
821
+ buttonBar: $e
822
+ }, G = ({ inColumns: t = [], inData: e = [], inOptions: r = {}, columns: s, data: a, options: n } = {}) => {
823
+ const i = Array.isArray(t) && t.length > 0 ? t : Array.isArray(s) ? s : [], d = Array.isArray(e) && e.length > 0 ? e : Array.isArray(a) ? a : [], o = r && Object.keys(r).length > 0 ? r : n ?? {}, u = j({
824
+ inColumns: i,
825
+ inData: d,
826
+ inOptions: { ...o, submitButton: !1, showSubmit: !1 }
827
+ }), l = structuredClone(Se.buttonBar);
828
+ return o.submitLabel && (l.children[0].textContent = o.submitLabel), o.cancelLabel && (l.children[1].textContent = o.cancelLabel), u.children.push(l), u;
829
+ }, je = {
830
+ stacked: j,
831
+ vertical: j,
832
+ inline: V,
833
+ horizontal: V,
834
+ withButtons: G,
835
+ buttons: G
836
+ }, J = (t = {}) => (t.type ?? (t.type = "stacked"), I(t), (je[t.type] || j)({
837
+ inColumns: t.columns,
838
+ inData: t.data,
839
+ inOptions: t.options
840
+ }));
841
+ he(J);
842
+ const Ie = ({
843
+ inType: t = "stacked",
844
+ inData: e,
845
+ inColumns: r
846
+ } = {}) => J({
847
+ type: t,
848
+ columns: r,
849
+ data: e
850
+ }), Le = {
851
+ table: F,
852
+ tableFromSpec: F,
853
+ select: Qt,
854
+ selectOptionsOnly: Yt,
855
+ dataList: M,
856
+ datalist: M,
857
+ searchInput: k,
858
+ search: k,
859
+ inputRow: k,
860
+ form: Ie
861
+ }, U = (t = {}) => {
862
+ I(t);
863
+ const e = t == null ? void 0 : t.showLog, r = t.type;
864
+ let s = r, a = r;
865
+ if (r.includes(".")) {
866
+ const d = r.split(".");
867
+ s = d[0], a = d[1];
868
+ }
869
+ const n = Le[s];
870
+ if (!n)
871
+ throw new Error(`Renderer for type "${s}" not found.`);
872
+ const i = n({
873
+ inType: a,
874
+ inColumns: t.columns,
875
+ inData: t.data,
876
+ inOptions: t.options,
877
+ options: t.options
878
+ });
879
+ return e && console.log("json-renderers-build output:", i), i;
880
+ };
881
+ wt(U);
882
+ const ve = ({
883
+ inColumns: t,
884
+ inType: e = "table",
885
+ inData: r,
886
+ inShowLog: s = !1
887
+ } = {}) => U({
888
+ type: e,
889
+ data: r ?? [],
890
+ columns: t,
891
+ showLog: s
892
+ }), ke = {
893
+ version: "v9",
894
+ description: "JSON-to-DOM engine with SVG namespace support, mixed text content, and centralized traversal"
895
+ }, Ee = ({ inFuncDefinition: t, inReviewSpec: e } = {}) => {
896
+ if (typeof globalThis > "u" || !t) return;
897
+ globalThis.ks ?? (globalThis.ks = {});
898
+ const r = {
899
+ meta: ke,
900
+ buildSpecElement: t,
901
+ reviewSpec: e
902
+ };
903
+ globalThis.ks["json-to-tag"] = r, globalThis.ks.jsonToTag = r;
904
+ }, Be = (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 ?? "") : Q(t), X = (t) => Array.isArray(t) ? t.map(Be).flat(1 / 0).filter(Boolean) : [], Pe = (t) => (t == null, t), De = "http://www.w3.org/2000/svg", Re = /* @__PURE__ */ new Set([
905
+ "svg",
906
+ "path",
907
+ "symbol",
908
+ "use",
909
+ "g",
910
+ "circle",
911
+ "ellipse",
912
+ "rect",
913
+ "line",
914
+ "polyline",
915
+ "polygon",
916
+ "text",
917
+ "tspan",
918
+ "defs",
919
+ "clippath",
920
+ "mask",
921
+ "pattern",
922
+ "marker",
923
+ "lineargradient",
924
+ "radialgradient",
925
+ "stop",
926
+ "image",
927
+ "filter",
928
+ "fegaussianblur",
929
+ "femerge",
930
+ "femergenode"
931
+ ]), Fe = ({ inTagName: t }) => {
932
+ const e = t == null ? void 0 : t.toLowerCase();
933
+ if (!e) return null;
934
+ if (e === "checkbox") {
935
+ const r = document.createElement("input");
936
+ return r.type = "checkbox", r;
937
+ }
938
+ return Re.has(e) ? document.createElementNS(De, e) : document.createElement(e);
939
+ }, Me = ({ inElement: t, inTextContent: e }) => (!t || e === void 0 || e === null || (t.textContent = e), t), He = ({ inElement: t, inProperties: e }) => (t && e && typeof e == "object" && Object.assign(t, e), t), Ve = "http://www.w3.org/1999/xlink", Ge = ({ inElement: t, inAttributes: e }) => {
940
+ const r = t, s = e;
941
+ if (!r || !s || typeof s != "object")
942
+ return r;
943
+ const a = typeof SVGElement < "u" ? r instanceof SVGElement : r.namespaceURI === "http://www.w3.org/2000/svg";
944
+ return Object.entries(s).forEach(([n, i]) => {
945
+ if (n === "class") {
946
+ a ? r.setAttribute("class", String(i)) : r.className = i;
947
+ return;
948
+ }
949
+ if (n === "xlink:href" || n === "href") {
950
+ if (i != null) {
951
+ const d = String(i);
952
+ if (a)
953
+ try {
954
+ r.setAttributeNS(Ve, "href", d);
955
+ } catch {
956
+ }
957
+ r.setAttribute("href", d), r.setAttribute("xlink:href", d);
958
+ }
959
+ return;
960
+ }
961
+ if (typeof i == "boolean") {
962
+ i ? r.setAttribute(n, "") : r.removeAttribute(n);
963
+ return;
964
+ }
965
+ i != null && r.setAttribute(n, String(i));
966
+ }), r;
967
+ }, Ke = ({ inElement: t, inClassList: e }) => {
968
+ if (!t || !e) return t;
969
+ const r = typeof e == "string" ? e.split(/\s+/).filter(Boolean) : Array.isArray(e) ? e.filter((s) => typeof s == "string" && s.trim()) : [];
970
+ return r.length && t.classList.add(...r), t;
971
+ }, ze = (t) => {
972
+ if (!t || typeof t != "object" || Array.isArray(t) || !t.tagName) return null;
973
+ const e = Fe({ inTagName: t.tagName });
974
+ if (!e) return null;
975
+ if (Me({
976
+ inElement: e,
977
+ inTextContent: Pe(t.textContent),
978
+ inTagName: t.tagName
979
+ }), He({
980
+ inElement: e,
981
+ inProperties: t.properties
982
+ }), Ge({
983
+ inElement: e,
984
+ inAttributes: t.attributes
985
+ }), Ke({
986
+ inElement: e,
987
+ inClassList: t.classList
988
+ }), Array.isArray(t.children)) {
989
+ const r = X(t.children);
990
+ r.length && e.append(...r);
991
+ }
992
+ return e;
993
+ }, Q = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? X(t) : typeof t == "object" ? ze(t) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : null, We = "./tags.schema.json", _e = {
994
+ allowsTextContent: !1,
995
+ allowsChildren: !0,
996
+ allowedAttributes: [
997
+ "title",
998
+ "role"
999
+ ],
1000
+ childTags: []
1001
+ }, qe = {
1002
+ allowsTextContent: !1,
1003
+ allowsChildren: !1,
1004
+ allowedAttributes: [
1005
+ "type",
1006
+ "placeholder",
1007
+ "value",
1008
+ "name",
1009
+ "disabled",
1010
+ "readonly",
1011
+ "required",
1012
+ "list"
1013
+ ]
1014
+ }, Oe = {
1015
+ allowsTextContent: !1,
1016
+ allowsChildren: !1,
1017
+ allowedAttributes: [
1018
+ "type",
1019
+ "checked",
1020
+ "name",
1021
+ "value",
1022
+ "disabled",
1023
+ "required"
1024
+ ]
1025
+ }, Je = {
1026
+ allowsTextContent: !1,
1027
+ allowsChildren: !0,
1028
+ allowedAttributes: [
1029
+ "span"
1030
+ ],
1031
+ childTags: [
1032
+ "col"
1033
+ ]
1034
+ }, Ue = {
1035
+ allowsTextContent: !1,
1036
+ allowsChildren: !1,
1037
+ allowedAttributes: [
1038
+ "span",
1039
+ "style",
1040
+ "width"
1041
+ ]
1042
+ }, Xe = {
1043
+ allowsTextContent: !0,
1044
+ allowsChildren: !0,
1045
+ allowedAttributes: [
1046
+ "for"
1047
+ ],
1048
+ childTags: []
1049
+ }, Qe = {
1050
+ allowsTextContent: !1,
1051
+ allowsChildren: !0,
1052
+ allowedAttributes: [
1053
+ "action",
1054
+ "method",
1055
+ "autocomplete",
1056
+ "enctype",
1057
+ "name",
1058
+ "novalidate",
1059
+ "target"
1060
+ ],
1061
+ childTags: []
1062
+ }, Ye = {
1063
+ allowsTextContent: !1,
1064
+ allowsChildren: !0,
1065
+ allowedAttributes: [
1066
+ "name",
1067
+ "disabled",
1068
+ "required",
1069
+ "multiple",
1070
+ "size"
1071
+ ],
1072
+ childTags: [
1073
+ "option"
1074
+ ]
1075
+ }, Ze = {
1076
+ allowsTextContent: !0,
1077
+ allowsChildren: !0,
1078
+ allowedAttributes: [],
1079
+ childTags: []
1080
+ }, tr = {
1081
+ allowsTextContent: !0,
1082
+ allowsChildren: !0,
1083
+ allowedAttributes: [],
1084
+ childTags: []
1085
+ }, er = {
1086
+ allowsTextContent: !0,
1087
+ allowsChildren: !0,
1088
+ allowedAttributes: [],
1089
+ childTags: []
1090
+ }, rr = {
1091
+ allowsTextContent: !0,
1092
+ allowsChildren: !0,
1093
+ allowedAttributes: [],
1094
+ childTags: []
1095
+ }, sr = {
1096
+ allowsTextContent: !1,
1097
+ allowsChildren: !1,
1098
+ allowedAttributes: [
1099
+ "src",
1100
+ "alt",
1101
+ "width",
1102
+ "height",
1103
+ "loading"
1104
+ ]
1105
+ }, nr = {
1106
+ allowsTextContent: !0,
1107
+ allowsChildren: !0,
1108
+ allowedAttributes: [
1109
+ "type",
1110
+ "disabled",
1111
+ "name",
1112
+ "value"
1113
+ ],
1114
+ childTags: []
1115
+ }, or = {
1116
+ allowsTextContent: !1,
1117
+ allowsChildren: !0,
1118
+ allowedAttributes: [
1119
+ "border",
1120
+ "cellpadding",
1121
+ "cellspacing"
1122
+ ],
1123
+ childTags: [
1124
+ "caption",
1125
+ "colgroup",
1126
+ "thead",
1127
+ "tbody",
1128
+ "tfoot",
1129
+ "tr"
1130
+ ]
1131
+ }, ar = {
1132
+ allowsTextContent: !1,
1133
+ allowsChildren: !0,
1134
+ allowedAttributes: [],
1135
+ childTags: [
1136
+ "tr"
1137
+ ]
1138
+ }, lr = {
1139
+ allowsTextContent: !1,
1140
+ allowsChildren: !0,
1141
+ allowedAttributes: [],
1142
+ childTags: [
1143
+ "tr"
1144
+ ]
1145
+ }, ir = {
1146
+ allowsTextContent: !1,
1147
+ allowsChildren: !0,
1148
+ allowedAttributes: [],
1149
+ childTags: [
1150
+ "tr"
1151
+ ]
1152
+ }, cr = {
1153
+ allowsTextContent: !1,
1154
+ allowsChildren: !0,
1155
+ allowedAttributes: [],
1156
+ childTags: [
1157
+ "td",
1158
+ "th"
1159
+ ]
1160
+ }, ur = {
1161
+ allowsTextContent: !0,
1162
+ allowsChildren: !0,
1163
+ allowedAttributes: [
1164
+ "scope",
1165
+ "colspan",
1166
+ "rowspan"
1167
+ ],
1168
+ childTags: []
1169
+ }, dr = {
1170
+ allowsTextContent: !0,
1171
+ allowsChildren: !0,
1172
+ allowedAttributes: [
1173
+ "colspan",
1174
+ "rowspan"
1175
+ ],
1176
+ childTags: []
1177
+ }, br = {
1178
+ allowsTextContent: !1,
1179
+ allowsChildren: !0,
1180
+ allowedAttributes: [],
1181
+ childTags: [
1182
+ "option"
1183
+ ]
1184
+ }, pr = {
1185
+ allowsTextContent: !0,
1186
+ allowsChildren: !1,
1187
+ allowedAttributes: [
1188
+ "value",
1189
+ "label",
1190
+ "selected",
1191
+ "disabled"
1192
+ ]
1193
+ }, fr = {
1194
+ allowsTextContent: !1,
1195
+ allowsChildren: !0,
1196
+ allowedAttributes: [
1197
+ "role"
1198
+ ],
1199
+ childTags: []
1200
+ }, hr = {
1201
+ allowsTextContent: !0,
1202
+ allowsChildren: !0,
1203
+ allowedAttributes: [
1204
+ "href",
1205
+ "target",
1206
+ "rel",
1207
+ "title",
1208
+ "download"
1209
+ ],
1210
+ childTags: []
1211
+ }, yr = {
1212
+ allowsTextContent: !0,
1213
+ allowsChildren: !0,
1214
+ allowedAttributes: [
1215
+ "aria-hidden"
1216
+ ],
1217
+ childTags: []
1218
+ }, mr = {
1219
+ allowsTextContent: !0,
1220
+ allowsChildren: !0,
1221
+ allowedAttributes: [],
1222
+ childTags: []
1223
+ }, wr = {
1224
+ allowsTextContent: !1,
1225
+ allowsChildren: !0,
1226
+ allowedAttributes: [
1227
+ "type"
1228
+ ],
1229
+ childTags: [
1230
+ "li"
1231
+ ]
1232
+ }, gr = {
1233
+ allowsTextContent: !0,
1234
+ allowsChildren: !0,
1235
+ allowedAttributes: [
1236
+ "value"
1237
+ ],
1238
+ childTags: []
1239
+ }, Tr = {
1240
+ allowsTextContent: !1,
1241
+ allowsChildren: !1,
1242
+ allowedAttributes: []
1243
+ }, Cr = {
1244
+ $schema: We,
1245
+ div: _e,
1246
+ input: qe,
1247
+ checkbox: Oe,
1248
+ colgroup: Je,
1249
+ col: Ue,
1250
+ label: Xe,
1251
+ form: Qe,
1252
+ select: Ye,
1253
+ p: Ze,
1254
+ h1: tr,
1255
+ h2: er,
1256
+ span: rr,
1257
+ img: sr,
1258
+ button: nr,
1259
+ table: or,
1260
+ thead: ar,
1261
+ tbody: lr,
1262
+ tfoot: ir,
1263
+ tr: cr,
1264
+ th: ur,
1265
+ td: dr,
1266
+ datalist: br,
1267
+ option: pr,
1268
+ header: fr,
1269
+ a: hr,
1270
+ i: yr,
1271
+ small: mr,
1272
+ ul: wr,
1273
+ li: gr,
1274
+ hr: Tr
1275
+ }, E = ({ inSpec: t }) => {
1276
+ const e = t;
1277
+ if (!e) return [];
1278
+ if (Array.isArray(e))
1279
+ return e.flatMap((s) => E({ inSpec: s }));
1280
+ if (typeof e != "object") return [];
1281
+ const r = [];
1282
+ return typeof e.tagName == "string" && e.tagName.trim().length > 0 && r.push(e.tagName.toLowerCase()), Array.isArray(e.children) && e.children.length > 0 && e.children.forEach((s) => {
1283
+ const a = E({ inSpec: s });
1284
+ r.push(...a);
1285
+ }), r;
1286
+ }, Ar = ({ inTagsFound: t, inAllowedTags: e }) => {
1287
+ const r = t ?? [], s = e ?? {}, a = new Set(
1288
+ Object.keys(s).filter((l) => l !== "$schema").map((l) => l.toLowerCase())
1289
+ ), n = {}, i = [], d = [];
1290
+ r.forEach((l) => {
1291
+ n[l] = (n[l] || 0) + 1, a.has(l) ? i.includes(l) || i.push(l) : d.includes(l) || d.push(l);
1292
+ });
1293
+ const o = r.length, u = d.length === 0;
1294
+ return {
1295
+ totalTags: o,
1296
+ tagCounts: n,
1297
+ uniqueTags: Object.keys(n),
1298
+ recognizedTags: i,
1299
+ unrecognizedTags: d,
1300
+ areAllTagsPresent: u
1301
+ };
1302
+ }, xr = ({ inSpec: t, inTags: e = Cr } = {}) => {
1303
+ const r = t, s = e, a = E({ inSpec: r }), n = Ar({
1304
+ inTagsFound: a,
1305
+ inAllowedTags: s
1306
+ });
1307
+ return {
1308
+ areAllTagsPresent: n.areAllTagsPresent,
1309
+ totalTags: n.totalTags,
1310
+ tagCounts: n.tagCounts,
1311
+ uniqueTags: n.uniqueTags,
1312
+ recognizedTags: n.recognizedTags,
1313
+ unrecognizedTags: n.unrecognizedTags
1314
+ };
1315
+ }, Y = (t = {}) => {
1316
+ const e = (t == null ? void 0 : t.spec) ?? (t == null ? void 0 : t.inSpec) ?? t;
1317
+ return Q(e);
1318
+ };
1319
+ Ee({
1320
+ inFuncDefinition: Y,
1321
+ inReviewSpec: xr
1322
+ });
1323
+ const Nr = ({
1324
+ inSpec: t,
1325
+ inTargetHtmlId: e,
1326
+ inAppendPosition: r,
1327
+ inShowLog: s = !1
1328
+ } = {}) => {
1329
+ const a = t, n = e, i = r, d = s, o = Y(a);
1330
+ d && console.log("renderToDom 1 (content):", o);
1331
+ const u = document.getElementById(n);
1332
+ return u ? (Array.isArray(o) || o instanceof NodeList || o instanceof HTMLCollection ? i === "prepend" ? u.prepend(...o) : u.append(...o) : i === "prepend" ? u.prepend(o) : (u.innerHTML = "", u.append(o)), d && console.log("renderToDom 2 (mounted):", u), u) : null;
1333
+ }, $r = (t = {}) => {
1334
+ T(t), (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);
1335
+ const r = ve({
1336
+ inColumns: t.columns,
1337
+ inData: t.data,
1338
+ inType: t.type,
1339
+ inShowLog: t.showLog
1340
+ });
1341
+ return Nr({
1342
+ inSpec: r,
1343
+ inTargetHtmlId: t.targetHtmlId,
1344
+ inAppendPosition: t.appendPosition,
1345
+ inShowLog: t.showLog
1346
+ });
1347
+ };
1348
+ rt($r);
1349
+ export {
1350
+ $r as default,
1351
+ $r as render
1352
+ };