json-renderers-build-table 1.9.1 → 1.17.3

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 (184) hide show
  1. package/package.json +5 -2
  2. package/src/index.js +2 -3
  3. package/src/v14/buildSpec/config/base.json +53 -0
  4. package/src/v14/buildSpec/config/columnInstructions.json +56 -0
  5. package/src/v14/buildSpec/config/optionsInstructions.json +82 -0
  6. package/src/v14/buildSpec/config/rowInstructions.json +20 -0
  7. package/src/v14/buildSpec/config/serialInstructions.json +82 -0
  8. package/src/v14/buildSpec/index.js +147 -0
  9. package/src/v14/buildSpec/writePath/index.js +55 -0
  10. package/src/v14/index.js +56 -0
  11. package/src/v14/register/index.js +30 -0
  12. package/src/v14/register/meta.js +6 -0
  13. package/src/v14/spec.json +65 -0
  14. package/src/v15/buildSpec/config/base.json +53 -0
  15. package/src/v15/buildSpec/config/columnInstructions.json +56 -0
  16. package/src/v15/buildSpec/config/optionsInstructions.json +82 -0
  17. package/src/v15/buildSpec/config/rowInstructions.json +20 -0
  18. package/src/v15/buildSpec/config/serialInstructions.json +82 -0
  19. package/src/v15/buildSpec/index.js +147 -0
  20. package/src/v15/buildSpec/writePath/index.js +55 -0
  21. package/src/v15/common/runner.js +33 -0
  22. package/src/v15/common/writePath.js +55 -0
  23. package/src/v15/index.js +85 -0
  24. package/src/v15/register/index.js +30 -0
  25. package/src/v15/register/meta.js +6 -0
  26. package/src/v15/simpleTable/config/base.json +31 -0
  27. package/src/v15/simpleTable/config/instructions.json +38 -0
  28. package/src/v15/simpleTable/index.js +58 -0
  29. package/src/v15/spec.json +65 -0
  30. package/src/v15/tableFullGrid/config/base.json +53 -0
  31. package/src/v15/tableFullGrid/config/instructions.json +234 -0
  32. package/src/v15/tableFullGrid/index.js +76 -0
  33. package/src/v15/tableHeadless/config/base.json +15 -0
  34. package/src/v15/tableHeadless/config/instructions.json +20 -0
  35. package/src/v15/tableHeadless/index.js +58 -0
  36. package/src/v15/tableWithButtonCell/config/base.json +38 -0
  37. package/src/v15/tableWithButtonCell/config/instructions.json +56 -0
  38. package/src/v15/tableWithButtonCell/index.js +57 -0
  39. package/src/v15/tableWithFooter/config/base.json +53 -0
  40. package/src/v15/tableWithFooter/config/instructions.json +74 -0
  41. package/src/v15/tableWithFooter/index.js +58 -0
  42. package/src/v15/tableWithOptions/config/base.json +38 -0
  43. package/src/v15/tableWithOptions/config/instructions.json +116 -0
  44. package/src/v15/tableWithOptions/index.js +66 -0
  45. package/src/v15/tableWithSerial/config/base.json +38 -0
  46. package/src/v15/tableWithSerial/config/instructions.json +116 -0
  47. package/src/v15/tableWithSerial/index.js +66 -0
  48. package/src/v15/tableWithWidths/config/base.json +38 -0
  49. package/src/v15/tableWithWidths/config/instructions.json +56 -0
  50. package/src/v15/tableWithWidths/index.js +58 -0
  51. package/src/v16/common/runner.js +33 -0
  52. package/src/v16/common/writePath.js +55 -0
  53. package/src/v16/index.js +7 -0
  54. package/src/v16/simpleTable/config/base.json +31 -0
  55. package/src/v16/simpleTable/config/instructions.json +38 -0
  56. package/src/v16/simpleTable/index.js +58 -0
  57. package/src/v16/spec.json +65 -0
  58. package/src/v16/tableWithOptions/config/base.json +38 -0
  59. package/src/v16/tableWithOptions/config/instructions.json +116 -0
  60. package/src/v16/tableWithOptions/index.js +66 -0
  61. package/src/v16/tableWithSerial/config/base.json +38 -0
  62. package/src/v16/tableWithSerial/config/instructions.json +116 -0
  63. package/src/v16/tableWithSerial/index.js +66 -0
  64. package/src/v17/index.js +5 -0
  65. package/src/v17/simple/base.json +53 -0
  66. package/src/v17/simple/index.js +56 -0
  67. package/src/v17/simple/instructions/double.json +19 -0
  68. package/src/v17/simple/instructions/single.json +38 -0
  69. package/src/v17/simple/spec.json +86 -0
  70. package/src/v17/simple/writePath/index.js +47 -0
  71. package/src/v17/spec.json +86 -0
  72. package/src/v5/index.js +0 -49
  73. package/src/v5/options/index.js +0 -18
  74. package/src/v5/options/showOptions/index.js +0 -39
  75. package/src/v5/options/showSerial/index.js +0 -19
  76. package/src/v5/render-requests.json +0 -70
  77. package/src/v5/table/body/cell/index.js +0 -12
  78. package/src/v5/table/body/cell/tag.json +0 -7
  79. package/src/v5/table/body/index.js +0 -17
  80. package/src/v5/table/body/row/index.js +0 -18
  81. package/src/v5/table/body/row/tag.json +0 -4
  82. package/src/v5/table/body/tag.json +0 -4
  83. package/src/v5/table/head/cell/index.js +0 -12
  84. package/src/v5/table/head/cell/tag.json +0 -7
  85. package/src/v5/table/head/index.js +0 -16
  86. package/src/v5/table/head/row/index.js +0 -14
  87. package/src/v5/table/head/row/tag.json +0 -4
  88. package/src/v5/table/head/tag.json +0 -4
  89. package/src/v5/table/index.js +0 -22
  90. package/src/v5/table/tag.json +0 -7
  91. package/src/v6/index.js +0 -29
  92. package/src/v6/options/index.js +0 -28
  93. package/src/v6/options/showFooter/cell/index.js +0 -16
  94. package/src/v6/options/showFooter/cell/tag.json +0 -4
  95. package/src/v6/options/showFooter/footer/index.js +0 -18
  96. package/src/v6/options/showFooter/footer/tag.json +0 -4
  97. package/src/v6/options/showFooter/index.js +0 -10
  98. package/src/v6/options/showFooter/input/index.js +0 -11
  99. package/src/v6/options/showFooter/input/tag.json +0 -7
  100. package/src/v6/options/showFooter/row/index.js +0 -35
  101. package/src/v6/options/showFooter/row/tag.json +0 -4
  102. package/src/v6/options/showFooterSave/button/tag.json +0 -7
  103. package/src/v6/options/showFooterSave/index.js +0 -14
  104. package/src/v6/options/showOptions/index.js +0 -39
  105. package/src/v6/options/showSerial/index.js +0 -19
  106. package/src/v6/render-requests.json +0 -90
  107. package/src/v6/table/body/cell/index.js +0 -12
  108. package/src/v6/table/body/cell/tag.json +0 -7
  109. package/src/v6/table/body/index.js +0 -17
  110. package/src/v6/table/body/row/index.js +0 -18
  111. package/src/v6/table/body/row/tag.json +0 -4
  112. package/src/v6/table/body/tag.json +0 -4
  113. package/src/v6/table/head/cell/index.js +0 -12
  114. package/src/v6/table/head/cell/tag.json +0 -7
  115. package/src/v6/table/head/index.js +0 -16
  116. package/src/v6/table/head/row/index.js +0 -14
  117. package/src/v6/table/head/row/tag.json +0 -4
  118. package/src/v6/table/head/tag.json +0 -4
  119. package/src/v6/table/index.js +0 -22
  120. package/src/v6/table/tag.json +0 -7
  121. package/src/v7/index.js +0 -29
  122. package/src/v7/options/index.js +0 -28
  123. package/src/v7/options/showFooter/cell/index.js +0 -16
  124. package/src/v7/options/showFooter/cell/tag.json +0 -4
  125. package/src/v7/options/showFooter/footer/index.js +0 -18
  126. package/src/v7/options/showFooter/footer/tag.json +0 -4
  127. package/src/v7/options/showFooter/index.js +0 -10
  128. package/src/v7/options/showFooter/input/index.js +0 -11
  129. package/src/v7/options/showFooter/input/tag.json +0 -7
  130. package/src/v7/options/showFooter/row/index.js +0 -35
  131. package/src/v7/options/showFooter/row/tag.json +0 -4
  132. package/src/v7/options/showFooterSave/button/tag.json +0 -7
  133. package/src/v7/options/showFooterSave/index.js +0 -14
  134. package/src/v7/options/showOptions/index.js +0 -39
  135. package/src/v7/options/showSerial/index.js +0 -19
  136. package/src/v7/render-requests.json +0 -90
  137. package/src/v7/table/body/cell/index.js +0 -12
  138. package/src/v7/table/body/cell/tag.json +0 -7
  139. package/src/v7/table/body/index.js +0 -17
  140. package/src/v7/table/body/row/index.js +0 -18
  141. package/src/v7/table/body/row/tag.json +0 -4
  142. package/src/v7/table/body/tag.json +0 -4
  143. package/src/v7/table/head/cell/index.js +0 -12
  144. package/src/v7/table/head/cell/tag.json +0 -7
  145. package/src/v7/table/head/index.js +0 -16
  146. package/src/v7/table/head/row/index.js +0 -14
  147. package/src/v7/table/head/row/tag.json +0 -4
  148. package/src/v7/table/head/tag.json +0 -4
  149. package/src/v7/table/index.js +0 -22
  150. package/src/v7/table/tag.json +0 -7
  151. package/src/v8/index.js +0 -29
  152. package/src/v8/options/index.js +0 -28
  153. package/src/v8/options/showFooter/cell/index.js +0 -16
  154. package/src/v8/options/showFooter/cell/tag.json +0 -4
  155. package/src/v8/options/showFooter/footer/index.js +0 -18
  156. package/src/v8/options/showFooter/footer/tag.json +0 -4
  157. package/src/v8/options/showFooter/index.js +0 -10
  158. package/src/v8/options/showFooter/input/index.js +0 -11
  159. package/src/v8/options/showFooter/input/tag.json +0 -7
  160. package/src/v8/options/showFooter/row/index.js +0 -35
  161. package/src/v8/options/showFooter/row/tag.json +0 -4
  162. package/src/v8/options/showFooterSave/button/tag.json +0 -7
  163. package/src/v8/options/showFooterSave/index.js +0 -14
  164. package/src/v8/options/showOptions/index.js +0 -39
  165. package/src/v8/options/showSerial/index.js +0 -19
  166. package/src/v8/render-requests.json +0 -90
  167. package/src/v8/table/body/cell/index.js +0 -12
  168. package/src/v8/table/body/cell/tag.json +0 -7
  169. package/src/v8/table/body/index.js +0 -17
  170. package/src/v8/table/body/row/index.js +0 -18
  171. package/src/v8/table/body/row/tag.json +0 -4
  172. package/src/v8/table/body/tag.json +0 -4
  173. package/src/v8/table/head/cell/index.js +0 -12
  174. package/src/v8/table/head/cell/tag.json +0 -7
  175. package/src/v8/table/head/index.js +0 -16
  176. package/src/v8/table/head/row/index.js +0 -14
  177. package/src/v8/table/head/row/tag.json +0 -4
  178. package/src/v8/table/head/tag.json +0 -4
  179. package/src/v8/table/index.js +0 -22
  180. package/src/v8/table/tag.json +0 -7
  181. package/src/v9/index.js +0 -28
  182. package/src/v9/table/index.js +0 -67
  183. package/src/v9/table/spec.json +0 -18
  184. package/src/v9/table/table.json +0 -24
@@ -1,35 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "tr",
3
- "children": []
4
- }
@@ -1,7 +0,0 @@
1
- {
2
- "tagName": "button",
3
- "attributes": {
4
- "type": "button"
5
- },
6
- "textContent": "Save"
7
- }
@@ -1,14 +0,0 @@
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;
@@ -1,39 +0,0 @@
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;
@@ -1,19 +0,0 @@
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;
@@ -1,90 +0,0 @@
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
- "tableWithFooter": {
57
- "type": "table",
58
- "data": [
59
- { "itemName": "0.09/30mm", "baseUnit": "kgs" }
60
- ],
61
- "columns": ["itemName", "baseUnit"],
62
- "options": {
63
- "showFooter": true
64
- }
65
- },
66
- "tableWithFooterSave": {
67
- "type": "table",
68
- "data": [
69
- { "itemName": "0.09/30mm", "baseUnit": "kgs" }
70
- ],
71
- "columns": ["itemName", "baseUnit"],
72
- "options": {
73
- "showFooterSave": true
74
- }
75
- },
76
- "tableHead": {
77
- "type": "tableHead",
78
- "data": [],
79
- "columns": ["itemName", "baseUnit"],
80
- "options": {}
81
- },
82
- "tableBody": {
83
- "type": "tableBody",
84
- "data": [
85
- { "itemName": "0.09/30mm", "baseUnit": "kgs" }
86
- ],
87
- "columns": ["itemName", "baseUnit"],
88
- "options": {}
89
- }
90
- }
@@ -1,12 +0,0 @@
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;
@@ -1,7 +0,0 @@
1
- {
2
- "tagName": "td",
3
- "attributes": {
4
- "value": ""
5
- },
6
- "textContent": ""
7
- }
@@ -1,17 +0,0 @@
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;
@@ -1,18 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "tr",
3
- "children": []
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "tbody",
3
- "children": []
4
- }
@@ -1,12 +0,0 @@
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;
@@ -1,7 +0,0 @@
1
- {
2
- "tagName": "th",
3
- "attributes": {
4
- "value": ""
5
- },
6
- "textContent": ""
7
- }
@@ -1,16 +0,0 @@
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;
@@ -1,14 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "tr",
3
- "children": []
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "thead",
3
- "children": []
4
- }
@@ -1,22 +0,0 @@
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;
@@ -1,7 +0,0 @@
1
- {
2
- "tagName": "table",
3
- "attributes": {
4
- "class": "table table-hover table-striped mb-0"
5
- },
6
- "children": []
7
- }
package/src/v7/index.js DELETED
@@ -1,29 +0,0 @@
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;
@@ -1,28 +0,0 @@
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;
@@ -1,16 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "td",
3
- "children": []
4
- }
@@ -1,18 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "tfoot",
3
- "children": []
4
- }
@@ -1,10 +0,0 @@
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;
@@ -1,11 +0,0 @@
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;
@@ -1,7 +0,0 @@
1
- {
2
- "tagName": "input",
3
- "attributes": {
4
- "type": "text",
5
- "name": ""
6
- }
7
- }
@@ -1,35 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- {
2
- "tagName": "tr",
3
- "children": []
4
- }
@@ -1,7 +0,0 @@
1
- {
2
- "tagName": "button",
3
- "attributes": {
4
- "type": "button"
5
- },
6
- "textContent": "Save"
7
- }
@@ -1,14 +0,0 @@
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;
@@ -1,39 +0,0 @@
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;
@@ -1,19 +0,0 @@
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;