json-renderers-build-table 1.22.3 → 1.26.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.
Files changed (191) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +2 -2
  3. package/src/{v21 → v23/builders}/bodyOnly/index.js +1 -1
  4. package/src/v23/builders/footerOnly/base.json +3 -0
  5. package/src/v23/builders/footerOnly/index.js +21 -0
  6. package/src/v23/builders/footerOnly/instructions/single.json +19 -0
  7. package/src/{v21 → v23/builders}/headerOnly/index.js +1 -1
  8. package/src/{v21 → v23/builders}/simple/index.js +2 -2
  9. package/src/{v17/simple → v23/builders}/spec.json +17 -0
  10. package/src/{v20/simple → v23/builders/withFooter}/index.js +7 -5
  11. package/src/v23/builders/withFooter/instructions/single.json +56 -0
  12. package/src/v23/builders/withOptions/index.js +51 -0
  13. package/src/v23/builders/withOptions/instructions/double.json +19 -0
  14. package/src/v23/builders/withOptions/instructions/postSingle.json +22 -0
  15. package/src/v23/builders/withOptions/instructions/single.json +78 -0
  16. package/src/v23/builders/withSerial/index.js +51 -0
  17. package/src/v23/builders/withSerial/instructions/double.json +19 -0
  18. package/src/v23/builders/withSerial/instructions/postSingle.json +22 -0
  19. package/src/v23/builders/withSerial/instructions/single.json +78 -0
  20. package/src/v23/index.js +34 -0
  21. package/src/{v21 → v23}/singleInstruction/index.js +14 -1
  22. package/src/v24/actions/index.js +5 -0
  23. package/src/v24/actions/insertOptions/index.js +47 -0
  24. package/src/v24/actions/insertOptions/instructions/footer.json +22 -0
  25. package/src/v24/actions/insertOptions/instructions/single.json +62 -0
  26. package/src/v24/actions/insertSerial/index.js +47 -0
  27. package/src/v24/actions/insertSerial/instructions/footer.json +22 -0
  28. package/src/v24/actions/insertSerial/instructions/single.json +62 -0
  29. package/src/{v20 → v24/builders}/bodyOnly/index.js +3 -3
  30. package/src/v24/builders/footerOnly/base.json +3 -0
  31. package/src/v24/builders/footerOnly/index.js +21 -0
  32. package/src/v24/builders/footerOnly/instructions/single.json +19 -0
  33. package/src/{v20 → v24/builders}/headerOnly/index.js +3 -3
  34. package/src/v24/builders/simple/index.js +49 -0
  35. package/src/{v18/headerOnly → v24/builders}/spec.json +21 -0
  36. package/src/v24/builders/withFooter/index.js +49 -0
  37. package/src/v24/builders/withFooter/instructions/single.json +56 -0
  38. package/src/{v20 → v24}/doubleInstruction/index.js +5 -3
  39. package/src/v24/guards/index.js +10 -0
  40. package/src/v24/guards/references/func/index.js +8 -0
  41. package/src/v24/guards/references/index.js +9 -0
  42. package/src/v24/guards/references/templateKey/index.js +8 -0
  43. package/src/v24/guards/structure/destinationPath/index.js +8 -0
  44. package/src/v24/guards/structure/func/index.js +8 -0
  45. package/src/v24/guards/structure/index.js +15 -0
  46. package/src/v24/guards/structure/sourcePath/index.js +8 -0
  47. package/src/v24/guards/structure/templateKey/index.js +9 -0
  48. package/src/v24/index.js +71 -0
  49. package/src/v24/singleInstruction/index.js +32 -0
  50. package/src/v25/actions/index.js +20 -0
  51. package/src/v25/actions/insertOptions/index.js +47 -0
  52. package/src/v25/actions/insertOptions/instructions/footer.json +22 -0
  53. package/src/v25/actions/insertOptions/instructions/single.json +62 -0
  54. package/src/v25/actions/insertSerial/index.js +47 -0
  55. package/src/v25/actions/insertSerial/instructions/footer.json +22 -0
  56. package/src/v25/actions/insertSerial/instructions/single.json +62 -0
  57. package/src/v25/builders/bodyOnly/index.js +18 -0
  58. package/src/v25/builders/footerOnly/base.json +3 -0
  59. package/src/v25/builders/footerOnly/index.js +21 -0
  60. package/src/v25/builders/footerOnly/instructions/single.json +19 -0
  61. package/src/v25/builders/headerOnly/index.js +18 -0
  62. package/src/v25/builders/simple/base.json +53 -0
  63. package/src/v25/builders/simple/index.js +40 -0
  64. package/src/{v18/bodyOnly → v25/builders}/spec.json +21 -0
  65. package/src/v25/builders/withFooter/base.json +53 -0
  66. package/src/v25/builders/withFooter/index.js +40 -0
  67. package/src/v25/builders/withFooter/instructions/double.json +19 -0
  68. package/src/v25/builders/withFooter/instructions/single.json +56 -0
  69. package/src/v25/doubleInstruction/index.js +21 -0
  70. package/src/v25/guards/index.js +10 -0
  71. package/src/v25/guards/references/func/index.js +8 -0
  72. package/src/v25/guards/references/index.js +9 -0
  73. package/src/v25/guards/references/templateKey/index.js +8 -0
  74. package/src/v25/guards/structure/destinationPath/index.js +8 -0
  75. package/src/v25/guards/structure/func/index.js +8 -0
  76. package/src/v25/guards/structure/index.js +15 -0
  77. package/src/v25/guards/structure/sourcePath/index.js +8 -0
  78. package/src/v25/guards/structure/templateKey/index.js +9 -0
  79. package/src/v25/index.js +21 -0
  80. package/src/v25/singleInstruction/index.js +32 -0
  81. package/src/v25/writePath/index.js +62 -0
  82. package/src/v26/actions/index.js +20 -0
  83. package/src/v26/actions/insertOptions/index.js +47 -0
  84. package/src/v26/actions/insertOptions/instructions/footer.json +22 -0
  85. package/src/v26/actions/insertOptions/instructions/single.json +62 -0
  86. package/src/v26/actions/insertSerial/index.js +47 -0
  87. package/src/v26/actions/insertSerial/instructions/footer.json +22 -0
  88. package/src/v26/actions/insertSerial/instructions/single.json +62 -0
  89. package/src/v26/builders/bodyOnly/base.json +1 -0
  90. package/src/v26/builders/bodyOnly/index.js +18 -0
  91. package/src/v26/builders/footerOnly/base.json +3 -0
  92. package/src/v26/builders/footerOnly/index.js +21 -0
  93. package/src/v26/builders/footerOnly/instructions/single.json +19 -0
  94. package/src/v26/builders/headerOnly/base.json +53 -0
  95. package/src/v26/builders/headerOnly/index.js +18 -0
  96. package/src/v26/builders/simple/base.json +53 -0
  97. package/src/v26/builders/simple/index.js +40 -0
  98. package/src/v26/builders/simple/instructions/double.json +19 -0
  99. package/src/{v17 → v26/builders}/spec.json +21 -0
  100. package/src/v26/builders/withFooter/base.json +53 -0
  101. package/src/v26/builders/withFooter/index.js +40 -0
  102. package/src/v26/builders/withFooter/instructions/double.json +19 -0
  103. package/src/v26/builders/withFooter/instructions/single.json +56 -0
  104. package/src/v26/doubleInstruction/index.js +21 -0
  105. package/src/v26/guards/index.js +10 -0
  106. package/src/v26/guards/references/func/index.js +8 -0
  107. package/src/v26/guards/references/index.js +9 -0
  108. package/src/v26/guards/references/templateKey/index.js +8 -0
  109. package/src/v26/guards/structure/destinationPath/index.js +8 -0
  110. package/src/v26/guards/structure/func/index.js +8 -0
  111. package/src/v26/guards/structure/index.js +15 -0
  112. package/src/v26/guards/structure/sourcePath/index.js +8 -0
  113. package/src/v26/guards/structure/templateKey/index.js +9 -0
  114. package/src/v26/index.js +21 -0
  115. package/src/v26/singleInstruction/index.js +32 -0
  116. package/src/v26/writePath/index.js +62 -0
  117. package/src/v17/index.js +0 -5
  118. package/src/v17/simple/index.js +0 -56
  119. package/src/v17/simple/writePath/index.js +0 -47
  120. package/src/v18/bodyOnly/base.json +0 -1
  121. package/src/v18/bodyOnly/index.js +0 -36
  122. package/src/v18/bodyOnly/writePath/index.js +0 -47
  123. package/src/v18/headerOnly/index.js +0 -42
  124. package/src/v18/headerOnly/writePath/index.js +0 -47
  125. package/src/v18/index.js +0 -5
  126. package/src/v18/simple/index.js +0 -57
  127. package/src/v18/simple/spec.json +0 -86
  128. package/src/v18/simple/writePath/index.js +0 -47
  129. package/src/v18/spec.json +0 -86
  130. package/src/v19/bodyOnly/index.js +0 -36
  131. package/src/v19/bodyOnly/spec.json +0 -86
  132. package/src/v19/headerOnly/index.js +0 -42
  133. package/src/v19/headerOnly/spec.json +0 -86
  134. package/src/v19/index.js +0 -5
  135. package/src/v19/simple/index.js +0 -57
  136. package/src/v19/simple/spec.json +0 -86
  137. package/src/v19/spec.json +0 -86
  138. package/src/v19/writePath/index.js +0 -47
  139. package/src/v20/bodyOnly/spec.json +0 -86
  140. package/src/v20/headerOnly/spec.json +0 -86
  141. package/src/v20/index.js +0 -5
  142. package/src/v20/simple/spec.json +0 -86
  143. package/src/v20/singleInstruction/index.js +0 -17
  144. package/src/v20/spec.json +0 -86
  145. package/src/v21/bodyOnly/spec.json +0 -86
  146. package/src/v21/headerOnly/spec.json +0 -86
  147. package/src/v21/index.js +0 -5
  148. package/src/v21/simple/instructions/single.json +0 -38
  149. package/src/v21/simple/spec.json +0 -86
  150. package/src/v21/spec.json +0 -86
  151. /package/src/{v19 → v23/builders}/bodyOnly/base.json +0 -0
  152. /package/src/{v18 → v23/builders}/bodyOnly/instructions/double.json +0 -0
  153. /package/src/{v17/simple → v23/builders/headerOnly}/base.json +0 -0
  154. /package/src/{v17/simple → v23/builders/headerOnly}/instructions/single.json +0 -0
  155. /package/src/{v18/headerOnly → v23/builders/simple}/base.json +0 -0
  156. /package/src/{v17 → v23/builders}/simple/instructions/double.json +0 -0
  157. /package/src/{v18/headerOnly → v23/builders/simple}/instructions/single.json +0 -0
  158. /package/src/{v18/simple → v23/builders/withFooter}/base.json +0 -0
  159. /package/src/{v18/simple → v23/builders/withFooter}/instructions/double.json +0 -0
  160. /package/src/{v19/headerOnly → v23/builders/withOptions}/base.json +0 -0
  161. /package/src/{v19/simple → v23/builders/withSerial}/base.json +0 -0
  162. /package/src/{v21 → v23}/doubleInstruction/index.js +0 -0
  163. /package/src/{v21 → v23}/guards/index.js +0 -0
  164. /package/src/{v21 → v23}/guards/references/func/index.js +0 -0
  165. /package/src/{v21 → v23}/guards/references/index.js +0 -0
  166. /package/src/{v21 → v23}/guards/references/templateKey/index.js +0 -0
  167. /package/src/{v21 → v23}/guards/structure/destinationPath/index.js +0 -0
  168. /package/src/{v21 → v23}/guards/structure/func/index.js +0 -0
  169. /package/src/{v21 → v23}/guards/structure/index.js +0 -0
  170. /package/src/{v21 → v23}/guards/structure/sourcePath/index.js +0 -0
  171. /package/src/{v21 → v23}/guards/structure/templateKey/index.js +0 -0
  172. /package/src/{v20 → v23}/writePath/index.js +0 -0
  173. /package/src/{v20 → v24/builders}/bodyOnly/base.json +0 -0
  174. /package/src/{v19 → v24/builders}/bodyOnly/instructions/double.json +0 -0
  175. /package/src/{v20 → v24/builders}/headerOnly/base.json +0 -0
  176. /package/src/{v18/simple → v24/builders/headerOnly}/instructions/single.json +0 -0
  177. /package/src/{v20 → v24/builders}/simple/base.json +0 -0
  178. /package/src/{v19 → v24/builders}/simple/instructions/double.json +0 -0
  179. /package/src/{v19/headerOnly → v24/builders/simple}/instructions/single.json +0 -0
  180. /package/src/{v21/headerOnly → v24/builders/withFooter}/base.json +0 -0
  181. /package/src/{v20/simple → v24/builders/withFooter}/instructions/double.json +0 -0
  182. /package/src/{v21 → v24}/writePath/index.js +0 -0
  183. /package/src/{v21 → v25/builders}/bodyOnly/base.json +0 -0
  184. /package/src/{v20 → v25/builders}/bodyOnly/instructions/double.json +0 -0
  185. /package/src/{v21/simple → v25/builders/headerOnly}/base.json +0 -0
  186. /package/src/{v19/simple → v25/builders/headerOnly}/instructions/single.json +0 -0
  187. /package/src/{v21 → v25/builders}/simple/instructions/double.json +0 -0
  188. /package/src/{v20/headerOnly → v25/builders/simple}/instructions/single.json +0 -0
  189. /package/src/{v21 → v26/builders}/bodyOnly/instructions/double.json +0 -0
  190. /package/src/{v20/simple → v26/builders/headerOnly}/instructions/single.json +0 -0
  191. /package/src/{v21/headerOnly → v26/builders/simple}/instructions/single.json +0 -0
@@ -0,0 +1,62 @@
1
+ import { findByRole } from "json-transformer-funcs";
2
+
3
+ const toArray = value => Array.isArray(value) ? value : [value];
4
+
5
+ const set = (parent, key, value) => {
6
+ parent[key] = value;
7
+ };
8
+
9
+ const push = (parent, key, value) => {
10
+ parent[key].push(...toArray(value));
11
+ };
12
+
13
+ const unshift = (parent, key, value) => {
14
+ parent[key].unshift(...toArray(value));
15
+ };
16
+
17
+ const pushToRows = (parent, key, value) => {
18
+ parent[key].forEach(row => {
19
+ row.children.push(...structuredClone(toArray(value)));
20
+ });
21
+ };
22
+
23
+ const unshiftToRows = (parent, key, value) => {
24
+ parent[key].forEach(row => {
25
+ row.children.unshift(...structuredClone(toArray(value)));
26
+ });
27
+ };
28
+
29
+ const unshiftSerialToRows = (parent, key, value) => {
30
+ parent[key].forEach((row, rowIndex) => {
31
+ const item = structuredClone(value);
32
+ item.textContent = rowIndex + 1;
33
+ row.children.unshift(item);
34
+ });
35
+ };
36
+
37
+ const actions = {
38
+ set,
39
+ push,
40
+ unshift,
41
+ pushToRows,
42
+ unshiftToRows,
43
+ unshiftSerialToRows
44
+ };
45
+
46
+ const resolveParent = (registry, path) => {
47
+ const root = path.dataRole
48
+ ? findByRole(registry[path.fileName], path.dataRole)
49
+ : registry[path.fileName];
50
+ const keys = [...(path.filePath ?? [])];
51
+ const key = keys.pop();
52
+ const parent = keys.reduce((current, nextKey) => current[nextKey], root);
53
+ return { parent, key };
54
+ };
55
+
56
+ const writePath = (registry, path, value) => {
57
+ const { parent, key } = resolveParent(registry, path);
58
+ const action = actions[path.action] || set;
59
+ action(parent, key, value);
60
+ };
61
+
62
+ export default writePath;
package/src/v17/index.js DELETED
@@ -1,5 +0,0 @@
1
- // V16 exposes three focused table scenarios. Each scenario owns its config and instructions.
2
- // Only genuinely shared execution helpers live in ./common.
3
- import simple from "./simple/index.js";
4
-
5
- export { simple };
@@ -1,56 +0,0 @@
1
- import fromCollection from "json-transformer-funcs-one-dimension";
2
- import twoDimensional from "json-transformer-funcs-two-dimensions";
3
-
4
- import { resolvePath } from "json-transformer-funcs";
5
-
6
- import spec from "../spec.json" with { type: "json" };
7
- import base from "./base.json" with { type: "json" };
8
-
9
- import singleInstructions from "./instructions/single.json" with { type: "json" };
10
- import twoDimensionalInstructions from "./instructions/double.json" with { type: "json" };
11
-
12
- import writePath from "./writePath/index.js";
13
-
14
- // 1. Keep the input, table structure, and templates together as the build context.
15
- const registry = { data: {}, base, spec };
16
- const functions = {
17
- fromCollection, twoDimensional
18
- };
19
-
20
- // 2. Apply each instruction: read source, build result, write destination.
21
- const runInstructions = instructions => {
22
- instructions.forEach(instruction => {
23
- const source = resolvePath(registry, instruction.sourcePath);
24
-
25
- if (source) {
26
- const result = functions[instruction.func](source, spec[instruction.templateKey]);
27
- writePath(registry, instruction.destinationPath, result);
28
- } else {
29
- console.log(" !instruction : ", instruction);
30
- console.log(" !source : ", source);
31
- };
32
- });
33
- };
34
-
35
- const runInstructions2 = instructions => {
36
- instructions.forEach(instruction => {
37
- const result = functions[instruction.func](
38
- registry.data.columns,
39
- registry.data.data,
40
- spec
41
- );
42
- writePath(registry, instruction.destinationPath, result);
43
- });
44
- };
45
-
46
- // 3. Complete the table and return its JSON specification.
47
- const startFunc = data => {
48
- registry.data = data;
49
-
50
- runInstructions(singleInstructions);
51
- runInstructions2(twoDimensionalInstructions);
52
-
53
- return base;
54
- };
55
-
56
- export default startFunc;
@@ -1,47 +0,0 @@
1
- import { findByRole } from "json-transformer-funcs";
2
-
3
- const toArray = val => (Array.isArray(val) ? val : [val]);
4
-
5
- const actions = {
6
- set: (parent, key, value) => {
7
- parent[key] = value;
8
- },
9
- push: (parent, key, value) => {
10
- parent[key].push(...toArray(value));
11
- },
12
- unshift: (parent, key, value) => {
13
- parent[key].unshift(...toArray(value));
14
- },
15
- pushToRows: (parent, key, value) => {
16
- parent[key].forEach(row => {
17
- row.children.push(...structuredClone(toArray(value)));
18
- });
19
- },
20
- unshiftToRows: (parent, key, value) => {
21
- parent[key].forEach(row => {
22
- row.children.unshift(...structuredClone(toArray(value)));
23
- });
24
- },
25
- unshiftSerialToRows: (parent, key, value) => {
26
- parent[key].forEach((row, rowIndex) => {
27
- const item = structuredClone(value);
28
- item.textContent = rowIndex + 1;
29
- row.children.unshift(item);
30
- });
31
- }
32
- };
33
-
34
- const writePath = (registry, path, value) => {
35
- const root = path.dataRole
36
- ? findByRole(registry[path.fileName], path.dataRole)
37
- : registry[path.fileName];
38
-
39
- const keys = [...(path.filePath ?? [])];
40
- const lastKey = keys.pop();
41
- const parent = keys.reduce((current, key) => current[key], root);
42
-
43
- const actionHandler = actions[path.action] || actions.set;
44
- actionHandler(parent, lastKey, value);
45
- };
46
-
47
- export default writePath;
@@ -1 +0,0 @@
1
- []
@@ -1,36 +0,0 @@
1
- import twoDimensional from "json-transformer-funcs-two-dimensions";
2
-
3
- import spec from "../spec.json" with { type: "json" };
4
- import base from "./base.json" with { type: "json" };
5
-
6
- import twoDimensionalInstructions from "./instructions/double.json" with { type: "json" };
7
-
8
- import writePath from "./writePath/index.js";
9
-
10
- // 1. Keep the input, table structure, and templates together as the build context.
11
- const registry = { data: {}, base, spec };
12
- const functions = {
13
- twoDimensional
14
- };
15
-
16
- const runInstructions2 = instructions => {
17
- instructions.forEach(instruction => {
18
- const result = functions[instruction.func](
19
- registry.data.columns,
20
- registry.data.data,
21
- spec
22
- );
23
- writePath(registry, instruction.destinationPath, result);
24
- });
25
- };
26
-
27
- // 3. Complete the table and return its JSON specification.
28
- const startFunc = data => {
29
- registry.data = data;
30
-
31
- runInstructions2(twoDimensionalInstructions);
32
-
33
- return base.children;
34
- };
35
-
36
- export default startFunc;
@@ -1,47 +0,0 @@
1
- import { findByRole } from "json-transformer-funcs";
2
-
3
- const toArray = val => (Array.isArray(val) ? val : [val]);
4
-
5
- const actions = {
6
- set: (parent, key, value) => {
7
- parent[key] = value;
8
- },
9
- push: (parent, key, value) => {
10
- parent[key].push(...toArray(value));
11
- },
12
- unshift: (parent, key, value) => {
13
- parent[key].unshift(...toArray(value));
14
- },
15
- pushToRows: (parent, key, value) => {
16
- parent[key].forEach(row => {
17
- row.children.push(...structuredClone(toArray(value)));
18
- });
19
- },
20
- unshiftToRows: (parent, key, value) => {
21
- parent[key].forEach(row => {
22
- row.children.unshift(...structuredClone(toArray(value)));
23
- });
24
- },
25
- unshiftSerialToRows: (parent, key, value) => {
26
- parent[key].forEach((row, rowIndex) => {
27
- const item = structuredClone(value);
28
- item.textContent = rowIndex + 1;
29
- row.children.unshift(item);
30
- });
31
- }
32
- };
33
-
34
- const writePath = (registry, path, value) => {
35
- const root = path.dataRole
36
- ? findByRole(registry[path.fileName], path.dataRole)
37
- : registry[path.fileName];
38
-
39
- const keys = [...(path.filePath ?? [])];
40
- const lastKey = keys.pop();
41
- const parent = keys.reduce((current, key) => current[key], root);
42
-
43
- const actionHandler = actions[path.action] || actions.set;
44
- actionHandler(parent, lastKey, value);
45
- };
46
-
47
- export default writePath;
@@ -1,42 +0,0 @@
1
- import fromCollection from "json-transformer-funcs-one-dimension";
2
-
3
- import { resolvePath } from "json-transformer-funcs";
4
-
5
- import spec from "../spec.json" with { type: "json" };
6
- import base from "./base.json" with { type: "json" };
7
-
8
- import singleInstructions from "./instructions/single.json" with { type: "json" };
9
-
10
- import writePath from "./writePath/index.js";
11
-
12
- // 1. Keep the input, table structure, and templates together as the build context.
13
- const registry = { data: {}, base, spec };
14
- const functions = {
15
- fromCollection
16
- };
17
-
18
- // 2. Apply each instruction: read source, build result, write destination.
19
- const runInstructions = instructions => {
20
- instructions.forEach(instruction => {
21
- const source = resolvePath(registry, instruction.sourcePath);
22
-
23
- if (source) {
24
- const result = functions[instruction.func](source, spec[instruction.templateKey]);
25
- writePath(registry, instruction.destinationPath, result);
26
- } else {
27
- console.log(" !instruction : ", instruction);
28
- console.log(" !source : ", source);
29
- };
30
- });
31
- };
32
-
33
- // 3. Complete the table and return its JSON specification.
34
- const startFunc = data => {
35
- registry.data = data;
36
-
37
- runInstructions(singleInstructions);
38
-
39
- return base;
40
- };
41
-
42
- export default startFunc;
@@ -1,47 +0,0 @@
1
- import { findByRole } from "json-transformer-funcs";
2
-
3
- const toArray = val => (Array.isArray(val) ? val : [val]);
4
-
5
- const actions = {
6
- set: (parent, key, value) => {
7
- parent[key] = value;
8
- },
9
- push: (parent, key, value) => {
10
- parent[key].push(...toArray(value));
11
- },
12
- unshift: (parent, key, value) => {
13
- parent[key].unshift(...toArray(value));
14
- },
15
- pushToRows: (parent, key, value) => {
16
- parent[key].forEach(row => {
17
- row.children.push(...structuredClone(toArray(value)));
18
- });
19
- },
20
- unshiftToRows: (parent, key, value) => {
21
- parent[key].forEach(row => {
22
- row.children.unshift(...structuredClone(toArray(value)));
23
- });
24
- },
25
- unshiftSerialToRows: (parent, key, value) => {
26
- parent[key].forEach((row, rowIndex) => {
27
- const item = structuredClone(value);
28
- item.textContent = rowIndex + 1;
29
- row.children.unshift(item);
30
- });
31
- }
32
- };
33
-
34
- const writePath = (registry, path, value) => {
35
- const root = path.dataRole
36
- ? findByRole(registry[path.fileName], path.dataRole)
37
- : registry[path.fileName];
38
-
39
- const keys = [...(path.filePath ?? [])];
40
- const lastKey = keys.pop();
41
- const parent = keys.reduce((current, key) => current[key], root);
42
-
43
- const actionHandler = actions[path.action] || actions.set;
44
- actionHandler(parent, lastKey, value);
45
- };
46
-
47
- export default writePath;
package/src/v18/index.js DELETED
@@ -1,5 +0,0 @@
1
- import simple from "./simple/index.js";
2
- import headerOnly from "./headerOnly/index.js";
3
- import bodyOnly from "./bodyOnly/index.js";
4
-
5
- export { simple, headerOnly, bodyOnly };
@@ -1,57 +0,0 @@
1
- import fromCollection from "json-transformer-funcs-one-dimension";
2
- import twoDimensional from "json-transformer-funcs-two-dimensions";
3
-
4
- import { resolvePath } from "json-transformer-funcs";
5
-
6
- import spec from "../spec.json" with { type: "json" };
7
- import base from "./base.json" with { type: "json" };
8
-
9
- import singleInstructions from "./instructions/single.json" with { type: "json" };
10
- import twoDimensionalInstructions from "./instructions/double.json" with { type: "json" };
11
-
12
- import writePath from "./writePath/index.js";
13
-
14
- // 1. Keep the input, table structure, and templates together as the build context.
15
- const registry = { data: {}, base, spec };
16
- const functions = {
17
- fromCollection, twoDimensional
18
- };
19
-
20
- // 2. Apply each instruction: read source, build result, write destination.
21
- const runInstructions = instructions => {
22
- instructions.forEach(instruction => {
23
- const source = resolvePath(registry, instruction.sourcePath);
24
-
25
- if (source) {
26
- const result = functions[instruction.func](source, spec[instruction.templateKey]);
27
- writePath(registry, instruction.destinationPath, result);
28
- } else {
29
- console.log(" !instruction : ", instruction);
30
- console.log(" !source : ", source);
31
- };
32
- });
33
- };
34
-
35
- const runInstructions2 = instructions => {
36
- instructions.forEach(instruction => {
37
- const result = functions[instruction.func](
38
- registry.data.columns,
39
- registry.data.data,
40
- spec
41
- );
42
- writePath(registry, instruction.destinationPath, result);
43
- });
44
- };
45
-
46
- // 3. Complete the table and return its JSON specification.
47
- const startFunc = data => {
48
- registry.data = data;
49
- console.log("registry : ", registry);
50
-
51
- runInstructions(singleInstructions);
52
- runInstructions2(twoDimensionalInstructions);
53
-
54
- return base;
55
- };
56
-
57
- export default startFunc;
@@ -1,86 +0,0 @@
1
- {
2
- "buildBodyTr": {
3
- "tagName": "tr",
4
- "attributes": {
5
- "class": "align-middle"
6
- },
7
- "children": []
8
- },
9
- "buildColGroup": {
10
- "tagName": "col",
11
- "attributes": {
12
- "width": "${width}"
13
- }
14
- },
15
- "buildHeader": {
16
- "tagName": "th",
17
- "textContent": "${columnName}",
18
- "attributes": {
19
- "class": "py-3 px-3 fw-semibold text-uppercase small"
20
- }
21
- },
22
- "buildFooter": {
23
- "tagName": "td",
24
- "children": [
25
- {
26
- "tagName": "input",
27
- "attributes": {
28
- "type": "text",
29
- "placeholder": "enter ${columnName}",
30
- "name": "${columnName}",
31
- "class": "form-control"
32
- }
33
- }
34
- ]
35
- },
36
- "buildBodyCell": {
37
- "tagName": "td",
38
- "textContent": "${rowValue}",
39
- "attributes": {
40
- "class": "py-3 px-3 text-secondary"
41
- }
42
- },
43
- "button": {
44
- "tagName": "button",
45
- "textContent": "${columnName}",
46
- "attributes": {
47
- "class": "btn btn-primary btn-sm"
48
- }
49
- },
50
- "buttonCell": {
51
- "tagName": "td",
52
- "attributes": {
53
- "class": "py-2 px-3 text-center"
54
- },
55
- "children": [
56
- {
57
- "tagName": "button",
58
- "textContent": "${agg:count}",
59
- "attributes": {
60
- "class": "btn btn-primary btn-sm"
61
- }
62
- }
63
- ]
64
- },
65
- "buildOption": {
66
- "tagName": "option",
67
- "textContent": "${rowValue}",
68
- "attributes": {
69
- "value": "${rowValue}"
70
- }
71
- },
72
- "buildSelect": {
73
- "tagName": "select",
74
- "attributes": {
75
- "id": "LedgerName"
76
- },
77
- "children": []
78
- },
79
- "buildDataList": {
80
- "tagName": "datalist",
81
- "attributes": {
82
- "data-name": "${columnName}"
83
- },
84
- "children": []
85
- }
86
- }
@@ -1,47 +0,0 @@
1
- import { findByRole } from "json-transformer-funcs";
2
-
3
- const toArray = val => (Array.isArray(val) ? val : [val]);
4
-
5
- const actions = {
6
- set: (parent, key, value) => {
7
- parent[key] = value;
8
- },
9
- push: (parent, key, value) => {
10
- parent[key].push(...toArray(value));
11
- },
12
- unshift: (parent, key, value) => {
13
- parent[key].unshift(...toArray(value));
14
- },
15
- pushToRows: (parent, key, value) => {
16
- parent[key].forEach(row => {
17
- row.children.push(...structuredClone(toArray(value)));
18
- });
19
- },
20
- unshiftToRows: (parent, key, value) => {
21
- parent[key].forEach(row => {
22
- row.children.unshift(...structuredClone(toArray(value)));
23
- });
24
- },
25
- unshiftSerialToRows: (parent, key, value) => {
26
- parent[key].forEach((row, rowIndex) => {
27
- const item = structuredClone(value);
28
- item.textContent = rowIndex + 1;
29
- row.children.unshift(item);
30
- });
31
- }
32
- };
33
-
34
- const writePath = (registry, path, value) => {
35
- const root = path.dataRole
36
- ? findByRole(registry[path.fileName], path.dataRole)
37
- : registry[path.fileName];
38
-
39
- const keys = [...(path.filePath ?? [])];
40
- const lastKey = keys.pop();
41
- const parent = keys.reduce((current, key) => current[key], root);
42
-
43
- const actionHandler = actions[path.action] || actions.set;
44
- actionHandler(parent, lastKey, value);
45
- };
46
-
47
- export default writePath;
package/src/v18/spec.json DELETED
@@ -1,86 +0,0 @@
1
- {
2
- "buildBodyTr": {
3
- "tagName": "tr",
4
- "attributes": {
5
- "class": "align-middle"
6
- },
7
- "children": []
8
- },
9
- "buildColGroup": {
10
- "tagName": "col",
11
- "attributes": {
12
- "width": "${width}"
13
- }
14
- },
15
- "buildHeader": {
16
- "tagName": "th",
17
- "textContent": "${columnName}",
18
- "attributes": {
19
- "class": "py-3 px-3 fw-semibold text-uppercase small"
20
- }
21
- },
22
- "buildFooter": {
23
- "tagName": "td",
24
- "children": [
25
- {
26
- "tagName": "input",
27
- "attributes": {
28
- "type": "text",
29
- "placeholder": "enter ${columnName}",
30
- "name": "${columnName}",
31
- "class": "form-control"
32
- }
33
- }
34
- ]
35
- },
36
- "buildBodyCell": {
37
- "tagName": "td",
38
- "textContent": "${rowValue}",
39
- "attributes": {
40
- "class": "py-3 px-3 text-secondary"
41
- }
42
- },
43
- "button": {
44
- "tagName": "button",
45
- "textContent": "${columnName}",
46
- "attributes": {
47
- "class": "btn btn-primary btn-sm"
48
- }
49
- },
50
- "buttonCell": {
51
- "tagName": "td",
52
- "attributes": {
53
- "class": "py-2 px-3 text-center"
54
- },
55
- "children": [
56
- {
57
- "tagName": "button",
58
- "textContent": "${agg:count}",
59
- "attributes": {
60
- "class": "btn btn-primary btn-sm"
61
- }
62
- }
63
- ]
64
- },
65
- "buildOption": {
66
- "tagName": "option",
67
- "textContent": "${rowValue}",
68
- "attributes": {
69
- "value": "${rowValue}"
70
- }
71
- },
72
- "buildSelect": {
73
- "tagName": "select",
74
- "attributes": {
75
- "id": "LedgerName"
76
- },
77
- "children": []
78
- },
79
- "buildDataList": {
80
- "tagName": "datalist",
81
- "attributes": {
82
- "data-name": "${columnName}"
83
- },
84
- "children": []
85
- }
86
- }
@@ -1,36 +0,0 @@
1
- import twoDimensional from "json-transformer-funcs-two-dimensions";
2
-
3
- import spec from "../spec.json" with { type: "json" };
4
- import base from "./base.json" with { type: "json" };
5
-
6
- import twoDimensionalInstructions from "./instructions/double.json" with { type: "json" };
7
-
8
- import writePath from "../writePath/index.js";
9
-
10
- // 1. Keep the input, table structure, and templates together as the build context.
11
- const registry = { data: {}, base, spec };
12
- const functions = {
13
- twoDimensional
14
- };
15
-
16
- const runInstructions2 = instructions => {
17
- instructions.forEach(instruction => {
18
- const result = functions[instruction.func](
19
- registry.data.columns,
20
- registry.data.data,
21
- spec
22
- );
23
- writePath(registry, instruction.destinationPath, result);
24
- });
25
- };
26
-
27
- // 3. Complete the table and return its JSON specification.
28
- const startFunc = data => {
29
- registry.data = data;
30
-
31
- runInstructions2(twoDimensionalInstructions);
32
-
33
- return base.children;
34
- };
35
-
36
- export default startFunc;