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.
- package/package.json +5 -2
- package/src/index.js +2 -3
- package/src/v14/buildSpec/config/base.json +53 -0
- package/src/v14/buildSpec/config/columnInstructions.json +56 -0
- package/src/v14/buildSpec/config/optionsInstructions.json +82 -0
- package/src/v14/buildSpec/config/rowInstructions.json +20 -0
- package/src/v14/buildSpec/config/serialInstructions.json +82 -0
- package/src/v14/buildSpec/index.js +147 -0
- package/src/v14/buildSpec/writePath/index.js +55 -0
- package/src/v14/index.js +56 -0
- package/src/v14/register/index.js +30 -0
- package/src/v14/register/meta.js +6 -0
- package/src/v14/spec.json +65 -0
- package/src/v15/buildSpec/config/base.json +53 -0
- package/src/v15/buildSpec/config/columnInstructions.json +56 -0
- package/src/v15/buildSpec/config/optionsInstructions.json +82 -0
- package/src/v15/buildSpec/config/rowInstructions.json +20 -0
- package/src/v15/buildSpec/config/serialInstructions.json +82 -0
- package/src/v15/buildSpec/index.js +147 -0
- package/src/v15/buildSpec/writePath/index.js +55 -0
- package/src/v15/common/runner.js +33 -0
- package/src/v15/common/writePath.js +55 -0
- package/src/v15/index.js +85 -0
- package/src/v15/register/index.js +30 -0
- package/src/v15/register/meta.js +6 -0
- package/src/v15/simpleTable/config/base.json +31 -0
- package/src/v15/simpleTable/config/instructions.json +38 -0
- package/src/v15/simpleTable/index.js +58 -0
- package/src/v15/spec.json +65 -0
- package/src/v15/tableFullGrid/config/base.json +53 -0
- package/src/v15/tableFullGrid/config/instructions.json +234 -0
- package/src/v15/tableFullGrid/index.js +76 -0
- package/src/v15/tableHeadless/config/base.json +15 -0
- package/src/v15/tableHeadless/config/instructions.json +20 -0
- package/src/v15/tableHeadless/index.js +58 -0
- package/src/v15/tableWithButtonCell/config/base.json +38 -0
- package/src/v15/tableWithButtonCell/config/instructions.json +56 -0
- package/src/v15/tableWithButtonCell/index.js +57 -0
- package/src/v15/tableWithFooter/config/base.json +53 -0
- package/src/v15/tableWithFooter/config/instructions.json +74 -0
- package/src/v15/tableWithFooter/index.js +58 -0
- package/src/v15/tableWithOptions/config/base.json +38 -0
- package/src/v15/tableWithOptions/config/instructions.json +116 -0
- package/src/v15/tableWithOptions/index.js +66 -0
- package/src/v15/tableWithSerial/config/base.json +38 -0
- package/src/v15/tableWithSerial/config/instructions.json +116 -0
- package/src/v15/tableWithSerial/index.js +66 -0
- package/src/v15/tableWithWidths/config/base.json +38 -0
- package/src/v15/tableWithWidths/config/instructions.json +56 -0
- package/src/v15/tableWithWidths/index.js +58 -0
- package/src/v16/common/runner.js +33 -0
- package/src/v16/common/writePath.js +55 -0
- package/src/v16/index.js +7 -0
- package/src/v16/simpleTable/config/base.json +31 -0
- package/src/v16/simpleTable/config/instructions.json +38 -0
- package/src/v16/simpleTable/index.js +58 -0
- package/src/v16/spec.json +65 -0
- package/src/v16/tableWithOptions/config/base.json +38 -0
- package/src/v16/tableWithOptions/config/instructions.json +116 -0
- package/src/v16/tableWithOptions/index.js +66 -0
- package/src/v16/tableWithSerial/config/base.json +38 -0
- package/src/v16/tableWithSerial/config/instructions.json +116 -0
- package/src/v16/tableWithSerial/index.js +66 -0
- package/src/v17/index.js +5 -0
- package/src/v17/simple/base.json +53 -0
- package/src/v17/simple/index.js +56 -0
- package/src/v17/simple/instructions/double.json +19 -0
- package/src/v17/simple/instructions/single.json +38 -0
- package/src/v17/simple/spec.json +86 -0
- package/src/v17/simple/writePath/index.js +47 -0
- package/src/v17/spec.json +86 -0
- package/src/v5/index.js +0 -49
- package/src/v5/options/index.js +0 -18
- package/src/v5/options/showOptions/index.js +0 -39
- package/src/v5/options/showSerial/index.js +0 -19
- package/src/v5/render-requests.json +0 -70
- package/src/v5/table/body/cell/index.js +0 -12
- package/src/v5/table/body/cell/tag.json +0 -7
- package/src/v5/table/body/index.js +0 -17
- package/src/v5/table/body/row/index.js +0 -18
- package/src/v5/table/body/row/tag.json +0 -4
- package/src/v5/table/body/tag.json +0 -4
- package/src/v5/table/head/cell/index.js +0 -12
- package/src/v5/table/head/cell/tag.json +0 -7
- package/src/v5/table/head/index.js +0 -16
- package/src/v5/table/head/row/index.js +0 -14
- package/src/v5/table/head/row/tag.json +0 -4
- package/src/v5/table/head/tag.json +0 -4
- package/src/v5/table/index.js +0 -22
- package/src/v5/table/tag.json +0 -7
- package/src/v6/index.js +0 -29
- package/src/v6/options/index.js +0 -28
- package/src/v6/options/showFooter/cell/index.js +0 -16
- package/src/v6/options/showFooter/cell/tag.json +0 -4
- package/src/v6/options/showFooter/footer/index.js +0 -18
- package/src/v6/options/showFooter/footer/tag.json +0 -4
- package/src/v6/options/showFooter/index.js +0 -10
- package/src/v6/options/showFooter/input/index.js +0 -11
- package/src/v6/options/showFooter/input/tag.json +0 -7
- package/src/v6/options/showFooter/row/index.js +0 -35
- package/src/v6/options/showFooter/row/tag.json +0 -4
- package/src/v6/options/showFooterSave/button/tag.json +0 -7
- package/src/v6/options/showFooterSave/index.js +0 -14
- package/src/v6/options/showOptions/index.js +0 -39
- package/src/v6/options/showSerial/index.js +0 -19
- package/src/v6/render-requests.json +0 -90
- package/src/v6/table/body/cell/index.js +0 -12
- package/src/v6/table/body/cell/tag.json +0 -7
- package/src/v6/table/body/index.js +0 -17
- package/src/v6/table/body/row/index.js +0 -18
- package/src/v6/table/body/row/tag.json +0 -4
- package/src/v6/table/body/tag.json +0 -4
- package/src/v6/table/head/cell/index.js +0 -12
- package/src/v6/table/head/cell/tag.json +0 -7
- package/src/v6/table/head/index.js +0 -16
- package/src/v6/table/head/row/index.js +0 -14
- package/src/v6/table/head/row/tag.json +0 -4
- package/src/v6/table/head/tag.json +0 -4
- package/src/v6/table/index.js +0 -22
- package/src/v6/table/tag.json +0 -7
- package/src/v7/index.js +0 -29
- package/src/v7/options/index.js +0 -28
- package/src/v7/options/showFooter/cell/index.js +0 -16
- package/src/v7/options/showFooter/cell/tag.json +0 -4
- package/src/v7/options/showFooter/footer/index.js +0 -18
- package/src/v7/options/showFooter/footer/tag.json +0 -4
- package/src/v7/options/showFooter/index.js +0 -10
- package/src/v7/options/showFooter/input/index.js +0 -11
- package/src/v7/options/showFooter/input/tag.json +0 -7
- package/src/v7/options/showFooter/row/index.js +0 -35
- package/src/v7/options/showFooter/row/tag.json +0 -4
- package/src/v7/options/showFooterSave/button/tag.json +0 -7
- package/src/v7/options/showFooterSave/index.js +0 -14
- package/src/v7/options/showOptions/index.js +0 -39
- package/src/v7/options/showSerial/index.js +0 -19
- package/src/v7/render-requests.json +0 -90
- package/src/v7/table/body/cell/index.js +0 -12
- package/src/v7/table/body/cell/tag.json +0 -7
- package/src/v7/table/body/index.js +0 -17
- package/src/v7/table/body/row/index.js +0 -18
- package/src/v7/table/body/row/tag.json +0 -4
- package/src/v7/table/body/tag.json +0 -4
- package/src/v7/table/head/cell/index.js +0 -12
- package/src/v7/table/head/cell/tag.json +0 -7
- package/src/v7/table/head/index.js +0 -16
- package/src/v7/table/head/row/index.js +0 -14
- package/src/v7/table/head/row/tag.json +0 -4
- package/src/v7/table/head/tag.json +0 -4
- package/src/v7/table/index.js +0 -22
- package/src/v7/table/tag.json +0 -7
- package/src/v8/index.js +0 -29
- package/src/v8/options/index.js +0 -28
- package/src/v8/options/showFooter/cell/index.js +0 -16
- package/src/v8/options/showFooter/cell/tag.json +0 -4
- package/src/v8/options/showFooter/footer/index.js +0 -18
- package/src/v8/options/showFooter/footer/tag.json +0 -4
- package/src/v8/options/showFooter/index.js +0 -10
- package/src/v8/options/showFooter/input/index.js +0 -11
- package/src/v8/options/showFooter/input/tag.json +0 -7
- package/src/v8/options/showFooter/row/index.js +0 -35
- package/src/v8/options/showFooter/row/tag.json +0 -4
- package/src/v8/options/showFooterSave/button/tag.json +0 -7
- package/src/v8/options/showFooterSave/index.js +0 -14
- package/src/v8/options/showOptions/index.js +0 -39
- package/src/v8/options/showSerial/index.js +0 -19
- package/src/v8/render-requests.json +0 -90
- package/src/v8/table/body/cell/index.js +0 -12
- package/src/v8/table/body/cell/tag.json +0 -7
- package/src/v8/table/body/index.js +0 -17
- package/src/v8/table/body/row/index.js +0 -18
- package/src/v8/table/body/row/tag.json +0 -4
- package/src/v8/table/body/tag.json +0 -4
- package/src/v8/table/head/cell/index.js +0 -12
- package/src/v8/table/head/cell/tag.json +0 -7
- package/src/v8/table/head/index.js +0 -16
- package/src/v8/table/head/row/index.js +0 -14
- package/src/v8/table/head/row/tag.json +0 -4
- package/src/v8/table/head/tag.json +0 -4
- package/src/v8/table/index.js +0 -22
- package/src/v8/table/tag.json +0 -7
- package/src/v9/index.js +0 -28
- package/src/v9/table/index.js +0 -67
- package/src/v9/table/spec.json +0 -18
- package/src/v9/table/table.json +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-renderers-build-table",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.3",
|
|
4
4
|
"description": "Focused table specification builder with configurable rows and cells",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@keshavsoft/json-to-tag": "^1.9.3",
|
|
21
|
-
"json-transformer-funcs": "^1.
|
|
21
|
+
"json-transformer-funcs": "^1.24.4",
|
|
22
|
+
"json-transformer-funcs-one-dimension": "^1.5.2",
|
|
23
|
+
"json-transformer-funcs-primitive": "^1.7.1",
|
|
24
|
+
"json-transformer-funcs-two-dimensions": "^1.6.1"
|
|
22
25
|
},
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"vite": "^8.3.4"
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export { default } from "./
|
|
3
|
-
|
|
1
|
+
export * from "./v17/index.js";
|
|
2
|
+
export { default } from "./v17/index.js";
|
|
@@ -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,56 @@
|
|
|
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": "Build the table footer row from the column metadata.",
|
|
40
|
+
"destinationPath": {
|
|
41
|
+
"fileName": "base",
|
|
42
|
+
"dataRole": "table-footer-row",
|
|
43
|
+
"filePath": [
|
|
44
|
+
"children"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"sourcePath": {
|
|
48
|
+
"fileName": "data",
|
|
49
|
+
"filePath": [
|
|
50
|
+
"columns"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"templateKey": "buildFooter",
|
|
54
|
+
"func": "fromCollection"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"narration": "Append the options column width to the table colgroup.",
|
|
4
|
+
"destinationPath": {
|
|
5
|
+
"fileName": "base",
|
|
6
|
+
"dataRole": "table-colgroup",
|
|
7
|
+
"filePath": [
|
|
8
|
+
"children"
|
|
9
|
+
],
|
|
10
|
+
"action": "push"
|
|
11
|
+
},
|
|
12
|
+
"sourcePath": {
|
|
13
|
+
"fileName": "data",
|
|
14
|
+
"filePath": [
|
|
15
|
+
"options",
|
|
16
|
+
"col"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"templateKey": "buildColGroup",
|
|
20
|
+
"func": "applyTemplate"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"narration": "Append the options header cell to the table header row.",
|
|
24
|
+
"destinationPath": {
|
|
25
|
+
"fileName": "base",
|
|
26
|
+
"dataRole": "table-header-row",
|
|
27
|
+
"filePath": [
|
|
28
|
+
"children"
|
|
29
|
+
],
|
|
30
|
+
"action": "push"
|
|
31
|
+
},
|
|
32
|
+
"sourcePath": {
|
|
33
|
+
"fileName": "data",
|
|
34
|
+
"filePath": [
|
|
35
|
+
"options",
|
|
36
|
+
"header"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"templateKey": "buildHeader",
|
|
40
|
+
"func": "applyTemplate"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"narration": "Append the options button cell into each table body row.",
|
|
44
|
+
"destinationPath": {
|
|
45
|
+
"fileName": "base",
|
|
46
|
+
"dataRole": "table-body",
|
|
47
|
+
"filePath": [
|
|
48
|
+
"children"
|
|
49
|
+
],
|
|
50
|
+
"action": "pushToRows"
|
|
51
|
+
},
|
|
52
|
+
"sourcePath": {
|
|
53
|
+
"fileName": "data",
|
|
54
|
+
"filePath": [
|
|
55
|
+
"options",
|
|
56
|
+
"body"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"templateKey": "buttonCell",
|
|
60
|
+
"func": "applyTemplate"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"narration": "Append the save button cell into the table footer row.",
|
|
64
|
+
"destinationPath": {
|
|
65
|
+
"fileName": "base",
|
|
66
|
+
"dataRole": "table-footer-row",
|
|
67
|
+
"filePath": [
|
|
68
|
+
"children"
|
|
69
|
+
],
|
|
70
|
+
"action": "push"
|
|
71
|
+
},
|
|
72
|
+
"sourcePath": {
|
|
73
|
+
"fileName": "data",
|
|
74
|
+
"filePath": [
|
|
75
|
+
"options",
|
|
76
|
+
"footer"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"templateKey": "buttonCell",
|
|
80
|
+
"func": "applyTemplate"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
@@ -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,82 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"narration": "Prepend the serial column width to the table colgroup.",
|
|
4
|
+
"destinationPath": {
|
|
5
|
+
"fileName": "base",
|
|
6
|
+
"dataRole": "table-colgroup",
|
|
7
|
+
"filePath": [
|
|
8
|
+
"children"
|
|
9
|
+
],
|
|
10
|
+
"action": "unshift"
|
|
11
|
+
},
|
|
12
|
+
"sourcePath": {
|
|
13
|
+
"fileName": "data",
|
|
14
|
+
"filePath": [
|
|
15
|
+
"serial",
|
|
16
|
+
"col"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"templateKey": "buildColGroup",
|
|
20
|
+
"func": "applyTemplate"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"narration": "Prepend the serial header cell to the table header row.",
|
|
24
|
+
"destinationPath": {
|
|
25
|
+
"fileName": "base",
|
|
26
|
+
"dataRole": "table-header-row",
|
|
27
|
+
"filePath": [
|
|
28
|
+
"children"
|
|
29
|
+
],
|
|
30
|
+
"action": "unshift"
|
|
31
|
+
},
|
|
32
|
+
"sourcePath": {
|
|
33
|
+
"fileName": "data",
|
|
34
|
+
"filePath": [
|
|
35
|
+
"serial",
|
|
36
|
+
"header"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"templateKey": "buildHeader",
|
|
40
|
+
"func": "applyTemplate"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"narration": "Prepend the serial number cell into each table body row.",
|
|
44
|
+
"destinationPath": {
|
|
45
|
+
"fileName": "base",
|
|
46
|
+
"dataRole": "table-body",
|
|
47
|
+
"filePath": [
|
|
48
|
+
"children"
|
|
49
|
+
],
|
|
50
|
+
"action": "unshiftSerialToRows"
|
|
51
|
+
},
|
|
52
|
+
"sourcePath": {
|
|
53
|
+
"fileName": "data",
|
|
54
|
+
"filePath": [
|
|
55
|
+
"serial",
|
|
56
|
+
"body"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"templateKey": "buildBodyCell",
|
|
60
|
+
"func": "applyTemplate"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"narration": "Prepend an empty cell into the table footer row.",
|
|
64
|
+
"destinationPath": {
|
|
65
|
+
"fileName": "base",
|
|
66
|
+
"dataRole": "table-footer-row",
|
|
67
|
+
"filePath": [
|
|
68
|
+
"children"
|
|
69
|
+
],
|
|
70
|
+
"action": "unshift"
|
|
71
|
+
},
|
|
72
|
+
"sourcePath": {
|
|
73
|
+
"fileName": "data",
|
|
74
|
+
"filePath": [
|
|
75
|
+
"serial",
|
|
76
|
+
"footer"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"templateKey": "buildBodyCell",
|
|
80
|
+
"func": "applyTemplate"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fromCollection, tableBody, buildBody,
|
|
3
|
+
findByRole, resolvePath, applyTemplate
|
|
4
|
+
} from "json-transformer-funcs";
|
|
5
|
+
|
|
6
|
+
import spec from "../spec.json" with { type: "json" };
|
|
7
|
+
import base from "./config/base.json" with { type: "json" };
|
|
8
|
+
|
|
9
|
+
import columnInstructions from "./config/columnInstructions.json" with { type: "json" };
|
|
10
|
+
import rowInstructions from "./config/rowInstructions.json" with { type: "json" };
|
|
11
|
+
import serialInstructions from "./config/serialInstructions.json" with { type: "json" };
|
|
12
|
+
import optionsInstructions from "./config/optionsInstructions.json" with { type: "json" };
|
|
13
|
+
|
|
14
|
+
import writePath from "./writePath/index.js";
|
|
15
|
+
|
|
16
|
+
const functions = {
|
|
17
|
+
fromCollection,
|
|
18
|
+
tableBody,
|
|
19
|
+
buildBody,
|
|
20
|
+
applyTemplate: (inSource, inTemplate) => applyTemplate(inTemplate, inSource)
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const runInstructions = ({ inInstructions, inRegistry }) => {
|
|
24
|
+
const localInstructions = inInstructions;
|
|
25
|
+
const localRegistry = inRegistry;
|
|
26
|
+
|
|
27
|
+
localInstructions.forEach(instruction => {
|
|
28
|
+
const source = resolvePath(localRegistry, instruction.sourcePath);
|
|
29
|
+
|
|
30
|
+
if (source) {
|
|
31
|
+
const result = functions[instruction.func](source, localRegistry.spec[instruction.templateKey]);
|
|
32
|
+
writePath({
|
|
33
|
+
inRegistry: localRegistry,
|
|
34
|
+
inPath: instruction.destinationPath,
|
|
35
|
+
inValue: result
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const buildSpec = ({ inConfig }) => {
|
|
42
|
+
const localConfig = inConfig;
|
|
43
|
+
|
|
44
|
+
const localBase = structuredClone(base);
|
|
45
|
+
const localSpec = structuredClone(spec);
|
|
46
|
+
|
|
47
|
+
// Determine whether to render the footer
|
|
48
|
+
const hasFooterDisabled = localConfig?.options?.showFooter === false
|
|
49
|
+
|| localConfig?.options?.footer === false
|
|
50
|
+
|| localConfig?.showFooter === false
|
|
51
|
+
|| localConfig?.footer === false;
|
|
52
|
+
const showFooter = !hasFooterDisabled;
|
|
53
|
+
|
|
54
|
+
if (!showFooter) {
|
|
55
|
+
localBase.children = localBase.children.filter(child => child.tagName !== "tfoot");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Default template.bodyCell to buildBodyCell if omitted
|
|
59
|
+
const normalizedColumns = (localConfig?.columns || []).map(col => {
|
|
60
|
+
const colCopy = structuredClone(col);
|
|
61
|
+
colCopy.template = {
|
|
62
|
+
bodyCell: "buildBodyCell",
|
|
63
|
+
...(colCopy.template || {})
|
|
64
|
+
};
|
|
65
|
+
return colCopy;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Support explicit serial object or options.showSerial boolean
|
|
69
|
+
const hasSerial = Boolean(localConfig?.serial || localConfig?.options?.showSerial);
|
|
70
|
+
const serialConfig = localConfig?.serial || (hasSerial ? {
|
|
71
|
+
col: { width: "50px" },
|
|
72
|
+
header: { columnName: "#" },
|
|
73
|
+
body: {},
|
|
74
|
+
footer: {}
|
|
75
|
+
} : null);
|
|
76
|
+
|
|
77
|
+
const buildData = {
|
|
78
|
+
...localConfig,
|
|
79
|
+
columns: normalizedColumns,
|
|
80
|
+
...(serialConfig ? { serial: serialConfig } : {})
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const registry = {
|
|
84
|
+
data: buildData,
|
|
85
|
+
base: localBase,
|
|
86
|
+
spec: localSpec
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// 1. Build row containers in tbody
|
|
90
|
+
runInstructions({
|
|
91
|
+
inInstructions: rowInstructions,
|
|
92
|
+
inRegistry: registry
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// 2. Build column group, header, and optional footer
|
|
96
|
+
const activeColumnInstructions = showFooter
|
|
97
|
+
? columnInstructions
|
|
98
|
+
: columnInstructions.filter(inst => inst.templateKey !== "buildFooter");
|
|
99
|
+
|
|
100
|
+
runInstructions({
|
|
101
|
+
inInstructions: activeColumnInstructions,
|
|
102
|
+
inRegistry: registry
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// 3. Build body cells for each row
|
|
106
|
+
const tbodyElement = findByRole(localBase, "table-body");
|
|
107
|
+
if (tbodyElement && Array.isArray(tbodyElement.children)) {
|
|
108
|
+
buildBody(tbodyElement.children, buildData, localSpec);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 4. Optional serial column
|
|
112
|
+
if (serialConfig) {
|
|
113
|
+
const activeSerialInstructions = showFooter
|
|
114
|
+
? serialInstructions
|
|
115
|
+
: serialInstructions.filter(inst => inst.destinationPath?.dataRole !== "table-footer-row");
|
|
116
|
+
|
|
117
|
+
runInstructions({
|
|
118
|
+
inInstructions: activeSerialInstructions,
|
|
119
|
+
inRegistry: registry
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 5. Optional action/options column
|
|
124
|
+
if (localConfig?.options && typeof localConfig.options === "object" && localConfig.options.header) {
|
|
125
|
+
const activeOptionsInstructions = showFooter
|
|
126
|
+
? optionsInstructions
|
|
127
|
+
: optionsInstructions.filter(inst => inst.destinationPath?.dataRole !== "table-footer-row");
|
|
128
|
+
|
|
129
|
+
runInstructions({
|
|
130
|
+
inInstructions: activeOptionsInstructions,
|
|
131
|
+
inRegistry: registry
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return localBase;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Wrapper supporting both { inConfig } and direct object argument
|
|
139
|
+
const startFunc = (input) => {
|
|
140
|
+
const localInput = (input && typeof input === "object" && "inConfig" in input)
|
|
141
|
+
? input.inConfig
|
|
142
|
+
: input;
|
|
143
|
+
|
|
144
|
+
return buildSpec({ inConfig: localInput });
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default startFunc;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { findByRole } from "json-transformer-funcs";
|
|
2
|
+
|
|
3
|
+
const toArray = val => (Array.isArray(val) ? val : [val]);
|
|
4
|
+
|
|
5
|
+
const actions = {
|
|
6
|
+
set: (parent, key, value) => {
|
|
7
|
+
parent[key] = value;
|
|
8
|
+
},
|
|
9
|
+
push: (parent, key, value) => {
|
|
10
|
+
parent[key].push(...toArray(value));
|
|
11
|
+
},
|
|
12
|
+
unshift: (parent, key, value) => {
|
|
13
|
+
parent[key].unshift(...toArray(value));
|
|
14
|
+
},
|
|
15
|
+
pushToRows: (parent, key, value) => {
|
|
16
|
+
parent[key].forEach(row => {
|
|
17
|
+
row.children.push(...structuredClone(toArray(value)));
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
unshiftToRows: (parent, key, value) => {
|
|
21
|
+
parent[key].forEach(row => {
|
|
22
|
+
row.children.unshift(...structuredClone(toArray(value)));
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
unshiftSerialToRows: (parent, key, value) => {
|
|
26
|
+
parent[key].forEach((row, rowIndex) => {
|
|
27
|
+
const item = structuredClone(value);
|
|
28
|
+
item.textContent = rowIndex + 1;
|
|
29
|
+
row.children.unshift(item);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const writePath = ({ inRegistry, inPath, inValue }) => {
|
|
35
|
+
const localRegistry = inRegistry;
|
|
36
|
+
const localPath = inPath;
|
|
37
|
+
const localValue = inValue;
|
|
38
|
+
|
|
39
|
+
const root = localPath.dataRole
|
|
40
|
+
? findByRole(localRegistry[localPath.fileName], localPath.dataRole)
|
|
41
|
+
: localRegistry[localPath.fileName];
|
|
42
|
+
|
|
43
|
+
if (!root) return;
|
|
44
|
+
|
|
45
|
+
const keys = [...(localPath.filePath ?? [])];
|
|
46
|
+
const lastKey = keys.pop();
|
|
47
|
+
const parent = keys.reduce((current, key) => current?.[key], root);
|
|
48
|
+
|
|
49
|
+
if (!parent) return;
|
|
50
|
+
|
|
51
|
+
const actionHandler = actions[localPath.action] || actions.set;
|
|
52
|
+
actionHandler(parent, lastKey, localValue);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default writePath;
|
package/src/v14/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import buildSpec from "./buildSpec/index.js";
|
|
2
|
+
import registerGlobal from "./register/index.js";
|
|
3
|
+
import spec from "./spec.json" with { type: "json" };
|
|
4
|
+
|
|
5
|
+
const render = (input = {}) => {
|
|
6
|
+
const localInput = (input && typeof input === "object" && "inConfig" in input)
|
|
7
|
+
? input.inConfig
|
|
8
|
+
: input;
|
|
9
|
+
|
|
10
|
+
const localColumns = localInput.columns || [];
|
|
11
|
+
const localData = localInput.data || [];
|
|
12
|
+
const localOptions = localInput.options || {};
|
|
13
|
+
const localSerial = localInput.serial;
|
|
14
|
+
const localTargetHtmlId = localInput.targetHtmlId;
|
|
15
|
+
|
|
16
|
+
const tableSpec = buildSpec({
|
|
17
|
+
inConfig: {
|
|
18
|
+
columns: localColumns,
|
|
19
|
+
data: localData,
|
|
20
|
+
options: localOptions,
|
|
21
|
+
serial: localSerial
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (localTargetHtmlId && typeof document !== "undefined") {
|
|
26
|
+
const container = document.getElementById(localTargetHtmlId);
|
|
27
|
+
if (container) {
|
|
28
|
+
const toTag = globalThis?.ks?.jsonToTag?.buildSpecElement;
|
|
29
|
+
if (typeof toTag === "function") {
|
|
30
|
+
const element = toTag(tableSpec);
|
|
31
|
+
container.innerHTML = "";
|
|
32
|
+
container.append(element);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return tableSpec;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
registerGlobal({
|
|
41
|
+
inDefinition: {
|
|
42
|
+
render,
|
|
43
|
+
renderToDom: render,
|
|
44
|
+
buildSpec,
|
|
45
|
+
spec
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
render,
|
|
51
|
+
render as renderToDom,
|
|
52
|
+
buildSpec,
|
|
53
|
+
spec
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default render;
|
|
@@ -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,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
|
+
}
|