json-renderers-build 1.3.2 → 1.3.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.
@@ -1,210 +1,210 @@
1
- const F = {
2
- version: "v2.0.0",
3
- description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
- }, O = (t) => {
5
- var e;
6
- typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
7
- meta: F,
8
- renderToDom: t
9
- }));
10
- }, w = {
11
- version: "v32",
12
- description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
13
- }, R = ({ inFuncDefinition: t } = {}) => {
14
- if (typeof globalThis > "u" || !t) return;
15
- globalThis.ks ?? (globalThis.ks = {});
16
- const e = {
17
- meta: w,
18
- buildSpecElement: t
19
- };
20
- globalThis.ks.jsonToSpec = e;
21
- }, I = (t, e) => n(t, e), f = (t, e) => Array.isArray(t) ? t.map((r) => I(r, e)).flat(1 / 0).filter(Boolean) : [], E = (t, e) => {
22
- if ("source" in t && (t == null ? void 0 : t.source) in e) {
23
- const r = e[t == null ? void 0 : t.source];
24
- if (Array.isArray(r))
25
- return r.map((l) => {
26
- const o = t == null ? void 0 : t.template;
27
- if (o)
28
- return n(o, l);
29
- });
30
- }
31
- }, H = (t, e) => {
32
- let r = [];
33
- for (const [a, l] of Object.entries(e)) {
34
- const o = t == null ? void 0 : t.template;
35
- if (o) {
36
- const u = n(o, {
37
- key: a,
38
- value: l
39
- });
40
- r.push(u);
41
- }
42
- }
43
- return r;
44
- }, x = (t, e) => {
45
- if ("source" in t && (t == null ? void 0 : t.source) in e) {
46
- const r = e[t == null ? void 0 : t.source];
47
- if (Array.isArray(r))
48
- return r.map((l) => {
49
- const o = t == null ? void 0 : t.template;
50
- if (o)
51
- return n(o, l);
52
- });
53
- }
54
- }, L = (t, e) => {
55
- if ("operation" in t) {
56
- if (t.operation === "loopArray")
57
- return E(t, e);
58
- if (t.operation === "loopObject")
59
- return H(t, e);
60
- if (t.operation === "loopCollection")
61
- return x(t, e);
62
- }
63
- }, d = (t, e) => {
64
- if (typeof e == "string") return e;
65
- if (typeof t != "string") return t;
66
- if (t === "${value}")
67
- return e.value;
68
- const r = t.match(/^\$\{(.+?)\}$/);
69
- if (r) {
70
- const a = r[1];
71
- return (e == null ? void 0 : e[a]) ?? "";
72
- }
73
- return t;
74
- }, G = (t, e) => {
75
- let r = {};
76
- for (const [a, l] of Object.entries(t)) {
77
- const o = d(l, e);
78
- r[a] = o;
79
- }
80
- return r;
81
- }, M = (t, e) => {
82
- if ("tagName" in t) {
83
- if ("textContent" in t) {
84
- const r = d(t.textContent, e);
85
- t.textContent = r;
86
- }
87
- if ("attributes" in t) {
88
- const r = G(t.attributes, e);
89
- t.attributes = r;
90
- }
91
- }
92
- }, B = (t, e) => {
93
- if (!t || typeof t != "object" || Array.isArray(t)) return null;
94
- const r = structuredClone(t);
95
- if (!r) return null;
96
- if ("tagName" in r && M(r, e), "jsonToSpec" in r) {
97
- const a = r == null ? void 0 : r.jsonToSpec, l = L(a, e);
98
- Array.isArray(l) ? r.children = l : r.children = [l], delete r.jsonToSpec;
99
- }
100
- if (Array.isArray(r == null ? void 0 : r.children)) {
101
- const a = f(r == null ? void 0 : r.children, e);
102
- r.children = a;
103
- }
104
- return r;
105
- }, n = (t, e) => {
106
- if (t == null) return null;
107
- debugger;
108
- return typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? f(t, e) : typeof t == "object" ? B(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t;
109
- }, m = (t, e) => n(t, e);
110
- R({
111
- inFuncDefinition: m
112
- });
113
- const z = {
114
- default: {
115
- tagName: "table",
116
- attributes: {
117
- class: "table table-hover table-striped mb-0"
118
- },
119
- children: [
120
- {
121
- tagName: "thead",
122
- children: [
123
- {
124
- tagName: "tr",
125
- jsonToSpec: {
126
- operation: "loopCollection",
127
- source: "columns",
128
- template: {
129
- tagName: "th",
130
- textContent: "${title}"
131
- }
132
- },
133
- children: []
134
- }
135
- ]
136
- },
137
- {
138
- tagName: "tbody",
139
- jsonToSpec: {
140
- operation: "loopCollection",
141
- source: "data",
142
- template: {
143
- tagName: "tr",
144
- jsonToSpec: {
145
- operation: "loopObject",
146
- source: "data",
147
- template: {
148
- tagName: "td",
149
- textContent: "${value}"
150
- }
151
- },
152
- children: []
153
- }
154
- },
155
- children: []
156
- }
157
- ]
158
- }
159
- }, P = ({
160
- targetHtmlId: t,
161
- inTargetHtmlId: e,
162
- inColumns: r,
163
- inData: a
164
- } = {}) => {
165
- const l = a ?? [], o = r;
166
- return m(z.default, {
167
- columns: o,
168
- data: l
169
- });
170
- }, c = {
171
- table: P
172
- }, U = ({
173
- type: t = "table",
174
- targetHtmlId: e,
175
- data: r,
176
- classToApply: a,
177
- inTargetHtmlId: l,
178
- inData: o,
179
- columns: u,
180
- inColumns: y,
181
- colGroup: b,
182
- inColGroup: g,
183
- footerData: h,
184
- inFooterData: v,
185
- config: A,
186
- inConfig: j,
187
- variant: $,
188
- skeletonType: p,
189
- inSkeletonType: N,
190
- showLog: C = !1,
191
- inShowLog: k
192
- } = {}) => {
193
- const i = t, D = typeof i == "string" ? i.toLowerCase() : "table", s = c[D];
194
- return s ? s({
195
- targetHtmlId: l ?? e,
196
- inColumns: y ?? u,
197
- inData: o ?? r,
198
- inColGroup: g ?? b,
199
- inFooterData: v ?? h ?? [],
200
- inConfig: j ?? A ?? {},
201
- inSkeletonType: N ?? p ?? $ ?? "default",
202
- inShowLog: k ?? C ?? !1
203
- }) : (console.error(
204
- `[Renderer] Unknown renderer type "${i}". Available types: ${Object.keys(c).join(", ")}`
205
- ), null);
206
- };
207
- O(U);
208
- export {
209
- U as default
210
- };
1
+ const F = {
2
+ version: "v2.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, O = (t) => {
5
+ var e;
6
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
7
+ meta: F,
8
+ renderToDom: t
9
+ }));
10
+ }, w = {
11
+ version: "v32",
12
+ description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
13
+ }, R = ({ inFuncDefinition: t } = {}) => {
14
+ if (typeof globalThis > "u" || !t) return;
15
+ globalThis.ks ?? (globalThis.ks = {});
16
+ const e = {
17
+ meta: w,
18
+ buildSpecElement: t
19
+ };
20
+ globalThis.ks.jsonToSpec = e;
21
+ }, I = (t, e) => n(t, e), f = (t, e) => Array.isArray(t) ? t.map((r) => I(r, e)).flat(1 / 0).filter(Boolean) : [], E = (t, e) => {
22
+ if ("source" in t && (t == null ? void 0 : t.source) in e) {
23
+ const r = e[t == null ? void 0 : t.source];
24
+ if (Array.isArray(r))
25
+ return r.map((l) => {
26
+ const o = t == null ? void 0 : t.template;
27
+ if (o)
28
+ return n(o, l);
29
+ });
30
+ }
31
+ }, H = (t, e) => {
32
+ let r = [];
33
+ for (const [a, l] of Object.entries(e)) {
34
+ const o = t == null ? void 0 : t.template;
35
+ if (o) {
36
+ const u = n(o, {
37
+ key: a,
38
+ value: l
39
+ });
40
+ r.push(u);
41
+ }
42
+ }
43
+ return r;
44
+ }, x = (t, e) => {
45
+ if ("source" in t && (t == null ? void 0 : t.source) in e) {
46
+ const r = e[t == null ? void 0 : t.source];
47
+ if (Array.isArray(r))
48
+ return r.map((l) => {
49
+ const o = t == null ? void 0 : t.template;
50
+ if (o)
51
+ return n(o, l);
52
+ });
53
+ }
54
+ }, L = (t, e) => {
55
+ if ("operation" in t) {
56
+ if (t.operation === "loopArray")
57
+ return E(t, e);
58
+ if (t.operation === "loopObject")
59
+ return H(t, e);
60
+ if (t.operation === "loopCollection")
61
+ return x(t, e);
62
+ }
63
+ }, d = (t, e) => {
64
+ if (typeof e == "string") return e;
65
+ if (typeof t != "string") return t;
66
+ if (t === "${value}")
67
+ return e.value;
68
+ const r = t.match(/^\$\{(.+?)\}$/);
69
+ if (r) {
70
+ const a = r[1];
71
+ return (e == null ? void 0 : e[a]) ?? "";
72
+ }
73
+ return t;
74
+ }, G = (t, e) => {
75
+ let r = {};
76
+ for (const [a, l] of Object.entries(t)) {
77
+ const o = d(l, e);
78
+ r[a] = o;
79
+ }
80
+ return r;
81
+ }, M = (t, e) => {
82
+ if ("tagName" in t) {
83
+ if ("textContent" in t) {
84
+ const r = d(t.textContent, e);
85
+ t.textContent = r;
86
+ }
87
+ if ("attributes" in t) {
88
+ const r = G(t.attributes, e);
89
+ t.attributes = r;
90
+ }
91
+ }
92
+ }, B = (t, e) => {
93
+ if (!t || typeof t != "object" || Array.isArray(t)) return null;
94
+ const r = structuredClone(t);
95
+ if (!r) return null;
96
+ if ("tagName" in r && M(r, e), "jsonToSpec" in r) {
97
+ const a = r == null ? void 0 : r.jsonToSpec, l = L(a, e);
98
+ Array.isArray(l) ? r.children = l : r.children = [l], delete r.jsonToSpec;
99
+ }
100
+ if (Array.isArray(r == null ? void 0 : r.children)) {
101
+ const a = f(r == null ? void 0 : r.children, e);
102
+ r.children = a;
103
+ }
104
+ return r;
105
+ }, n = (t, e) => {
106
+ if (t == null) return null;
107
+ debugger;
108
+ return typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? f(t, e) : typeof t == "object" ? B(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t;
109
+ }, m = (t, e) => n(t, e);
110
+ R({
111
+ inFuncDefinition: m
112
+ });
113
+ const z = {
114
+ default: {
115
+ tagName: "table",
116
+ attributes: {
117
+ class: "table table-hover table-striped mb-0"
118
+ },
119
+ children: [
120
+ {
121
+ tagName: "thead",
122
+ children: [
123
+ {
124
+ tagName: "tr",
125
+ jsonToSpec: {
126
+ operation: "loopCollection",
127
+ source: "columns",
128
+ template: {
129
+ tagName: "th",
130
+ textContent: "${title}"
131
+ }
132
+ },
133
+ children: []
134
+ }
135
+ ]
136
+ },
137
+ {
138
+ tagName: "tbody",
139
+ jsonToSpec: {
140
+ operation: "loopCollection",
141
+ source: "data",
142
+ template: {
143
+ tagName: "tr",
144
+ jsonToSpec: {
145
+ operation: "loopObject",
146
+ source: "data",
147
+ template: {
148
+ tagName: "td",
149
+ textContent: "${value}"
150
+ }
151
+ },
152
+ children: []
153
+ }
154
+ },
155
+ children: []
156
+ }
157
+ ]
158
+ }
159
+ }, P = ({
160
+ targetHtmlId: t,
161
+ inTargetHtmlId: e,
162
+ inColumns: r,
163
+ inData: a
164
+ } = {}) => {
165
+ const l = a ?? [], o = r;
166
+ return m(z.default, {
167
+ columns: o,
168
+ data: l
169
+ });
170
+ }, c = {
171
+ table: P
172
+ }, U = ({
173
+ type: t = "table",
174
+ targetHtmlId: e,
175
+ data: r,
176
+ classToApply: a,
177
+ inTargetHtmlId: l,
178
+ inData: o,
179
+ columns: u,
180
+ inColumns: y,
181
+ colGroup: b,
182
+ inColGroup: g,
183
+ footerData: h,
184
+ inFooterData: v,
185
+ config: A,
186
+ inConfig: j,
187
+ variant: $,
188
+ skeletonType: p,
189
+ inSkeletonType: N,
190
+ showLog: C = !1,
191
+ inShowLog: k
192
+ } = {}) => {
193
+ const i = t, D = typeof i == "string" ? i.toLowerCase() : "table", s = c[D];
194
+ return s ? s({
195
+ targetHtmlId: l ?? e,
196
+ inColumns: y ?? u,
197
+ inData: o ?? r,
198
+ inColGroup: g ?? b,
199
+ inFooterData: v ?? h ?? [],
200
+ inConfig: j ?? A ?? {},
201
+ inSkeletonType: N ?? p ?? $ ?? "default",
202
+ inShowLog: k ?? C ?? !1
203
+ }) : (console.error(
204
+ `[Renderer] Unknown renderer type "${i}". Available types: ${Object.keys(c).join(", ")}`
205
+ ), null);
206
+ };
207
+ O(U);
208
+ export {
209
+ U as default
210
+ };
@@ -0,0 +1,208 @@
1
+ const d = {
2
+ version: "v3.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ }, m = (t) => {
5
+ var e;
6
+ typeof globalThis > "u" || !t || (globalThis.ks ?? (globalThis.ks = {}), (e = globalThis.ks).jsonRenderersBuild ?? (e.jsonRenderersBuild = {
7
+ meta: d,
8
+ renderToDom: t
9
+ }));
10
+ }, b = {
11
+ version: "v32",
12
+ description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
13
+ }, y = ({ inFuncDefinition: t } = {}) => {
14
+ if (typeof globalThis > "u" || !t) return;
15
+ globalThis.ks ?? (globalThis.ks = {});
16
+ const e = {
17
+ meta: b,
18
+ buildSpecElement: t
19
+ };
20
+ globalThis.ks.jsonToSpec = e;
21
+ }, g = (t, e) => n(t, e), c = (t, e) => Array.isArray(t) ? t.map((r) => g(r, e)).flat(1 / 0).filter(Boolean) : [], h = (t, e) => {
22
+ if ("source" in t && (t == null ? void 0 : t.source) in e) {
23
+ const r = e[t == null ? void 0 : t.source];
24
+ if (Array.isArray(r))
25
+ return r.map((a) => {
26
+ const o = t == null ? void 0 : t.template;
27
+ if (o)
28
+ return n(o, a);
29
+ });
30
+ }
31
+ }, v = (t, e) => {
32
+ let r = [];
33
+ for (const [l, a] of Object.entries(e)) {
34
+ const o = t == null ? void 0 : t.template;
35
+ if (o) {
36
+ const u = n(o, {
37
+ key: l,
38
+ value: a
39
+ });
40
+ r.push(u);
41
+ }
42
+ }
43
+ return r;
44
+ }, A = (t, e) => {
45
+ if ("source" in t && (t == null ? void 0 : t.source) in e) {
46
+ const r = e[t == null ? void 0 : t.source];
47
+ if (Array.isArray(r))
48
+ return r.map((a) => {
49
+ const o = t == null ? void 0 : t.template;
50
+ if (o)
51
+ return n(o, a);
52
+ });
53
+ }
54
+ }, j = (t, e) => {
55
+ if ("operation" in t) {
56
+ if (t.operation === "loopArray")
57
+ return h(t, e);
58
+ if (t.operation === "loopObject")
59
+ return v(t, e);
60
+ if (t.operation === "loopCollection")
61
+ return A(t, e);
62
+ }
63
+ }, f = (t, e) => {
64
+ if (typeof e == "string") return e;
65
+ if (typeof t != "string") return t;
66
+ if (t === "${value}")
67
+ return e.value;
68
+ const r = t.match(/^\$\{(.+?)\}$/);
69
+ if (r) {
70
+ const l = r[1];
71
+ return (e == null ? void 0 : e[l]) ?? "";
72
+ }
73
+ return t;
74
+ }, $ = (t, e) => {
75
+ let r = {};
76
+ for (const [l, a] of Object.entries(t)) {
77
+ const o = f(a, e);
78
+ r[l] = o;
79
+ }
80
+ return r;
81
+ }, N = (t, e) => {
82
+ if ("tagName" in t) {
83
+ if ("textContent" in t) {
84
+ const r = f(t.textContent, e);
85
+ t.textContent = r;
86
+ }
87
+ if ("attributes" in t) {
88
+ const r = $(t.attributes, e);
89
+ t.attributes = r;
90
+ }
91
+ }
92
+ }, p = (t, e) => {
93
+ if (!t || typeof t != "object" || Array.isArray(t)) return null;
94
+ const r = structuredClone(t);
95
+ if (!r) return null;
96
+ if ("tagName" in r && N(r, e), "jsonToSpec" in r) {
97
+ const l = r == null ? void 0 : r.jsonToSpec, a = j(l, e);
98
+ Array.isArray(a) ? r.children = a : r.children = [a], delete r.jsonToSpec;
99
+ }
100
+ if (Array.isArray(r == null ? void 0 : r.children)) {
101
+ const l = c(r == null ? void 0 : r.children, e);
102
+ r.children = l;
103
+ }
104
+ return r;
105
+ }, n = (t, e) => {
106
+ if (t == null) return null;
107
+ debugger;
108
+ return typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? c(t, e) : typeof t == "object" ? p(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t;
109
+ }, s = (t, e) => n(t, e);
110
+ y({
111
+ inFuncDefinition: s
112
+ });
113
+ const C = {
114
+ default: {
115
+ tagName: "table",
116
+ attributes: {
117
+ class: "table table-hover table-striped mb-0"
118
+ },
119
+ children: [
120
+ {
121
+ tagName: "thead",
122
+ children: [
123
+ {
124
+ tagName: "tr",
125
+ jsonToSpec: {
126
+ operation: "loopCollection",
127
+ source: "columns",
128
+ template: {
129
+ tagName: "th",
130
+ textContent: "${title}"
131
+ }
132
+ },
133
+ children: []
134
+ }
135
+ ]
136
+ },
137
+ {
138
+ tagName: "tbody",
139
+ jsonToSpec: {
140
+ operation: "loopCollection",
141
+ source: "data",
142
+ template: {
143
+ tagName: "tr",
144
+ jsonToSpec: {
145
+ operation: "loopObject",
146
+ source: "data",
147
+ template: {
148
+ tagName: "td",
149
+ textContent: "${value}"
150
+ }
151
+ },
152
+ children: []
153
+ }
154
+ },
155
+ children: []
156
+ }
157
+ ]
158
+ }
159
+ }, D = ({
160
+ inColumns: t,
161
+ inData: e
162
+ } = {}) => {
163
+ const r = e ?? [], l = t;
164
+ return s(C.default, {
165
+ columns: l,
166
+ data: r
167
+ });
168
+ }, k = "select", O = {
169
+ id: "LedgerName"
170
+ }, F = {
171
+ operation: "loopArray",
172
+ source: "arrayOfStrings",
173
+ template: {
174
+ tagName: "option",
175
+ attributes: {
176
+ value: "${}"
177
+ },
178
+ textContent: "${}"
179
+ }
180
+ }, R = [], w = {
181
+ tagName: k,
182
+ attributes: O,
183
+ jsonToSpec: F,
184
+ children: R
185
+ }, x = ({
186
+ inData: t
187
+ } = {}) => s(w, {
188
+ arrayOfStrings: t ?? []
189
+ }), i = {
190
+ table: D,
191
+ select: x
192
+ }, E = ({
193
+ type: t = "table",
194
+ data: e,
195
+ columns: r
196
+ } = {}) => {
197
+ const l = t, a = typeof l == "string" ? l.toLowerCase() : "table", o = i[a];
198
+ return o ? o({
199
+ inColumns: r,
200
+ inData: e
201
+ }) : (console.error(
202
+ `[Renderer] Unknown renderer type "${l}". Available types: ${Object.keys(i).join(", ")}`
203
+ ), null);
204
+ };
205
+ m(E);
206
+ export {
207
+ E as default
208
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-renderers-build",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Standalone, config-driven Table renderer built on top of json-to-dom",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/v3/index.js CHANGED
@@ -2,10 +2,12 @@ import registerGlobal from "./registerGlobal.js";
2
2
 
3
3
  import renderTable from "./table/index.js";
4
4
  import renderSelect from "./select/index.js";
5
+ import renderSelectOptionsOnly from "./selectOptionsOnly/index.js";
5
6
 
6
7
  const RENDERER_MAP = {
7
8
  table: renderTable,
8
- select: renderSelect
9
+ select: renderSelect,
10
+ selectOptionsOnly: renderSelectOptionsOnly
9
11
  };
10
12
 
11
13
  const render = ({
@@ -0,0 +1,18 @@
1
+ import jsonToSpec from "json-to-spec";
2
+
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ // --- Story of Table Render ---
6
+ const startFunc = ({
7
+ inData,
8
+ } = {}) => {
9
+ const localData = inData ?? [];
10
+
11
+ let specAsJsonToDom = jsonToSpec(skeletonJson, {
12
+ arrayOfStrings: localData
13
+ });
14
+
15
+ return specAsJsonToDom;
16
+ };
17
+
18
+ export default startFunc;
@@ -0,0 +1,14 @@
1
+ {
2
+ "jsonToSpec": {
3
+ "operation": "loopArray",
4
+ "source": "arrayOfStrings",
5
+ "template": {
6
+ "tagName": "option",
7
+ "attributes": {
8
+ "value": "${}"
9
+ },
10
+ "textContent": "${}"
11
+ }
12
+ },
13
+ "children": []
14
+ }