json-renderers-build 1.9.1 → 1.9.2
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.
- package/package.json +1 -1
- package/src/index.js +2 -2
- package/src/v9/table/index.js +33 -33
- package/src/v9/table/options/index.js +18 -18
- package/src/v9/table/options/showOptions/index.js +39 -39
- package/src/v9/table/options/showSerial/index.js +19 -19
- package/src/v9/table/table/body/cell/index.js +12 -12
- package/src/v9/table/table/body/cell/tag.json +7 -7
- package/src/v9/table/table/body/index.js +17 -17
- package/src/v9/table/table/body/row/index.js +18 -18
- package/src/v9/table/table/body/row/tag.json +4 -4
- package/src/v9/table/table/body/tag.json +4 -4
- package/src/v9/table/table/head/cell/index.js +12 -12
- package/src/v9/table/table/head/cell/tag.json +7 -7
- package/src/v9/table/table/head/index.js +16 -16
- package/src/v9/table/table/head/row/index.js +14 -14
- package/src/v9/table/table/head/row/tag.json +4 -4
- package/src/v9/table/table/head/tag.json +4 -4
- package/src/v9/table/table/index.js +36 -36
- package/src/v9/table/table/tag.json +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-renderers-build",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "Headless component specification builder for json-renderers, compiling UI skeletons and data into JSON-to-DOM specs using json-to-spec",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export { default } from "./
|
|
1
|
+
export * from "./v9/index.js";
|
|
2
|
+
export { default } from "./v9/index.js";
|
package/src/v9/table/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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
|
-
inData,
|
|
9
|
-
inColumns,
|
|
10
|
-
footer = [],
|
|
11
|
-
options = {}
|
|
12
|
-
} = {}) => {
|
|
13
|
-
if (type === "table") {
|
|
14
|
-
const spec = renderTable({
|
|
15
|
-
inColumns,
|
|
16
|
-
inData,
|
|
17
|
-
inFooter: footer
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return applyOptions(spec, options);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
throw new Error(`Unknown table renderer type "${type}".`);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
render.requests = renderRequests;
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
render,
|
|
30
|
-
renderRequests
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default render;
|
|
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
|
+
inData,
|
|
9
|
+
inColumns,
|
|
10
|
+
footer = [],
|
|
11
|
+
options = {}
|
|
12
|
+
} = {}) => {
|
|
13
|
+
if (type === "table") {
|
|
14
|
+
const spec = renderTable({
|
|
15
|
+
inColumns,
|
|
16
|
+
inData,
|
|
17
|
+
inFooter: footer
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return applyOptions(spec, options);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
throw new Error(`Unknown table renderer type "${type}".`);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
render.requests = renderRequests;
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
render,
|
|
30
|
+
renderRequests
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default render;
|
|
@@ -1,18 +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;
|
|
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;
|
|
@@ -1,39 +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;
|
|
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 +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;
|
|
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,12 +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;
|
|
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 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "td",
|
|
3
|
-
"attributes": {
|
|
4
|
-
"value": ""
|
|
5
|
-
},
|
|
6
|
-
"textContent": ""
|
|
7
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "td",
|
|
3
|
+
"attributes": {
|
|
4
|
+
"value": ""
|
|
5
|
+
},
|
|
6
|
+
"textContent": ""
|
|
7
|
+
}
|
|
@@ -1,17 +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;
|
|
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 +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;
|
|
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 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "tr",
|
|
3
|
-
"children": []
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "tr",
|
|
3
|
+
"children": []
|
|
4
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "tbody",
|
|
3
|
-
"children": []
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "tbody",
|
|
3
|
+
"children": []
|
|
4
|
+
}
|
|
@@ -1,12 +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;
|
|
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 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "th",
|
|
3
|
-
"attributes": {
|
|
4
|
-
"value": ""
|
|
5
|
-
},
|
|
6
|
-
"textContent": ""
|
|
7
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "th",
|
|
3
|
+
"attributes": {
|
|
4
|
+
"value": ""
|
|
5
|
+
},
|
|
6
|
+
"textContent": ""
|
|
7
|
+
}
|
|
@@ -1,16 +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;
|
|
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 +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;
|
|
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 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "tr",
|
|
3
|
-
"children": []
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "tr",
|
|
3
|
+
"children": []
|
|
4
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "thead",
|
|
3
|
-
"children": []
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "thead",
|
|
3
|
+
"children": []
|
|
4
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import tagJson from "./tag.json" with { type: "json" };
|
|
2
|
-
import renderTableHead from "./head/index.js";
|
|
3
|
-
import renderTableBody from "./body/index.js";
|
|
4
|
-
import renderTableFooter from "../footer/index.js";
|
|
5
|
-
|
|
6
|
-
const renderTable = ({
|
|
7
|
-
inColumns = [],
|
|
8
|
-
inData = [],
|
|
9
|
-
inFooter = []
|
|
10
|
-
} = {}) => {
|
|
11
|
-
const table = structuredClone(tagJson);
|
|
12
|
-
|
|
13
|
-
const children = [
|
|
14
|
-
renderTableHead({ inColumns }),
|
|
15
|
-
renderTableBody({ inData, inColumns })
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
if (!Array.isArray(inFooter)) {
|
|
19
|
-
throw new TypeError("The footer property must be an array of footer names.");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (inFooter.length > 0) {
|
|
23
|
-
children.push(renderTableFooter({
|
|
24
|
-
inFooter,
|
|
25
|
-
inColumns,
|
|
26
|
-
inData
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
table.children = children;
|
|
31
|
-
|
|
32
|
-
return table;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { renderTableHead, renderTableBody };
|
|
36
|
-
export default renderTable;
|
|
1
|
+
import tagJson from "./tag.json" with { type: "json" };
|
|
2
|
+
import renderTableHead from "./head/index.js";
|
|
3
|
+
import renderTableBody from "./body/index.js";
|
|
4
|
+
import renderTableFooter from "../footer/index.js";
|
|
5
|
+
|
|
6
|
+
const renderTable = ({
|
|
7
|
+
inColumns = [],
|
|
8
|
+
inData = [],
|
|
9
|
+
inFooter = []
|
|
10
|
+
} = {}) => {
|
|
11
|
+
const table = structuredClone(tagJson);
|
|
12
|
+
|
|
13
|
+
const children = [
|
|
14
|
+
renderTableHead({ inColumns }),
|
|
15
|
+
renderTableBody({ inData, inColumns })
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
if (!Array.isArray(inFooter)) {
|
|
19
|
+
throw new TypeError("The footer property must be an array of footer names.");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (inFooter.length > 0) {
|
|
23
|
+
children.push(renderTableFooter({
|
|
24
|
+
inFooter,
|
|
25
|
+
inColumns,
|
|
26
|
+
inData
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
table.children = children;
|
|
31
|
+
|
|
32
|
+
return table;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { renderTableHead, renderTableBody };
|
|
36
|
+
export default renderTable;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagName": "table",
|
|
3
|
-
"attributes": {
|
|
4
|
-
"class": "table table-hover table-striped mb-0"
|
|
5
|
-
},
|
|
6
|
-
"children": []
|
|
7
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tagName": "table",
|
|
3
|
+
"attributes": {
|
|
4
|
+
"class": "table table-hover table-striped mb-0"
|
|
5
|
+
},
|
|
6
|
+
"children": []
|
|
7
|
+
}
|