json-renderers-build 1.7.1 → 1.9.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 (116) hide show
  1. package/README.md +8 -4
  2. package/docs/dist/min.js +541 -266
  3. package/docs/dist/v4/min.js +320 -320
  4. package/docs/dist/v5/min.js +312 -312
  5. package/docs/dist/v7/min.js +272 -0
  6. package/docs/dist/v8/min.js +268 -0
  7. package/docs/dist/v9/min.js +587 -0
  8. package/docs/index.html +2 -2
  9. package/package.json +1 -1
  10. package/src/index.js +2 -2
  11. package/src/v7/index.js +47 -47
  12. package/src/v7/select/index.js +20 -20
  13. package/src/v7/select/options/index.js +17 -17
  14. package/src/v7/select/options/skeleton.json +17 -17
  15. package/src/v7/table/body/cells/index.js +23 -23
  16. package/src/v7/table/body/cells/skeleton.json +17 -17
  17. package/src/v7/table/body/index.js +15 -15
  18. package/src/v7/table/body/rows/index.js +36 -36
  19. package/src/v7/table/body/rows/skeleton.json +4 -4
  20. package/src/v7/table/body/skeleton.json +4 -4
  21. package/src/v7/table/head/cells/index.js +23 -23
  22. package/src/v7/table/head/cells/skeleton.json +17 -17
  23. package/src/v7/table/head/index.js +15 -15
  24. package/src/v7/table/head/row/index.js +15 -15
  25. package/src/v7/table/head/row/skeleton.json +4 -4
  26. package/src/v7/table/head/skeleton.json +4 -4
  27. package/src/v7/table/index.js +26 -26
  28. package/src/v7/table/skeleton.json +6 -6
  29. package/src/v8/common/deriveColumnsFromData.js +20 -0
  30. package/src/v8/index.js +40 -0
  31. package/src/v8/meta.js +6 -0
  32. package/src/v8/registerGlobal.js +14 -0
  33. package/src/v8/select/index.js +21 -0
  34. package/src/v8/select/options/index.js +17 -0
  35. package/src/v8/select/options/skeleton.json +17 -0
  36. package/src/v8/select/skeleton.json +7 -0
  37. package/src/v8/table/body/cells/index.js +17 -0
  38. package/src/v8/table/body/cells/skeleton.json +17 -0
  39. package/src/v8/table/body/index.js +20 -0
  40. package/src/v8/table/body/rows/index.js +23 -0
  41. package/src/v8/table/body/rows/skeleton.json +4 -0
  42. package/src/v8/table/body/skeleton.json +4 -0
  43. package/src/v8/table/head/cells/index.js +17 -0
  44. package/src/v8/table/head/cells/skeleton.json +17 -0
  45. package/src/v8/table/head/index.js +15 -0
  46. package/src/v8/table/head/row/index.js +15 -0
  47. package/src/v8/table/head/row/skeleton.json +4 -0
  48. package/src/v8/table/head/skeleton.json +4 -0
  49. package/src/v8/table/index.js +26 -0
  50. package/src/v8/table/skeleton.json +7 -0
  51. package/src/v9/common/deriveColumnsFromData.js +20 -0
  52. package/src/v9/index.js +36 -0
  53. package/src/v9/meta.js +6 -0
  54. package/src/v9/registerGlobal.js +14 -0
  55. package/src/v9/select/index.js +21 -0
  56. package/src/v9/select/options/index.js +17 -0
  57. package/src/v9/select/options/skeleton.json +17 -0
  58. package/src/v9/select/skeleton.json +7 -0
  59. package/src/v9/table/footer/empty/cell/index.js +5 -0
  60. package/src/v9/table/footer/empty/cell/tag.json +6 -0
  61. package/src/v9/table/footer/empty/index.js +6 -0
  62. package/src/v9/table/footer/empty/row/index.js +10 -0
  63. package/src/v9/table/footer/empty/row/tag.json +7 -0
  64. package/src/v9/table/footer/index.js +28 -0
  65. package/src/v9/table/footer/inputs/cell/index.js +15 -0
  66. package/src/v9/table/footer/inputs/cell/tag.json +7 -0
  67. package/src/v9/table/footer/inputs/index.js +6 -0
  68. package/src/v9/table/footer/inputs/input/tag.json +9 -0
  69. package/src/v9/table/footer/inputs/row/index.js +10 -0
  70. package/src/v9/table/footer/inputs/row/tag.json +7 -0
  71. package/src/v9/table/footer/inputsWithSave/button/tag.json +8 -0
  72. package/src/v9/table/footer/inputsWithSave/cell/index.js +20 -0
  73. package/src/v9/table/footer/inputsWithSave/cell/tag.json +7 -0
  74. package/src/v9/table/footer/inputsWithSave/index.js +6 -0
  75. package/src/v9/table/footer/inputsWithSave/input/tag.json +9 -0
  76. package/src/v9/table/footer/inputsWithSave/row/index.js +13 -0
  77. package/src/v9/table/footer/inputsWithSave/row/tag.json +7 -0
  78. package/src/v9/table/footer/tag.json +7 -0
  79. package/src/v9/table/footer/totals/cell/index.js +21 -0
  80. package/src/v9/table/footer/totals/cell/tag.json +7 -0
  81. package/src/v9/table/footer/totals/index.js +6 -0
  82. package/src/v9/table/footer/totals/row/index.js +12 -0
  83. package/src/v9/table/footer/totals/row/tag.json +7 -0
  84. package/src/v9/table/index.js +33 -0
  85. package/src/v9/table/options/index.js +18 -0
  86. package/src/v9/table/options/showOptions/index.js +39 -0
  87. package/src/v9/table/options/showSerial/index.js +19 -0
  88. package/src/v9/table/render-requests.json +107 -0
  89. package/src/v9/table/table/body/cell/index.js +12 -0
  90. package/src/v9/table/table/body/cell/tag.json +7 -0
  91. package/src/v9/table/table/body/index.js +17 -0
  92. package/src/v9/table/table/body/row/index.js +18 -0
  93. package/src/v9/table/table/body/row/tag.json +4 -0
  94. package/src/v9/table/table/body/tag.json +4 -0
  95. package/src/v9/table/table/head/cell/index.js +12 -0
  96. package/src/v9/table/table/head/cell/tag.json +7 -0
  97. package/src/v9/table/table/head/index.js +16 -0
  98. package/src/v9/table/table/head/row/index.js +14 -0
  99. package/src/v9/table/table/head/row/tag.json +4 -0
  100. package/src/v9/table/table/head/tag.json +4 -0
  101. package/src/v9/table/table/index.js +36 -0
  102. package/src/v9/table/table/tag.json +7 -0
  103. package/src/v9/table_10oct/body/cells/index.js +17 -0
  104. package/src/v9/table_10oct/body/cells/skeleton.json +17 -0
  105. package/src/v9/table_10oct/body/index.js +20 -0
  106. package/src/v9/table_10oct/body/rows/index.js +23 -0
  107. package/src/v9/table_10oct/body/rows/skeleton.json +4 -0
  108. package/src/v9/table_10oct/body/skeleton.json +4 -0
  109. package/src/v9/table_10oct/head/cells/index.js +17 -0
  110. package/src/v9/table_10oct/head/cells/skeleton.json +17 -0
  111. package/src/v9/table_10oct/head/index.js +15 -0
  112. package/src/v9/table_10oct/head/row/index.js +15 -0
  113. package/src/v9/table_10oct/head/row/skeleton.json +4 -0
  114. package/src/v9/table_10oct/head/skeleton.json +4 -0
  115. package/src/v9/table_10oct/index.js +26 -0
  116. package/src/v9/table_10oct/skeleton.json +7 -0
@@ -0,0 +1,17 @@
1
+ import jsonTransform from "@keshavsoft/json-transformer";
2
+
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ const startFunc = ({
6
+ inData,
7
+ }) => {
8
+ const localData = inData;
9
+
10
+ let specAsJsonToDom = jsonTransform({
11
+ children: localData
12
+ }, skeletonJson);
13
+
14
+ return specAsJsonToDom?.children;
15
+ };
16
+
17
+ export default startFunc;
@@ -0,0 +1,17 @@
1
+ {
2
+ "transform": {
3
+ "children": ""
4
+ },
5
+ "operation": {
6
+ "children": {
7
+ "operationType": "loopArray",
8
+ "template": {
9
+ "tagName": "option",
10
+ "attributes": {
11
+ "value": "${}"
12
+ },
13
+ "textContent": "${}"
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "select",
3
+ "attributes": {
4
+ "id": "LedgerName"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,17 @@
1
+ import jsonTransform from "@keshavsoft/json-transformer";
2
+
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ const startFunc = ({
6
+ inData,
7
+ }) => {
8
+ const localData = inData;
9
+
10
+ let tdAsArray = jsonTransform({
11
+ children: localData
12
+ }, skeletonJson);
13
+
14
+ return tdAsArray?.children;
15
+ };
16
+
17
+ export default startFunc;
@@ -0,0 +1,17 @@
1
+ {
2
+ "transform": {
3
+ "children": ""
4
+ },
5
+ "operation": {
6
+ "children": {
7
+ "operationType": "loopArray",
8
+ "template": {
9
+ "tagName": "td",
10
+ "attributes": {
11
+ "value": "${}"
12
+ },
13
+ "textContent": "${}"
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,20 @@
1
+ import bodyRows from "./rows/index.js";
2
+ import skeletonJson from './skeleton.json' with { type: 'json' };
3
+
4
+ const startFunc = ({
5
+ inData,
6
+ inColumns
7
+ }) => {
8
+ const localData = inData;
9
+ const localColumns = inColumns;
10
+ const tbody = structuredClone(skeletonJson);
11
+
12
+ tbody.children = bodyRows({
13
+ inData: localData,
14
+ inColumns: localColumns
15
+ });
16
+
17
+ return tbody;
18
+ };
19
+
20
+ export default startFunc;
@@ -0,0 +1,23 @@
1
+ import bodyCells from "../cells/index.js";
2
+ import skeletonJson from './skeleton.json' with { type: 'json' };
3
+
4
+ const startFunc = ({
5
+ inData,
6
+ inColumns
7
+ }) => {
8
+ const localData = inData;
9
+ const localColumns = inColumns;
10
+
11
+ return localData.map(row => {
12
+ const cellValues = Array.isArray(row)
13
+ ? row
14
+ : localColumns.map(col => row[col]);
15
+
16
+ const tr = structuredClone(skeletonJson);
17
+ tr.children = bodyCells({ inData: cellValues });
18
+
19
+ return tr;
20
+ });
21
+ };
22
+
23
+ export default startFunc;
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "tr",
3
+ "children": []
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "tbody",
3
+ "children": []
4
+ }
@@ -0,0 +1,17 @@
1
+ import jsonTransform from "@keshavsoft/json-transformer";
2
+
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ const startFunc = ({
6
+ inData,
7
+ }) => {
8
+ const localData = inData;
9
+
10
+ let thAsArray = jsonTransform({
11
+ children: localData
12
+ }, skeletonJson);
13
+
14
+ return thAsArray?.children;
15
+ };
16
+
17
+ export default startFunc;
@@ -0,0 +1,17 @@
1
+ {
2
+ "transform": {
3
+ "children": ""
4
+ },
5
+ "operation": {
6
+ "children": {
7
+ "operationType": "loopArray",
8
+ "template": {
9
+ "tagName": "th",
10
+ "attributes": {
11
+ "value": "${}"
12
+ },
13
+ "textContent": "${}"
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ import headRow from "./row/index.js";
2
+ import skeletonJson from './skeleton.json' with { type: 'json' };
3
+
4
+ const startFunc = ({
5
+ inData,
6
+ }) => {
7
+ const localData = inData;
8
+ const thead = structuredClone(skeletonJson);
9
+
10
+ thead.children = [headRow({ inData: localData })];
11
+
12
+ return thead;
13
+ };
14
+
15
+ export default startFunc;
@@ -0,0 +1,15 @@
1
+ import headCells from "../cells/index.js";
2
+ import skeletonJson from './skeleton.json' with { type: 'json' };
3
+
4
+ const startFunc = ({
5
+ inData,
6
+ }) => {
7
+ const localData = inData;
8
+ const row = structuredClone(skeletonJson);
9
+
10
+ row.children = headCells({ inData: localData });
11
+
12
+ return row;
13
+ };
14
+
15
+ export default startFunc;
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "tr",
3
+ "children": []
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "thead",
3
+ "children": []
4
+ }
@@ -0,0 +1,26 @@
1
+ import renderTableHead from "./head/index.js";
2
+ import renderTableBody from "./body/index.js";
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ const startFunc = ({
6
+ inColumns,
7
+ inData
8
+ }) => {
9
+ const localColumns = inColumns;
10
+ const localData = inData;
11
+
12
+ const table = structuredClone(skeletonJson);
13
+
14
+ table.children = [
15
+ renderTableHead({ inData: localColumns }),
16
+ renderTableBody({ inData: localData, inColumns: localColumns })
17
+ ];
18
+
19
+ return table;
20
+ };
21
+
22
+ export {
23
+ renderTableHead,
24
+ renderTableBody
25
+ };
26
+ export default startFunc;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "table",
3
+ "attributes": {
4
+ "class": "table table-hover table-striped mb-0"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,20 @@
1
+ const deriveColumnsFromData = ({ inData = [] } = {}) => {
2
+ const localData = inData;
3
+
4
+ if (!Array.isArray(localData) || localData.length === 0) {
5
+ return [];
6
+ }
7
+
8
+ const firstRow = localData[0];
9
+ if (!firstRow || typeof firstRow !== "object") {
10
+ return [];
11
+ }
12
+
13
+ return Object.keys(firstRow).map(key => ({
14
+ key,
15
+ label: key
16
+ }));
17
+ };
18
+
19
+ export { deriveColumnsFromData };
20
+ export default deriveColumnsFromData;
@@ -0,0 +1,36 @@
1
+ import registerGlobal from "./registerGlobal.js";
2
+
3
+ import renderTable from "./table/index.js";
4
+ import renderSelect, { renderSelectOptions } from "./select/index.js";
5
+
6
+ const RENDERER_MAP = {
7
+ table: renderTable,
8
+ select: renderSelect,
9
+ selectOptionsOnly: renderSelectOptions
10
+ };
11
+
12
+ const render = ({
13
+ type = "table",
14
+ data,
15
+ columns
16
+ }) => {
17
+ const rawType = type;
18
+ const renderer = RENDERER_MAP[rawType];
19
+
20
+ const localData = data;
21
+ const localColumns = columns;
22
+
23
+ return renderer({
24
+ inColumns: localColumns,
25
+ inData: localData
26
+ });
27
+ };
28
+
29
+ registerGlobal(render);
30
+
31
+ export {
32
+ renderTable,
33
+ renderSelect,
34
+ renderSelectOptions
35
+ };
36
+ export default render;
package/src/v9/meta.js ADDED
@@ -0,0 +1,6 @@
1
+ export const meta = {
2
+ version: "v9.0.0",
3
+ description: "build table from store data and render to DOM uses json-to-spec, json-to-dom under the hood"
4
+ };
5
+
6
+ export default meta;
@@ -0,0 +1,14 @@
1
+ import meta from "./meta.js";
2
+
3
+ export const registerGlobal = (inFuncDefinition) => {
4
+ if (typeof globalThis === "undefined" || !inFuncDefinition) return;
5
+
6
+ globalThis.ks ??= {};
7
+
8
+ globalThis.ks.jsonRenderersBuild ??= {
9
+ meta,
10
+ renderToDom: inFuncDefinition
11
+ };
12
+ };
13
+
14
+ export default registerGlobal;
@@ -0,0 +1,21 @@
1
+ import renderSelectOptions from "./options/index.js";
2
+
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ const startFunc = ({
6
+ inData,
7
+ }) => {
8
+ const localData = inData;
9
+
10
+ let localChildren = renderSelectOptions({
11
+ inData: localData
12
+ });
13
+
14
+ const select = structuredClone(skeletonJson);
15
+ select.children = localChildren;
16
+
17
+ return select;
18
+ };
19
+
20
+ export { renderSelectOptions };
21
+ export default startFunc;
@@ -0,0 +1,17 @@
1
+ import jsonTransform from "@keshavsoft/json-transformer";
2
+
3
+ import skeletonJson from './skeleton.json' with { type: 'json' };
4
+
5
+ const startFunc = ({
6
+ inData,
7
+ }) => {
8
+ const localData = inData;
9
+
10
+ let specAsJsonToDom = jsonTransform({
11
+ children: localData
12
+ }, skeletonJson);
13
+
14
+ return specAsJsonToDom?.children;
15
+ };
16
+
17
+ export default startFunc;
@@ -0,0 +1,17 @@
1
+ {
2
+ "transform": {
3
+ "children": ""
4
+ },
5
+ "operation": {
6
+ "children": {
7
+ "operationType": "loopArray",
8
+ "template": {
9
+ "tagName": "option",
10
+ "attributes": {
11
+ "value": "${}"
12
+ },
13
+ "textContent": "${}"
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "select",
3
+ "attributes": {
4
+ "id": "LedgerName"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,5 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+
3
+ const renderCell = () => structuredClone(tagJson);
4
+
5
+ export default renderCell;
@@ -0,0 +1,6 @@
1
+ {
2
+ "tagName": "td",
3
+ "attributes": {
4
+ "class": "align-middle py-2"
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ import renderRow from "./row/index.js";
2
+
3
+ const renderEmpty = ({ inColumns = [] } = {}) =>
4
+ renderRow({ inColumns });
5
+
6
+ export default renderEmpty;
@@ -0,0 +1,10 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import renderCell from "../cell/index.js";
3
+
4
+ const renderRow = ({ inColumns = [] } = {}) => {
5
+ const row = structuredClone(tagJson);
6
+ row.children = inColumns.map(() => renderCell());
7
+ return row;
8
+ };
9
+
10
+ export default renderRow;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "tr",
3
+ "attributes": {
4
+ "class": "align-middle"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,28 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import renderInputs from "./inputs/index.js";
3
+ import renderInputsWithSave from "./inputsWithSave/index.js";
4
+ import renderTotals from "./totals/index.js";
5
+ import renderEmpty from "./empty/index.js";
6
+
7
+ const footerBuilders = {
8
+ inputs: renderInputs,
9
+ inputsWithSave: renderInputsWithSave,
10
+ totals: renderTotals,
11
+ empty: renderEmpty
12
+ };
13
+
14
+ const renderTableFooter = ({ inFooter = [], inColumns = [], inData = [] } = {}) => {
15
+ const tfoot = structuredClone(tagJson);
16
+
17
+ tfoot.children = inFooter.map(footerName => {
18
+ if (!Object.hasOwn(footerBuilders, footerName)) {
19
+ throw new Error(`Unknown footer "${footerName}".`);
20
+ }
21
+
22
+ return footerBuilders[footerName]({ inColumns, inData });
23
+ });
24
+
25
+ return tfoot;
26
+ };
27
+
28
+ export default renderTableFooter;
@@ -0,0 +1,15 @@
1
+ import cellJson from "./tag.json" with { type: "json" };
2
+ import inputJson from "../input/tag.json" with { type: "json" };
3
+
4
+ const renderCell = ({ inColumn } = {}) => {
5
+ const cell = structuredClone(cellJson);
6
+ const input = structuredClone(inputJson);
7
+
8
+ input.attributes.name = inColumn;
9
+ input.attributes.placeholder = inColumn;
10
+ cell.children.push(input);
11
+
12
+ return cell;
13
+ };
14
+
15
+ export default renderCell;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "td",
3
+ "attributes": {
4
+ "class": "align-middle py-2"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,6 @@
1
+ import renderRow from "./row/index.js";
2
+
3
+ const renderInputs = ({ inColumns = [] } = {}) =>
4
+ renderRow({ inColumns });
5
+
6
+ export default renderInputs;
@@ -0,0 +1,9 @@
1
+ {
2
+ "tagName": "input",
3
+ "attributes": {
4
+ "type": "text",
5
+ "name": "",
6
+ "placeholder": "",
7
+ "class": "form-control form-control-sm"
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import renderCell from "../cell/index.js";
3
+
4
+ const renderRow = ({ inColumns = [] } = {}) => {
5
+ const row = structuredClone(tagJson);
6
+ row.children = inColumns.map(inColumn => renderCell({ inColumn }));
7
+ return row;
8
+ };
9
+
10
+ export default renderRow;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "tr",
3
+ "attributes": {
4
+ "class": "align-middle"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tagName": "button",
3
+ "attributes": {
4
+ "type": "button",
5
+ "class": "btn btn-primary btn-sm ms-2"
6
+ },
7
+ "textContent": "Save"
8
+ }
@@ -0,0 +1,20 @@
1
+ import cellJson from "./tag.json" with { type: "json" };
2
+ import inputJson from "../input/tag.json" with { type: "json" };
3
+ import buttonJson from "../button/tag.json" with { type: "json" };
4
+
5
+ const renderCell = ({ inColumn, inSave = false } = {}) => {
6
+ const cell = structuredClone(cellJson);
7
+ const input = structuredClone(inputJson);
8
+
9
+ input.attributes.name = inColumn;
10
+ input.attributes.placeholder = inColumn;
11
+ cell.children.push(input);
12
+
13
+ if (inSave) {
14
+ cell.children.push(structuredClone(buttonJson));
15
+ }
16
+
17
+ return cell;
18
+ };
19
+
20
+ export default renderCell;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "td",
3
+ "attributes": {
4
+ "class": "align-middle py-2"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,6 @@
1
+ import renderRow from "./row/index.js";
2
+
3
+ const renderInputsWithSave = ({ inColumns = [] } = {}) =>
4
+ renderRow({ inColumns });
5
+
6
+ export default renderInputsWithSave;
@@ -0,0 +1,9 @@
1
+ {
2
+ "tagName": "input",
3
+ "attributes": {
4
+ "type": "text",
5
+ "name": "",
6
+ "placeholder": "",
7
+ "class": "form-control form-control-sm"
8
+ }
9
+ }
@@ -0,0 +1,13 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import renderCell from "../cell/index.js";
3
+
4
+ const renderRow = ({ inColumns = [] } = {}) => {
5
+ const row = structuredClone(tagJson);
6
+ row.children = inColumns.map((inColumn, index) => renderCell({
7
+ inColumn,
8
+ inSave: index === inColumns.length - 1
9
+ }));
10
+ return row;
11
+ };
12
+
13
+ export default renderRow;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "tr",
3
+ "attributes": {
4
+ "class": "align-middle"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "tfoot",
3
+ "attributes": {
4
+ "class": "table-light"
5
+ },
6
+ "children": []
7
+ }
@@ -0,0 +1,21 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+
3
+ const getValue = (row, column) =>
4
+ Array.isArray(row) ? row[column] : row?.[column];
5
+
6
+ const renderCell = ({ inColumn, inIndex, inData = [] } = {}) => {
7
+ const cell = structuredClone(tagJson);
8
+ const values = inData
9
+ .map(row => getValue(row, inColumn))
10
+ .filter(value => value !== null && value !== undefined && String(value).trim() !== "")
11
+ .map(Number)
12
+ .filter(Number.isFinite);
13
+
14
+ cell.textContent = values.length
15
+ ? String(values.reduce((sum, value) => sum + value, 0))
16
+ : inIndex === 0 ? "Total" : "";
17
+
18
+ return cell;
19
+ };
20
+
21
+ export default renderCell;