json-renderers-build-table 0.0.0-stage → 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 +28 -3
  2. package/package.json +25 -5
  3. package/src/index.js +3 -0
  4. package/src/v5/index.js +49 -0
  5. package/src/v5/options/index.js +18 -0
  6. package/src/v5/options/showOptions/index.js +39 -0
  7. package/src/v5/options/showSerial/index.js +19 -0
  8. package/src/v5/render-requests.json +70 -0
  9. package/src/v5/table/body/cell/index.js +12 -0
  10. package/src/v5/table/body/cell/tag.json +7 -0
  11. package/src/v5/table/body/index.js +17 -0
  12. package/src/v5/table/body/row/index.js +18 -0
  13. package/src/v5/table/body/row/tag.json +4 -0
  14. package/src/v5/table/body/tag.json +4 -0
  15. package/src/v5/table/head/cell/index.js +12 -0
  16. package/src/v5/table/head/cell/tag.json +7 -0
  17. package/src/v5/table/head/index.js +16 -0
  18. package/src/v5/table/head/row/index.js +14 -0
  19. package/src/v5/table/head/row/tag.json +4 -0
  20. package/src/v5/table/head/tag.json +4 -0
  21. package/src/v5/table/index.js +22 -0
  22. package/src/v5/table/tag.json +7 -0
  23. package/src/v6/index.js +29 -0
  24. package/src/v6/options/index.js +28 -0
  25. package/src/v6/options/showFooter/cell/index.js +16 -0
  26. package/src/v6/options/showFooter/cell/tag.json +4 -0
  27. package/src/v6/options/showFooter/footer/index.js +18 -0
  28. package/src/v6/options/showFooter/footer/tag.json +4 -0
  29. package/src/v6/options/showFooter/index.js +10 -0
  30. package/src/v6/options/showFooter/input/index.js +11 -0
  31. package/src/v6/options/showFooter/input/tag.json +7 -0
  32. package/src/v6/options/showFooter/row/index.js +35 -0
  33. package/src/v6/options/showFooter/row/tag.json +4 -0
  34. package/src/v6/options/showFooterSave/button/tag.json +7 -0
  35. package/src/v6/options/showFooterSave/index.js +14 -0
  36. package/src/v6/options/showOptions/index.js +39 -0
  37. package/src/v6/options/showSerial/index.js +19 -0
  38. package/src/v6/render-requests.json +90 -0
  39. package/src/v6/table/body/cell/index.js +12 -0
  40. package/src/v6/table/body/cell/tag.json +7 -0
  41. package/src/v6/table/body/index.js +17 -0
  42. package/src/v6/table/body/row/index.js +18 -0
  43. package/src/v6/table/body/row/tag.json +4 -0
  44. package/src/v6/table/body/tag.json +4 -0
  45. package/src/v6/table/head/cell/index.js +12 -0
  46. package/src/v6/table/head/cell/tag.json +7 -0
  47. package/src/v6/table/head/index.js +16 -0
  48. package/src/v6/table/head/row/index.js +14 -0
  49. package/src/v6/table/head/row/tag.json +4 -0
  50. package/src/v6/table/head/tag.json +4 -0
  51. package/src/v6/table/index.js +22 -0
  52. package/src/v6/table/tag.json +7 -0
  53. package/src/v7/index.js +29 -0
  54. package/src/v7/options/index.js +28 -0
  55. package/src/v7/options/showFooter/cell/index.js +16 -0
  56. package/src/v7/options/showFooter/cell/tag.json +4 -0
  57. package/src/v7/options/showFooter/footer/index.js +18 -0
  58. package/src/v7/options/showFooter/footer/tag.json +4 -0
  59. package/src/v7/options/showFooter/index.js +10 -0
  60. package/src/v7/options/showFooter/input/index.js +11 -0
  61. package/src/v7/options/showFooter/input/tag.json +7 -0
  62. package/src/v7/options/showFooter/row/index.js +35 -0
  63. package/src/v7/options/showFooter/row/tag.json +4 -0
  64. package/src/v7/options/showFooterSave/button/tag.json +7 -0
  65. package/src/v7/options/showFooterSave/index.js +14 -0
  66. package/src/v7/options/showOptions/index.js +39 -0
  67. package/src/v7/options/showSerial/index.js +19 -0
  68. package/src/v7/render-requests.json +90 -0
  69. package/src/v7/table/body/cell/index.js +12 -0
  70. package/src/v7/table/body/cell/tag.json +7 -0
  71. package/src/v7/table/body/index.js +17 -0
  72. package/src/v7/table/body/row/index.js +18 -0
  73. package/src/v7/table/body/row/tag.json +4 -0
  74. package/src/v7/table/body/tag.json +4 -0
  75. package/src/v7/table/head/cell/index.js +12 -0
  76. package/src/v7/table/head/cell/tag.json +7 -0
  77. package/src/v7/table/head/index.js +16 -0
  78. package/src/v7/table/head/row/index.js +14 -0
  79. package/src/v7/table/head/row/tag.json +4 -0
  80. package/src/v7/table/head/tag.json +4 -0
  81. package/src/v7/table/index.js +22 -0
  82. package/src/v7/table/tag.json +7 -0
  83. package/src/v8/index.js +29 -0
  84. package/src/v8/options/index.js +28 -0
  85. package/src/v8/options/showFooter/cell/index.js +16 -0
  86. package/src/v8/options/showFooter/cell/tag.json +4 -0
  87. package/src/v8/options/showFooter/footer/index.js +18 -0
  88. package/src/v8/options/showFooter/footer/tag.json +4 -0
  89. package/src/v8/options/showFooter/index.js +10 -0
  90. package/src/v8/options/showFooter/input/index.js +11 -0
  91. package/src/v8/options/showFooter/input/tag.json +7 -0
  92. package/src/v8/options/showFooter/row/index.js +35 -0
  93. package/src/v8/options/showFooter/row/tag.json +4 -0
  94. package/src/v8/options/showFooterSave/button/tag.json +7 -0
  95. package/src/v8/options/showFooterSave/index.js +14 -0
  96. package/src/v8/options/showOptions/index.js +39 -0
  97. package/src/v8/options/showSerial/index.js +19 -0
  98. package/src/v8/render-requests.json +90 -0
  99. package/src/v8/table/body/cell/index.js +12 -0
  100. package/src/v8/table/body/cell/tag.json +7 -0
  101. package/src/v8/table/body/index.js +17 -0
  102. package/src/v8/table/body/row/index.js +18 -0
  103. package/src/v8/table/body/row/tag.json +4 -0
  104. package/src/v8/table/body/tag.json +4 -0
  105. package/src/v8/table/head/cell/index.js +12 -0
  106. package/src/v8/table/head/cell/tag.json +7 -0
  107. package/src/v8/table/head/index.js +16 -0
  108. package/src/v8/table/head/row/index.js +14 -0
  109. package/src/v8/table/head/row/tag.json +4 -0
  110. package/src/v8/table/head/tag.json +4 -0
  111. package/src/v8/table/index.js +22 -0
  112. package/src/v8/table/tag.json +7 -0
  113. package/src/v9/index.js +28 -0
  114. package/src/v9/table/index.js +67 -0
  115. package/src/v9/table/spec.json +18 -0
  116. package/src/v9/table/table.json +24 -0
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # json-renderers-build-table
2
+
3
+ Focused table specification builder extracted from the table work in `json-renderers-build`.
4
+
5
+ The package builds JSON DOM specifications for table sections. Table data remains separate from table and row options, so row actions, row attributes, and custom cell elements can evolve without adding table-specific behavior to the generic renderer package.
6
+
7
+ Use the exported `renderRequests` JSON catalog to see complete requests for each supported flavor. It includes a basic table, serial numbers, default or custom actions, combined options, and standalone table head/body requests:
8
+
9
+ ```js
10
+ import render, { renderRequests } from "json-renderers-build-table";
11
+
12
+ const request = structuredClone(renderRequests.tableWithSerialAndActions);
13
+ request.data = [{ itemName: "0.11-25", baseUnit: "kgs" }];
14
+
15
+ const table = render(request);
16
+ ```
17
+
18
+ The catalog is also available as `render.requests` when importing the default renderer. Clone a catalog entry before changing it so the shared examples remain unchanged.
19
+
20
+ To add a footer row with one text input per column, enable `showFooter`:
21
+
22
+ ```js
23
+ const request = structuredClone(renderRequests.tableWithFooter);
24
+ request.data = myData;
25
+ const table = render(request);
26
+ ```
27
+
28
+ Use `showFooterSave` to add a separate footer row with the same inputs and a Save button in the last input cell.
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
- {
2
- "name": "json-renderers-build-table",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
1
+ {
2
+ "name": "json-renderers-build-table",
3
+ "version": "1.9.1",
4
+ "description": "Focused table specification builder with configurable rows and cells",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js"
9
+ },
10
+ "files": [
11
+ "src",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "test": "node test/v1/index.js && node test/v2/index.js && node test/v3/index.js && node test/v4/index.js && node test/v5/index.js",
16
+ "dev": "vite",
17
+ "build": "vite build"
18
+ },
19
+ "dependencies": {
20
+ "@keshavsoft/json-to-tag": "^1.9.3",
21
+ "json-transformer-funcs": "^1.3.1"
22
+ },
23
+ "devDependencies": {
24
+ "vite": "^8.3.4"
25
+ }
6
26
  }
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./v9/index.js";
2
+ export { default } from "./v9/index.js";
3
+
@@ -0,0 +1,49 @@
1
+ import renderTable, {
2
+ renderTableHead,
3
+ renderTableBody
4
+ } from "./table/index.js";
5
+
6
+ import applyOptions from "./options/index.js";
7
+ import renderRequests from "./render-requests.json" with { type: "json" };
8
+
9
+ const render = ({
10
+ type = "table",
11
+ data = [],
12
+ columns = [],
13
+ options = {}
14
+ } = {}) => {
15
+ if (type === "table") {
16
+ const spec = renderTable({
17
+ inColumns: columns,
18
+ inData: data
19
+ });
20
+ console.log("inOptions : ", options);
21
+
22
+ return applyOptions(spec, options);
23
+ }
24
+
25
+ if (type === "tableHead" || type === "head") {
26
+ return renderTableHead({
27
+ inColumns: columns
28
+ });
29
+ }
30
+
31
+ if (type === "tableBody" || type === "body") {
32
+ return renderTableBody({
33
+ inData: data,
34
+ inColumns: columns
35
+ });
36
+ }
37
+
38
+ throw new Error(`Unknown table renderer type "${type}".`);
39
+ };
40
+
41
+ export {
42
+ render,
43
+ renderRequests,
44
+ renderTable,
45
+ renderTableHead,
46
+ renderTableBody
47
+ };
48
+
49
+ export default render;
@@ -0,0 +1,18 @@
1
+ import applyShowSerial from "./showSerial/index.js";
2
+ import applyShowOptions from "./showOptions/index.js";
3
+
4
+ const applyOptions = (inSpec, inOptions = {}) => {
5
+ console.log("inOptions : ", inOptions);
6
+
7
+ if (inOptions.showSerial) {
8
+ applyShowSerial(inSpec);
9
+ }
10
+
11
+ if (inOptions.showOptions) {
12
+ applyShowOptions(inSpec, inOptions.showOptions);
13
+ }
14
+
15
+ return inSpec;
16
+ };
17
+
18
+ export default applyOptions;
@@ -0,0 +1,39 @@
1
+ const resolveButtons = (inShowOptions) => {
2
+ if (inShowOptions === true) {
3
+ return [{ label: "Apply", type: "button" }];
4
+ }
5
+
6
+ if (Array.isArray(inShowOptions)) {
7
+ return inShowOptions;
8
+ }
9
+
10
+ return [];
11
+ };
12
+
13
+ const applyShowOptions = (inSpec, inShowOptions) => {
14
+ const buttons = resolveButtons(inShowOptions);
15
+
16
+ if (buttons.length === 0) return;
17
+
18
+ const [thead, tbody] = inSpec.children;
19
+
20
+ // append <th>Actions</th> to head row
21
+ thead.children[0].children.push({
22
+ tagName: "th",
23
+ textContent: "Actions"
24
+ });
25
+
26
+ // append <td> with buttons to each body row
27
+ tbody.children.forEach(tr => {
28
+ tr.children.push({
29
+ tagName: "td",
30
+ children: buttons.map(btn => ({
31
+ tagName: "button",
32
+ attributes: { type: btn.type || "button" },
33
+ textContent: btn.label
34
+ }))
35
+ });
36
+ });
37
+ };
38
+
39
+ export default applyShowOptions;
@@ -0,0 +1,19 @@
1
+ const applyShowSerial = (inSpec) => {
2
+ const [thead, tbody] = inSpec.children;
3
+
4
+ // prepend <th>#</th> to head row
5
+ thead.children[0].children.unshift({
6
+ tagName: "th",
7
+ textContent: "#"
8
+ });
9
+
10
+ // prepend <td>{rowIndex}</td> to each body row
11
+ tbody.children.forEach((tr, index) => {
12
+ tr.children.unshift({
13
+ tagName: "td",
14
+ textContent: String(index + 1)
15
+ });
16
+ });
17
+ };
18
+
19
+ export default applyShowSerial;
@@ -0,0 +1,70 @@
1
+ {
2
+ "table": {
3
+ "type": "table",
4
+ "data": [
5
+ { "itemName": "0.09/30mm", "baseUnit": "kgs" }
6
+ ],
7
+ "columns": ["itemName", "baseUnit"],
8
+ "options": {}
9
+ },
10
+ "tableWithSerial": {
11
+ "type": "table",
12
+ "data": [
13
+ { "itemName": "0.09/30mm", "baseUnit": "kgs" }
14
+ ],
15
+ "columns": ["itemName", "baseUnit"],
16
+ "options": {
17
+ "showSerial": true
18
+ }
19
+ },
20
+ "tableWithDefaultAction": {
21
+ "type": "table",
22
+ "data": [
23
+ { "itemName": "0.09/30mm", "baseUnit": "kgs" }
24
+ ],
25
+ "columns": ["itemName", "baseUnit"],
26
+ "options": {
27
+ "showOptions": true
28
+ }
29
+ },
30
+ "tableWithCustomActions": {
31
+ "type": "table",
32
+ "data": [
33
+ { "itemName": "0.09/30mm", "baseUnit": "kgs" }
34
+ ],
35
+ "columns": ["itemName", "baseUnit"],
36
+ "options": {
37
+ "showOptions": [
38
+ { "label": "Show", "type": "button" },
39
+ { "label": "Edit", "type": "button" }
40
+ ]
41
+ }
42
+ },
43
+ "tableWithSerialAndActions": {
44
+ "type": "table",
45
+ "data": [
46
+ { "itemName": "0.09/30mm", "baseUnit": "kgs" }
47
+ ],
48
+ "columns": ["itemName", "baseUnit"],
49
+ "options": {
50
+ "showSerial": true,
51
+ "showOptions": [
52
+ { "label": "Show", "type": "button" }
53
+ ]
54
+ }
55
+ },
56
+ "tableHead": {
57
+ "type": "tableHead",
58
+ "data": [],
59
+ "columns": ["itemName", "baseUnit"],
60
+ "options": {}
61
+ },
62
+ "tableBody": {
63
+ "type": "tableBody",
64
+ "data": [
65
+ { "itemName": "0.09/30mm", "baseUnit": "kgs" }
66
+ ],
67
+ "columns": ["itemName", "baseUnit"],
68
+ "options": {}
69
+ }
70
+ }
@@ -0,0 +1,12 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+
3
+ const buildBodyCell = ({ inValue } = {}) => {
4
+ const td = structuredClone(tagJson);
5
+
6
+ td.attributes.value = inValue;
7
+ td.textContent = inValue;
8
+
9
+ return td;
10
+ };
11
+
12
+ export default buildBodyCell;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "td",
3
+ "attributes": {
4
+ "value": ""
5
+ },
6
+ "textContent": ""
7
+ }
@@ -0,0 +1,17 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildBodyRow from "./row/index.js";
3
+
4
+ const renderTableBody = ({ inData = [], inColumns = [] } = {}) => {
5
+ const tbody = structuredClone(tagJson);
6
+
7
+ const children = inData.map(row => buildBodyRow({
8
+ inRow: row,
9
+ inColumns
10
+ }));
11
+
12
+ tbody.children = children;
13
+
14
+ return tbody;
15
+ };
16
+
17
+ export default renderTableBody;
@@ -0,0 +1,18 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildBodyCell from "../cell/index.js";
3
+
4
+ const buildBodyRow = ({ inRow, inColumns = [] } = {}) => {
5
+ const tr = structuredClone(tagJson);
6
+
7
+ const children = inColumns.map(column => {
8
+ const value = Array.isArray(inRow) ? inRow[column] : inRow?.[column];
9
+
10
+ return buildBodyCell({ inValue: value });
11
+ });
12
+
13
+ tr.children = children;
14
+
15
+ return tr;
16
+ };
17
+
18
+ export default buildBodyRow;
@@ -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,12 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+
3
+ const buildHeadCell = ({ inColumn } = {}) => {
4
+ const th = structuredClone(tagJson);
5
+
6
+ th.attributes.value = inColumn;
7
+ th.textContent = inColumn;
8
+
9
+ return th;
10
+ };
11
+
12
+ export default buildHeadCell;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "th",
3
+ "attributes": {
4
+ "value": ""
5
+ },
6
+ "textContent": ""
7
+ }
@@ -0,0 +1,16 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildHeadRow from "./row/index.js";
3
+
4
+ const renderTableHead = ({ inColumns = [] } = {}) => {
5
+ const thead = structuredClone(tagJson);
6
+
7
+ const children = [
8
+ buildHeadRow({ inColumns })
9
+ ];
10
+
11
+ thead.children = children;
12
+
13
+ return thead;
14
+ };
15
+
16
+ export default renderTableHead;
@@ -0,0 +1,14 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildHeadCell from "../cell/index.js";
3
+
4
+ const buildHeadRow = ({ inColumns = [] } = {}) => {
5
+ const tr = structuredClone(tagJson);
6
+
7
+ const children = inColumns.map(column => buildHeadCell({ inColumn: column }));
8
+
9
+ tr.children = children;
10
+
11
+ return tr;
12
+ };
13
+
14
+ export default buildHeadRow;
@@ -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,22 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import renderTableHead from "./head/index.js";
3
+ import renderTableBody from "./body/index.js";
4
+
5
+ const renderTable = ({
6
+ inColumns = [],
7
+ inData = []
8
+ } = {}) => {
9
+ const table = structuredClone(tagJson);
10
+
11
+ const children = [
12
+ renderTableHead({ inColumns }),
13
+ renderTableBody({ inData, inColumns })
14
+ ];
15
+
16
+ table.children = children;
17
+
18
+ return table;
19
+ };
20
+
21
+ export { renderTableHead, renderTableBody };
22
+ export default renderTable;
@@ -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,29 @@
1
+ import renderTable from "./table/index.js";
2
+
3
+ import applyOptions from "./options/index.js";
4
+ import renderRequests from "./render-requests.json" with { type: "json" };
5
+
6
+ const render = ({
7
+ type = "table",
8
+ data = [],
9
+ columns = [],
10
+ options = {}
11
+ } = {}) => {
12
+ if (type === "table") {
13
+ const spec = renderTable({
14
+ inColumns: columns,
15
+ inData: data
16
+ });
17
+
18
+ return applyOptions(spec, options, columns);
19
+ };
20
+
21
+ throw new Error(`Unknown table renderer type "${type}".`);
22
+ };
23
+
24
+ export {
25
+ render,
26
+ renderRequests
27
+ };
28
+
29
+ export default render;
@@ -0,0 +1,28 @@
1
+ import applyShowSerial from "./showSerial/index.js";
2
+ import applyShowOptions from "./showOptions/index.js";
3
+ import applyShowFooter from "./showFooter/index.js";
4
+ import applyShowFooterSave from "./showFooterSave/index.js";
5
+
6
+ const applyOptions = (inSpec, inOptions = {}, inColumns = []) => {
7
+ // console.log("inOptions : ", inOptions);
8
+
9
+ if (inOptions.showSerial) {
10
+ applyShowSerial(inSpec);
11
+ }
12
+
13
+ if (inOptions.showOptions) {
14
+ applyShowOptions(inSpec, inOptions.showOptions);
15
+ }
16
+
17
+ if (inOptions.showFooter) {
18
+ applyShowFooter(inSpec, inColumns, inOptions);
19
+ }
20
+
21
+ if (inOptions.showFooterSave) {
22
+ applyShowFooterSave(inSpec, inColumns, inOptions);
23
+ }
24
+
25
+ return inSpec;
26
+ };
27
+
28
+ export default applyOptions;
@@ -0,0 +1,16 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildFooterInput from "../input/index.js";
3
+
4
+ const buildFooterCell = ({ inColumn, inChildren = [] } = {}) => {
5
+ const td = structuredClone(tagJson);
6
+
7
+ if (inColumn !== undefined) {
8
+ td.children.push(buildFooterInput({ inColumn }));
9
+ }
10
+
11
+ td.children.push(...inChildren);
12
+
13
+ return td;
14
+ };
15
+
16
+ export default buildFooterCell;
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "td",
3
+ "children": []
4
+ }
@@ -0,0 +1,18 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildFooterRow from "../row/index.js";
3
+
4
+ const buildFooter = ({ inColumns = [], inOptions = {}, inSaveButton } = {}) => {
5
+ const tfoot = structuredClone(tagJson);
6
+
7
+ tfoot.children = [
8
+ buildFooterRow({
9
+ inColumns,
10
+ inOptions,
11
+ inSaveButton
12
+ })
13
+ ];
14
+
15
+ return tfoot;
16
+ };
17
+
18
+ export default buildFooter;
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "tfoot",
3
+ "children": []
4
+ }
@@ -0,0 +1,10 @@
1
+ import buildFooter from "./footer/index.js";
2
+
3
+ const applyShowFooter = (inSpec, inColumns, inOptions) => {
4
+ inSpec.children.push(buildFooter({
5
+ inColumns,
6
+ inOptions
7
+ }));
8
+ };
9
+
10
+ export default applyShowFooter;
@@ -0,0 +1,11 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+
3
+ const buildFooterInput = ({ inColumn } = {}) => {
4
+ const input = structuredClone(tagJson);
5
+
6
+ input.attributes.name = inColumn;
7
+
8
+ return input;
9
+ };
10
+
11
+ export default buildFooterInput;
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "input",
3
+ "attributes": {
4
+ "type": "text",
5
+ "name": ""
6
+ }
7
+ }
@@ -0,0 +1,35 @@
1
+ import tagJson from "./tag.json" with { type: "json" };
2
+ import buildFooterCell from "../cell/index.js";
3
+
4
+ const buildFooterRow = ({
5
+ inColumns = [],
6
+ inOptions = {},
7
+ inSaveButton
8
+ } = {}) => {
9
+ const tr = structuredClone(tagJson);
10
+ const columns = [...inColumns];
11
+
12
+ if (columns.length === 0 && inSaveButton) {
13
+ tr.children = [buildFooterCell({ inChildren: [inSaveButton] })];
14
+ return tr;
15
+ }
16
+
17
+ tr.children = columns.map((column, index) => buildFooterCell({
18
+ inColumn: column,
19
+ inChildren: inSaveButton && index === columns.length - 1
20
+ ? [inSaveButton]
21
+ : []
22
+ }));
23
+
24
+ if (inOptions.showSerial) {
25
+ tr.children.unshift(buildFooterCell());
26
+ }
27
+
28
+ if (inOptions.showOptions) {
29
+ tr.children.push(buildFooterCell());
30
+ }
31
+
32
+ return tr;
33
+ };
34
+
35
+ export default buildFooterRow;
@@ -0,0 +1,4 @@
1
+ {
2
+ "tagName": "tr",
3
+ "children": []
4
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "tagName": "button",
3
+ "attributes": {
4
+ "type": "button"
5
+ },
6
+ "textContent": "Save"
7
+ }
@@ -0,0 +1,14 @@
1
+ import buildFooter from "../showFooter/footer/index.js";
2
+ import tagJson from "./button/tag.json" with { type: "json" };
3
+
4
+ const applyShowFooterSave = (inSpec, inColumns, inOptions) => {
5
+ const button = structuredClone(tagJson);
6
+
7
+ inSpec.children.push(buildFooter({
8
+ inColumns,
9
+ inOptions,
10
+ inSaveButton: button
11
+ }));
12
+ };
13
+
14
+ export default applyShowFooterSave;