json-renderers-build 1.3.3 → 1.3.6

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.
@@ -7,18 +7,18 @@ const d = {
7
7
  meta: d,
8
8
  renderToDom: t
9
9
  }));
10
- }, b = {
10
+ }, y = {
11
11
  version: "v32",
12
12
  description: "JSON-to-DOM engine with centralized traversal and responsibility-focused construction"
13
- }, y = ({ inFuncDefinition: t } = {}) => {
13
+ }, b = ({ inFuncDefinition: t } = {}) => {
14
14
  if (typeof globalThis > "u" || !t) return;
15
15
  globalThis.ks ?? (globalThis.ks = {});
16
16
  const e = {
17
- meta: b,
17
+ meta: y,
18
18
  buildSpecElement: t
19
19
  };
20
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) => {
21
+ }, g = (t, e) => n(t, e), i = (t, e) => Array.isArray(t) ? t.map((r) => g(r, e)).flat(1 / 0).filter(Boolean) : [], h = (t, e) => {
22
22
  if ("source" in t && (t == null ? void 0 : t.source) in e) {
23
23
  const r = e[t == null ? void 0 : t.source];
24
24
  if (Array.isArray(r))
@@ -28,20 +28,20 @@ const d = {
28
28
  return n(o, a);
29
29
  });
30
30
  }
31
- }, v = (t, e) => {
31
+ }, A = (t, e) => {
32
32
  let r = [];
33
33
  for (const [l, a] of Object.entries(e)) {
34
34
  const o = t == null ? void 0 : t.template;
35
35
  if (o) {
36
- const u = n(o, {
36
+ const s = n(o, {
37
37
  key: l,
38
38
  value: a
39
39
  });
40
- r.push(u);
40
+ r.push(s);
41
41
  }
42
42
  }
43
43
  return r;
44
- }, A = (t, e) => {
44
+ }, v = (t, e) => {
45
45
  if ("source" in t && (t == null ? void 0 : t.source) in e) {
46
46
  const r = e[t == null ? void 0 : t.source];
47
47
  if (Array.isArray(r))
@@ -51,14 +51,14 @@ const d = {
51
51
  return n(o, a);
52
52
  });
53
53
  }
54
- }, j = (t, e) => {
54
+ }, $ = (t, e) => {
55
55
  if ("operation" in t) {
56
56
  if (t.operation === "loopArray")
57
57
  return h(t, e);
58
58
  if (t.operation === "loopObject")
59
- return v(t, e);
60
- if (t.operation === "loopCollection")
61
59
  return A(t, e);
60
+ if (t.operation === "loopCollection")
61
+ return v(t, e);
62
62
  }
63
63
  }, f = (t, e) => {
64
64
  if (typeof e == "string") return e;
@@ -71,46 +71,42 @@ const d = {
71
71
  return (e == null ? void 0 : e[l]) ?? "";
72
72
  }
73
73
  return t;
74
- }, $ = (t, e) => {
74
+ }, j = (t, e) => {
75
75
  let r = {};
76
76
  for (const [l, a] of Object.entries(t)) {
77
77
  const o = f(a, e);
78
78
  r[l] = o;
79
79
  }
80
80
  return r;
81
- }, N = (t, e) => {
81
+ }, p = (t, e) => {
82
82
  if ("tagName" in t) {
83
83
  if ("textContent" in t) {
84
84
  const r = f(t.textContent, e);
85
85
  t.textContent = r;
86
86
  }
87
87
  if ("attributes" in t) {
88
- const r = $(t.attributes, e);
88
+ const r = j(t.attributes, e);
89
89
  t.attributes = r;
90
90
  }
91
91
  }
92
- }, p = (t, e) => {
92
+ }, N = (t, e) => {
93
93
  if (!t || typeof t != "object" || Array.isArray(t)) return null;
94
94
  const r = structuredClone(t);
95
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);
96
+ if ("tagName" in r && p(r, e), "jsonToSpec" in r) {
97
+ const l = r == null ? void 0 : r.jsonToSpec, a = $(l, e);
98
98
  Array.isArray(a) ? r.children = a : r.children = [a], delete r.jsonToSpec;
99
99
  }
100
100
  if (Array.isArray(r == null ? void 0 : r.children)) {
101
- const l = c(r == null ? void 0 : r.children, e);
101
+ const l = i(r == null ? void 0 : r.children, e);
102
102
  r.children = l;
103
103
  }
104
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
105
+ }, n = (t, e) => t == null ? null : typeof Node < "u" && t instanceof Node ? t : Array.isArray(t) ? i(t, e) : typeof t == "object" ? N(t, e) : typeof t == "string" || typeof t == "number" ? document.createTextNode(String(t)) : t, u = (t, e) => n(t, e);
106
+ b({
107
+ inFuncDefinition: u
112
108
  });
113
- const C = {
109
+ const D = {
114
110
  default: {
115
111
  tagName: "table",
116
112
  attributes: {
@@ -156,16 +152,16 @@ const C = {
156
152
  }
157
153
  ]
158
154
  }
159
- }, D = ({
155
+ }, O = ({
160
156
  inColumns: t,
161
157
  inData: e
162
158
  } = {}) => {
163
159
  const r = e ?? [], l = t;
164
- return s(C.default, {
160
+ return u(D.default, {
165
161
  columns: l,
166
162
  data: r
167
163
  });
168
- }, k = "select", O = {
164
+ }, C = "select", k = {
169
165
  id: "LedgerName"
170
166
  }, F = {
171
167
  operation: "loopArray",
@@ -177,32 +173,50 @@ const C = {
177
173
  },
178
174
  textContent: "${}"
179
175
  }
180
- }, R = [], w = {
181
- tagName: k,
182
- attributes: O,
176
+ }, R = [], x = {
177
+ tagName: C,
178
+ attributes: k,
183
179
  jsonToSpec: F,
184
180
  children: R
185
- }, x = ({
181
+ }, E = ({
186
182
  inData: t
187
- } = {}) => s(w, {
183
+ } = {}) => u(x, {
188
184
  arrayOfStrings: t ?? []
189
- }), i = {
190
- table: D,
191
- select: x
192
- }, E = ({
185
+ }), w = {
186
+ operation: "loopArray",
187
+ source: "arrayOfStrings",
188
+ template: {
189
+ tagName: "option",
190
+ attributes: {
191
+ value: "${}"
192
+ },
193
+ textContent: "${}"
194
+ }
195
+ }, M = [], B = {
196
+ jsonToSpec: w,
197
+ children: M
198
+ }, G = ({
199
+ inData: t
200
+ } = {}) => u(B, {
201
+ arrayOfStrings: t ?? []
202
+ }), c = {
203
+ table: O,
204
+ select: E,
205
+ selectOptionsOnly: G
206
+ }, z = ({
193
207
  type: t = "table",
194
208
  data: e,
195
209
  columns: r
196
210
  } = {}) => {
197
- const l = t, a = typeof l == "string" ? l.toLowerCase() : "table", o = i[a];
198
- return o ? o({
211
+ const l = t, a = c[l];
212
+ return a ? a({
199
213
  inColumns: r,
200
214
  inData: e
201
215
  }) : (console.error(
202
- `[Renderer] Unknown renderer type "${l}". Available types: ${Object.keys(i).join(", ")}`
216
+ `[Renderer] Unknown renderer type "${l}". Available types: ${Object.keys(c).join(", ")}`
203
217
  ), null);
204
218
  };
205
- m(E);
219
+ m(z);
206
220
  export {
207
- E as default
221
+ z as default
208
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-renderers-build",
3
- "version": "1.3.3",
3
+ "version": "1.3.6",
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",
@@ -29,6 +29,6 @@
29
29
  "vite": "^5.4.2"
30
30
  },
31
31
  "dependencies": {
32
- "json-to-spec": "^32.1.2"
32
+ "json-to-spec": "^32.1.3"
33
33
  }
34
34
  }
package/src/v3/index.js CHANGED
@@ -6,7 +6,8 @@ import renderSelectOptionsOnly from "./selectOptionsOnly/index.js";
6
6
 
7
7
  const RENDERER_MAP = {
8
8
  table: renderTable,
9
- select: renderSelect
9
+ select: renderSelect,
10
+ selectOptionsOnly: renderSelectOptionsOnly
10
11
  };
11
12
 
12
13
  const render = ({
@@ -15,8 +16,7 @@ const render = ({
15
16
  columns
16
17
  } = {}) => {
17
18
  const rawType = type;
18
- const resolvedType = typeof rawType === "string" ? rawType.toLowerCase() : "table";
19
- const renderer = RENDERER_MAP[resolvedType];
19
+ const renderer = RENDERER_MAP[rawType];
20
20
 
21
21
  if (!renderer) {
22
22
  console.error(