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
@@ -0,0 +1,30 @@
1
+ import meta from "./meta.js";
2
+
3
+ export const registerGlobal = ({ inDefinition } = {}) => {
4
+ const localDefinition = inDefinition;
5
+
6
+ if (typeof globalThis === "undefined" || !localDefinition) return;
7
+
8
+ globalThis.ks ??= {};
9
+
10
+ const renderFunc = typeof localDefinition === "function"
11
+ ? localDefinition
12
+ : localDefinition.render;
13
+
14
+ const buildSpecFunc = typeof localDefinition === "object"
15
+ ? localDefinition.buildSpec
16
+ : undefined;
17
+
18
+ const tablePackage = {
19
+ meta,
20
+ renderToDom: renderFunc,
21
+ render: renderFunc,
22
+ ...(buildSpecFunc ? { buildSpec: buildSpecFunc } : {}),
23
+ ...(typeof localDefinition === "object" ? localDefinition : {})
24
+ };
25
+
26
+ globalThis.ks.jsonRenderersBuildTable = tablePackage;
27
+ globalThis.ks.jsonRenderersBuild ??= tablePackage;
28
+ };
29
+
30
+ export default registerGlobal;
@@ -0,0 +1,6 @@
1
+ export const meta = {
2
+ version: "1.15.0",
3
+ name: "json-renderers-build-table"
4
+ };
5
+
6
+ export default meta;
@@ -0,0 +1,31 @@
1
+ {
2
+ "tagName": "table",
3
+ "attributes": {
4
+ "class": "table table-hover table-striped align-middle border mb-0"
5
+ },
6
+ "children": [
7
+ {
8
+ "tagName": "thead",
9
+ "attributes": {
10
+ "class": "table-dark",
11
+ "data-role": "table-header"
12
+ },
13
+ "children": [
14
+ {
15
+ "tagName": "tr",
16
+ "attributes": {
17
+ "data-role": "table-header-row"
18
+ },
19
+ "children": []
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ "tagName": "tbody",
25
+ "attributes": {
26
+ "data-role": "table-body"
27
+ },
28
+ "children": []
29
+ }
30
+ ]
31
+ }
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "narration": "Build the table header row from the column metadata.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-header-row",
7
+ "filePath": [
8
+ "children"
9
+ ]
10
+ },
11
+ "sourcePath": {
12
+ "fileName": "data",
13
+ "filePath": [
14
+ "columns"
15
+ ]
16
+ },
17
+ "templateKey": "buildHeader",
18
+ "func": "fromCollection"
19
+ },
20
+ {
21
+ "narration": "Create one table row for each record and place it into the table body container.",
22
+ "destinationPath": {
23
+ "fileName": "base",
24
+ "dataRole": "table-body",
25
+ "filePath": [
26
+ "children"
27
+ ]
28
+ },
29
+ "sourcePath": {
30
+ "fileName": "data",
31
+ "filePath": [
32
+ "data"
33
+ ]
34
+ },
35
+ "templateKey": "buildBodyTr",
36
+ "func": "fromCollection"
37
+ }
38
+ ]
@@ -0,0 +1,58 @@
1
+ import { runInstructions, buildBody, findByRole } from "../common/runner.js";
2
+ import spec from "../spec.json" with { type: "json" };
3
+ import base from "./config/base.json" with { type: "json" };
4
+ import instructions from "./config/instructions.json" with { type: "json" };
5
+
6
+ const buildSpec = ({ inColumns = [], inData = [] } = {}) => {
7
+ const localColumns = inColumns;
8
+ const localData = inData;
9
+
10
+ const localBase = structuredClone(base);
11
+ const localSpec = structuredClone(spec);
12
+
13
+ const normalizedColumns = localColumns.map(col => {
14
+ const colCopy = structuredClone(col);
15
+ colCopy.template = {
16
+ bodyCell: "buildBodyCell",
17
+ ...(colCopy.template || {})
18
+ };
19
+ return colCopy;
20
+ });
21
+
22
+ const buildData = {
23
+ columns: normalizedColumns,
24
+ data: localData
25
+ };
26
+
27
+ const registry = {
28
+ data: buildData,
29
+ base: localBase,
30
+ spec: localSpec
31
+ };
32
+
33
+ runInstructions({
34
+ inInstructions: instructions,
35
+ inRegistry: registry
36
+ });
37
+
38
+ const tbodyElement = findByRole(localBase, "table-body");
39
+ if (tbodyElement && Array.isArray(tbodyElement.children)) {
40
+ buildBody(tbodyElement.children, buildData, localSpec);
41
+ }
42
+
43
+ return localBase;
44
+ };
45
+
46
+ const startFunc = (input = {}) => {
47
+ const localInput = (input && typeof input === "object" && "inConfig" in input)
48
+ ? input.inConfig
49
+ : input;
50
+
51
+ return buildSpec({
52
+ inColumns: localInput.columns || [],
53
+ inData: localInput.data || []
54
+ });
55
+ };
56
+
57
+ export { buildSpec };
58
+ export default startFunc;
@@ -0,0 +1,65 @@
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
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "tagName": "table",
3
+ "attributes": {
4
+ "class": "table table-hover table-striped align-middle border mb-0"
5
+ },
6
+ "children": [
7
+ {
8
+ "tagName": "colgroup",
9
+ "attributes": {
10
+ "data-role": "table-colgroup"
11
+ },
12
+ "children": []
13
+ },
14
+ {
15
+ "tagName": "thead",
16
+ "attributes": {
17
+ "class": "table-dark",
18
+ "data-role": "table-header"
19
+ },
20
+ "children": [
21
+ {
22
+ "tagName": "tr",
23
+ "attributes": {
24
+ "data-role": "table-header-row"
25
+ },
26
+ "children": []
27
+ }
28
+ ]
29
+ },
30
+ {
31
+ "tagName": "tbody",
32
+ "attributes": {
33
+ "data-role": "table-body"
34
+ },
35
+ "children": []
36
+ },
37
+ {
38
+ "tagName": "tfoot",
39
+ "attributes": {
40
+ "data-role": "table-footer"
41
+ },
42
+ "children": [
43
+ {
44
+ "tagName": "tr",
45
+ "attributes": {
46
+ "data-role": "table-footer-row"
47
+ },
48
+ "children": []
49
+ }
50
+ ]
51
+ }
52
+ ]
53
+ }
@@ -0,0 +1,234 @@
1
+ [
2
+ {
3
+ "narration": "Build the column widths for the table using the configured columns.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-colgroup",
7
+ "filePath": [
8
+ "children"
9
+ ]
10
+ },
11
+ "sourcePath": {
12
+ "fileName": "data",
13
+ "filePath": [
14
+ "columns"
15
+ ]
16
+ },
17
+ "templateKey": "buildColGroup",
18
+ "func": "fromCollection"
19
+ },
20
+ {
21
+ "narration": "Build the table header row from the column metadata.",
22
+ "destinationPath": {
23
+ "fileName": "base",
24
+ "dataRole": "table-header-row",
25
+ "filePath": [
26
+ "children"
27
+ ]
28
+ },
29
+ "sourcePath": {
30
+ "fileName": "data",
31
+ "filePath": [
32
+ "columns"
33
+ ]
34
+ },
35
+ "templateKey": "buildHeader",
36
+ "func": "fromCollection"
37
+ },
38
+ {
39
+ "narration": "Create one table row for each record and place it into the table body container.",
40
+ "destinationPath": {
41
+ "fileName": "base",
42
+ "dataRole": "table-body",
43
+ "filePath": [
44
+ "children"
45
+ ]
46
+ },
47
+ "sourcePath": {
48
+ "fileName": "data",
49
+ "filePath": [
50
+ "data"
51
+ ]
52
+ },
53
+ "templateKey": "buildBodyTr",
54
+ "func": "fromCollection"
55
+ },
56
+ {
57
+ "narration": "Build the table footer row from the column metadata.",
58
+ "destinationPath": {
59
+ "fileName": "base",
60
+ "dataRole": "table-footer-row",
61
+ "filePath": [
62
+ "children"
63
+ ]
64
+ },
65
+ "sourcePath": {
66
+ "fileName": "data",
67
+ "filePath": [
68
+ "columns"
69
+ ]
70
+ },
71
+ "templateKey": "buildFooter",
72
+ "func": "fromCollection"
73
+ },
74
+ {
75
+ "narration": "Prepend the serial column width to the table colgroup.",
76
+ "destinationPath": {
77
+ "fileName": "base",
78
+ "dataRole": "table-colgroup",
79
+ "filePath": [
80
+ "children"
81
+ ],
82
+ "action": "unshift"
83
+ },
84
+ "sourcePath": {
85
+ "fileName": "data",
86
+ "filePath": [
87
+ "serial",
88
+ "col"
89
+ ]
90
+ },
91
+ "templateKey": "buildColGroup",
92
+ "func": "applyTemplate"
93
+ },
94
+ {
95
+ "narration": "Prepend the serial header cell to the table header row.",
96
+ "destinationPath": {
97
+ "fileName": "base",
98
+ "dataRole": "table-header-row",
99
+ "filePath": [
100
+ "children"
101
+ ],
102
+ "action": "unshift"
103
+ },
104
+ "sourcePath": {
105
+ "fileName": "data",
106
+ "filePath": [
107
+ "serial",
108
+ "header"
109
+ ]
110
+ },
111
+ "templateKey": "buildHeader",
112
+ "func": "applyTemplate"
113
+ },
114
+ {
115
+ "narration": "Prepend the serial number cell into each table body row.",
116
+ "destinationPath": {
117
+ "fileName": "base",
118
+ "dataRole": "table-body",
119
+ "filePath": [
120
+ "children"
121
+ ],
122
+ "action": "unshiftSerialToRows"
123
+ },
124
+ "sourcePath": {
125
+ "fileName": "data",
126
+ "filePath": [
127
+ "serial",
128
+ "body"
129
+ ]
130
+ },
131
+ "templateKey": "buildBodyCell",
132
+ "func": "applyTemplate"
133
+ },
134
+ {
135
+ "narration": "Prepend an empty cell into the table footer row.",
136
+ "destinationPath": {
137
+ "fileName": "base",
138
+ "dataRole": "table-footer-row",
139
+ "filePath": [
140
+ "children"
141
+ ],
142
+ "action": "unshift"
143
+ },
144
+ "sourcePath": {
145
+ "fileName": "data",
146
+ "filePath": [
147
+ "serial",
148
+ "footer"
149
+ ]
150
+ },
151
+ "templateKey": "buildBodyCell",
152
+ "func": "applyTemplate"
153
+ },
154
+ {
155
+ "narration": "Append the options column width to the table colgroup.",
156
+ "destinationPath": {
157
+ "fileName": "base",
158
+ "dataRole": "table-colgroup",
159
+ "filePath": [
160
+ "children"
161
+ ],
162
+ "action": "push"
163
+ },
164
+ "sourcePath": {
165
+ "fileName": "data",
166
+ "filePath": [
167
+ "options",
168
+ "col"
169
+ ]
170
+ },
171
+ "templateKey": "buildColGroup",
172
+ "func": "applyTemplate"
173
+ },
174
+ {
175
+ "narration": "Append the options header cell to the table header row.",
176
+ "destinationPath": {
177
+ "fileName": "base",
178
+ "dataRole": "table-header-row",
179
+ "filePath": [
180
+ "children"
181
+ ],
182
+ "action": "push"
183
+ },
184
+ "sourcePath": {
185
+ "fileName": "data",
186
+ "filePath": [
187
+ "options",
188
+ "header"
189
+ ]
190
+ },
191
+ "templateKey": "buildHeader",
192
+ "func": "applyTemplate"
193
+ },
194
+ {
195
+ "narration": "Append the options button cell into each table body row.",
196
+ "destinationPath": {
197
+ "fileName": "base",
198
+ "dataRole": "table-body",
199
+ "filePath": [
200
+ "children"
201
+ ],
202
+ "action": "pushToRows"
203
+ },
204
+ "sourcePath": {
205
+ "fileName": "data",
206
+ "filePath": [
207
+ "options",
208
+ "body"
209
+ ]
210
+ },
211
+ "templateKey": "buttonCell",
212
+ "func": "applyTemplate"
213
+ },
214
+ {
215
+ "narration": "Append the save button cell into the table footer row.",
216
+ "destinationPath": {
217
+ "fileName": "base",
218
+ "dataRole": "table-footer-row",
219
+ "filePath": [
220
+ "children"
221
+ ],
222
+ "action": "push"
223
+ },
224
+ "sourcePath": {
225
+ "fileName": "data",
226
+ "filePath": [
227
+ "options",
228
+ "footer"
229
+ ]
230
+ },
231
+ "templateKey": "buttonCell",
232
+ "func": "applyTemplate"
233
+ }
234
+ ]
@@ -0,0 +1,76 @@
1
+ import { runInstructions, buildBody, findByRole } from "../common/runner.js";
2
+ import spec from "../spec.json" with { type: "json" };
3
+ import base from "./config/base.json" with { type: "json" };
4
+ import instructions from "./config/instructions.json" with { type: "json" };
5
+
6
+ const buildSpec = ({ inColumns = [], inData = [], inSerial = {}, inOptions = {} } = {}) => {
7
+ const localColumns = inColumns;
8
+ const localData = inData;
9
+ const localSerial = {
10
+ col: { width: "50px" },
11
+ header: { columnName: "#" },
12
+ body: {},
13
+ footer: {},
14
+ ...inSerial
15
+ };
16
+ const localOptions = {
17
+ col: { width: "100px" },
18
+ header: { columnName: "options" },
19
+ body: { columnName: "show" },
20
+ footer: { columnName: "save" },
21
+ ...inOptions
22
+ };
23
+
24
+ const localBase = structuredClone(base);
25
+ const localSpec = structuredClone(spec);
26
+
27
+ const normalizedColumns = localColumns.map(col => {
28
+ const colCopy = structuredClone(col);
29
+ colCopy.template = {
30
+ bodyCell: "buildBodyCell",
31
+ ...(colCopy.template || {})
32
+ };
33
+ return colCopy;
34
+ });
35
+
36
+ const buildData = {
37
+ columns: normalizedColumns,
38
+ data: localData,
39
+ serial: localSerial,
40
+ options: localOptions
41
+ };
42
+
43
+ const registry = {
44
+ data: buildData,
45
+ base: localBase,
46
+ spec: localSpec
47
+ };
48
+
49
+ runInstructions({
50
+ inInstructions: instructions,
51
+ inRegistry: registry
52
+ });
53
+
54
+ const tbodyElement = findByRole(localBase, "table-body");
55
+ if (tbodyElement && Array.isArray(tbodyElement.children)) {
56
+ buildBody(tbodyElement.children, buildData, localSpec);
57
+ }
58
+
59
+ return localBase;
60
+ };
61
+
62
+ const startFunc = (input = {}) => {
63
+ const localInput = (input && typeof input === "object" && "inConfig" in input)
64
+ ? input.inConfig
65
+ : input;
66
+
67
+ return buildSpec({
68
+ inColumns: localInput.columns || [],
69
+ inData: localInput.data || [],
70
+ inSerial: localInput.serial || {},
71
+ inOptions: localInput.options || {}
72
+ });
73
+ };
74
+
75
+ export { buildSpec };
76
+ export default startFunc;
@@ -0,0 +1,15 @@
1
+ {
2
+ "tagName": "table",
3
+ "attributes": {
4
+ "class": "table table-hover table-striped align-middle border mb-0"
5
+ },
6
+ "children": [
7
+ {
8
+ "tagName": "tbody",
9
+ "attributes": {
10
+ "data-role": "table-body"
11
+ },
12
+ "children": []
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "narration": "Create one table row for each record and place it into the table body container.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-body",
7
+ "filePath": [
8
+ "children"
9
+ ]
10
+ },
11
+ "sourcePath": {
12
+ "fileName": "data",
13
+ "filePath": [
14
+ "data"
15
+ ]
16
+ },
17
+ "templateKey": "buildBodyTr",
18
+ "func": "fromCollection"
19
+ }
20
+ ]
@@ -0,0 +1,58 @@
1
+ import { runInstructions, buildBody, findByRole } from "../common/runner.js";
2
+ import spec from "../spec.json" with { type: "json" };
3
+ import base from "./config/base.json" with { type: "json" };
4
+ import instructions from "./config/instructions.json" with { type: "json" };
5
+
6
+ const buildSpec = ({ inColumns = [], inData = [] } = {}) => {
7
+ const localColumns = inColumns;
8
+ const localData = inData;
9
+
10
+ const localBase = structuredClone(base);
11
+ const localSpec = structuredClone(spec);
12
+
13
+ const normalizedColumns = localColumns.map(col => {
14
+ const colCopy = structuredClone(col);
15
+ colCopy.template = {
16
+ bodyCell: "buildBodyCell",
17
+ ...(colCopy.template || {})
18
+ };
19
+ return colCopy;
20
+ });
21
+
22
+ const buildData = {
23
+ columns: normalizedColumns,
24
+ data: localData
25
+ };
26
+
27
+ const registry = {
28
+ data: buildData,
29
+ base: localBase,
30
+ spec: localSpec
31
+ };
32
+
33
+ runInstructions({
34
+ inInstructions: instructions,
35
+ inRegistry: registry
36
+ });
37
+
38
+ const tbodyElement = findByRole(localBase, "table-body");
39
+ if (tbodyElement && Array.isArray(tbodyElement.children)) {
40
+ buildBody(tbodyElement.children, buildData, localSpec);
41
+ }
42
+
43
+ return localBase;
44
+ };
45
+
46
+ const startFunc = (input = {}) => {
47
+ const localInput = (input && typeof input === "object" && "inConfig" in input)
48
+ ? input.inConfig
49
+ : input;
50
+
51
+ return buildSpec({
52
+ inColumns: localInput.columns || [],
53
+ inData: localInput.data || []
54
+ });
55
+ };
56
+
57
+ export { buildSpec };
58
+ export default startFunc;