json-renderers 1.14.1 → 1.16.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.
@@ -1,1063 +1,1063 @@
1
- const A = {
2
- version: "v14.0.0",
3
- description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
- }, S = (t) => {
5
- var e;
6
- typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderers ?? (e.jsonRenderers = {
7
- meta: A,
8
- renderToDom: t
9
- }));
10
- }, E = {
11
- version: "v9.0.0",
12
- description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
13
- }, v = (t) => {
14
- var e;
15
- typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
16
- meta: E,
17
- renderToDom: t
18
- }));
19
- }, k = "table", j = {
20
- class: "table table-hover table-striped mb-0"
21
- }, O = [], U = {
22
- tagName: k,
23
- attributes: j,
24
- children: O
25
- }, J = "thead", R = [], F = {
26
- tagName: J,
27
- children: R
28
- }, W = "tr", D = [], V = {
29
- tagName: W,
30
- children: D
31
- }, B = "th", I = {
32
- value: ""
33
- }, M = "", H = {
34
- tagName: B,
35
- attributes: I,
36
- textContent: M
37
- }, G = ({ inColumn: t } = {}) => {
38
- const e = structuredClone(H);
39
- return e.attributes.value = t, e.textContent = t, e;
40
- }, q = ({ inColumns: t = [] } = {}) => {
41
- const e = structuredClone(V), n = t.map((o) => G({ inColumn: o }));
42
- return e.children = n, e;
43
- }, z = ({ inColumns: t = [] } = {}) => {
44
- const e = structuredClone(F), n = [
45
- q({ inColumns: t })
46
- ];
47
- return e.children = n, e;
48
- }, K = "tbody", L = [], P = {
49
- tagName: K,
50
- children: L
51
- }, _ = "tr", X = [], Q = {
52
- tagName: _,
53
- children: X
54
- }, Y = "td", Z = {
55
- value: ""
56
- }, tt = "", et = {
57
- tagName: Y,
58
- attributes: Z,
59
- textContent: tt
60
- }, nt = ({ inValue: t } = {}) => {
61
- const e = structuredClone(et);
62
- return e.attributes.value = t, e.textContent = t, e;
63
- }, ot = ({ inRow: t, inColumns: e = [] } = {}) => {
64
- const n = structuredClone(Q), o = e.map((s) => {
65
- const l = Array.isArray(t) ? t[s] : t == null ? void 0 : t[s];
66
- return nt({ inValue: l });
67
- });
68
- return n.children = o, n;
69
- }, st = ({ inData: t = [], inColumns: e = [] } = {}) => {
70
- const n = structuredClone(P), o = t.map((s) => ot({
71
- inRow: s,
72
- inColumns: e
73
- }));
74
- return n.children = o, n;
75
- }, lt = "tfoot", rt = {
76
- class: "table-light"
77
- }, at = [], ct = {
78
- tagName: lt,
79
- attributes: rt,
80
- children: at
81
- }, it = "tr", ut = {
82
- class: "align-middle"
83
- }, dt = [], mt = {
84
- tagName: it,
85
- attributes: ut,
86
- children: dt
87
- }, bt = "td", ht = {
88
- class: "align-middle py-2"
89
- }, pt = [], ft = {
90
- tagName: bt,
91
- attributes: ht,
92
- children: pt
93
- }, gt = "input", yt = {
94
- type: "text",
95
- name: "",
96
- placeholder: "",
97
- class: "form-control form-control-sm"
98
- }, wt = {
99
- tagName: gt,
100
- attributes: yt
101
- }, Tt = ({ inColumn: t } = {}) => {
102
- const e = structuredClone(ft), n = structuredClone(wt);
103
- return n.attributes.name = t, n.attributes.placeholder = t, e.children.push(n), e;
104
- }, Ct = ({ inColumns: t = [] } = {}) => {
105
- const e = structuredClone(mt);
106
- return e.children = t.map((n) => Tt({ inColumn: n })), e;
107
- }, $t = ({ inColumns: t = [] } = {}) => Ct({ inColumns: t }), Nt = "tr", xt = {
108
- class: "align-middle"
109
- }, At = [], St = {
110
- tagName: Nt,
111
- attributes: xt,
112
- children: At
113
- }, Et = "td", vt = {
114
- class: "align-middle py-2"
115
- }, kt = [], jt = {
116
- tagName: Et,
117
- attributes: vt,
118
- children: kt
119
- }, Ot = "input", Ut = {
120
- type: "text",
121
- name: "",
122
- placeholder: "",
123
- class: "form-control form-control-sm"
124
- }, Jt = {
125
- tagName: Ot,
126
- attributes: Ut
127
- }, Rt = "button", Ft = {
128
- type: "button",
129
- class: "btn btn-primary btn-sm ms-2"
130
- }, Wt = "Save", Dt = {
131
- tagName: Rt,
132
- attributes: Ft,
133
- textContent: Wt
134
- }, Vt = ({ inColumn: t, inSave: e = !1 } = {}) => {
135
- const n = structuredClone(jt), o = structuredClone(Jt);
136
- return o.attributes.name = t, o.attributes.placeholder = t, n.children.push(o), e && n.children.push(structuredClone(Dt)), n;
137
- }, Bt = ({ inColumns: t = [] } = {}) => {
138
- const e = structuredClone(St);
139
- return e.children = t.map((n, o) => Vt({
140
- inColumn: n,
141
- inSave: o === t.length - 1
142
- })), e;
143
- }, It = ({ inColumns: t = [] } = {}) => Bt({ inColumns: t }), Mt = "tr", Ht = {
144
- class: "fw-semibold align-middle"
145
- }, Gt = [], qt = {
146
- tagName: Mt,
147
- attributes: Ht,
148
- children: Gt
149
- }, zt = "td", Kt = {
150
- class: "align-middle py-2"
151
- }, Lt = "", Pt = {
152
- tagName: zt,
153
- attributes: Kt,
154
- textContent: Lt
155
- }, _t = (t, e) => Array.isArray(t) ? t[e] : t == null ? void 0 : t[e], Xt = ({ inColumn: t, inIndex: e, inData: n = [] } = {}) => {
156
- const o = structuredClone(Pt), s = n.map((l) => _t(l, t)).filter((l) => l != null && String(l).trim() !== "").map(Number).filter(Number.isFinite);
157
- return o.textContent = s.length ? String(s.reduce((l, r) => l + r, 0)) : e === 0 ? "Total" : "", o;
158
- }, Qt = ({ inColumns: t = [], inData: e = [] } = {}) => {
159
- const n = structuredClone(qt);
160
- return n.children = t.map(
161
- (o, s) => Xt({ inColumn: o, inIndex: s, inData: e })
162
- ), n;
163
- }, Yt = ({ inColumns: t = [], inData: e = [] } = {}) => Qt({ inColumns: t, inData: e }), Zt = "tr", te = {
164
- class: "align-middle"
165
- }, ee = [], ne = {
166
- tagName: Zt,
167
- attributes: te,
168
- children: ee
169
- }, oe = "td", se = {
170
- class: "align-middle py-2"
171
- }, le = {
172
- tagName: oe,
173
- attributes: se
174
- }, re = () => structuredClone(le), ae = ({ inColumns: t = [] } = {}) => {
175
- const e = structuredClone(ne);
176
- return e.children = t.map(() => re()), e;
177
- }, ce = ({ inColumns: t = [] } = {}) => ae({ inColumns: t }), f = {
178
- inputs: $t,
179
- inputsWithSave: It,
180
- totals: Yt,
181
- empty: ce
182
- }, ie = ({ inFooter: t = [], inColumns: e = [], inData: n = [] } = {}) => {
183
- const o = structuredClone(ct);
184
- return o.children = t.map((s) => {
185
- if (!Object.hasOwn(f, s))
186
- throw new Error(`Unknown footer "${s}".`);
187
- return f[s]({ inColumns: e, inData: n });
188
- }), o;
189
- }, ue = ({
190
- inColumns: t = [],
191
- inData: e = [],
192
- inFooter: n = []
193
- } = {}) => {
194
- const o = structuredClone(U), s = [
195
- z({ inColumns: t }),
196
- st({ inData: e, inColumns: t })
197
- ];
198
- if (!Array.isArray(n))
199
- throw new TypeError("The footer property must be an array of footer names.");
200
- return n.length > 0 && s.push(ie({
201
- inFooter: n,
202
- inColumns: t,
203
- inData: e
204
- })), o.children = s, o;
205
- }, de = (t) => {
206
- const [e, n] = t.children;
207
- e.children[0].children.unshift({
208
- tagName: "th",
209
- textContent: "#"
210
- }), n.children.forEach((o, s) => {
211
- o.children.unshift({
212
- tagName: "td",
213
- textContent: String(s + 1)
214
- });
215
- });
216
- }, me = (t) => t === !0 ? [{ label: "Apply", type: "button" }] : Array.isArray(t) ? t : [], be = (t, e) => {
217
- const n = me(e);
218
- if (n.length === 0) return;
219
- const [o, s] = t.children;
220
- o.children[0].children.push({
221
- tagName: "th",
222
- textContent: "Actions"
223
- }), s.children.forEach((l) => {
224
- l.children.push({
225
- tagName: "td",
226
- children: n.map((r) => ({
227
- tagName: "button",
228
- attributes: { type: r.type || "button" },
229
- textContent: r.label
230
- }))
231
- });
232
- });
233
- }, he = (t, e = {}) => (e.showSerial && de(t), e.showOptions && be(t, e.showOptions), t), pe = {
234
- type: "table",
235
- data: [
236
- {
237
- itemName: "0.09/30mm",
238
- baseUnit: "kgs"
239
- }
240
- ],
241
- columns: [
242
- "itemName",
243
- "baseUnit"
244
- ],
245
- options: {}
246
- }, fe = {
247
- type: "table",
248
- data: [
249
- {
250
- itemName: "0.09/30mm",
251
- baseUnit: "kgs"
252
- }
253
- ],
254
- columns: [
255
- "itemName",
256
- "baseUnit"
257
- ],
258
- options: {
259
- showSerial: !0
260
- }
261
- }, ge = {
262
- type: "table",
263
- data: [
264
- {
265
- itemName: "0.09/30mm",
266
- baseUnit: "kgs"
267
- }
268
- ],
269
- columns: [
270
- "itemName",
271
- "baseUnit"
272
- ],
273
- options: {
274
- showOptions: !0
275
- }
276
- }, ye = {
277
- type: "table",
278
- data: [
279
- {
280
- itemName: "0.09/30mm",
281
- baseUnit: "kgs"
282
- }
283
- ],
284
- columns: [
285
- "itemName",
286
- "baseUnit"
287
- ],
288
- options: {
289
- showOptions: [
290
- {
291
- label: "Show",
292
- type: "button"
293
- },
294
- {
295
- label: "Edit",
296
- type: "button"
297
- }
298
- ]
299
- }
300
- }, we = {
301
- type: "table",
302
- data: [
303
- {
304
- itemName: "0.09/30mm",
305
- baseUnit: "kgs"
306
- }
307
- ],
308
- columns: [
309
- "itemName",
310
- "baseUnit"
311
- ],
312
- options: {
313
- showSerial: !0,
314
- showOptions: [
315
- {
316
- label: "Show",
317
- type: "button"
318
- }
319
- ]
320
- }
321
- }, Te = {
322
- type: "table",
323
- data: [
324
- {
325
- itemName: "0.09/30mm",
326
- baseUnit: "kgs"
327
- }
328
- ],
329
- columns: [
330
- "itemName",
331
- "baseUnit"
332
- ],
333
- footer: [
334
- "inputs"
335
- ],
336
- options: {}
337
- }, Ce = {
338
- type: "table",
339
- data: [
340
- {
341
- itemName: "0.09/30mm",
342
- baseUnit: "kgs"
343
- }
344
- ],
345
- columns: [
346
- "itemName",
347
- "baseUnit"
348
- ],
349
- footer: [
350
- "inputsWithSave"
351
- ],
352
- options: {}
353
- }, $e = {
354
- type: "table",
355
- data: [
356
- {
357
- itemName: "0.09/30mm",
358
- baseUnit: "2"
359
- },
360
- {
361
- itemName: "0.11-25",
362
- baseUnit: "3"
363
- }
364
- ],
365
- columns: [
366
- "itemName",
367
- "baseUnit"
368
- ],
369
- footer: [
370
- "totals"
371
- ],
372
- options: {}
373
- }, Ne = {
374
- type: "table",
375
- data: [
376
- {
377
- itemName: "0.09/30mm",
378
- baseUnit: "2"
379
- }
380
- ],
381
- columns: [
382
- "itemName",
383
- "baseUnit"
384
- ],
385
- footer: [
386
- "inputs",
387
- "totals",
388
- "inputsWithSave",
389
- "empty"
390
- ],
391
- options: {}
392
- }, xe = {
393
- type: "tableHead",
394
- data: [],
395
- columns: [
396
- "itemName",
397
- "baseUnit"
398
- ],
399
- options: {}
400
- }, Ae = {
401
- type: "tableBody",
402
- data: [
403
- {
404
- itemName: "0.09/30mm",
405
- baseUnit: "kgs"
406
- }
407
- ],
408
- columns: [
409
- "itemName",
410
- "baseUnit"
411
- ],
412
- options: {}
413
- }, Se = {
414
- table: pe,
415
- tableWithSerial: fe,
416
- tableWithDefaultAction: ge,
417
- tableWithCustomActions: ye,
418
- tableWithSerialAndActions: we,
419
- tableWithFooter: Te,
420
- tableWithFooterSave: Ce,
421
- tableWithTotals: $e,
422
- tableWithMultipleFooters: Ne,
423
- tableHead: xe,
424
- tableBody: Ae
425
- }, g = ({
426
- type: t = "table",
427
- inData: e,
428
- inColumns: n,
429
- footer: o = [],
430
- options: s = {}
431
- } = {}) => {
432
- if (t === "table") {
433
- const l = ue({
434
- inColumns: n,
435
- inData: e,
436
- inFooter: o
437
- });
438
- return he(l, s);
439
- }
440
- throw new Error(`Unknown table renderer type "${t}".`);
441
- };
442
- g.requests = Se;
443
- const y = ({ inItems: t, inRecipe: e, inExecute: n }) => {
444
- const o = t, s = e, l = n;
445
- return o.map((r) => p({
446
- inSource: r,
447
- inRecipe: s,
448
- inExecute: l
449
- })).flat(1 / 0).filter(Boolean);
450
- }, Ee = ({ inSource: t, inRecipe: e, inExecute: n }) => {
451
- const o = t, s = e, l = n;
452
- let r = o;
453
- typeof l == "function" && (r = l({
454
- inSource: o,
455
- inRecipe: s
456
- }));
457
- for (const [a, d] of Object.entries(r))
458
- Array.isArray(d) && s && a in s && (r[a] = y({
459
- inItems: d,
460
- inRecipe: s[a],
461
- inExecute: l
462
- }));
463
- return r;
464
- }, p = ({ inSource: t, inRecipe: e, inExecute: n }) => {
465
- const o = t, s = e, l = n;
466
- return Array.isArray(o) ? y({
467
- inItems: o,
468
- inRecipe: s,
469
- inExecute: l
470
- }) : typeof o == "object" && o !== null ? Ee({
471
- inSource: o,
472
- inRecipe: s,
473
- inExecute: l
474
- }) : o;
475
- }, ve = ({ inKey: t, inDirective: e }) => {
476
- const n = t, o = e;
477
- return (o == null ? void 0 : o.alterKey) || n;
478
- }, ke = ({ inValue: t, inDirective: e, inExecute: n }) => {
479
- const o = t, s = e, l = n;
480
- return s && "transform" in s ? p({
481
- inSource: o,
482
- inRecipe: s,
483
- inExecute: l
484
- }) : o;
485
- }, je = ({ inValue: t, inDirective: e }) => {
486
- const n = t, o = e;
487
- return (o == null ? void 0 : o.valueType) === "array" && !Array.isArray(n) ? [n] : n;
488
- }, Oe = ({ inValue: t, inDirective: e }) => {
489
- const n = t, o = e;
490
- return o != null && o.valueKey && n && typeof n == "object" ? n[o.valueKey] : n;
491
- }, Ue = ({ inSource: t, inTransform: e, inExecute: n }) => {
492
- const o = t, s = e, l = n, r = {};
493
- for (const [a, d] of Object.entries(o)) {
494
- if (!(a in s))
495
- continue;
496
- const u = s[a], c = ve({ inKey: a, inDirective: u });
497
- let i = d;
498
- i = ke({
499
- inValue: i,
500
- inDirective: u,
501
- inExecute: l
502
- }), i = je({ inValue: i, inDirective: u }), i = Oe({ inValue: i, inDirective: u }), r[c] = i;
503
- }
504
- return r;
505
- };
506
- function w(t, e) {
507
- for (const n in t)
508
- typeof t[n] == "object" && t[n] !== null ? w(t[n], e) : typeof t[n] == "string" && t[n] === "${}" && (t[n] = e);
509
- return t;
510
- }
511
- const Je = ({ inSource: t, inOperation: e, inExecute: n }) => {
512
- const o = t, s = e;
513
- for (const [l, r] of Object.entries(s))
514
- if ("operationType" in r && r.operationType === "loopArray" && l in o) {
515
- const a = o[l].map((d) => {
516
- const u = structuredClone(r == null ? void 0 : r.template);
517
- return w(u, d), u;
518
- });
519
- o[l] = a;
520
- }
521
- return o;
522
- }, b = ({ inSource: t, inRecipe: e }) => {
523
- let n = t;
524
- const o = e;
525
- return o && typeof o == "object" && "transform" in o && (n = Ue({
526
- inSource: n,
527
- inTransform: o.transform,
528
- inExecute: b
529
- })), o && typeof o == "object" && "operation" in o && (n = Je({
530
- inSource: n,
531
- inOperation: o.operation,
532
- inExecute: b
533
- })), n;
534
- }, Re = (t, e) => p({
535
- inSource: t,
536
- inRecipe: e,
537
- inExecute: b
538
- }), Fe = {
539
- children: ""
540
- }, We = {
541
- children: {
542
- operationType: "loopArray",
543
- template: {
544
- tagName: "option",
545
- attributes: {
546
- value: "${}"
547
- },
548
- textContent: "${}"
549
- }
550
- }
551
- }, De = {
552
- transform: Fe,
553
- operation: We
554
- }, T = ({
555
- inData: t
556
- }) => {
557
- let n = Re({
558
- children: t
559
- }, De);
560
- return n == null ? void 0 : n.children;
561
- }, Ve = "select", Be = {
562
- id: "LedgerName"
563
- }, Ie = [], Me = {
564
- tagName: Ve,
565
- attributes: Be,
566
- children: Ie
567
- }, He = ({
568
- inData: t
569
- }) => {
570
- let n = T({
571
- inData: t
572
- });
573
- const o = structuredClone(Me);
574
- return o.children = n, o;
575
- }, Ge = {
576
- table: g,
577
- select: He,
578
- selectOptionsOnly: T
579
- }, C = ({
580
- type: t = "table",
581
- data: e,
582
- columns: n
583
- }) => {
584
- const s = Ge[t];
585
- return s({
586
- inColumns: n,
587
- inData: e
588
- });
589
- };
590
- v(C);
591
- const qe = {
592
- version: "v9",
593
- description: "JSON-to-DOM engine with SVG namespace support, mixed text content, and centralized traversal"
594
- }, ze = ({ inFuncDefinition: t, inReviewSpec: e } = {}) => {
595
- if (typeof globalThis > "u" || !t) return;
596
- globalThis.ks ?? (globalThis.ks = {});
597
- const n = {
598
- meta: qe,
599
- buildSpecElement: t,
600
- reviewSpec: e
601
- };
602
- globalThis.ks["json-to-tag"] = n, globalThis.ks.jsonToTag = n;
603
- }, Ke = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : typeof t == "object" && (t.nodeType === 3 || t.tagName === "#text" || !t.tagName && (t.textContent !== void 0 || t.text !== void 0)) ? document.createTextNode(t.textContent ?? t.text ?? "") : N(t), $ = (t) => Array.isArray(t) ? t.map(Ke).flat(1 / 0).filter(Boolean) : [], Le = (t) => (t == null, t), Pe = "http://www.w3.org/2000/svg", _e = /* @__PURE__ */ new Set([
604
- "svg",
605
- "path",
606
- "symbol",
607
- "use",
608
- "g",
609
- "circle",
610
- "ellipse",
611
- "rect",
612
- "line",
613
- "polyline",
614
- "polygon",
615
- "text",
616
- "tspan",
617
- "defs",
618
- "clippath",
619
- "mask",
620
- "pattern",
621
- "marker",
622
- "lineargradient",
623
- "radialgradient",
624
- "stop",
625
- "image",
626
- "filter",
627
- "fegaussianblur",
628
- "femerge",
629
- "femergenode"
630
- ]), Xe = ({ inTagName: t }) => {
631
- const e = t == null ? void 0 : t.toLowerCase();
632
- if (!e) return null;
633
- if (e === "checkbox") {
634
- const n = document.createElement("input");
635
- return n.type = "checkbox", n;
636
- }
637
- return _e.has(e) ? document.createElementNS(Pe, e) : document.createElement(e);
638
- }, Qe = ({ inElement: t, inTextContent: e }) => (!t || e === void 0 || e === null || (t.textContent = e), t), Ye = ({ inElement: t, inProperties: e }) => (t && e && typeof e == "object" && Object.assign(t, e), t), Ze = "http://www.w3.org/1999/xlink", tn = ({ inElement: t, inAttributes: e }) => {
639
- const n = t, o = e;
640
- if (!n || !o || typeof o != "object")
641
- return n;
642
- const s = typeof SVGElement < "u" ? n instanceof SVGElement : n.namespaceURI === "http://www.w3.org/2000/svg";
643
- return Object.entries(o).forEach(([l, r]) => {
644
- if (l === "class") {
645
- s ? n.setAttribute("class", String(r)) : n.className = r;
646
- return;
647
- }
648
- if (l === "xlink:href" || l === "href") {
649
- if (r != null) {
650
- const a = String(r);
651
- if (s)
652
- try {
653
- n.setAttributeNS(Ze, "href", a);
654
- } catch {
655
- }
656
- n.setAttribute("href", a), n.setAttribute("xlink:href", a);
657
- }
658
- return;
659
- }
660
- if (typeof r == "boolean") {
661
- r ? n.setAttribute(l, "") : n.removeAttribute(l);
662
- return;
663
- }
664
- r != null && n.setAttribute(l, String(r));
665
- }), n;
666
- }, en = ({ inElement: t, inClassList: e }) => {
667
- if (!t || !e) return t;
668
- const n = typeof e == "string" ? e.split(/\s+/).filter(Boolean) : Array.isArray(e) ? e.filter((o) => typeof o == "string" && o.trim()) : [];
669
- return n.length && t.classList.add(...n), t;
670
- }, nn = (t) => {
671
- if (!t || typeof t != "object" || Array.isArray(t) || !t.tagName) return null;
672
- const e = Xe({ inTagName: t.tagName });
673
- if (!e) return null;
674
- if (Qe({
675
- inElement: e,
676
- inTextContent: Le(t.textContent),
677
- inTagName: t.tagName
678
- }), Ye({
679
- inElement: e,
680
- inProperties: t.properties
681
- }), tn({
682
- inElement: e,
683
- inAttributes: t.attributes
684
- }), en({
685
- inElement: e,
686
- inClassList: t.classList
687
- }), Array.isArray(t.children)) {
688
- const n = $(t.children);
689
- n.length && e.append(...n);
690
- }
691
- return e;
692
- }, N = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? $(t) : typeof t == "object" ? nn(t) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : null, on = "./tags.schema.json", sn = {
693
- allowsTextContent: !1,
694
- allowsChildren: !0,
695
- allowedAttributes: [
696
- "title",
697
- "role"
698
- ],
699
- childTags: []
700
- }, ln = {
701
- allowsTextContent: !1,
702
- allowsChildren: !1,
703
- allowedAttributes: [
704
- "type",
705
- "placeholder",
706
- "value",
707
- "name",
708
- "disabled",
709
- "readonly",
710
- "required",
711
- "list"
712
- ]
713
- }, rn = {
714
- allowsTextContent: !1,
715
- allowsChildren: !1,
716
- allowedAttributes: [
717
- "type",
718
- "checked",
719
- "name",
720
- "value",
721
- "disabled",
722
- "required"
723
- ]
724
- }, an = {
725
- allowsTextContent: !1,
726
- allowsChildren: !0,
727
- allowedAttributes: [
728
- "span"
729
- ],
730
- childTags: [
731
- "col"
732
- ]
733
- }, cn = {
734
- allowsTextContent: !1,
735
- allowsChildren: !1,
736
- allowedAttributes: [
737
- "span",
738
- "style",
739
- "width"
740
- ]
741
- }, un = {
742
- allowsTextContent: !0,
743
- allowsChildren: !0,
744
- allowedAttributes: [
745
- "for"
746
- ],
747
- childTags: []
748
- }, dn = {
749
- allowsTextContent: !1,
750
- allowsChildren: !0,
751
- allowedAttributes: [
752
- "action",
753
- "method",
754
- "autocomplete",
755
- "enctype",
756
- "name",
757
- "novalidate",
758
- "target"
759
- ],
760
- childTags: []
761
- }, mn = {
762
- allowsTextContent: !1,
763
- allowsChildren: !0,
764
- allowedAttributes: [
765
- "name",
766
- "disabled",
767
- "required",
768
- "multiple",
769
- "size"
770
- ],
771
- childTags: [
772
- "option"
773
- ]
774
- }, bn = {
775
- allowsTextContent: !0,
776
- allowsChildren: !0,
777
- allowedAttributes: [],
778
- childTags: []
779
- }, hn = {
780
- allowsTextContent: !0,
781
- allowsChildren: !0,
782
- allowedAttributes: [],
783
- childTags: []
784
- }, pn = {
785
- allowsTextContent: !0,
786
- allowsChildren: !0,
787
- allowedAttributes: [],
788
- childTags: []
789
- }, fn = {
790
- allowsTextContent: !0,
791
- allowsChildren: !0,
792
- allowedAttributes: [],
793
- childTags: []
794
- }, gn = {
795
- allowsTextContent: !1,
796
- allowsChildren: !1,
797
- allowedAttributes: [
798
- "src",
799
- "alt",
800
- "width",
801
- "height",
802
- "loading"
803
- ]
804
- }, yn = {
805
- allowsTextContent: !0,
806
- allowsChildren: !0,
807
- allowedAttributes: [
808
- "type",
809
- "disabled",
810
- "name",
811
- "value"
812
- ],
813
- childTags: []
814
- }, wn = {
815
- allowsTextContent: !1,
816
- allowsChildren: !0,
817
- allowedAttributes: [
818
- "border",
819
- "cellpadding",
820
- "cellspacing"
821
- ],
822
- childTags: [
823
- "caption",
824
- "colgroup",
825
- "thead",
826
- "tbody",
827
- "tfoot",
828
- "tr"
829
- ]
830
- }, Tn = {
831
- allowsTextContent: !1,
832
- allowsChildren: !0,
833
- allowedAttributes: [],
834
- childTags: [
835
- "tr"
836
- ]
837
- }, Cn = {
838
- allowsTextContent: !1,
839
- allowsChildren: !0,
840
- allowedAttributes: [],
841
- childTags: [
842
- "tr"
843
- ]
844
- }, $n = {
845
- allowsTextContent: !1,
846
- allowsChildren: !0,
847
- allowedAttributes: [],
848
- childTags: [
849
- "tr"
850
- ]
851
- }, Nn = {
852
- allowsTextContent: !1,
853
- allowsChildren: !0,
854
- allowedAttributes: [],
855
- childTags: [
856
- "td",
857
- "th"
858
- ]
859
- }, xn = {
860
- allowsTextContent: !0,
861
- allowsChildren: !0,
862
- allowedAttributes: [
863
- "scope",
864
- "colspan",
865
- "rowspan"
866
- ],
867
- childTags: []
868
- }, An = {
869
- allowsTextContent: !0,
870
- allowsChildren: !0,
871
- allowedAttributes: [
872
- "colspan",
873
- "rowspan"
874
- ],
875
- childTags: []
876
- }, Sn = {
877
- allowsTextContent: !1,
878
- allowsChildren: !0,
879
- allowedAttributes: [],
880
- childTags: [
881
- "option"
882
- ]
883
- }, En = {
884
- allowsTextContent: !0,
885
- allowsChildren: !1,
886
- allowedAttributes: [
887
- "value",
888
- "label",
889
- "selected",
890
- "disabled"
891
- ]
892
- }, vn = {
893
- allowsTextContent: !1,
894
- allowsChildren: !0,
895
- allowedAttributes: [
896
- "role"
897
- ],
898
- childTags: []
899
- }, kn = {
900
- allowsTextContent: !0,
901
- allowsChildren: !0,
902
- allowedAttributes: [
903
- "href",
904
- "target",
905
- "rel",
906
- "title",
907
- "download"
908
- ],
909
- childTags: []
910
- }, jn = {
911
- allowsTextContent: !0,
912
- allowsChildren: !0,
913
- allowedAttributes: [
914
- "aria-hidden"
915
- ],
916
- childTags: []
917
- }, On = {
918
- allowsTextContent: !0,
919
- allowsChildren: !0,
920
- allowedAttributes: [],
921
- childTags: []
922
- }, Un = {
923
- allowsTextContent: !1,
924
- allowsChildren: !0,
925
- allowedAttributes: [
926
- "type"
927
- ],
928
- childTags: [
929
- "li"
930
- ]
931
- }, Jn = {
932
- allowsTextContent: !0,
933
- allowsChildren: !0,
934
- allowedAttributes: [
935
- "value"
936
- ],
937
- childTags: []
938
- }, Rn = {
939
- allowsTextContent: !1,
940
- allowsChildren: !1,
941
- allowedAttributes: []
942
- }, Fn = {
943
- $schema: on,
944
- div: sn,
945
- input: ln,
946
- checkbox: rn,
947
- colgroup: an,
948
- col: cn,
949
- label: un,
950
- form: dn,
951
- select: mn,
952
- p: bn,
953
- h1: hn,
954
- h2: pn,
955
- span: fn,
956
- img: gn,
957
- button: yn,
958
- table: wn,
959
- thead: Tn,
960
- tbody: Cn,
961
- tfoot: $n,
962
- tr: Nn,
963
- th: xn,
964
- td: An,
965
- datalist: Sn,
966
- option: En,
967
- header: vn,
968
- a: kn,
969
- i: jn,
970
- small: On,
971
- ul: Un,
972
- li: Jn,
973
- hr: Rn
974
- }, h = ({ inSpec: t }) => {
975
- const e = t;
976
- if (!e) return [];
977
- if (Array.isArray(e))
978
- return e.flatMap((o) => h({ inSpec: o }));
979
- if (typeof e != "object") return [];
980
- const n = [];
981
- return typeof e.tagName == "string" && e.tagName.trim().length > 0 && n.push(e.tagName.toLowerCase()), Array.isArray(e.children) && e.children.length > 0 && e.children.forEach((o) => {
982
- const s = h({ inSpec: o });
983
- n.push(...s);
984
- }), n;
985
- }, Wn = ({ inTagsFound: t, inAllowedTags: e }) => {
986
- const n = t ?? [], o = e ?? {}, s = new Set(
987
- Object.keys(o).filter((c) => c !== "$schema").map((c) => c.toLowerCase())
988
- ), l = {}, r = [], a = [];
989
- n.forEach((c) => {
990
- l[c] = (l[c] || 0) + 1, s.has(c) ? r.includes(c) || r.push(c) : a.includes(c) || a.push(c);
991
- });
992
- const d = n.length, u = a.length === 0;
993
- return {
994
- totalTags: d,
995
- tagCounts: l,
996
- uniqueTags: Object.keys(l),
997
- recognizedTags: r,
998
- unrecognizedTags: a,
999
- areAllTagsPresent: u
1000
- };
1001
- }, Dn = ({ inSpec: t, inTags: e = Fn } = {}) => {
1002
- const n = t, o = e, s = h({ inSpec: n }), l = Wn({
1003
- inTagsFound: s,
1004
- inAllowedTags: o
1005
- });
1006
- return {
1007
- areAllTagsPresent: l.areAllTagsPresent,
1008
- totalTags: l.totalTags,
1009
- tagCounts: l.tagCounts,
1010
- uniqueTags: l.uniqueTags,
1011
- recognizedTags: l.recognizedTags,
1012
- unrecognizedTags: l.unrecognizedTags
1013
- };
1014
- }, x = (t = {}) => {
1015
- const e = (t == null ? void 0 : t.spec) ?? (t == null ? void 0 : t.inSpec) ?? t;
1016
- return N(e);
1017
- };
1018
- ze({
1019
- inFuncDefinition: x,
1020
- inReviewSpec: Dn
1021
- });
1022
- const Vn = ({
1023
- inTargetHtmlId: t,
1024
- inColumns: e,
1025
- type: n,
1026
- inData: o,
1027
- showLog: s
1028
- } = {}) => {
1029
- const l = t, r = o ?? [], a = e;
1030
- s && console.log("buildSpec 1 :", l, r.localColumns);
1031
- let u = C({
1032
- type: n,
1033
- data: r,
1034
- columns: a
1035
- });
1036
- const c = x(u);
1037
- return console.log("buildSpec 2 :", u, c), s && console.log("buildSpec 3 :", c), c;
1038
- }, Bn = ({
1039
- type: t = "table",
1040
- targetHtmlId: e,
1041
- data: n,
1042
- classToApply: o,
1043
- columns: s,
1044
- appendPosition: l,
1045
- showLog: r = !1
1046
- } = {}) => {
1047
- const a = t, d = e, u = n, c = s;
1048
- r && console.log("showLog 1 :", a, e, n, o, s, l);
1049
- const i = Vn({
1050
- inTargetHtmlId: d,
1051
- inColumns: c,
1052
- showLog: r,
1053
- inData: u,
1054
- type: a
1055
- });
1056
- r && console.log("showLog 2 :", i);
1057
- const m = document.getElementById(d);
1058
- return r && console.log("showLog 3 :", m), Array.isArray(i) || i instanceof NodeList || i instanceof HTMLCollection ? l === "prepend" ? m.prepend(...i) : m.append(...i) : l === "prepend" ? m.prepend(i) : (m && (m.innerHTML = ""), m.append(i)), r && console.log("showLog 5 :", m), m;
1059
- };
1060
- S(Bn);
1061
- export {
1062
- Bn as default
1063
- };
1
+ const A = {
2
+ version: "v14.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, S = (t) => {
5
+ var e;
6
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderers ?? (e.jsonRenderers = {
7
+ meta: A,
8
+ renderToDom: t
9
+ }));
10
+ }, E = {
11
+ version: "v9.0.0",
12
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
13
+ }, v = (t) => {
14
+ var e;
15
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
16
+ meta: E,
17
+ renderToDom: t
18
+ }));
19
+ }, k = "table", j = {
20
+ class: "table table-hover table-striped mb-0"
21
+ }, O = [], U = {
22
+ tagName: k,
23
+ attributes: j,
24
+ children: O
25
+ }, J = "thead", R = [], F = {
26
+ tagName: J,
27
+ children: R
28
+ }, W = "tr", D = [], V = {
29
+ tagName: W,
30
+ children: D
31
+ }, B = "th", I = {
32
+ value: ""
33
+ }, M = "", H = {
34
+ tagName: B,
35
+ attributes: I,
36
+ textContent: M
37
+ }, G = ({ inColumn: t } = {}) => {
38
+ const e = structuredClone(H);
39
+ return e.attributes.value = t, e.textContent = t, e;
40
+ }, q = ({ inColumns: t = [] } = {}) => {
41
+ const e = structuredClone(V), n = t.map((o) => G({ inColumn: o }));
42
+ return e.children = n, e;
43
+ }, z = ({ inColumns: t = [] } = {}) => {
44
+ const e = structuredClone(F), n = [
45
+ q({ inColumns: t })
46
+ ];
47
+ return e.children = n, e;
48
+ }, K = "tbody", L = [], P = {
49
+ tagName: K,
50
+ children: L
51
+ }, _ = "tr", X = [], Q = {
52
+ tagName: _,
53
+ children: X
54
+ }, Y = "td", Z = {
55
+ value: ""
56
+ }, tt = "", et = {
57
+ tagName: Y,
58
+ attributes: Z,
59
+ textContent: tt
60
+ }, nt = ({ inValue: t } = {}) => {
61
+ const e = structuredClone(et);
62
+ return e.attributes.value = t, e.textContent = t, e;
63
+ }, ot = ({ inRow: t, inColumns: e = [] } = {}) => {
64
+ const n = structuredClone(Q), o = e.map((s) => {
65
+ const l = Array.isArray(t) ? t[s] : t == null ? void 0 : t[s];
66
+ return nt({ inValue: l });
67
+ });
68
+ return n.children = o, n;
69
+ }, st = ({ inData: t = [], inColumns: e = [] } = {}) => {
70
+ const n = structuredClone(P), o = t.map((s) => ot({
71
+ inRow: s,
72
+ inColumns: e
73
+ }));
74
+ return n.children = o, n;
75
+ }, lt = "tfoot", rt = {
76
+ class: "table-light"
77
+ }, at = [], ct = {
78
+ tagName: lt,
79
+ attributes: rt,
80
+ children: at
81
+ }, it = "tr", ut = {
82
+ class: "align-middle"
83
+ }, dt = [], mt = {
84
+ tagName: it,
85
+ attributes: ut,
86
+ children: dt
87
+ }, bt = "td", ht = {
88
+ class: "align-middle py-2"
89
+ }, pt = [], ft = {
90
+ tagName: bt,
91
+ attributes: ht,
92
+ children: pt
93
+ }, gt = "input", yt = {
94
+ type: "text",
95
+ name: "",
96
+ placeholder: "",
97
+ class: "form-control form-control-sm"
98
+ }, wt = {
99
+ tagName: gt,
100
+ attributes: yt
101
+ }, Tt = ({ inColumn: t } = {}) => {
102
+ const e = structuredClone(ft), n = structuredClone(wt);
103
+ return n.attributes.name = t, n.attributes.placeholder = t, e.children.push(n), e;
104
+ }, Ct = ({ inColumns: t = [] } = {}) => {
105
+ const e = structuredClone(mt);
106
+ return e.children = t.map((n) => Tt({ inColumn: n })), e;
107
+ }, $t = ({ inColumns: t = [] } = {}) => Ct({ inColumns: t }), Nt = "tr", xt = {
108
+ class: "align-middle"
109
+ }, At = [], St = {
110
+ tagName: Nt,
111
+ attributes: xt,
112
+ children: At
113
+ }, Et = "td", vt = {
114
+ class: "align-middle py-2"
115
+ }, kt = [], jt = {
116
+ tagName: Et,
117
+ attributes: vt,
118
+ children: kt
119
+ }, Ot = "input", Ut = {
120
+ type: "text",
121
+ name: "",
122
+ placeholder: "",
123
+ class: "form-control form-control-sm"
124
+ }, Jt = {
125
+ tagName: Ot,
126
+ attributes: Ut
127
+ }, Rt = "button", Ft = {
128
+ type: "button",
129
+ class: "btn btn-primary btn-sm ms-2"
130
+ }, Wt = "Save", Dt = {
131
+ tagName: Rt,
132
+ attributes: Ft,
133
+ textContent: Wt
134
+ }, Vt = ({ inColumn: t, inSave: e = !1 } = {}) => {
135
+ const n = structuredClone(jt), o = structuredClone(Jt);
136
+ return o.attributes.name = t, o.attributes.placeholder = t, n.children.push(o), e && n.children.push(structuredClone(Dt)), n;
137
+ }, Bt = ({ inColumns: t = [] } = {}) => {
138
+ const e = structuredClone(St);
139
+ return e.children = t.map((n, o) => Vt({
140
+ inColumn: n,
141
+ inSave: o === t.length - 1
142
+ })), e;
143
+ }, It = ({ inColumns: t = [] } = {}) => Bt({ inColumns: t }), Mt = "tr", Ht = {
144
+ class: "fw-semibold align-middle"
145
+ }, Gt = [], qt = {
146
+ tagName: Mt,
147
+ attributes: Ht,
148
+ children: Gt
149
+ }, zt = "td", Kt = {
150
+ class: "align-middle py-2"
151
+ }, Lt = "", Pt = {
152
+ tagName: zt,
153
+ attributes: Kt,
154
+ textContent: Lt
155
+ }, _t = (t, e) => Array.isArray(t) ? t[e] : t == null ? void 0 : t[e], Xt = ({ inColumn: t, inIndex: e, inData: n = [] } = {}) => {
156
+ const o = structuredClone(Pt), s = n.map((l) => _t(l, t)).filter((l) => l != null && String(l).trim() !== "").map(Number).filter(Number.isFinite);
157
+ return o.textContent = s.length ? String(s.reduce((l, r) => l + r, 0)) : e === 0 ? "Total" : "", o;
158
+ }, Qt = ({ inColumns: t = [], inData: e = [] } = {}) => {
159
+ const n = structuredClone(qt);
160
+ return n.children = t.map(
161
+ (o, s) => Xt({ inColumn: o, inIndex: s, inData: e })
162
+ ), n;
163
+ }, Yt = ({ inColumns: t = [], inData: e = [] } = {}) => Qt({ inColumns: t, inData: e }), Zt = "tr", te = {
164
+ class: "align-middle"
165
+ }, ee = [], ne = {
166
+ tagName: Zt,
167
+ attributes: te,
168
+ children: ee
169
+ }, oe = "td", se = {
170
+ class: "align-middle py-2"
171
+ }, le = {
172
+ tagName: oe,
173
+ attributes: se
174
+ }, re = () => structuredClone(le), ae = ({ inColumns: t = [] } = {}) => {
175
+ const e = structuredClone(ne);
176
+ return e.children = t.map(() => re()), e;
177
+ }, ce = ({ inColumns: t = [] } = {}) => ae({ inColumns: t }), f = {
178
+ inputs: $t,
179
+ inputsWithSave: It,
180
+ totals: Yt,
181
+ empty: ce
182
+ }, ie = ({ inFooter: t = [], inColumns: e = [], inData: n = [] } = {}) => {
183
+ const o = structuredClone(ct);
184
+ return o.children = t.map((s) => {
185
+ if (!Object.hasOwn(f, s))
186
+ throw new Error(`Unknown footer "${s}".`);
187
+ return f[s]({ inColumns: e, inData: n });
188
+ }), o;
189
+ }, ue = ({
190
+ inColumns: t = [],
191
+ inData: e = [],
192
+ inFooter: n = []
193
+ } = {}) => {
194
+ const o = structuredClone(U), s = [
195
+ z({ inColumns: t }),
196
+ st({ inData: e, inColumns: t })
197
+ ];
198
+ if (!Array.isArray(n))
199
+ throw new TypeError("The footer property must be an array of footer names.");
200
+ return n.length > 0 && s.push(ie({
201
+ inFooter: n,
202
+ inColumns: t,
203
+ inData: e
204
+ })), o.children = s, o;
205
+ }, de = (t) => {
206
+ const [e, n] = t.children;
207
+ e.children[0].children.unshift({
208
+ tagName: "th",
209
+ textContent: "#"
210
+ }), n.children.forEach((o, s) => {
211
+ o.children.unshift({
212
+ tagName: "td",
213
+ textContent: String(s + 1)
214
+ });
215
+ });
216
+ }, me = (t) => t === !0 ? [{ label: "Apply", type: "button" }] : Array.isArray(t) ? t : [], be = (t, e) => {
217
+ const n = me(e);
218
+ if (n.length === 0) return;
219
+ const [o, s] = t.children;
220
+ o.children[0].children.push({
221
+ tagName: "th",
222
+ textContent: "Actions"
223
+ }), s.children.forEach((l) => {
224
+ l.children.push({
225
+ tagName: "td",
226
+ children: n.map((r) => ({
227
+ tagName: "button",
228
+ attributes: { type: r.type || "button" },
229
+ textContent: r.label
230
+ }))
231
+ });
232
+ });
233
+ }, he = (t, e = {}) => (e.showSerial && de(t), e.showOptions && be(t, e.showOptions), t), pe = {
234
+ type: "table",
235
+ data: [
236
+ {
237
+ itemName: "0.09/30mm",
238
+ baseUnit: "kgs"
239
+ }
240
+ ],
241
+ columns: [
242
+ "itemName",
243
+ "baseUnit"
244
+ ],
245
+ options: {}
246
+ }, fe = {
247
+ type: "table",
248
+ data: [
249
+ {
250
+ itemName: "0.09/30mm",
251
+ baseUnit: "kgs"
252
+ }
253
+ ],
254
+ columns: [
255
+ "itemName",
256
+ "baseUnit"
257
+ ],
258
+ options: {
259
+ showSerial: !0
260
+ }
261
+ }, ge = {
262
+ type: "table",
263
+ data: [
264
+ {
265
+ itemName: "0.09/30mm",
266
+ baseUnit: "kgs"
267
+ }
268
+ ],
269
+ columns: [
270
+ "itemName",
271
+ "baseUnit"
272
+ ],
273
+ options: {
274
+ showOptions: !0
275
+ }
276
+ }, ye = {
277
+ type: "table",
278
+ data: [
279
+ {
280
+ itemName: "0.09/30mm",
281
+ baseUnit: "kgs"
282
+ }
283
+ ],
284
+ columns: [
285
+ "itemName",
286
+ "baseUnit"
287
+ ],
288
+ options: {
289
+ showOptions: [
290
+ {
291
+ label: "Show",
292
+ type: "button"
293
+ },
294
+ {
295
+ label: "Edit",
296
+ type: "button"
297
+ }
298
+ ]
299
+ }
300
+ }, we = {
301
+ type: "table",
302
+ data: [
303
+ {
304
+ itemName: "0.09/30mm",
305
+ baseUnit: "kgs"
306
+ }
307
+ ],
308
+ columns: [
309
+ "itemName",
310
+ "baseUnit"
311
+ ],
312
+ options: {
313
+ showSerial: !0,
314
+ showOptions: [
315
+ {
316
+ label: "Show",
317
+ type: "button"
318
+ }
319
+ ]
320
+ }
321
+ }, Te = {
322
+ type: "table",
323
+ data: [
324
+ {
325
+ itemName: "0.09/30mm",
326
+ baseUnit: "kgs"
327
+ }
328
+ ],
329
+ columns: [
330
+ "itemName",
331
+ "baseUnit"
332
+ ],
333
+ footer: [
334
+ "inputs"
335
+ ],
336
+ options: {}
337
+ }, Ce = {
338
+ type: "table",
339
+ data: [
340
+ {
341
+ itemName: "0.09/30mm",
342
+ baseUnit: "kgs"
343
+ }
344
+ ],
345
+ columns: [
346
+ "itemName",
347
+ "baseUnit"
348
+ ],
349
+ footer: [
350
+ "inputsWithSave"
351
+ ],
352
+ options: {}
353
+ }, $e = {
354
+ type: "table",
355
+ data: [
356
+ {
357
+ itemName: "0.09/30mm",
358
+ baseUnit: "2"
359
+ },
360
+ {
361
+ itemName: "0.11-25",
362
+ baseUnit: "3"
363
+ }
364
+ ],
365
+ columns: [
366
+ "itemName",
367
+ "baseUnit"
368
+ ],
369
+ footer: [
370
+ "totals"
371
+ ],
372
+ options: {}
373
+ }, Ne = {
374
+ type: "table",
375
+ data: [
376
+ {
377
+ itemName: "0.09/30mm",
378
+ baseUnit: "2"
379
+ }
380
+ ],
381
+ columns: [
382
+ "itemName",
383
+ "baseUnit"
384
+ ],
385
+ footer: [
386
+ "inputs",
387
+ "totals",
388
+ "inputsWithSave",
389
+ "empty"
390
+ ],
391
+ options: {}
392
+ }, xe = {
393
+ type: "tableHead",
394
+ data: [],
395
+ columns: [
396
+ "itemName",
397
+ "baseUnit"
398
+ ],
399
+ options: {}
400
+ }, Ae = {
401
+ type: "tableBody",
402
+ data: [
403
+ {
404
+ itemName: "0.09/30mm",
405
+ baseUnit: "kgs"
406
+ }
407
+ ],
408
+ columns: [
409
+ "itemName",
410
+ "baseUnit"
411
+ ],
412
+ options: {}
413
+ }, Se = {
414
+ table: pe,
415
+ tableWithSerial: fe,
416
+ tableWithDefaultAction: ge,
417
+ tableWithCustomActions: ye,
418
+ tableWithSerialAndActions: we,
419
+ tableWithFooter: Te,
420
+ tableWithFooterSave: Ce,
421
+ tableWithTotals: $e,
422
+ tableWithMultipleFooters: Ne,
423
+ tableHead: xe,
424
+ tableBody: Ae
425
+ }, g = ({
426
+ type: t = "table",
427
+ inData: e,
428
+ inColumns: n,
429
+ footer: o = [],
430
+ options: s = {}
431
+ } = {}) => {
432
+ if (t === "table") {
433
+ const l = ue({
434
+ inColumns: n,
435
+ inData: e,
436
+ inFooter: o
437
+ });
438
+ return he(l, s);
439
+ }
440
+ throw new Error(`Unknown table renderer type "${t}".`);
441
+ };
442
+ g.requests = Se;
443
+ const y = ({ inItems: t, inRecipe: e, inExecute: n }) => {
444
+ const o = t, s = e, l = n;
445
+ return o.map((r) => p({
446
+ inSource: r,
447
+ inRecipe: s,
448
+ inExecute: l
449
+ })).flat(1 / 0).filter(Boolean);
450
+ }, Ee = ({ inSource: t, inRecipe: e, inExecute: n }) => {
451
+ const o = t, s = e, l = n;
452
+ let r = o;
453
+ typeof l == "function" && (r = l({
454
+ inSource: o,
455
+ inRecipe: s
456
+ }));
457
+ for (const [a, d] of Object.entries(r))
458
+ Array.isArray(d) && s && a in s && (r[a] = y({
459
+ inItems: d,
460
+ inRecipe: s[a],
461
+ inExecute: l
462
+ }));
463
+ return r;
464
+ }, p = ({ inSource: t, inRecipe: e, inExecute: n }) => {
465
+ const o = t, s = e, l = n;
466
+ return Array.isArray(o) ? y({
467
+ inItems: o,
468
+ inRecipe: s,
469
+ inExecute: l
470
+ }) : typeof o == "object" && o !== null ? Ee({
471
+ inSource: o,
472
+ inRecipe: s,
473
+ inExecute: l
474
+ }) : o;
475
+ }, ve = ({ inKey: t, inDirective: e }) => {
476
+ const n = t, o = e;
477
+ return (o == null ? void 0 : o.alterKey) || n;
478
+ }, ke = ({ inValue: t, inDirective: e, inExecute: n }) => {
479
+ const o = t, s = e, l = n;
480
+ return s && "transform" in s ? p({
481
+ inSource: o,
482
+ inRecipe: s,
483
+ inExecute: l
484
+ }) : o;
485
+ }, je = ({ inValue: t, inDirective: e }) => {
486
+ const n = t, o = e;
487
+ return (o == null ? void 0 : o.valueType) === "array" && !Array.isArray(n) ? [n] : n;
488
+ }, Oe = ({ inValue: t, inDirective: e }) => {
489
+ const n = t, o = e;
490
+ return o != null && o.valueKey && n && typeof n == "object" ? n[o.valueKey] : n;
491
+ }, Ue = ({ inSource: t, inTransform: e, inExecute: n }) => {
492
+ const o = t, s = e, l = n, r = {};
493
+ for (const [a, d] of Object.entries(o)) {
494
+ if (!(a in s))
495
+ continue;
496
+ const u = s[a], c = ve({ inKey: a, inDirective: u });
497
+ let i = d;
498
+ i = ke({
499
+ inValue: i,
500
+ inDirective: u,
501
+ inExecute: l
502
+ }), i = je({ inValue: i, inDirective: u }), i = Oe({ inValue: i, inDirective: u }), r[c] = i;
503
+ }
504
+ return r;
505
+ };
506
+ function w(t, e) {
507
+ for (const n in t)
508
+ typeof t[n] == "object" && t[n] !== null ? w(t[n], e) : typeof t[n] == "string" && t[n] === "${}" && (t[n] = e);
509
+ return t;
510
+ }
511
+ const Je = ({ inSource: t, inOperation: e, inExecute: n }) => {
512
+ const o = t, s = e;
513
+ for (const [l, r] of Object.entries(s))
514
+ if ("operationType" in r && r.operationType === "loopArray" && l in o) {
515
+ const a = o[l].map((d) => {
516
+ const u = structuredClone(r == null ? void 0 : r.template);
517
+ return w(u, d), u;
518
+ });
519
+ o[l] = a;
520
+ }
521
+ return o;
522
+ }, b = ({ inSource: t, inRecipe: e }) => {
523
+ let n = t;
524
+ const o = e;
525
+ return o && typeof o == "object" && "transform" in o && (n = Ue({
526
+ inSource: n,
527
+ inTransform: o.transform,
528
+ inExecute: b
529
+ })), o && typeof o == "object" && "operation" in o && (n = Je({
530
+ inSource: n,
531
+ inOperation: o.operation,
532
+ inExecute: b
533
+ })), n;
534
+ }, Re = (t, e) => p({
535
+ inSource: t,
536
+ inRecipe: e,
537
+ inExecute: b
538
+ }), Fe = {
539
+ children: ""
540
+ }, We = {
541
+ children: {
542
+ operationType: "loopArray",
543
+ template: {
544
+ tagName: "option",
545
+ attributes: {
546
+ value: "${}"
547
+ },
548
+ textContent: "${}"
549
+ }
550
+ }
551
+ }, De = {
552
+ transform: Fe,
553
+ operation: We
554
+ }, T = ({
555
+ inData: t
556
+ }) => {
557
+ let n = Re({
558
+ children: t
559
+ }, De);
560
+ return n == null ? void 0 : n.children;
561
+ }, Ve = "select", Be = {
562
+ id: "LedgerName"
563
+ }, Ie = [], Me = {
564
+ tagName: Ve,
565
+ attributes: Be,
566
+ children: Ie
567
+ }, He = ({
568
+ inData: t
569
+ }) => {
570
+ let n = T({
571
+ inData: t
572
+ });
573
+ const o = structuredClone(Me);
574
+ return o.children = n, o;
575
+ }, Ge = {
576
+ table: g,
577
+ select: He,
578
+ selectOptionsOnly: T
579
+ }, C = ({
580
+ type: t = "table",
581
+ data: e,
582
+ columns: n
583
+ }) => {
584
+ const s = Ge[t];
585
+ return s({
586
+ inColumns: n,
587
+ inData: e
588
+ });
589
+ };
590
+ v(C);
591
+ const qe = {
592
+ version: "v9",
593
+ description: "JSON-to-DOM engine with SVG namespace support, mixed text content, and centralized traversal"
594
+ }, ze = ({ inFuncDefinition: t, inReviewSpec: e } = {}) => {
595
+ if (typeof globalThis > "u" || !t) return;
596
+ globalThis.ks ?? (globalThis.ks = {});
597
+ const n = {
598
+ meta: qe,
599
+ buildSpecElement: t,
600
+ reviewSpec: e
601
+ };
602
+ globalThis.ks["json-to-tag"] = n, globalThis.ks.jsonToTag = n;
603
+ }, Ke = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : typeof t == "object" && (t.nodeType === 3 || t.tagName === "#text" || !t.tagName && (t.textContent !== void 0 || t.text !== void 0)) ? document.createTextNode(t.textContent ?? t.text ?? "") : N(t), $ = (t) => Array.isArray(t) ? t.map(Ke).flat(1 / 0).filter(Boolean) : [], Le = (t) => (t == null, t), Pe = "http://www.w3.org/2000/svg", _e = /* @__PURE__ */ new Set([
604
+ "svg",
605
+ "path",
606
+ "symbol",
607
+ "use",
608
+ "g",
609
+ "circle",
610
+ "ellipse",
611
+ "rect",
612
+ "line",
613
+ "polyline",
614
+ "polygon",
615
+ "text",
616
+ "tspan",
617
+ "defs",
618
+ "clippath",
619
+ "mask",
620
+ "pattern",
621
+ "marker",
622
+ "lineargradient",
623
+ "radialgradient",
624
+ "stop",
625
+ "image",
626
+ "filter",
627
+ "fegaussianblur",
628
+ "femerge",
629
+ "femergenode"
630
+ ]), Xe = ({ inTagName: t }) => {
631
+ const e = t == null ? void 0 : t.toLowerCase();
632
+ if (!e) return null;
633
+ if (e === "checkbox") {
634
+ const n = document.createElement("input");
635
+ return n.type = "checkbox", n;
636
+ }
637
+ return _e.has(e) ? document.createElementNS(Pe, e) : document.createElement(e);
638
+ }, Qe = ({ inElement: t, inTextContent: e }) => (!t || e === void 0 || e === null || (t.textContent = e), t), Ye = ({ inElement: t, inProperties: e }) => (t && e && typeof e == "object" && Object.assign(t, e), t), Ze = "http://www.w3.org/1999/xlink", tn = ({ inElement: t, inAttributes: e }) => {
639
+ const n = t, o = e;
640
+ if (!n || !o || typeof o != "object")
641
+ return n;
642
+ const s = typeof SVGElement < "u" ? n instanceof SVGElement : n.namespaceURI === "http://www.w3.org/2000/svg";
643
+ return Object.entries(o).forEach(([l, r]) => {
644
+ if (l === "class") {
645
+ s ? n.setAttribute("class", String(r)) : n.className = r;
646
+ return;
647
+ }
648
+ if (l === "xlink:href" || l === "href") {
649
+ if (r != null) {
650
+ const a = String(r);
651
+ if (s)
652
+ try {
653
+ n.setAttributeNS(Ze, "href", a);
654
+ } catch {
655
+ }
656
+ n.setAttribute("href", a), n.setAttribute("xlink:href", a);
657
+ }
658
+ return;
659
+ }
660
+ if (typeof r == "boolean") {
661
+ r ? n.setAttribute(l, "") : n.removeAttribute(l);
662
+ return;
663
+ }
664
+ r != null && n.setAttribute(l, String(r));
665
+ }), n;
666
+ }, en = ({ inElement: t, inClassList: e }) => {
667
+ if (!t || !e) return t;
668
+ const n = typeof e == "string" ? e.split(/\s+/).filter(Boolean) : Array.isArray(e) ? e.filter((o) => typeof o == "string" && o.trim()) : [];
669
+ return n.length && t.classList.add(...n), t;
670
+ }, nn = (t) => {
671
+ if (!t || typeof t != "object" || Array.isArray(t) || !t.tagName) return null;
672
+ const e = Xe({ inTagName: t.tagName });
673
+ if (!e) return null;
674
+ if (Qe({
675
+ inElement: e,
676
+ inTextContent: Le(t.textContent),
677
+ inTagName: t.tagName
678
+ }), Ye({
679
+ inElement: e,
680
+ inProperties: t.properties
681
+ }), tn({
682
+ inElement: e,
683
+ inAttributes: t.attributes
684
+ }), en({
685
+ inElement: e,
686
+ inClassList: t.classList
687
+ }), Array.isArray(t.children)) {
688
+ const n = $(t.children);
689
+ n.length && e.append(...n);
690
+ }
691
+ return e;
692
+ }, N = (t) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? $(t) : typeof t == "object" ? nn(t) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : null, on = "./tags.schema.json", sn = {
693
+ allowsTextContent: !1,
694
+ allowsChildren: !0,
695
+ allowedAttributes: [
696
+ "title",
697
+ "role"
698
+ ],
699
+ childTags: []
700
+ }, ln = {
701
+ allowsTextContent: !1,
702
+ allowsChildren: !1,
703
+ allowedAttributes: [
704
+ "type",
705
+ "placeholder",
706
+ "value",
707
+ "name",
708
+ "disabled",
709
+ "readonly",
710
+ "required",
711
+ "list"
712
+ ]
713
+ }, rn = {
714
+ allowsTextContent: !1,
715
+ allowsChildren: !1,
716
+ allowedAttributes: [
717
+ "type",
718
+ "checked",
719
+ "name",
720
+ "value",
721
+ "disabled",
722
+ "required"
723
+ ]
724
+ }, an = {
725
+ allowsTextContent: !1,
726
+ allowsChildren: !0,
727
+ allowedAttributes: [
728
+ "span"
729
+ ],
730
+ childTags: [
731
+ "col"
732
+ ]
733
+ }, cn = {
734
+ allowsTextContent: !1,
735
+ allowsChildren: !1,
736
+ allowedAttributes: [
737
+ "span",
738
+ "style",
739
+ "width"
740
+ ]
741
+ }, un = {
742
+ allowsTextContent: !0,
743
+ allowsChildren: !0,
744
+ allowedAttributes: [
745
+ "for"
746
+ ],
747
+ childTags: []
748
+ }, dn = {
749
+ allowsTextContent: !1,
750
+ allowsChildren: !0,
751
+ allowedAttributes: [
752
+ "action",
753
+ "method",
754
+ "autocomplete",
755
+ "enctype",
756
+ "name",
757
+ "novalidate",
758
+ "target"
759
+ ],
760
+ childTags: []
761
+ }, mn = {
762
+ allowsTextContent: !1,
763
+ allowsChildren: !0,
764
+ allowedAttributes: [
765
+ "name",
766
+ "disabled",
767
+ "required",
768
+ "multiple",
769
+ "size"
770
+ ],
771
+ childTags: [
772
+ "option"
773
+ ]
774
+ }, bn = {
775
+ allowsTextContent: !0,
776
+ allowsChildren: !0,
777
+ allowedAttributes: [],
778
+ childTags: []
779
+ }, hn = {
780
+ allowsTextContent: !0,
781
+ allowsChildren: !0,
782
+ allowedAttributes: [],
783
+ childTags: []
784
+ }, pn = {
785
+ allowsTextContent: !0,
786
+ allowsChildren: !0,
787
+ allowedAttributes: [],
788
+ childTags: []
789
+ }, fn = {
790
+ allowsTextContent: !0,
791
+ allowsChildren: !0,
792
+ allowedAttributes: [],
793
+ childTags: []
794
+ }, gn = {
795
+ allowsTextContent: !1,
796
+ allowsChildren: !1,
797
+ allowedAttributes: [
798
+ "src",
799
+ "alt",
800
+ "width",
801
+ "height",
802
+ "loading"
803
+ ]
804
+ }, yn = {
805
+ allowsTextContent: !0,
806
+ allowsChildren: !0,
807
+ allowedAttributes: [
808
+ "type",
809
+ "disabled",
810
+ "name",
811
+ "value"
812
+ ],
813
+ childTags: []
814
+ }, wn = {
815
+ allowsTextContent: !1,
816
+ allowsChildren: !0,
817
+ allowedAttributes: [
818
+ "border",
819
+ "cellpadding",
820
+ "cellspacing"
821
+ ],
822
+ childTags: [
823
+ "caption",
824
+ "colgroup",
825
+ "thead",
826
+ "tbody",
827
+ "tfoot",
828
+ "tr"
829
+ ]
830
+ }, Tn = {
831
+ allowsTextContent: !1,
832
+ allowsChildren: !0,
833
+ allowedAttributes: [],
834
+ childTags: [
835
+ "tr"
836
+ ]
837
+ }, Cn = {
838
+ allowsTextContent: !1,
839
+ allowsChildren: !0,
840
+ allowedAttributes: [],
841
+ childTags: [
842
+ "tr"
843
+ ]
844
+ }, $n = {
845
+ allowsTextContent: !1,
846
+ allowsChildren: !0,
847
+ allowedAttributes: [],
848
+ childTags: [
849
+ "tr"
850
+ ]
851
+ }, Nn = {
852
+ allowsTextContent: !1,
853
+ allowsChildren: !0,
854
+ allowedAttributes: [],
855
+ childTags: [
856
+ "td",
857
+ "th"
858
+ ]
859
+ }, xn = {
860
+ allowsTextContent: !0,
861
+ allowsChildren: !0,
862
+ allowedAttributes: [
863
+ "scope",
864
+ "colspan",
865
+ "rowspan"
866
+ ],
867
+ childTags: []
868
+ }, An = {
869
+ allowsTextContent: !0,
870
+ allowsChildren: !0,
871
+ allowedAttributes: [
872
+ "colspan",
873
+ "rowspan"
874
+ ],
875
+ childTags: []
876
+ }, Sn = {
877
+ allowsTextContent: !1,
878
+ allowsChildren: !0,
879
+ allowedAttributes: [],
880
+ childTags: [
881
+ "option"
882
+ ]
883
+ }, En = {
884
+ allowsTextContent: !0,
885
+ allowsChildren: !1,
886
+ allowedAttributes: [
887
+ "value",
888
+ "label",
889
+ "selected",
890
+ "disabled"
891
+ ]
892
+ }, vn = {
893
+ allowsTextContent: !1,
894
+ allowsChildren: !0,
895
+ allowedAttributes: [
896
+ "role"
897
+ ],
898
+ childTags: []
899
+ }, kn = {
900
+ allowsTextContent: !0,
901
+ allowsChildren: !0,
902
+ allowedAttributes: [
903
+ "href",
904
+ "target",
905
+ "rel",
906
+ "title",
907
+ "download"
908
+ ],
909
+ childTags: []
910
+ }, jn = {
911
+ allowsTextContent: !0,
912
+ allowsChildren: !0,
913
+ allowedAttributes: [
914
+ "aria-hidden"
915
+ ],
916
+ childTags: []
917
+ }, On = {
918
+ allowsTextContent: !0,
919
+ allowsChildren: !0,
920
+ allowedAttributes: [],
921
+ childTags: []
922
+ }, Un = {
923
+ allowsTextContent: !1,
924
+ allowsChildren: !0,
925
+ allowedAttributes: [
926
+ "type"
927
+ ],
928
+ childTags: [
929
+ "li"
930
+ ]
931
+ }, Jn = {
932
+ allowsTextContent: !0,
933
+ allowsChildren: !0,
934
+ allowedAttributes: [
935
+ "value"
936
+ ],
937
+ childTags: []
938
+ }, Rn = {
939
+ allowsTextContent: !1,
940
+ allowsChildren: !1,
941
+ allowedAttributes: []
942
+ }, Fn = {
943
+ $schema: on,
944
+ div: sn,
945
+ input: ln,
946
+ checkbox: rn,
947
+ colgroup: an,
948
+ col: cn,
949
+ label: un,
950
+ form: dn,
951
+ select: mn,
952
+ p: bn,
953
+ h1: hn,
954
+ h2: pn,
955
+ span: fn,
956
+ img: gn,
957
+ button: yn,
958
+ table: wn,
959
+ thead: Tn,
960
+ tbody: Cn,
961
+ tfoot: $n,
962
+ tr: Nn,
963
+ th: xn,
964
+ td: An,
965
+ datalist: Sn,
966
+ option: En,
967
+ header: vn,
968
+ a: kn,
969
+ i: jn,
970
+ small: On,
971
+ ul: Un,
972
+ li: Jn,
973
+ hr: Rn
974
+ }, h = ({ inSpec: t }) => {
975
+ const e = t;
976
+ if (!e) return [];
977
+ if (Array.isArray(e))
978
+ return e.flatMap((o) => h({ inSpec: o }));
979
+ if (typeof e != "object") return [];
980
+ const n = [];
981
+ return typeof e.tagName == "string" && e.tagName.trim().length > 0 && n.push(e.tagName.toLowerCase()), Array.isArray(e.children) && e.children.length > 0 && e.children.forEach((o) => {
982
+ const s = h({ inSpec: o });
983
+ n.push(...s);
984
+ }), n;
985
+ }, Wn = ({ inTagsFound: t, inAllowedTags: e }) => {
986
+ const n = t ?? [], o = e ?? {}, s = new Set(
987
+ Object.keys(o).filter((c) => c !== "$schema").map((c) => c.toLowerCase())
988
+ ), l = {}, r = [], a = [];
989
+ n.forEach((c) => {
990
+ l[c] = (l[c] || 0) + 1, s.has(c) ? r.includes(c) || r.push(c) : a.includes(c) || a.push(c);
991
+ });
992
+ const d = n.length, u = a.length === 0;
993
+ return {
994
+ totalTags: d,
995
+ tagCounts: l,
996
+ uniqueTags: Object.keys(l),
997
+ recognizedTags: r,
998
+ unrecognizedTags: a,
999
+ areAllTagsPresent: u
1000
+ };
1001
+ }, Dn = ({ inSpec: t, inTags: e = Fn } = {}) => {
1002
+ const n = t, o = e, s = h({ inSpec: n }), l = Wn({
1003
+ inTagsFound: s,
1004
+ inAllowedTags: o
1005
+ });
1006
+ return {
1007
+ areAllTagsPresent: l.areAllTagsPresent,
1008
+ totalTags: l.totalTags,
1009
+ tagCounts: l.tagCounts,
1010
+ uniqueTags: l.uniqueTags,
1011
+ recognizedTags: l.recognizedTags,
1012
+ unrecognizedTags: l.unrecognizedTags
1013
+ };
1014
+ }, x = (t = {}) => {
1015
+ const e = (t == null ? void 0 : t.spec) ?? (t == null ? void 0 : t.inSpec) ?? t;
1016
+ return N(e);
1017
+ };
1018
+ ze({
1019
+ inFuncDefinition: x,
1020
+ inReviewSpec: Dn
1021
+ });
1022
+ const Vn = ({
1023
+ inTargetHtmlId: t,
1024
+ inColumns: e,
1025
+ type: n,
1026
+ inData: o,
1027
+ showLog: s
1028
+ } = {}) => {
1029
+ const l = t, r = o ?? [], a = e;
1030
+ s && console.log("buildSpec 1 :", l, r.localColumns);
1031
+ let u = C({
1032
+ type: n,
1033
+ data: r,
1034
+ columns: a
1035
+ });
1036
+ const c = x(u);
1037
+ return console.log("buildSpec 2 :", u, c), s && console.log("buildSpec 3 :", c), c;
1038
+ }, Bn = ({
1039
+ type: t = "table",
1040
+ targetHtmlId: e,
1041
+ data: n,
1042
+ classToApply: o,
1043
+ columns: s,
1044
+ appendPosition: l,
1045
+ showLog: r = !1
1046
+ } = {}) => {
1047
+ const a = t, d = e, u = n, c = s;
1048
+ r && console.log("showLog 1 :", a, e, n, o, s, l);
1049
+ const i = Vn({
1050
+ inTargetHtmlId: d,
1051
+ inColumns: c,
1052
+ showLog: r,
1053
+ inData: u,
1054
+ type: a
1055
+ });
1056
+ r && console.log("showLog 2 :", i);
1057
+ const m = document.getElementById(d);
1058
+ return r && console.log("showLog 3 :", m), Array.isArray(i) || i instanceof NodeList || i instanceof HTMLCollection ? l === "prepend" ? m.prepend(...i) : m.append(...i) : l === "prepend" ? m.prepend(i) : (m && (m.innerHTML = ""), m.append(i)), r && console.log("showLog 5 :", m), m;
1059
+ };
1060
+ S(Bn);
1061
+ export {
1062
+ Bn as default
1063
+ };