json-renderers 1.12.3 → 1.13.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 (178) hide show
  1. package/docs/dist/v13/min.js +678 -0
  2. package/docs/index.html +14 -0
  3. package/package.json +3 -3
  4. package/src/index.js +2 -2
  5. package/src/v13/buildSpec/index.js +28 -0
  6. package/src/v13/index.js +41 -0
  7. package/src/{v10 → v13}/meta.js +1 -1
  8. package/src/v10/dataLists/fragments.json +0 -1
  9. package/src/v10/dataLists/index.js +0 -32
  10. package/src/v10/dataLists/skeleton.json +0 -38
  11. package/src/v10/index.js +0 -142
  12. package/src/v10/select/fragments.json +0 -1
  13. package/src/v10/select/index.js +0 -34
  14. package/src/v10/select/skeleton.json +0 -23
  15. package/src/v10/table/index.js +0 -35
  16. package/src/v10/table/skeleton.json +0 -47
  17. package/src/v5/dataLists/fragments.json +0 -1
  18. package/src/v5/dataLists/index.js +0 -26
  19. package/src/v5/dataLists/skeleton.json +0 -20
  20. package/src/v5/form/attachFormClickEventListener.js +0 -27
  21. package/src/v5/form/clickFunc/extractFormData.js +0 -27
  22. package/src/v5/form/clickFunc/handleNew.js +0 -24
  23. package/src/v5/form/clickFunc/handleSave.js +0 -33
  24. package/src/v5/form/clickFunc/index.js +0 -32
  25. package/src/v5/form/index.js +0 -87
  26. package/src/v5/form/structure.json +0 -410
  27. package/src/v5/index.js +0 -150
  28. package/src/v5/meta.js +0 -6
  29. package/src/v5/navTabs/fragments.json +0 -59
  30. package/src/v5/navTabs/index.js +0 -82
  31. package/src/v5/navTabs/skeleton.json +0 -18
  32. package/src/v5/registerGlobal.js +0 -14
  33. package/src/v5/select/fragments.json +0 -1
  34. package/src/v5/select/index.js +0 -31
  35. package/src/v5/select/skeleton.json +0 -21
  36. package/src/v5/table/attachTableClickEventListener.js +0 -22
  37. package/src/v5/table/buildTableDataAsJson.js +0 -19
  38. package/src/v5/table/buildTableDomElement.js +0 -21
  39. package/src/v5/table/buildTableStructureSpec.js +0 -28
  40. package/src/v5/table/clickFunc/v3/createTable.js +0 -16
  41. package/src/v5/table/clickFunc/v3/getContainer/extractClickedRowDetails.js +0 -23
  42. package/src/v5/table/clickFunc/v3/getContainer/getOrCreateChildTableContainer.js +0 -21
  43. package/src/v5/table/clickFunc/v3/getContainer/index.js +0 -39
  44. package/src/v5/table/clickFunc/v3/getContainer/isSameRowClickedToToggleOff.js +0 -14
  45. package/src/v5/table/clickFunc/v3/getContainer/resetAndShowChildTableContainer.js +0 -12
  46. package/src/v5/table/clickFunc/v3/index.js +0 -21
  47. package/src/v5/table/fragments.json +0 -112
  48. package/src/v5/table/index.js +0 -72
  49. package/src/v5/table/resolveTargetContainer.js +0 -9
  50. package/src/v5/table/skeleton.json +0 -371
  51. package/src/v6/dataLists/fragments.json +0 -1
  52. package/src/v6/dataLists/index.js +0 -32
  53. package/src/v6/dataLists/skeleton.json +0 -38
  54. package/src/v6/form/attachFormClickEventListener.js +0 -27
  55. package/src/v6/form/clickFunc/extractFormData.js +0 -27
  56. package/src/v6/form/clickFunc/handleNew.js +0 -24
  57. package/src/v6/form/clickFunc/handleSave.js +0 -33
  58. package/src/v6/form/clickFunc/index.js +0 -32
  59. package/src/v6/form/index.js +0 -87
  60. package/src/v6/form/structure.json +0 -410
  61. package/src/v6/index.js +0 -150
  62. package/src/v6/meta.js +0 -6
  63. package/src/v6/navTabs/fragments.json +0 -59
  64. package/src/v6/navTabs/index.js +0 -82
  65. package/src/v6/navTabs/skeleton.json +0 -18
  66. package/src/v6/registerGlobal.js +0 -14
  67. package/src/v6/select/fragments.json +0 -1
  68. package/src/v6/select/index.js +0 -34
  69. package/src/v6/select/skeleton.json +0 -23
  70. package/src/v6/table/attachTableClickEventListener.js +0 -22
  71. package/src/v6/table/buildTableDataAsJson.js +0 -19
  72. package/src/v6/table/buildTableDomElement.js +0 -21
  73. package/src/v6/table/buildTableStructureSpec.js +0 -28
  74. package/src/v6/table/clickFunc/v3/createTable.js +0 -16
  75. package/src/v6/table/clickFunc/v3/getContainer/extractClickedRowDetails.js +0 -23
  76. package/src/v6/table/clickFunc/v3/getContainer/getOrCreateChildTableContainer.js +0 -21
  77. package/src/v6/table/clickFunc/v3/getContainer/index.js +0 -39
  78. package/src/v6/table/clickFunc/v3/getContainer/isSameRowClickedToToggleOff.js +0 -14
  79. package/src/v6/table/clickFunc/v3/getContainer/resetAndShowChildTableContainer.js +0 -12
  80. package/src/v6/table/clickFunc/v3/index.js +0 -21
  81. package/src/v6/table/fragments.json +0 -112
  82. package/src/v6/table/index.js +0 -72
  83. package/src/v6/table/resolveTargetContainer.js +0 -9
  84. package/src/v6/table/skeleton.json +0 -371
  85. package/src/v7/common/deriveColumnsFromData.js +0 -20
  86. package/src/v7/dataLists/fragments.json +0 -1
  87. package/src/v7/dataLists/index.js +0 -32
  88. package/src/v7/dataLists/skeleton.json +0 -38
  89. package/src/v7/form/attachFormClickEventListener.js +0 -27
  90. package/src/v7/form/clickFunc/extractFormData.js +0 -27
  91. package/src/v7/form/clickFunc/handleNew.js +0 -24
  92. package/src/v7/form/clickFunc/handleSave.js +0 -33
  93. package/src/v7/form/clickFunc/index.js +0 -32
  94. package/src/v7/form/index.js +0 -87
  95. package/src/v7/form/structure.json +0 -410
  96. package/src/v7/index.js +0 -141
  97. package/src/v7/meta.js +0 -6
  98. package/src/v7/navTabs/fragments.json +0 -59
  99. package/src/v7/navTabs/index.js +0 -82
  100. package/src/v7/navTabs/skeleton.json +0 -18
  101. package/src/v7/registerGlobal.js +0 -14
  102. package/src/v7/select/fragments.json +0 -1
  103. package/src/v7/select/index.js +0 -34
  104. package/src/v7/select/skeleton.json +0 -23
  105. package/src/v7/table/attachTableClickEventListener.js +0 -28
  106. package/src/v7/table/buildTableDataAsJson.js +0 -25
  107. package/src/v7/table/buildTableDomElement.js +0 -25
  108. package/src/v7/table/buildTableStructureSpec.js +0 -33
  109. package/src/v7/table/clickFunc/v3/createTable.js +0 -20
  110. package/src/v7/table/clickFunc/v3/getContainer/extractClickedRowDetails.js +0 -27
  111. package/src/v7/table/clickFunc/v3/getContainer/getOrCreateChildTableContainer.js +0 -24
  112. package/src/v7/table/clickFunc/v3/getContainer/index.js +0 -44
  113. package/src/v7/table/clickFunc/v3/getContainer/isSameRowClickedToToggleOff.js +0 -17
  114. package/src/v7/table/clickFunc/v3/getContainer/resetAndShowChildTableContainer.js +0 -15
  115. package/src/v7/table/clickFunc/v3/index.js +0 -35
  116. package/src/v7/table/fragments.json +0 -112
  117. package/src/v7/table/index.js +0 -82
  118. package/src/v7/table/resolveTargetContainer.js +0 -11
  119. package/src/v7/table/skeleton.json +0 -371
  120. package/src/v8/common/deriveColumnsFromData.js +0 -20
  121. package/src/v8/dataLists/fragments.json +0 -1
  122. package/src/v8/dataLists/index.js +0 -32
  123. package/src/v8/dataLists/skeleton.json +0 -38
  124. package/src/v8/form/attachFormClickEventListener.js +0 -27
  125. package/src/v8/form/clickFunc/extractFormData.js +0 -27
  126. package/src/v8/form/clickFunc/handleNew.js +0 -24
  127. package/src/v8/form/clickFunc/handleSave.js +0 -33
  128. package/src/v8/form/clickFunc/index.js +0 -32
  129. package/src/v8/form/index.js +0 -87
  130. package/src/v8/form/structure.json +0 -410
  131. package/src/v8/index.js +0 -141
  132. package/src/v8/meta.js +0 -6
  133. package/src/v8/navTabs/fragments.json +0 -59
  134. package/src/v8/navTabs/index.js +0 -82
  135. package/src/v8/navTabs/skeleton.json +0 -18
  136. package/src/v8/registerGlobal.js +0 -14
  137. package/src/v8/select/fragments.json +0 -1
  138. package/src/v8/select/index.js +0 -34
  139. package/src/v8/select/skeleton.json +0 -23
  140. package/src/v8/table/attachTableClickEventListener.js +0 -28
  141. package/src/v8/table/buildTableDataAsJson.js +0 -25
  142. package/src/v8/table/buildTableDomElement.js +0 -25
  143. package/src/v8/table/buildTableStructureSpec.js +0 -33
  144. package/src/v8/table/clickFunc/v3/createTable.js +0 -20
  145. package/src/v8/table/clickFunc/v3/getContainer/extractClickedRowDetails.js +0 -27
  146. package/src/v8/table/clickFunc/v3/getContainer/getOrCreateChildTableContainer.js +0 -24
  147. package/src/v8/table/clickFunc/v3/getContainer/index.js +0 -44
  148. package/src/v8/table/clickFunc/v3/getContainer/isSameRowClickedToToggleOff.js +0 -17
  149. package/src/v8/table/clickFunc/v3/getContainer/resetAndShowChildTableContainer.js +0 -15
  150. package/src/v8/table/clickFunc/v3/index.js +0 -35
  151. package/src/v8/table/fragments.json +0 -112
  152. package/src/v8/table/index.js +0 -82
  153. package/src/v8/table/resolveTargetContainer.js +0 -11
  154. package/src/v8/table/skeleton.json +0 -371
  155. package/src/v9/common/deriveColumnsFromData.js +0 -20
  156. package/src/v9/dataLists/fragments.json +0 -1
  157. package/src/v9/dataLists/index.js +0 -32
  158. package/src/v9/dataLists/skeleton.json +0 -38
  159. package/src/v9/form/attachFormClickEventListener.js +0 -27
  160. package/src/v9/form/clickFunc/extractFormData.js +0 -27
  161. package/src/v9/form/clickFunc/handleNew.js +0 -24
  162. package/src/v9/form/clickFunc/handleSave.js +0 -33
  163. package/src/v9/form/clickFunc/index.js +0 -32
  164. package/src/v9/form/index.js +0 -87
  165. package/src/v9/form/structure.json +0 -410
  166. package/src/v9/index.js +0 -141
  167. package/src/v9/meta.js +0 -6
  168. package/src/v9/navTabs/fragments.json +0 -59
  169. package/src/v9/navTabs/index.js +0 -82
  170. package/src/v9/navTabs/skeleton.json +0 -18
  171. package/src/v9/registerGlobal.js +0 -14
  172. package/src/v9/select/fragments.json +0 -1
  173. package/src/v9/select/index.js +0 -34
  174. package/src/v9/select/skeleton.json +0 -23
  175. package/src/v9/table/index.js +0 -35
  176. package/src/v9/table/skeleton.json +0 -47
  177. /package/src/{v10 → v13}/common/deriveColumnsFromData.js +0 -0
  178. /package/src/{v10 → v13}/registerGlobal.js +0 -0
@@ -1,59 +0,0 @@
1
- {
2
- "navTabsList": {
3
- "tagName": "ul",
4
- "attributes": {
5
- "class": "nav nav-tabs",
6
- "role": "tablist"
7
- },
8
- "jsonToSpec": {
9
- "operation": "loopArray",
10
- "source": "tabs",
11
- "template": {
12
- "tagName": "li",
13
- "attributes": {
14
- "class": "nav-item",
15
- "role": "presentation"
16
- },
17
- "children": [
18
- {
19
- "tagName": "button",
20
- "attributes": {
21
- "class": "nav-link ${activeClass}",
22
- "id": "${id}-tab",
23
- "data-bs-toggle": "tab",
24
- "data-bs-target": "#${id}-pane",
25
- "type": "button",
26
- "role": "tab",
27
- "aria-controls": "${id}-pane",
28
- "aria-selected": "${isSelected}"
29
- },
30
- "textContent": "${label}"
31
- }
32
- ]
33
- }
34
- },
35
- "children": []
36
- },
37
- "tabContent": {
38
- "tagName": "div",
39
- "attributes": {
40
- "class": "tab-content pt-3"
41
- },
42
- "jsonToSpec": {
43
- "operation": "loopArray",
44
- "source": "tabs",
45
- "template": {
46
- "tagName": "div",
47
- "attributes": {
48
- "class": "tab-pane fade ${showActiveClass}",
49
- "id": "${id}-pane",
50
- "role": "tabpanel",
51
- "aria-labelledby": "${id}-tab",
52
- "tabindex": "0"
53
- },
54
- "textContent": "${content}"
55
- }
56
- },
57
- "children": []
58
- }
59
- }
@@ -1,82 +0,0 @@
1
- import skeletonToSpec from "../../../../../skeletonToSpec/v3/index.js";
2
- import jsonToSpec from "../../../jsonToSpec/v2/index.js";
3
- import jsonToTag from "../../../jsonToTag/v2/index.js";
4
-
5
- import skeletonJson from './skeleton.json' with {type: 'json'};
6
- import fragmentsJson from './fragments.json' with {type: 'json'};
7
-
8
- const startFunc = ({
9
- targetHtmlId,
10
- inTargetHtmlId,
11
- inTabs = [],
12
- inData = [],
13
- inSkeletonType = "default",
14
- inShowLog = false
15
- } = {}) => {
16
- const localTargetHtmlId = inTargetHtmlId ?? targetHtmlId;
17
- const localTabs = inTabs;
18
- const localData = inData;
19
- const localSkeletonType = inSkeletonType;
20
- const localShowLog = inShowLog;
21
-
22
- try {
23
- let tabsArray = [];
24
-
25
- if (Array.isArray(localTabs) && localTabs.length > 0) {
26
- tabsArray = localTabs.map((tab, idx) => ({
27
- id: tab.id ?? `tab-${idx + 1}`,
28
- label: tab.label ?? tab.title ?? `Tab ${idx + 1}`,
29
- activeClass: tab.activeClass ?? (idx === 0 ? "active" : ""),
30
- showActiveClass: tab.showActiveClass ?? (idx === 0 ? "show active" : ""),
31
- isSelected: tab.isSelected ?? (idx === 0 ? "true" : "false"),
32
- content: tab.content ?? ""
33
- }));
34
- } else if (Array.isArray(localData) && localData.length > 0) {
35
- tabsArray = localData.map((row, idx) => {
36
- const id = `tab-${row.VOUCHERNUMBER ?? row.id ?? idx + 1}`;
37
- const label = row.REFERENCE || row.VOUCHERTYPENAME || `Tab ${idx + 1}`;
38
- const isActive = idx === 0;
39
- return {
40
- id,
41
- label,
42
- activeClass: isActive ? "active" : "",
43
- showActiveClass: isActive ? "show active" : "",
44
- isSelected: isActive ? "true" : "false",
45
- content: ""
46
- };
47
- });
48
- }
49
-
50
- const dataAsJson = { tabs: tabsArray };
51
-
52
- const rawSkeleton = skeletonJson[localSkeletonType] ?? skeletonJson.default ?? skeletonJson;
53
- const targetSkeleton = structuredClone(rawSkeleton);
54
-
55
- if (localShowLog) console.log("navTabs targetSkeleton : ", targetSkeleton);
56
-
57
- const structureJson = skeletonToSpec({
58
- inSkeleton: targetSkeleton,
59
- inFragments: fragmentsJson
60
- });
61
- if (localShowLog) console.log("navTabs structureJson : ", structureJson);
62
-
63
- const specAsJsonToDom = jsonToSpec({ specJson: structureJson, dataJson: dataAsJson, showLog: false });
64
- if (localShowLog) console.log("navTabs specAsJsonToDom : ", specAsJsonToDom);
65
-
66
- const fromRenderer = jsonToTag(specAsJsonToDom);
67
-
68
- const html = (typeof localTargetHtmlId === "string")
69
- ? document.getElementById(localTargetHtmlId)
70
- : localTargetHtmlId;
71
-
72
- if (!html) return fromRenderer;
73
-
74
- html.append(fromRenderer);
75
- return fromRenderer;
76
- } catch (error) {
77
- console.log("error : ", error);
78
- };
79
- };
80
-
81
- export { startFunc };
82
- export default startFunc;
@@ -1,18 +0,0 @@
1
- {
2
- "default": {
3
- "tagName": "div",
4
- "attributes": {
5
- "class": "bootstrap-nav-tabs"
6
- },
7
- "slots": [
8
- "navTabsList",
9
- "tabContent"
10
- ]
11
- },
12
- "tabsOnly": {
13
- "tagName": "div",
14
- "slots": [
15
- "navTabsList"
16
- ]
17
- }
18
- }
@@ -1,14 +0,0 @@
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.jsonRenderers ??= {
9
- meta,
10
- renderToDom: inFuncDefinition
11
- };
12
- };
13
-
14
- export default registerGlobal;
@@ -1 +0,0 @@
1
- {}
@@ -1,34 +0,0 @@
1
- import jsonTraversal from "../../../node_modules/json-traversal/index.js";
2
-
3
- // import jsonToSpec from "../../../node_modules/json-to-spec/index.js";
4
- // import jsonToTag from "@keshavsoft/json-to-tag";
5
- import jsonToTag from "@keshavsoft/json-to-tag";
6
-
7
- import skeletonJson from "./skeleton.json" with { type: "json" };
8
-
9
- const startFunc = ({ targetHtmlId, inData,
10
- inSkeletonType = "default", inClassToApply } = {}) => {
11
-
12
- console.log("aaaaaaaaaa");
13
-
14
- const skeletonNeeded = skeletonJson[inSkeletonType];
15
- skeletonNeeded.mapping.attributes.class = `$${inClassToApply}`;
16
- // skeletonNeeded.mapping.attributes.class = inClassToApply;
17
- debugger;
18
-
19
- const specAsJsonToDom = jsonTraversal.transform(inData, skeletonNeeded);
20
-
21
- const container = document.getElementById(targetHtmlId);
22
- if (container) container.innerHTML = "";
23
-
24
- const createdElement = jsonToTag(specAsJsonToDom);
25
-
26
- if (Array.isArray(createdElement)) {
27
- // container.appendChild(createdElement)
28
- createdElement.forEach(element => container.append(element));
29
- } else {
30
- container.append(createdElement);
31
- };
32
- };
33
-
34
- export default startFunc;
@@ -1,23 +0,0 @@
1
- {
2
- "default": {
3
- "mapping": {
4
- "tagName": "$select",
5
- "attributes": {
6
- "id": "$LedgerName",
7
- "class": "$keshav"
8
- },
9
- "children": [
10
- {
11
- "list": "LedgerName",
12
- "item": {
13
- "tagName": "$option",
14
- "attributes": {
15
- "value": ""
16
- },
17
- "textContent": ""
18
- }
19
- }
20
- ]
21
- }
22
- }
23
- }
@@ -1,28 +0,0 @@
1
- import clickFunc from "./clickFunc/v3/index.js";
2
-
3
- // Story 5: Attach click event listener for child table rendering
4
- const startFunc = ({
5
- inTargetContainer,
6
- inData,
7
- inColumns,
8
- inRenderFunc,
9
- inTargetHtmlId
10
- } = {}) => {
11
- const localTargetContainer = inTargetContainer;
12
- const localData = inData;
13
- const localColumns = inColumns;
14
- const localRenderFunc = inRenderFunc;
15
- const localTargetHtmlId = inTargetHtmlId;
16
-
17
- localTargetContainer.addEventListener('click', (event) => {
18
- clickFunc({
19
- inEvent: event,
20
- inData: localData,
21
- inColumns: localColumns,
22
- inRenderFunc: localRenderFunc,
23
- inTargetHtmlId: localTargetHtmlId
24
- });
25
- });
26
- };
27
-
28
- export default startFunc;
@@ -1,25 +0,0 @@
1
- // Story 1: Prepare table data payload as JSON
2
- const startFunc = ({
3
- inColumns,
4
- inData,
5
- inColGroup,
6
- inFooterData = [],
7
- inConfig = {}
8
- } = {}) => {
9
- const localColumns = inColumns;
10
- const localData = inData;
11
- const localColGroup = inColGroup;
12
- const localFooterData = inFooterData;
13
- const localConfig = inConfig;
14
-
15
- return {
16
- columns: localColumns,
17
- data: localData,
18
- colGroup: localColGroup,
19
- foot: localFooterData,
20
- title: localConfig?.title ?? localConfig?.caption?.text ?? "",
21
- footerText: localConfig?.footerText ?? ""
22
- };
23
- };
24
-
25
- export default startFunc;
@@ -1,25 +0,0 @@
1
- import jsonToSpec from "../../../node_modules/json-to-spec/index.js";
2
- import jsonToTag from "@keshavsoft/json-to-tag";
3
-
4
- // Story 3: Generate table DOM element from structure specification and data
5
- const startFunc = ({
6
- inStructureJson,
7
- inDataAsJson,
8
- inShowLog = false
9
- } = {}) => {
10
- const localStructureJson = inStructureJson;
11
- const localDataAsJson = inDataAsJson;
12
- const localShowLog = inShowLog;
13
-
14
- const specAsJsonToDom = jsonToSpec({
15
- specJson: localStructureJson,
16
- dataJson: localDataAsJson,
17
- showLog: localShowLog
18
- });
19
-
20
- if (localShowLog) console.log("specAsJsonToDom : ", specAsJsonToDom);
21
-
22
- return jsonToTag(specAsJsonToDom);
23
- };
24
-
25
- export default startFunc;
@@ -1,33 +0,0 @@
1
- import skeletonToSpec from "../../../skeletonToSpec/v1/index.js";
2
-
3
- import skeletonJson from './skeleton.json' with {type: 'json'};
4
- import fragmentsJson from './fragments.json' with {type: 'json'};
5
-
6
- // Story 2: Build table structure specification from skeleton and fragments
7
- const startFunc = ({
8
- inSkeletonType = "default",
9
- inSkeletonJson = skeletonJson,
10
- inFragmentsJson = fragmentsJson,
11
- inShowLog = false
12
- } = {}) => {
13
- const localSkeletonType = inSkeletonType;
14
- const localSkeletonJson = inSkeletonJson;
15
- const localFragmentsJson = inFragmentsJson;
16
- const localShowLog = inShowLog;
17
-
18
- const rawSkeleton = localSkeletonJson[localSkeletonType] ?? localSkeletonJson.default ?? localSkeletonJson;
19
- const targetSkeleton = structuredClone(rawSkeleton);
20
-
21
- if (localShowLog) console.log("targetSkeleton : ", targetSkeleton);
22
-
23
- const structureJson = skeletonToSpec({
24
- inSkeleton: targetSkeleton,
25
- inFragments: localFragmentsJson
26
- });
27
-
28
- if (localShowLog) console.log("structureJson : ", structureJson);
29
-
30
- return structureJson;
31
- };
32
-
33
- export default startFunc;
@@ -1,20 +0,0 @@
1
- import deriveColumnsFromData from "../../../common/deriveColumnsFromData.js";
2
-
3
- // Step 2: Create the child table inside the container
4
- const startFunc = ({ inChildTableContainer, inContainer, inRenderFunc } = {}) => {
5
- const localChildTableContainer = inChildTableContainer;
6
- const localContainer = inContainer;
7
- const localRenderFunc = inRenderFunc;
8
-
9
- const targetContainer = localChildTableContainer || localContainer;
10
- const childTableData = targetContainer?.childData;
11
-
12
- localRenderFunc({
13
- inTargetHtmlId: targetContainer,
14
- inColumns: deriveColumnsFromData({ inData: childTableData }),
15
- inData: childTableData,
16
- inSkeletonType: "tableOnly"
17
- });
18
- };
19
-
20
- export default startFunc;
@@ -1,27 +0,0 @@
1
- // Step 1: Who clicked what? (Resolve parent row, column key, and child table data)
2
- const startFunc = ({ inEvent, inColumns, inData } = {}) => {
3
- const localEvent = inEvent;
4
- const localColumns = inColumns;
5
- const localData = inData;
6
-
7
- const clickedButton = localEvent?.target?.closest("button");
8
- if (!clickedButton) return null;
9
-
10
- const parentRow = clickedButton.closest("tr");
11
- const parentCell = clickedButton.closest("td");
12
- if (!parentRow || !parentCell) return null;
13
-
14
- const parentRowIndex = parentRow.sectionRowIndex;
15
- const childColumnKey = localColumns?.[parentCell.cellIndex]?.key;
16
- const childTableData = localData?.[parentRowIndex]?.[childColumnKey];
17
-
18
- if (!Array.isArray(childTableData) || childTableData.length === 0) return null;
19
-
20
- return {
21
- parentRowIndex,
22
- childColumnKey,
23
- childTableData
24
- };
25
- };
26
-
27
- export default startFunc;
@@ -1,24 +0,0 @@
1
- // Step 2: Where does the child table live? (Find or create the container div)
2
- const startFunc = ({ inTargetHtmlId, inChildColumnKey } = {}) => {
3
- const localTargetHtmlId = inTargetHtmlId;
4
- const localChildColumnKey = inChildColumnKey;
5
-
6
- const targetTableElement = (typeof localTargetHtmlId === "string")
7
- ? document.getElementById(localTargetHtmlId)
8
- : localTargetHtmlId;
9
- if (!targetTableElement) return null;
10
-
11
- const childContainerHtmlId = `${targetTableElement.id || "table"}-${localChildColumnKey}`;
12
- let childTableContainer = document.getElementById(childContainerHtmlId);
13
-
14
- if (!childTableContainer) {
15
- childTableContainer = document.createElement("div");
16
- childTableContainer.id = childContainerHtmlId;
17
- childTableContainer.className = "child-table-container mt-3";
18
- targetTableElement.insertAdjacentElement("afterend", childTableContainer);
19
- }
20
-
21
- return childTableContainer;
22
- };
23
-
24
- export default startFunc;
@@ -1,44 +0,0 @@
1
- import extractClickedRowDetails from "./extractClickedRowDetails.js";
2
- import getOrCreateChildTableContainer from "./getOrCreateChildTableContainer.js";
3
- import isSameRowClickedToToggleOff from "./isSameRowClickedToToggleOff.js";
4
- import resetAndShowChildTableContainer from "./resetAndShowChildTableContainer.js";
5
-
6
- // --- Story of getContainer ---
7
- const startFunc = ({ inEvent, inTargetHtmlId, inColumns, inData } = {}) => {
8
- const localEvent = inEvent;
9
- const localTargetHtmlId = inTargetHtmlId;
10
- const localColumns = inColumns;
11
- const localData = inData;
12
-
13
- // Story 1: Who was clicked? (Resolve parent row and child table data)
14
- const clickedRowDetails = extractClickedRowDetails({
15
- inEvent: localEvent,
16
- inColumns: localColumns,
17
- inData: localData
18
- });
19
- if (!clickedRowDetails) return null;
20
-
21
- // Story 2: Where does the child table container go?
22
- const childTableContainer = getOrCreateChildTableContainer({
23
- inTargetHtmlId: localTargetHtmlId,
24
- inChildColumnKey: clickedRowDetails.childColumnKey
25
- });
26
- if (!childTableContainer) return null;
27
-
28
- // Story 3: Same row clicked again? Close it.
29
- if (isSameRowClickedToToggleOff({
30
- inChildTableContainer: childTableContainer,
31
- inParentRowIndex: clickedRowDetails.parentRowIndex
32
- })) {
33
- return null;
34
- }
35
-
36
- // Story 4: Clean and activate container for rendering
37
- return resetAndShowChildTableContainer({
38
- inChildTableContainer: childTableContainer,
39
- inClickedRowDetails: clickedRowDetails
40
- });
41
- };
42
-
43
- export { startFunc };
44
- export default startFunc;
@@ -1,17 +0,0 @@
1
- // Step 3: Did user click the same row again? Close it (toggle)
2
- const startFunc = ({ inChildTableContainer, inParentRowIndex } = {}) => {
3
- const localChildTableContainer = inChildTableContainer;
4
- const localParentRowIndex = inParentRowIndex;
5
-
6
- const isMatchingActiveRow = localChildTableContainer.dataset.activeRow === String(localParentRowIndex);
7
- const isCurrentlyVisible = localChildTableContainer.style.display !== "none";
8
-
9
- if (isMatchingActiveRow && isCurrentlyVisible) {
10
- localChildTableContainer.style.display = "none";
11
- return true;
12
- }
13
-
14
- return false;
15
- };
16
-
17
- export default startFunc;
@@ -1,15 +0,0 @@
1
- // Step 4: Ready the container for the new child table
2
- const startFunc = ({ inChildTableContainer, inClickedRowDetails } = {}) => {
3
- const localChildTableContainer = inChildTableContainer;
4
- const localClickedRowDetails = inClickedRowDetails;
5
-
6
- localChildTableContainer.style.display = "";
7
- localChildTableContainer.dataset.activeRow = String(localClickedRowDetails.parentRowIndex);
8
- localChildTableContainer.dataset.fieldName = localClickedRowDetails.childColumnKey;
9
- localChildTableContainer.innerHTML = "";
10
- localChildTableContainer.childData = localClickedRowDetails.childTableData;
11
-
12
- return localChildTableContainer;
13
- };
14
-
15
- export default startFunc;
@@ -1,35 +0,0 @@
1
- import getContainer from "./getContainer/index.js";
2
- import createTable from "./createTable.js";
3
-
4
- // Main click handler: only 2 clear steps from the outside
5
- const clickFunc = ({
6
- inEvent,
7
- inData,
8
- inColumns,
9
- inRenderFunc,
10
- inTargetHtmlId
11
- } = {}) => {
12
- const localEvent = inEvent;
13
- const localData = inData;
14
- const localColumns = inColumns;
15
- const localRenderFunc = inRenderFunc;
16
- const localTargetHtmlId = inTargetHtmlId;
17
-
18
- // 1. Get or prepare child table container
19
- const childTableContainer = getContainer({
20
- inEvent: localEvent,
21
- inTargetHtmlId: localTargetHtmlId,
22
- inColumns: localColumns,
23
- inData: localData
24
- });
25
- if (!childTableContainer) return;
26
-
27
- // 2. Create and render child table inside the container
28
- createTable({
29
- inChildTableContainer: childTableContainer,
30
- inRenderFunc: localRenderFunc
31
- });
32
- };
33
-
34
- export { clickFunc };
35
- export default clickFunc;
@@ -1,112 +0,0 @@
1
- {
2
- "colGroup": {
3
- "tagName": "colgroup",
4
- "jsonToSpec": {
5
- "operation": "loopArray",
6
- "source": "colGroup",
7
- "template": {
8
- "tagName": "col",
9
- "attributes": {
10
- "style": "${style}"
11
- }
12
- }
13
- },
14
- "children": []
15
- },
16
- "thead": {
17
- "tagName": "thead",
18
- "attributes": {
19
- "class": "table-dark"
20
- },
21
- "children": [
22
- {
23
- "tagName": "tr",
24
- "jsonToSpec": {
25
- "operation": "loopArray",
26
- "source": "columns",
27
- "template": {
28
- "tagName": "th",
29
- "textContent": "${label}"
30
- }
31
- },
32
- "children": []
33
- }
34
- ]
35
- },
36
- "tbody": {
37
- "tagName": "tbody",
38
- "attributes": {
39
- "id": "table-body"
40
- },
41
- "jsonToSpec": {
42
- "operation": "loopArray",
43
- "source": "data",
44
- "template": {
45
- "tagName": "tr",
46
- "jsonToSpec": {
47
- "operation": "loopObject",
48
- "source": "data",
49
- "template": {
50
- "tagName": "td",
51
- "attributes": {
52
- "class": "tdddddd ${value}"
53
- },
54
- "textContent": "${value}"
55
- }
56
- },
57
- "children": []
58
- }
59
- },
60
- "children": []
61
- },
62
- "tfoot": {
63
- "tagName": "tfoot",
64
- "attributes": {
65
- "class": "table-light fw-bold"
66
- },
67
- "jsonToSpec": {
68
- "operation": "loopArray",
69
- "source": "foot",
70
- "template": {
71
- "tagName": "tr",
72
- "jsonToSpec": {
73
- "operation": "loopObject",
74
- "source": "foot",
75
- "template": {
76
- "tagName": "td",
77
- "textContent": "${value}"
78
- }
79
- },
80
- "children": []
81
- }
82
- },
83
- "children": []
84
- },
85
- "cardHeader": {
86
- "tagName": "div",
87
- "attributes": {
88
- "class": "d-flex justify-content-between align-items-center"
89
- },
90
- "children": [
91
- {
92
- "tagName": "h5",
93
- "attributes": {
94
- "class": "card-title mb-0"
95
- },
96
- "textContent": "${title}"
97
- }
98
- ]
99
- },
100
- "cardFooter": {
101
- "tagName": "div",
102
- "attributes": {
103
- "class": "d-flex justify-content-between align-items-center text-muted small"
104
- },
105
- "children": [
106
- {
107
- "tagName": "span",
108
- "textContent": "${footerText}"
109
- }
110
- ]
111
- }
112
- }