json-renderers-build 1.3.6 → 1.5.2

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.
@@ -0,0 +1,320 @@
1
+ const g = {
2
+ version: "v4.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, j = (t) => {
5
+ var r;
6
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (r = globalThis.ks).jsonRenderersBuild ?? (r.jsonRenderersBuild = {
7
+ meta: g,
8
+ renderToDom: t
9
+ }));
10
+ }, E = {
11
+ version: "v32",
12
+ description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
13
+ }, N = ({ inFuncDefinition: t } = {}) => {
14
+ if (typeof globalThis > "u" || !t) return;
15
+ globalThis.ks ?? (globalThis.ks = {});
16
+ const r = {
17
+ meta: E,
18
+ buildSpecElement: t
19
+ };
20
+ globalThis.ks.jsonToSpec = r;
21
+ }, O = (t, r) => f(t, r), b = (t, r) => Array.isArray(t) ? t.map((e) => O(e, r)).flat(1 / 0).filter(Boolean) : [], x = (t, r) => {
22
+ if ("source" in t && (t == null ? void 0 : t.source) in r) {
23
+ const e = r[t == null ? void 0 : t.source];
24
+ if (Array.isArray(e))
25
+ return e.map((o) => {
26
+ const c = t == null ? void 0 : t.template;
27
+ if (c)
28
+ return f(c, o);
29
+ });
30
+ }
31
+ }, F = (t, r) => {
32
+ let e = [];
33
+ for (const [n, o] of Object.entries(r)) {
34
+ const c = t == null ? void 0 : t.template;
35
+ if (c) {
36
+ const a = f(c, {
37
+ key: n,
38
+ value: o
39
+ });
40
+ e.push(a);
41
+ }
42
+ }
43
+ return e;
44
+ }, R = (t, r) => {
45
+ if ("source" in t && (t == null ? void 0 : t.source) in r) {
46
+ const e = r[t == null ? void 0 : t.source];
47
+ if (Array.isArray(e))
48
+ return e.map((o) => {
49
+ const c = t == null ? void 0 : t.template;
50
+ if (c)
51
+ return f(c, o);
52
+ });
53
+ }
54
+ }, D = (t, r) => {
55
+ if ("operation" in t) {
56
+ if (t.operation === "loopArray")
57
+ return x(t, r);
58
+ if (t.operation === "loopObject")
59
+ return F(t, r);
60
+ if (t.operation === "loopCollection")
61
+ return R(t, r);
62
+ }
63
+ }, A = (t, r) => {
64
+ if (typeof r == "string") return r;
65
+ if (typeof t != "string") return t;
66
+ if (t === "${value}")
67
+ return r.value;
68
+ const e = t.match(/^\$\{(.+?)\}$/);
69
+ if (e) {
70
+ const n = e[1];
71
+ return (r == null ? void 0 : r[n]) ?? "";
72
+ }
73
+ return t;
74
+ }, k = (t, r) => {
75
+ let e = {};
76
+ for (const [n, o] of Object.entries(t)) {
77
+ const c = A(o, r);
78
+ e[n] = c;
79
+ }
80
+ return e;
81
+ }, C = (t, r) => {
82
+ if ("tagName" in t) {
83
+ if ("textContent" in t) {
84
+ const e = A(t.textContent, r);
85
+ t.textContent = e;
86
+ }
87
+ if ("attributes" in t) {
88
+ const e = k(t.attributes, r);
89
+ t.attributes = e;
90
+ }
91
+ }
92
+ }, w = (t, r) => {
93
+ if (!t || typeof t != "object" || Array.isArray(t)) return null;
94
+ const e = structuredClone(t);
95
+ if (!e) return null;
96
+ if ("tagName" in e && C(e, r), "jsonToSpec" in e) {
97
+ const n = e == null ? void 0 : e.jsonToSpec, o = D(n, r);
98
+ Array.isArray(o) ? e.children = o : e.children = [o], delete e.jsonToSpec;
99
+ }
100
+ if (Array.isArray(e == null ? void 0 : e.children)) {
101
+ const n = b(e == null ? void 0 : e.children, r);
102
+ e.children = n;
103
+ }
104
+ return e;
105
+ }, f = (t, r) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? b(t, r) : typeof t == "object" ? w(t, r) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t, y = (t, r) => f(t, r);
106
+ N({
107
+ inFuncDefinition: y
108
+ });
109
+ const V = {
110
+ default: {
111
+ tagName: "table",
112
+ attributes: {
113
+ class: "table table-hover table-striped mb-0"
114
+ },
115
+ children: [
116
+ {
117
+ tagName: "thead",
118
+ children: [
119
+ {
120
+ tagName: "tr",
121
+ jsonToSpec: {
122
+ operation: "loopCollection",
123
+ source: "columns",
124
+ template: {
125
+ tagName: "th",
126
+ textContent: "${title}"
127
+ }
128
+ },
129
+ children: []
130
+ }
131
+ ]
132
+ },
133
+ {
134
+ tagName: "tbody",
135
+ jsonToSpec: {
136
+ operation: "loopCollection",
137
+ source: "data",
138
+ template: {
139
+ tagName: "tr",
140
+ jsonToSpec: {
141
+ operation: "loopObject",
142
+ source: "data",
143
+ template: {
144
+ tagName: "td",
145
+ textContent: "${value}"
146
+ }
147
+ },
148
+ children: []
149
+ }
150
+ },
151
+ children: []
152
+ }
153
+ ]
154
+ }
155
+ }, I = ({
156
+ inColumns: t,
157
+ inData: r
158
+ } = {}) => {
159
+ const e = r ?? [], n = t;
160
+ return y(V.default, {
161
+ columns: n,
162
+ data: e
163
+ });
164
+ }, K = "select", B = {
165
+ id: "LedgerName"
166
+ }, M = {
167
+ operation: "loopArray",
168
+ source: "arrayOfStrings",
169
+ template: {
170
+ tagName: "option",
171
+ attributes: {
172
+ value: "${}"
173
+ },
174
+ textContent: "${}"
175
+ }
176
+ }, T = [], G = {
177
+ tagName: K,
178
+ attributes: B,
179
+ jsonToSpec: M,
180
+ children: T
181
+ }, z = ({
182
+ inData: t
183
+ } = {}) => y(G, {
184
+ arrayOfStrings: t ?? []
185
+ }), $ = ({ inItems: t, inRecipe: r, inExecute: e }) => {
186
+ const n = t, o = r, c = e;
187
+ return n.map((a) => d({
188
+ inSource: a,
189
+ inRecipe: o,
190
+ inExecute: c
191
+ })).flat(1 / 0).filter(Boolean);
192
+ }, L = ({ inSource: t, inRecipe: r, inExecute: e }) => {
193
+ const n = t, o = r, c = e;
194
+ let a = n;
195
+ typeof c == "function" && (a = c({
196
+ inSource: n,
197
+ inRecipe: o
198
+ }));
199
+ for (const [l, u] of Object.entries(a))
200
+ Array.isArray(u) && o && l in o && (a[l] = $({
201
+ inItems: u,
202
+ inRecipe: o[l],
203
+ inExecute: c
204
+ }));
205
+ return a;
206
+ }, d = ({ inSource: t, inRecipe: r, inExecute: e }) => {
207
+ const n = t, o = r, c = e;
208
+ return Array.isArray(n) ? $({
209
+ inItems: n,
210
+ inRecipe: o,
211
+ inExecute: c
212
+ }) : typeof n == "object" && n !== null ? L({
213
+ inSource: n,
214
+ inRecipe: o,
215
+ inExecute: c
216
+ }) : n;
217
+ }, P = ({ inKey: t, inDirective: r }) => {
218
+ const e = t, n = r;
219
+ return (n == null ? void 0 : n.alterKey) || e;
220
+ }, U = ({ inValue: t, inDirective: r, inExecute: e }) => {
221
+ const n = t, o = r, c = e;
222
+ return o && "transform" in o ? d({
223
+ inSource: n,
224
+ inRecipe: o,
225
+ inExecute: c
226
+ }) : n;
227
+ }, _ = ({ inValue: t, inDirective: r }) => {
228
+ const e = t, n = r;
229
+ return (n == null ? void 0 : n.valueType) === "array" && !Array.isArray(e) ? [e] : e;
230
+ }, q = ({ inValue: t, inDirective: r }) => {
231
+ const e = t, n = r;
232
+ return n != null && n.valueKey && e && typeof e == "object" ? e[n.valueKey] : e;
233
+ }, H = ({ inSource: t, inTransform: r, inExecute: e }) => {
234
+ const n = t, o = r, c = e, a = {};
235
+ for (const [l, u] of Object.entries(n)) {
236
+ if (!(l in o))
237
+ continue;
238
+ const i = o[l], h = P({ inKey: l, inDirective: i });
239
+ let s = u;
240
+ s = U({
241
+ inValue: s,
242
+ inDirective: i,
243
+ inExecute: c
244
+ }), s = _({ inValue: s, inDirective: i }), s = q({ inValue: s, inDirective: i }), a[h] = s;
245
+ }
246
+ return a;
247
+ };
248
+ function v(t, r) {
249
+ for (const e in t)
250
+ typeof t[e] == "object" && t[e] !== null ? v(t[e], r) : typeof t[e] == "string" && t[e] === "${}" && (t[e] = r);
251
+ return t;
252
+ }
253
+ const Q = ({ inSource: t, inOperation: r, inExecute: e }) => {
254
+ const n = t, o = r;
255
+ for (const [c, a] of Object.entries(o))
256
+ if ("operationType" in a && a.operationType === "loopArray" && c in n) {
257
+ const l = n[c].map((u) => {
258
+ const i = { ...a == null ? void 0 : a.template };
259
+ return v(i, u), i;
260
+ });
261
+ n[c] = l;
262
+ }
263
+ return n;
264
+ }, m = ({ inSource: t, inRecipe: r }) => {
265
+ let e = t;
266
+ const n = r;
267
+ return n && typeof n == "object" && "transform" in n && (e = H({
268
+ inSource: e,
269
+ inTransform: n.transform,
270
+ inExecute: m
271
+ })), n && typeof n == "object" && "operation" in n && (e = Q({
272
+ inSource: e,
273
+ inOperation: n.operation,
274
+ inExecute: m
275
+ })), e;
276
+ }, W = (t, r) => d({
277
+ inSource: t,
278
+ inRecipe: r,
279
+ inExecute: m
280
+ }), X = {
281
+ children: ""
282
+ }, Y = {
283
+ children: {
284
+ operationType: "loopArray",
285
+ template: {
286
+ tagName: "option",
287
+ attributes: {
288
+ value: "${}"
289
+ },
290
+ textContent: "${}"
291
+ }
292
+ }
293
+ }, Z = {
294
+ transform: X,
295
+ operation: Y
296
+ }, S = ({
297
+ inData: t
298
+ } = {}) => W({
299
+ Children: t ?? []
300
+ }, Z), p = {
301
+ table: I,
302
+ select: z,
303
+ selectOptionsOnly: S
304
+ }, J = ({
305
+ type: t = "table",
306
+ data: r,
307
+ columns: e
308
+ } = {}) => {
309
+ const n = t, o = p[n];
310
+ return o ? o({
311
+ inColumns: e,
312
+ inData: r
313
+ }) : (console.error(
314
+ `[Renderer] Unknown renderer type "${n}". Available types: ${Object.keys(p).join(", ")}`
315
+ ), null);
316
+ };
317
+ j(J);
318
+ export {
319
+ J as default
320
+ };
@@ -0,0 +1,312 @@
1
+ const E = {
2
+ version: "v4.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, N = (t) => {
5
+ var r;
6
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (r = globalThis.ks).jsonRenderersBuild ?? (r.jsonRenderersBuild = {
7
+ meta: E,
8
+ renderToDom: t
9
+ }));
10
+ }, x = {
11
+ version: "v32",
12
+ description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
13
+ }, F = ({ inFuncDefinition: t } = {}) => {
14
+ if (typeof globalThis > "u" || !t) return;
15
+ globalThis.ks ?? (globalThis.ks = {});
16
+ const r = {
17
+ meta: x,
18
+ buildSpecElement: t
19
+ };
20
+ globalThis.ks.jsonToSpec = r;
21
+ }, O = (t, r) => f(t, r), b = (t, r) => Array.isArray(t) ? t.map((e) => O(e, r)).flat(1 / 0).filter(Boolean) : [], R = (t, r) => {
22
+ if ("source" in t && (t == null ? void 0 : t.source) in r) {
23
+ const e = r[t == null ? void 0 : t.source];
24
+ if (Array.isArray(e))
25
+ return e.map((o) => {
26
+ const c = t == null ? void 0 : t.template;
27
+ if (c)
28
+ return f(c, o);
29
+ });
30
+ }
31
+ }, D = (t, r) => {
32
+ let e = [];
33
+ for (const [n, o] of Object.entries(r)) {
34
+ const c = t == null ? void 0 : t.template;
35
+ if (c) {
36
+ const l = f(c, {
37
+ key: n,
38
+ value: o
39
+ });
40
+ e.push(l);
41
+ }
42
+ }
43
+ return e;
44
+ }, k = (t, r) => {
45
+ if ("source" in t && (t == null ? void 0 : t.source) in r) {
46
+ const e = r[t == null ? void 0 : t.source];
47
+ if (Array.isArray(e))
48
+ return e.map((o) => {
49
+ const c = t == null ? void 0 : t.template;
50
+ if (c)
51
+ return f(c, o);
52
+ });
53
+ }
54
+ }, C = (t, r) => {
55
+ if ("operation" in t) {
56
+ if (t.operation === "loopArray")
57
+ return R(t, r);
58
+ if (t.operation === "loopObject")
59
+ return D(t, r);
60
+ if (t.operation === "loopCollection")
61
+ return k(t, r);
62
+ }
63
+ }, A = (t, r) => {
64
+ if (typeof r == "string") return r;
65
+ if (typeof t != "string") return t;
66
+ if (t === "${value}")
67
+ return r.value;
68
+ const e = t.match(/^\$\{(.+?)\}$/);
69
+ if (e) {
70
+ const n = e[1];
71
+ return (r == null ? void 0 : r[n]) ?? "";
72
+ }
73
+ return t;
74
+ }, w = (t, r) => {
75
+ let e = {};
76
+ for (const [n, o] of Object.entries(t)) {
77
+ const c = A(o, r);
78
+ e[n] = c;
79
+ }
80
+ return e;
81
+ }, V = (t, r) => {
82
+ if ("tagName" in t) {
83
+ if ("textContent" in t) {
84
+ const e = A(t.textContent, r);
85
+ t.textContent = e;
86
+ }
87
+ if ("attributes" in t) {
88
+ const e = w(t.attributes, r);
89
+ t.attributes = e;
90
+ }
91
+ }
92
+ }, I = (t, r) => {
93
+ if (!t || typeof t != "object" || Array.isArray(t)) return null;
94
+ const e = structuredClone(t);
95
+ if (!e) return null;
96
+ if ("tagName" in e && V(e, r), "jsonToSpec" in e) {
97
+ const n = e == null ? void 0 : e.jsonToSpec, o = C(n, r);
98
+ Array.isArray(o) ? e.children = o : e.children = [o], delete e.jsonToSpec;
99
+ }
100
+ if (Array.isArray(e == null ? void 0 : e.children)) {
101
+ const n = b(e == null ? void 0 : e.children, r);
102
+ e.children = n;
103
+ }
104
+ return e;
105
+ }, f = (t, r) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? b(t, r) : typeof t == "object" ? I(t, r) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t, $ = (t, r) => f(t, r);
106
+ F({
107
+ inFuncDefinition: $
108
+ });
109
+ const K = {
110
+ default: {
111
+ tagName: "table",
112
+ attributes: {
113
+ class: "table table-hover table-striped mb-0"
114
+ },
115
+ children: [
116
+ {
117
+ tagName: "thead",
118
+ children: [
119
+ {
120
+ tagName: "tr",
121
+ jsonToSpec: {
122
+ operation: "loopCollection",
123
+ source: "columns",
124
+ template: {
125
+ tagName: "th",
126
+ textContent: "${title}"
127
+ }
128
+ },
129
+ children: []
130
+ }
131
+ ]
132
+ },
133
+ {
134
+ tagName: "tbody",
135
+ jsonToSpec: {
136
+ operation: "loopCollection",
137
+ source: "data",
138
+ template: {
139
+ tagName: "tr",
140
+ jsonToSpec: {
141
+ operation: "loopObject",
142
+ source: "data",
143
+ template: {
144
+ tagName: "td",
145
+ textContent: "${value}"
146
+ }
147
+ },
148
+ children: []
149
+ }
150
+ },
151
+ children: []
152
+ }
153
+ ]
154
+ }
155
+ }, B = ({
156
+ inColumns: t,
157
+ inData: r
158
+ } = {}) => {
159
+ const e = r ?? [], n = t;
160
+ return $(K.default, {
161
+ columns: n,
162
+ data: e
163
+ });
164
+ }, h = ({ inItems: t, inRecipe: r, inExecute: e }) => {
165
+ const n = t, o = r, c = e;
166
+ return n.map((l) => y({
167
+ inSource: l,
168
+ inRecipe: o,
169
+ inExecute: c
170
+ })).flat(1 / 0).filter(Boolean);
171
+ }, M = ({ inSource: t, inRecipe: r, inExecute: e }) => {
172
+ const n = t, o = r, c = e;
173
+ let l = n;
174
+ typeof c == "function" && (l = c({
175
+ inSource: n,
176
+ inRecipe: o
177
+ }));
178
+ for (const [a, u] of Object.entries(l))
179
+ Array.isArray(u) && o && a in o && (l[a] = h({
180
+ inItems: u,
181
+ inRecipe: o[a],
182
+ inExecute: c
183
+ }));
184
+ return l;
185
+ }, y = ({ inSource: t, inRecipe: r, inExecute: e }) => {
186
+ const n = t, o = r, c = e;
187
+ return Array.isArray(n) ? h({
188
+ inItems: n,
189
+ inRecipe: o,
190
+ inExecute: c
191
+ }) : typeof n == "object" && n !== null ? M({
192
+ inSource: n,
193
+ inRecipe: o,
194
+ inExecute: c
195
+ }) : n;
196
+ }, G = ({ inKey: t, inDirective: r }) => {
197
+ const e = t, n = r;
198
+ return (n == null ? void 0 : n.alterKey) || e;
199
+ }, z = ({ inValue: t, inDirective: r, inExecute: e }) => {
200
+ const n = t, o = r, c = e;
201
+ return o && "transform" in o ? y({
202
+ inSource: n,
203
+ inRecipe: o,
204
+ inExecute: c
205
+ }) : n;
206
+ }, L = ({ inValue: t, inDirective: r }) => {
207
+ const e = t, n = r;
208
+ return (n == null ? void 0 : n.valueType) === "array" && !Array.isArray(e) ? [e] : e;
209
+ }, P = ({ inValue: t, inDirective: r }) => {
210
+ const e = t, n = r;
211
+ return n != null && n.valueKey && e && typeof e == "object" ? e[n.valueKey] : e;
212
+ }, U = ({ inSource: t, inTransform: r, inExecute: e }) => {
213
+ const n = t, o = r, c = e, l = {};
214
+ for (const [a, u] of Object.entries(n)) {
215
+ if (!(a in o))
216
+ continue;
217
+ const i = o[a], j = G({ inKey: a, inDirective: i });
218
+ let s = u;
219
+ s = z({
220
+ inValue: s,
221
+ inDirective: i,
222
+ inExecute: c
223
+ }), s = L({ inValue: s, inDirective: i }), s = P({ inValue: s, inDirective: i }), l[j] = s;
224
+ }
225
+ return l;
226
+ };
227
+ function v(t, r) {
228
+ for (const e in t)
229
+ typeof t[e] == "object" && t[e] !== null ? v(t[e], r) : typeof t[e] == "string" && t[e] === "${}" && (t[e] = r);
230
+ return t;
231
+ }
232
+ const _ = ({ inSource: t, inOperation: r, inExecute: e }) => {
233
+ const n = t, o = r;
234
+ for (const [c, l] of Object.entries(o))
235
+ if ("operationType" in l && l.operationType === "loopArray" && c in n) {
236
+ const a = n[c].map((u) => {
237
+ const i = { ...l == null ? void 0 : l.template };
238
+ return v(i, u), i;
239
+ });
240
+ n[c] = a;
241
+ }
242
+ return n;
243
+ }, m = ({ inSource: t, inRecipe: r }) => {
244
+ let e = t;
245
+ const n = r;
246
+ return n && typeof n == "object" && "transform" in n && (e = U({
247
+ inSource: e,
248
+ inTransform: n.transform,
249
+ inExecute: m
250
+ })), n && typeof n == "object" && "operation" in n && (e = _({
251
+ inSource: e,
252
+ inOperation: n.operation,
253
+ inExecute: m
254
+ })), e;
255
+ }, q = (t, r) => y({
256
+ inSource: t,
257
+ inRecipe: r,
258
+ inExecute: m
259
+ }), H = {
260
+ children: ""
261
+ }, Q = {
262
+ children: {
263
+ operationType: "loopArray",
264
+ template: {
265
+ tagName: "option",
266
+ attributes: {
267
+ value: "${}"
268
+ },
269
+ textContent: "${}"
270
+ }
271
+ }
272
+ }, W = {
273
+ transform: H,
274
+ operation: Q
275
+ }, g = ({
276
+ inData: t
277
+ } = {}) => q({
278
+ children: t ?? []
279
+ }, W), X = "select", Y = {
280
+ id: "LedgerName"
281
+ }, Z = [], d = {
282
+ tagName: X,
283
+ attributes: Y,
284
+ children: Z
285
+ }, T = ({
286
+ inData: t
287
+ } = {}) => {
288
+ let e = g({
289
+ inData: t ?? []
290
+ });
291
+ return d.children = e == null ? void 0 : e.children, d;
292
+ }, p = {
293
+ table: B,
294
+ select: T,
295
+ selectOptionsOnly: g
296
+ }, S = ({
297
+ type: t = "table",
298
+ data: r,
299
+ columns: e
300
+ } = {}) => {
301
+ const n = t, o = p[n];
302
+ return o ? o({
303
+ inColumns: e,
304
+ inData: r
305
+ }) : (console.error(
306
+ `[Renderer] Unknown renderer type "${n}". Available types: ${Object.keys(p).join(", ")}`
307
+ ), null);
308
+ };
309
+ N(S);
310
+ export {
311
+ S as default
312
+ };