playbook_ui 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2010 → 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2023
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +8 -8
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +22 -14
- data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/README.md +133 -0
- data/app/pb_kits/playbook/pb_advanced_table/{SubComponents → SubKits}/TableBody.tsx +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/{helper_functions.tsx → ExpansionControlHelpers.tsx} +1 -15
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx +8 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +11 -10
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +27 -19
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +2 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +13 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +39 -39
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +11 -0
- data/dist/menu.yml +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +10 -5
- data/app/pb_kits/playbook/pb_advanced_table/{SubComponents → SubKits}/TableHeader.tsx +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7de4a52108e01951e999ec72a392167e7ca613eedc6b2460454cea0fb265fcf8
|
4
|
+
data.tar.gz: 33e05379b7d7004b6943995d1710a1b91a844942710e2c8ca62dbc6e6bbbda0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e8d2d44b46b465a9d3cf4e954d0621abfc2da9cef8b9004f1d5e7e535f37bc57b8f4d54c46e26a2a4a79721c7e36e991ba9902170740b6ffe76f27a6becf207
|
7
|
+
data.tar.gz: 9e2878d9346444289f740ae5f3804c871e02d7c49f6283351768e68ffbfd0f19d6215eba7ee897cdb947ca332a2d802cd40ce8d5f118ff07b176707c0a1c9add
|
@@ -10,17 +10,17 @@ import { DataType } from "../Utilities/types";
|
|
10
10
|
import AdvancedTableContext from "../Context/AdvancedTableContext";
|
11
11
|
|
12
12
|
interface CustomCellProps {
|
13
|
-
row: Row<DataType>;
|
14
13
|
getValue?: Getter<string>;
|
15
|
-
value?: string;
|
16
14
|
onRowToggleClick?: (arg: Row<DataType>) => void;
|
15
|
+
row: Row<DataType>;
|
16
|
+
value?: string;
|
17
17
|
}
|
18
18
|
|
19
19
|
export const CustomCell = ({
|
20
|
-
row,
|
21
20
|
getValue,
|
22
|
-
value,
|
23
21
|
onRowToggleClick,
|
22
|
+
row,
|
23
|
+
value,
|
24
24
|
}: CustomCellProps & GlobalProps) => {
|
25
25
|
const { setExpanded, expanded } = useContext(AdvancedTableContext);
|
26
26
|
const RowWithoutChildren = row.originalSubRows === undefined;
|
@@ -2,7 +2,7 @@ import React from "react"
|
|
2
2
|
import Icon from "../../pb_icon/_icon"
|
3
3
|
import { Header } from "@tanstack/react-table"
|
4
4
|
import { DataType } from "../Utilities/types"
|
5
|
-
import { displayIcon } from "../Utilities/
|
5
|
+
import { displayIcon } from "../Utilities/IconHelpers"
|
6
6
|
|
7
7
|
type SortIconButtonProps = {
|
8
8
|
header: Header<DataType, unknown>
|
@@ -6,26 +6,26 @@ import { Row, Table } from "@tanstack/react-table"
|
|
6
6
|
import { ToggleIconButton } from "./ToggleIconButton"
|
7
7
|
import { renderCollapsibleTrail } from "./CollapsibleTrail"
|
8
8
|
|
9
|
-
import { isChrome } from "../Utilities/
|
9
|
+
import { isChrome } from "../Utilities/BrowserCheck"
|
10
10
|
import { DataType } from "../Utilities/types"
|
11
11
|
import { GlobalProps } from "../../utilities/globalProps"
|
12
12
|
|
13
13
|
interface SubRowHeaderRowProps {
|
14
|
+
collapsibleTrail?: boolean
|
15
|
+
enableToggleExpansion?: "all" | "header"
|
14
16
|
onClick: (row: Row<DataType>) => void
|
15
17
|
row: Row<DataType>
|
16
|
-
table: Table<DataType>
|
17
|
-
collapsibleTrail?: boolean
|
18
18
|
subRowHeaders?: string[]
|
19
|
-
|
19
|
+
table: Table<DataType>
|
20
20
|
}
|
21
21
|
|
22
22
|
export const SubRowHeaderRow = ({
|
23
|
-
row,
|
24
|
-
table,
|
25
|
-
onClick,
|
26
23
|
collapsibleTrail,
|
27
|
-
subRowHeaders,
|
28
24
|
enableToggleExpansion,
|
25
|
+
onClick,
|
26
|
+
row,
|
27
|
+
subRowHeaders,
|
28
|
+
table,
|
29
29
|
}: SubRowHeaderRowProps & GlobalProps) => {
|
30
30
|
const numberOfColumns = table.getAllFlatColumns().length
|
31
31
|
|
@@ -1,34 +1,35 @@
|
|
1
1
|
import React, { useContext } from "react"
|
2
|
+
import classnames from "classnames";
|
2
3
|
import Flex from "../../pb_flex/_flex"
|
3
4
|
import { flexRender, Header } from "@tanstack/react-table"
|
4
5
|
|
5
6
|
import { SortIconButton } from "./SortIconButton"
|
6
7
|
import { ToggleIconButton } from "./ToggleIconButton"
|
7
|
-
import { isChrome } from "../Utilities/
|
8
|
+
import { isChrome } from "../Utilities/BrowserCheck"
|
8
9
|
import { DataType } from "../Utilities/types"
|
9
10
|
import AdvancedTableContext from "../Context/AdvancedTableContext"
|
10
11
|
import { GlobalProps } from "../../utilities/globalProps"
|
11
12
|
|
12
13
|
type TableHeaderCellProps = {
|
13
|
-
headerChildren?: React.ReactNode | React.ReactNode[]
|
14
14
|
enableSorting?: boolean
|
15
15
|
enableToggleExpansion?: "all" | "header"
|
16
16
|
handleExpandOrCollapse?: () => void
|
17
17
|
header?: Header<DataType, unknown>
|
18
|
+
headerChildren?: React.ReactNode | React.ReactNode[]
|
18
19
|
headerId?: string
|
19
20
|
loading?: boolean
|
20
21
|
sortIcon?: string | string[]
|
21
22
|
} & GlobalProps
|
22
23
|
|
23
24
|
export const TableHeaderCell = ({
|
24
|
-
header,
|
25
|
-
headerId,
|
26
25
|
enableSorting,
|
27
|
-
sortIcon,
|
28
|
-
headerChildren,
|
29
|
-
loading,
|
30
26
|
enableToggleExpansion,
|
31
27
|
handleExpandOrCollapse,
|
28
|
+
header,
|
29
|
+
headerChildren,
|
30
|
+
headerId,
|
31
|
+
loading,
|
32
|
+
sortIcon,
|
32
33
|
}: TableHeaderCellProps) => {
|
33
34
|
const { sortControl } = useContext(AdvancedTableContext)
|
34
35
|
|
@@ -43,15 +44,21 @@ export const TableHeaderCell = ({
|
|
43
44
|
}
|
44
45
|
}
|
45
46
|
|
47
|
+
const cellClassName = classnames("table-header-cells",
|
48
|
+
`${isChrome() ? "chrome-styles" : ""}`,
|
49
|
+
`${enableSorting ? "table-header-cells-active" : ""}`
|
50
|
+
);
|
51
|
+
|
52
|
+
const cellId = `${loading ?
|
53
|
+
`loading-${header.id}${headerId ? `-${headerId}` : ""}`
|
54
|
+
: `${header.id}${headerId ? `-${headerId}` : ""}`
|
55
|
+
}`;
|
56
|
+
|
46
57
|
return (
|
47
58
|
<th
|
48
59
|
align="right"
|
49
|
-
className={
|
50
|
-
id={
|
51
|
-
loading
|
52
|
-
? `loading-${header.id}-${headerId}`
|
53
|
-
: `${header.id}-${headerId}`
|
54
|
-
}`}
|
60
|
+
className={cellClassName}
|
61
|
+
id={cellId}
|
55
62
|
key={`${header.id}-header`}
|
56
63
|
>
|
57
64
|
{header.isPlaceholder ? null : headerChildren && header.index === 0 ? (
|
@@ -64,7 +71,7 @@ export const TableHeaderCell = ({
|
|
64
71
|
) : (
|
65
72
|
<Flex
|
66
73
|
alignItems="center"
|
67
|
-
justify={header.index === 0 ? "between" : "
|
74
|
+
justify={header.index === 0 && enableSorting ? "between" : header.index === 0 && !enableSorting ? "start" : "end"}
|
68
75
|
paddingLeft={loading ? "sm" : "none"}
|
69
76
|
>
|
70
77
|
{header.index === 0 &&
|
@@ -97,6 +104,7 @@ export const TableHeaderCell = ({
|
|
97
104
|
},
|
98
105
|
})}
|
99
106
|
justify={header.index === 0 && enableSorting ? "between" : "none"}
|
107
|
+
paddingLeft={enableSorting ? "xxs" : "xs"}
|
100
108
|
>
|
101
109
|
<div>
|
102
110
|
{flexRender(header.column.columnDef.header, header.getContext())}
|
@@ -3,11 +3,11 @@ import Icon from "../../pb_icon/_icon"
|
|
3
3
|
import { Row } from "@tanstack/react-table"
|
4
4
|
import AdvancedTableContext from "../Context/AdvancedTableContext"
|
5
5
|
import { DataType } from "../Utilities/types"
|
6
|
-
import { displayIcon } from "../Utilities/
|
6
|
+
import { displayIcon } from "../Utilities/IconHelpers"
|
7
7
|
|
8
8
|
interface ToggleIconButtonProps {
|
9
|
-
row?: Row<DataType>
|
10
9
|
onClick: (row: Row<DataType>) => void
|
10
|
+
row?: Row<DataType>
|
11
11
|
}
|
12
12
|
|
13
13
|
export const ToggleIconButton = ({ row, onClick }: ToggleIconButtonProps) => {
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# Advanced Table Kit Data Structure
|
2
|
+
|
3
|
+
The AdvancedTable Kit's `tableData` prop consumes the data that will render the table and as such has a specific structure. It must be an array of objects, where the key/value pairs will become the values rendered within each column. If children are present, they must also take the form of an array of objects. The kit will automatically render `children` as subRows.
|
4
|
+
|
5
|
+
Here is the data structure being used within the kits doc examples:
|
6
|
+
|
7
|
+
```
|
8
|
+
MOCK_DATA = [
|
9
|
+
{
|
10
|
+
year: "2021",
|
11
|
+
quarter: null,
|
12
|
+
month: null,
|
13
|
+
day: null,
|
14
|
+
newEnrollments: "20",
|
15
|
+
scheduledMeetings: "10",
|
16
|
+
attendanceRate: "51%",
|
17
|
+
completedClasses: "3",
|
18
|
+
classCompletionRate: "33%",
|
19
|
+
graduatedStudents: "19",
|
20
|
+
children: [
|
21
|
+
{
|
22
|
+
year: "2021",
|
23
|
+
quarter: "Q1",
|
24
|
+
month: null,
|
25
|
+
day: null,
|
26
|
+
newEnrollments: "2",
|
27
|
+
scheduledMeetings: "35",
|
28
|
+
attendanceRate: "32%",
|
29
|
+
completedClasses: "15",
|
30
|
+
classCompletionRate: "52%",
|
31
|
+
graduatedStudents: "36",
|
32
|
+
children: [
|
33
|
+
{
|
34
|
+
year: "2021",
|
35
|
+
quarter: "Q1",
|
36
|
+
month: "January",
|
37
|
+
day: null,
|
38
|
+
newEnrollments: "16",
|
39
|
+
scheduledMeetings: "20",
|
40
|
+
attendanceRate: "11%",
|
41
|
+
completedClasses: "13",
|
42
|
+
classCompletionRate: "47%",
|
43
|
+
graduatedStudents: "28",
|
44
|
+
children: [
|
45
|
+
{
|
46
|
+
year: "2021",
|
47
|
+
quarter: "Q1",
|
48
|
+
month: "January",
|
49
|
+
day: "10",
|
50
|
+
newEnrollments: "34",
|
51
|
+
scheduledMeetings: "28",
|
52
|
+
attendanceRate: "97%",
|
53
|
+
completedClasses: "20",
|
54
|
+
classCompletionRate: "15%",
|
55
|
+
graduatedStudents: "17",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
year: "2021",
|
59
|
+
quarter: "Q1",
|
60
|
+
month: "January",
|
61
|
+
day: "20",
|
62
|
+
newEnrollments: "43",
|
63
|
+
scheduledMeetings: "23",
|
64
|
+
attendanceRate: "66%",
|
65
|
+
completedClasses: "26",
|
66
|
+
classCompletionRate: "47%",
|
67
|
+
graduatedStudents: "9",
|
68
|
+
},
|
69
|
+
],
|
70
|
+
},
|
71
|
+
{
|
72
|
+
year: "2021",
|
73
|
+
quarter: "Q1",
|
74
|
+
month: "February",
|
75
|
+
day: null,
|
76
|
+
newEnrollments: "20",
|
77
|
+
scheduledMeetings: "41",
|
78
|
+
attendanceRate: "95%",
|
79
|
+
completedClasses: "26",
|
80
|
+
classCompletionRate: "83%",
|
81
|
+
graduatedStudents: "43",
|
82
|
+
children: [
|
83
|
+
{
|
84
|
+
year: "2011",
|
85
|
+
quarter: "Q1",
|
86
|
+
month: "February",
|
87
|
+
day: "15",
|
88
|
+
newEnrollments: "19",
|
89
|
+
scheduledMeetings: "35",
|
90
|
+
attendanceRate: "69%",
|
91
|
+
completedClasses: "8",
|
92
|
+
classCompletionRate: "75%",
|
93
|
+
graduatedStudents: "23",
|
94
|
+
},
|
95
|
+
],
|
96
|
+
},
|
97
|
+
],
|
98
|
+
},
|
99
|
+
],
|
100
|
+
},
|
101
|
+
{
|
102
|
+
year: "2022",
|
103
|
+
quarter: null,
|
104
|
+
month: null,
|
105
|
+
day: null,
|
106
|
+
newEnrollments: "25",
|
107
|
+
scheduledMeetings: "17",
|
108
|
+
attendanceRate: "75%",
|
109
|
+
completedClasses: "5",
|
110
|
+
classCompletionRate: "45%",
|
111
|
+
graduatedStudents: "32",
|
112
|
+
children: [
|
113
|
+
//similar to chldren above
|
114
|
+
]
|
115
|
+
},
|
116
|
+
{
|
117
|
+
year: "2023",
|
118
|
+
quarter: null,
|
119
|
+
month: null,
|
120
|
+
day: null,
|
121
|
+
newEnrollments: "10",
|
122
|
+
scheduledMeetings: "15",
|
123
|
+
attendanceRate: "65%",
|
124
|
+
completedClasses: "4",
|
125
|
+
classCompletionRate: "49%",
|
126
|
+
graduatedStudents: "29",
|
127
|
+
children: [
|
128
|
+
//similar to children above
|
129
|
+
],
|
130
|
+
},
|
131
|
+
];
|
132
|
+
|
133
|
+
```
|
@@ -6,7 +6,7 @@ import { SubRowHeaderRow } from "../Components/SubRowHeaderRow"
|
|
6
6
|
import { LoadingCell } from "../Components/LoadingCell"
|
7
7
|
import { renderCollapsibleTrail } from "../Components/CollapsibleTrail"
|
8
8
|
import AdvancedTableContext from "../Context/AdvancedTableContext"
|
9
|
-
import { isChrome } from "../Utilities/
|
9
|
+
import { isChrome } from "../Utilities/BrowserCheck"
|
10
10
|
import { DataType } from "../Utilities/types"
|
11
11
|
|
12
12
|
type TableBodyProps = {
|
@@ -19,10 +19,10 @@ export const TableBody = ({
|
|
19
19
|
subRowHeaders,
|
20
20
|
}: TableBodyProps) => {
|
21
21
|
const {
|
22
|
-
|
22
|
+
enableToggleExpansion,
|
23
23
|
handleExpandOrCollapse,
|
24
24
|
loading,
|
25
|
-
|
25
|
+
table,
|
26
26
|
} = useContext(AdvancedTableContext)
|
27
27
|
return (
|
28
28
|
<>
|
@@ -78,7 +78,7 @@ export const TableBody = ({
|
|
78
78
|
))}
|
79
79
|
</tr>
|
80
80
|
|
81
|
-
{/* Display LoadingInline if
|
81
|
+
{/* Display LoadingInline if Row Data is querying and there are no children already */}
|
82
82
|
{isExpandable && rowHasNoChildren && row.depth === 0 ? (
|
83
83
|
<tr key={`${row.id}-row`}>
|
84
84
|
<td colSpan={numberOfColumns}>
|
@@ -60,18 +60,4 @@ export const updateExpandAndCollapseState = (
|
|
60
60
|
...(expanded as ExpandedStateObject),
|
61
61
|
...updateExpandedRows,
|
62
62
|
})
|
63
|
-
}
|
64
|
-
|
65
|
-
//Checking browser. Using this to add classname and css for browser specific issues with table borders
|
66
|
-
export const isChrome = () => {
|
67
|
-
const userAgent = navigator.userAgent.toLowerCase()
|
68
|
-
return userAgent.includes("chrome") && !userAgent.includes("edg")
|
69
|
-
}
|
70
|
-
|
71
|
-
// Logic for handling icons related props to allow for string or array of strings
|
72
|
-
export const displayIcon = (icon: string | string[]) => {
|
73
|
-
if (typeof icon === "string") {
|
74
|
-
return [icon, icon]
|
75
|
-
}
|
76
|
-
return icon
|
77
|
-
}
|
63
|
+
}
|
@@ -8,15 +8,6 @@
|
|
8
8
|
.pb_advanced_table {
|
9
9
|
$border-color: 1px solid $border_light !important;
|
10
10
|
|
11
|
-
//animation scss
|
12
|
-
@keyframes wave {
|
13
|
-
0% {
|
14
|
-
background-position: -468px 0;
|
15
|
-
}
|
16
|
-
100% {
|
17
|
-
background-position: 468px 0;
|
18
|
-
}
|
19
|
-
}
|
20
11
|
[id$="-span"] {
|
21
12
|
word-wrap: normal;
|
22
13
|
}
|
@@ -34,9 +25,13 @@
|
|
34
25
|
}
|
35
26
|
|
36
27
|
.table-header-cells:first-child {
|
37
|
-
color: $primary !important;
|
38
28
|
min-width: 180px;
|
39
29
|
}
|
30
|
+
|
31
|
+
.table-header-cells-active:first-child {
|
32
|
+
color: $primary !important;
|
33
|
+
}
|
34
|
+
|
40
35
|
// Icons
|
41
36
|
.button-icon {
|
42
37
|
display: flex;
|
@@ -94,4 +89,10 @@
|
|
94
89
|
.chrome-styles:first-child {
|
95
90
|
border-right: $border-color;
|
96
91
|
}
|
92
|
+
|
93
|
+
.table-card {
|
94
|
+
.chrome-styles:first-child {
|
95
|
+
border-right: $transparent !important;
|
96
|
+
}
|
97
|
+
}
|
97
98
|
}
|
@@ -13,54 +13,54 @@ import {
|
|
13
13
|
Getter,
|
14
14
|
} from "@tanstack/react-table";
|
15
15
|
|
16
|
-
import { updateExpandAndCollapseState } from "./Utilities/
|
16
|
+
import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers";
|
17
17
|
|
18
18
|
import { CustomCell } from "./Components/CustomCell";
|
19
19
|
import AdvancedTableContext from "./Context/AdvancedTableContext";
|
20
|
-
import { TableHeader } from "./
|
21
|
-
import { TableBody } from "./
|
20
|
+
import { TableHeader } from "./SubKits/TableHeader";
|
21
|
+
import { TableBody } from "./SubKits/TableBody";
|
22
22
|
|
23
23
|
import { DataType, ExpandedStateObject } from "./Utilities/types";
|
24
24
|
|
25
25
|
type AdvancedTableProps = {
|
26
26
|
aria?: { [key: string]: string };
|
27
|
+
children?: React.ReactNode | React.ReactNode[];
|
27
28
|
className?: string;
|
29
|
+
columnDefinitions: DataType[];
|
28
30
|
data?: { [key: string]: string };
|
31
|
+
enableToggleExpansion?: "all" | "header";
|
32
|
+
expandedControl?: DataType;
|
29
33
|
id?: string;
|
30
|
-
|
34
|
+
initialLoadingRowsCount?: number;
|
31
35
|
loading?: boolean | string;
|
32
|
-
columnDefinitions: DataType[];
|
33
|
-
children?: React.ReactNode | React.ReactNode[];
|
34
36
|
onRowToggleClick?: (arg: Row<DataType>) => void;
|
35
37
|
onToggleExpansionClick?: (arg: Row<DataType>) => void;
|
38
|
+
sortControl?: DataType;
|
39
|
+
tableData: DataType[];
|
36
40
|
tableOptions?: DataType;
|
37
41
|
tableProps?: DataType;
|
38
|
-
enableToggleExpansion?: "all" | "header";
|
39
42
|
toggleExpansionIcon?: string | string[];
|
40
|
-
initialLoadingRowsCount?: number;
|
41
|
-
expandedControl?: DataType;
|
42
|
-
sortControl?: DataType;
|
43
43
|
} & GlobalProps;
|
44
44
|
|
45
45
|
const AdvancedTable = (props: AdvancedTableProps) => {
|
46
46
|
const {
|
47
47
|
aria = {},
|
48
|
+
children,
|
48
49
|
className,
|
50
|
+
columnDefinitions,
|
49
51
|
data = {},
|
52
|
+
enableToggleExpansion = "header",
|
53
|
+
expandedControl,
|
50
54
|
id,
|
51
|
-
|
55
|
+
initialLoadingRowsCount = 10,
|
52
56
|
loading,
|
53
57
|
onRowToggleClick,
|
54
58
|
onToggleExpansionClick,
|
55
|
-
|
56
|
-
|
59
|
+
sortControl,
|
60
|
+
tableData,
|
57
61
|
tableOptions,
|
58
62
|
tableProps,
|
59
|
-
enableToggleExpansion = "header",
|
60
63
|
toggleExpansionIcon = "arrows-from-line",
|
61
|
-
initialLoadingRowsCount = 10,
|
62
|
-
expandedControl,
|
63
|
-
sortControl,
|
64
64
|
} = props;
|
65
65
|
|
66
66
|
const [loadingStateRowCount, setLoadingStateRowCount] = useState(
|
@@ -152,6 +152,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
152
152
|
}
|
153
153
|
};
|
154
154
|
|
155
|
+
//initialize table
|
155
156
|
const table = useReactTable({
|
156
157
|
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
157
158
|
columns,
|
@@ -218,13 +219,20 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
218
219
|
}}
|
219
220
|
>
|
220
221
|
<Table
|
221
|
-
className={`${loading
|
222
|
+
className={`${loading ? "content-loading" : ""}`}
|
222
223
|
dataTable
|
223
224
|
numberSpacing="tabular"
|
224
225
|
responsive="none"
|
225
226
|
{...tableProps}
|
226
227
|
>
|
227
|
-
{children
|
228
|
+
{children ? (
|
229
|
+
children
|
230
|
+
) : (
|
231
|
+
<>
|
232
|
+
<TableHeader />
|
233
|
+
<TableBody />
|
234
|
+
</>
|
235
|
+
)}
|
228
236
|
</Table>
|
229
237
|
</AdvancedTableContext.Provider>
|
230
238
|
</div>
|
@@ -27,7 +27,7 @@ const AdvancedTableDefault = (props) => {
|
|
27
27
|
},
|
28
28
|
{
|
29
29
|
accessor: "classCompletionRate",
|
30
|
-
label: "
|
30
|
+
label: "Class Completion Rate",
|
31
31
|
},
|
32
32
|
{
|
33
33
|
accessor: "graduatedStudents",
|
@@ -41,10 +41,7 @@ const AdvancedTableDefault = (props) => {
|
|
41
41
|
columnDefinitions={columnDefinitions}
|
42
42
|
tableData={MOCK_DATA}
|
43
43
|
{...props}
|
44
|
-
|
45
|
-
<AdvancedTable.Header/>
|
46
|
-
<AdvancedTable.Body/>
|
47
|
-
</AdvancedTable>
|
44
|
+
/>
|
48
45
|
</div>
|
49
46
|
);
|
50
47
|
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
The AdvancedTable kit takes the table data and automatically renders expandable subrows for nested items to any depth needed. In it's simplest form, the kit has two required props:
|
2
|
+
|
3
|
+
`tableData` is the data that the kit needs to consume to render the table. This data will take the structure of an array of objects where each object will be rendered as a row with the key/value pairs being the column values. If an object within that data has children, the kit will automatically create subRows with icon buttons on the parent rows to toggle the subRows open or closed. The toggleExpansionAll button in the first column header can also be used to toggle expansion for the top level parent rows. For a visual of the data structure needed for `tableData`, see [here](https://github.com/powerhome/playbook/blob/1b2481c06137d2bc63031a1120c1bd4d01bfd9ec/playbook/app/pb_kits/playbook/pb_advanced_table/README.md).
|
4
|
+
|
5
|
+
|
6
|
+
`columnDefinitions` maps to the columns prop on the Tanstack table. Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `ColumnDefinitions` in the AdvancedTable kit is a array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
|
7
|
+
|
8
|
+
- `accessor`: this is the key from your data for the value you want rendered in that column
|
9
|
+
- `label`: this is what will be rendered as the column header label
|
10
|
+
|
11
|
+
There is also one optional item that is only required if the table has nested data:
|
12
|
+
|
13
|
+
- `cellAccessors`: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
|
@@ -0,0 +1 @@
|
|
1
|
+
The AdvancedTable kit uses the [Tanstack Table v8](https://tanstack.com/table/v8/docs/introduction) under the hood to render advanced tables that allow for complex, nested data structures with expansion and sort options.
|
@@ -12,7 +12,7 @@ export const MOCK_DATA = [
|
|
12
12
|
graduatedStudents: "19",
|
13
13
|
children: [
|
14
14
|
{
|
15
|
-
year: "
|
15
|
+
year: "2021",
|
16
16
|
quarter: "Q1",
|
17
17
|
month: null,
|
18
18
|
day: null,
|
@@ -24,7 +24,7 @@ export const MOCK_DATA = [
|
|
24
24
|
graduatedStudents: "36",
|
25
25
|
children: [
|
26
26
|
{
|
27
|
-
year: "
|
27
|
+
year: "2021",
|
28
28
|
quarter: "Q1",
|
29
29
|
month: "January",
|
30
30
|
day: null,
|
@@ -36,7 +36,7 @@ export const MOCK_DATA = [
|
|
36
36
|
graduatedStudents: "28",
|
37
37
|
children: [
|
38
38
|
{
|
39
|
-
year: "
|
39
|
+
year: "2021",
|
40
40
|
quarter: "Q1",
|
41
41
|
month: "January",
|
42
42
|
day: "10",
|
@@ -48,7 +48,7 @@ export const MOCK_DATA = [
|
|
48
48
|
graduatedStudents: "17",
|
49
49
|
},
|
50
50
|
{
|
51
|
-
year: "
|
51
|
+
year: "2021",
|
52
52
|
quarter: "Q1",
|
53
53
|
month: "January",
|
54
54
|
day: "20",
|
@@ -62,7 +62,7 @@ export const MOCK_DATA = [
|
|
62
62
|
],
|
63
63
|
},
|
64
64
|
{
|
65
|
-
year: "
|
65
|
+
year: "2021",
|
66
66
|
quarter: "Q1",
|
67
67
|
month: "February",
|
68
68
|
day: null,
|
@@ -96,15 +96,15 @@ export const MOCK_DATA = [
|
|
96
96
|
quarter: null,
|
97
97
|
month: null,
|
98
98
|
day: null,
|
99
|
-
newEnrollments: "
|
100
|
-
scheduledMeetings: "
|
101
|
-
attendanceRate: "
|
102
|
-
completedClasses: "
|
103
|
-
classCompletionRate: "
|
104
|
-
graduatedStudents: "
|
99
|
+
newEnrollments: "25",
|
100
|
+
scheduledMeetings: "17",
|
101
|
+
attendanceRate: "75%",
|
102
|
+
completedClasses: "5",
|
103
|
+
classCompletionRate: "45%",
|
104
|
+
graduatedStudents: "32",
|
105
105
|
children: [
|
106
106
|
{
|
107
|
-
year: "
|
107
|
+
year: "2022",
|
108
108
|
quarter: "Q1",
|
109
109
|
month: null,
|
110
110
|
day: null,
|
@@ -116,7 +116,7 @@ export const MOCK_DATA = [
|
|
116
116
|
graduatedStudents: "36",
|
117
117
|
children: [
|
118
118
|
{
|
119
|
-
year: "
|
119
|
+
year: "2022",
|
120
120
|
quarter: "Q1",
|
121
121
|
month: "January",
|
122
122
|
day: null,
|
@@ -128,10 +128,10 @@ export const MOCK_DATA = [
|
|
128
128
|
graduatedStudents: "28",
|
129
129
|
children: [
|
130
130
|
{
|
131
|
-
year: "
|
131
|
+
year: "2022",
|
132
132
|
quarter: "Q1",
|
133
133
|
month: "January",
|
134
|
-
day: "
|
134
|
+
day: "15",
|
135
135
|
newEnrollments: "34",
|
136
136
|
scheduledMeetings: "28",
|
137
137
|
attendanceRate: "97%",
|
@@ -140,10 +140,10 @@ export const MOCK_DATA = [
|
|
140
140
|
graduatedStudents: "17",
|
141
141
|
},
|
142
142
|
{
|
143
|
-
year: "
|
143
|
+
year: "2022",
|
144
144
|
quarter: "Q1",
|
145
145
|
month: "January",
|
146
|
-
day: "
|
146
|
+
day: "25",
|
147
147
|
newEnrollments: "43",
|
148
148
|
scheduledMeetings: "23",
|
149
149
|
attendanceRate: "66%",
|
@@ -154,9 +154,9 @@ export const MOCK_DATA = [
|
|
154
154
|
],
|
155
155
|
},
|
156
156
|
{
|
157
|
-
year: "
|
157
|
+
year: "2022",
|
158
158
|
quarter: "Q1",
|
159
|
-
month: "
|
159
|
+
month: "May",
|
160
160
|
day: null,
|
161
161
|
newEnrollments: "20",
|
162
162
|
scheduledMeetings: "41",
|
@@ -168,8 +168,8 @@ export const MOCK_DATA = [
|
|
168
168
|
{
|
169
169
|
year: "2011",
|
170
170
|
quarter: "Q1",
|
171
|
-
month: "
|
172
|
-
day: "
|
171
|
+
month: "May",
|
172
|
+
day: "2",
|
173
173
|
newEnrollments: "19",
|
174
174
|
scheduledMeetings: "35",
|
175
175
|
attendanceRate: "69%",
|
@@ -188,15 +188,15 @@ export const MOCK_DATA = [
|
|
188
188
|
quarter: null,
|
189
189
|
month: null,
|
190
190
|
day: null,
|
191
|
-
newEnrollments: "
|
192
|
-
scheduledMeetings: "
|
193
|
-
attendanceRate: "
|
194
|
-
completedClasses: "
|
195
|
-
classCompletionRate: "
|
196
|
-
graduatedStudents: "
|
191
|
+
newEnrollments: "10",
|
192
|
+
scheduledMeetings: "15",
|
193
|
+
attendanceRate: "65%",
|
194
|
+
completedClasses: "4",
|
195
|
+
classCompletionRate: "49%",
|
196
|
+
graduatedStudents: "29",
|
197
197
|
children: [
|
198
198
|
{
|
199
|
-
year: "
|
199
|
+
year: "2023",
|
200
200
|
quarter: "Q1",
|
201
201
|
month: null,
|
202
202
|
day: null,
|
@@ -208,9 +208,9 @@ export const MOCK_DATA = [
|
|
208
208
|
graduatedStudents: "36",
|
209
209
|
children: [
|
210
210
|
{
|
211
|
-
year: "
|
211
|
+
year: "2023",
|
212
212
|
quarter: "Q1",
|
213
|
-
month: "
|
213
|
+
month: "March",
|
214
214
|
day: null,
|
215
215
|
newEnrollments: "16",
|
216
216
|
scheduledMeetings: "20",
|
@@ -220,9 +220,9 @@ export const MOCK_DATA = [
|
|
220
220
|
graduatedStudents: "28",
|
221
221
|
children: [
|
222
222
|
{
|
223
|
-
year: "
|
223
|
+
year: "2023",
|
224
224
|
quarter: "Q1",
|
225
|
-
month: "
|
225
|
+
month: "March",
|
226
226
|
day: "10",
|
227
227
|
newEnrollments: "34",
|
228
228
|
scheduledMeetings: "28",
|
@@ -232,10 +232,10 @@ export const MOCK_DATA = [
|
|
232
232
|
graduatedStudents: "17",
|
233
233
|
},
|
234
234
|
{
|
235
|
-
year: "
|
235
|
+
year: "2023",
|
236
236
|
quarter: "Q1",
|
237
|
-
month: "
|
238
|
-
day: "
|
237
|
+
month: "March",
|
238
|
+
day: "11",
|
239
239
|
newEnrollments: "43",
|
240
240
|
scheduledMeetings: "23",
|
241
241
|
attendanceRate: "66%",
|
@@ -246,9 +246,9 @@ export const MOCK_DATA = [
|
|
246
246
|
],
|
247
247
|
},
|
248
248
|
{
|
249
|
-
year: "
|
249
|
+
year: "2023",
|
250
250
|
quarter: "Q1",
|
251
|
-
month: "
|
251
|
+
month: "April",
|
252
252
|
day: null,
|
253
253
|
newEnrollments: "20",
|
254
254
|
scheduledMeetings: "41",
|
@@ -258,9 +258,9 @@ export const MOCK_DATA = [
|
|
258
258
|
graduatedStudents: "43",
|
259
259
|
children: [
|
260
260
|
{
|
261
|
-
year: "
|
261
|
+
year: "2023",
|
262
262
|
quarter: "Q1",
|
263
|
-
month: "
|
263
|
+
month: "April",
|
264
264
|
day: "15",
|
265
265
|
newEnrollments: "19",
|
266
266
|
scheduledMeetings: "35",
|
data/dist/menu.yml
CHANGED
@@ -45,7 +45,7 @@ kits:
|
|
45
45
|
description: Tables display a collection of structured data and typically have the ability to sort, filter, and paginate data.
|
46
46
|
- name: "advanced_table"
|
47
47
|
platforms: *react_only
|
48
|
-
description:
|
48
|
+
description: The Advanced Table can be used to display complex, nested data in a way that allows for expansion and/or sorting.
|
49
49
|
- name: "list"
|
50
50
|
platforms: *web
|
51
51
|
description: Lists display a vertical set of related content.
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.16.0.pre.alpha.
|
4
|
+
version: 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2023
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-01-
|
12
|
+
date: 2024-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -277,14 +277,19 @@ files:
|
|
277
277
|
- app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx
|
278
278
|
- app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx
|
279
279
|
- app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx
|
280
|
-
- app/pb_kits/playbook/pb_advanced_table/
|
281
|
-
- app/pb_kits/playbook/pb_advanced_table/
|
282
|
-
- app/pb_kits/playbook/pb_advanced_table/
|
280
|
+
- app/pb_kits/playbook/pb_advanced_table/README.md
|
281
|
+
- app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx
|
282
|
+
- app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
|
283
|
+
- app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx
|
284
|
+
- app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx
|
285
|
+
- app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx
|
283
286
|
- app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts
|
284
287
|
- app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss
|
285
288
|
- app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx
|
286
289
|
- app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx
|
287
290
|
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx
|
291
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md
|
292
|
+
- app/pb_kits/playbook/pb_advanced_table/docs/_description.md
|
288
293
|
- app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js
|
289
294
|
- app/pb_kits/playbook/pb_advanced_table/docs/example.yml
|
290
295
|
- app/pb_kits/playbook/pb_advanced_table/docs/index.js
|
@@ -5,23 +5,23 @@ import { TableHeaderCell } from "../Components/TableHeaderCell"
|
|
5
5
|
import { DataType } from "../Utilities/types"
|
6
6
|
|
7
7
|
type TableHeaderProps = {
|
8
|
-
|
8
|
+
children?: React.ReactNode | React.ReactNode[]
|
9
9
|
enableSorting?: boolean
|
10
|
+
headerId?: string
|
10
11
|
sortIcon?: string | string[]
|
11
|
-
children?: React.ReactNode | React.ReactNode[]
|
12
12
|
}
|
13
13
|
|
14
14
|
export const TableHeader = ({
|
15
|
-
headerId,
|
16
|
-
enableSorting = false,
|
17
15
|
children,
|
16
|
+
enableSorting = false,
|
17
|
+
headerId,
|
18
18
|
sortIcon = ["arrow-up-short-wide", "arrow-down-short-wide"],
|
19
19
|
}: TableHeaderProps) => {
|
20
20
|
const {
|
21
|
-
|
21
|
+
enableToggleExpansion,
|
22
22
|
handleExpandOrCollapse,
|
23
23
|
loading,
|
24
|
-
|
24
|
+
table,
|
25
25
|
} = useContext(AdvancedTableContext)
|
26
26
|
|
27
27
|
return (
|