playbook_ui 14.11.0.pre.rc.1 → 14.11.0.pre.rc.2
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/TableHeaderCell.tsx +32 -19
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +37 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +32 -18
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.jsx +60 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.jsx +74 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
- data/dist/chunks/_weekday_stacked-DTEGnoFz.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -2
- data/dist/chunks/_weekday_stacked-BTD8fZBg.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f210185c14f4c66f506ae616a8529b1801e176873f5c9eff4cdd6fb0b679b4e8
|
4
|
+
data.tar.gz: 97e4ce19a6289a4c4f07bca8b92577d038082015580c3095057e9b91be61e525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec08afa91d77abeb281e783b92812e4899724ff5a0a9596e18790c78b9f6a07906f268549eebe5ac7cade92b3bf0b01d4a539df1d00a72f820f0356fa7c6ce79
|
7
|
+
data.tar.gz: '0823854e9f0960fc58a411b9f757cd63661782b73a35729045f61364de5ed38f510258e8c9d16be945488ebaaa4381567f26cc64a4a445958836aa7ec2e718b2'
|
@@ -40,46 +40,59 @@ export const TableHeaderCell = ({
|
|
40
40
|
|
41
41
|
const toggleSortButton = (event: React.SyntheticEvent) => {
|
42
42
|
if (sortControl) {
|
43
|
-
const sortIsDesc = header
|
43
|
+
const sortIsDesc = header?.column.getIsSorted() === "desc"
|
44
44
|
sortIsDesc
|
45
45
|
? sortControl.onChange({ desc: true })
|
46
46
|
: sortControl.onChange({ desc: false })
|
47
47
|
} else {
|
48
|
-
header
|
48
|
+
header?.column.getToggleSortingHandler()(event)
|
49
49
|
}
|
50
50
|
}
|
51
51
|
|
52
|
-
const
|
53
|
-
|
52
|
+
const isLeafColumn =
|
53
|
+
header?.column.getLeafColumns().length === 1 &&
|
54
|
+
header?.column.getLeafColumns()[0].id === header.column.id
|
55
|
+
|
56
|
+
const isLastHeaderCell =
|
57
|
+
header?.column.parent?.columns.at(-1) === header?.column ||
|
58
|
+
(header?.colSpan > 1 && header?.column.parent !== undefined);
|
59
|
+
|
60
|
+
const cellClassName = classnames(
|
61
|
+
"table-header-cells",
|
62
|
+
`${isChrome() ? "chrome-styles" : ""}`,
|
54
63
|
`${enableSorting ? "table-header-cells-active" : ""}`,
|
55
|
-
{
|
56
|
-
|
64
|
+
{ "pinned-left": responsive === "scroll" && isPinnedLeft },
|
65
|
+
isLastHeaderCell ? "last-header-cell" : ""
|
66
|
+
);
|
57
67
|
|
58
68
|
const cellId = `${loading ?
|
59
|
-
`loading-${header
|
60
|
-
: `${header
|
69
|
+
`loading-${header?.id}`
|
70
|
+
: `${header?.id}`
|
61
71
|
}`
|
62
72
|
|
63
73
|
const isToggleExpansionEnabledLoading =
|
64
|
-
header
|
74
|
+
header?.index === 0 &&
|
65
75
|
loading &&
|
66
76
|
(enableToggleExpansion === "all" || "header") &&
|
67
77
|
enableToggleExpansion !== "none"
|
68
78
|
|
69
79
|
const isToggleExpansionEnabled =
|
70
|
-
header
|
80
|
+
header?.index === 0 &&
|
71
81
|
!loading &&
|
72
82
|
(enableToggleExpansion === "all" || "header") &&
|
73
83
|
enableToggleExpansion !== "none"
|
74
84
|
|
85
|
+
const justifyHeader = isLeafColumn ? "end" : "center"
|
86
|
+
|
75
87
|
return (
|
76
88
|
<th
|
77
89
|
align="right"
|
78
90
|
className={cellClassName}
|
91
|
+
colSpan={header?.colSpan}
|
79
92
|
id={cellId}
|
80
|
-
key={`${header
|
93
|
+
key={`${header?.id}-header`}
|
81
94
|
>
|
82
|
-
{header
|
95
|
+
{header?.isPlaceholder ? null : headerChildren && header?.index === 0 ? (
|
83
96
|
<Flex alignItems="center">
|
84
97
|
{headerChildren}
|
85
98
|
<div>
|
@@ -89,7 +102,7 @@ const isToggleExpansionEnabled =
|
|
89
102
|
) : (
|
90
103
|
<Flex
|
91
104
|
alignItems="center"
|
92
|
-
justify={header
|
105
|
+
justify={header?.index === 0 && enableSorting ? "between" : header?.index === 0 && !enableSorting ? "start" : justifyHeader}
|
93
106
|
>
|
94
107
|
{isToggleExpansionEnabled && (
|
95
108
|
<ToggleIconButton onClick={handleExpandOrCollapse} />
|
@@ -100,11 +113,11 @@ const isToggleExpansionEnabled =
|
|
100
113
|
)}
|
101
114
|
|
102
115
|
<Flex
|
103
|
-
className={`${header
|
116
|
+
className={`${header?.index === 0 &&
|
104
117
|
enableSorting &&
|
105
118
|
"header-sort-button pb_th_link"}`}
|
106
|
-
cursor={header
|
107
|
-
{...(header
|
119
|
+
cursor={header?.index === 0 && enableSorting ? "pointer" : "default"}
|
120
|
+
{...(header?.index === 0 &&
|
108
121
|
enableSorting && {
|
109
122
|
htmlOptions: {
|
110
123
|
onClick: (event: React.MouseEvent) => toggleSortButton(event),
|
@@ -116,14 +129,14 @@ const isToggleExpansionEnabled =
|
|
116
129
|
tabIndex: 0,
|
117
130
|
},
|
118
131
|
})}
|
119
|
-
justify={header
|
132
|
+
justify={header?.index === 0 && enableSorting ? "between" : "none"}
|
120
133
|
paddingLeft={enableSorting ? "xxs" : "xs"}
|
121
134
|
>
|
122
135
|
<div>
|
123
|
-
{flexRender(header
|
136
|
+
{flexRender(header?.column.columnDef.header, header?.getContext())}
|
124
137
|
</div>
|
125
138
|
|
126
|
-
{header
|
139
|
+
{header?.index === 0 &&
|
127
140
|
header.column.getCanSort() &&
|
128
141
|
enableSorting &&
|
129
142
|
(loading ? (
|
@@ -86,6 +86,7 @@ export const TableBody = ({
|
|
86
86
|
>
|
87
87
|
{row.getVisibleCells().map((cell, i) => {
|
88
88
|
const isPinnedLeft = columnPinning.left.includes(cell.column.id)
|
89
|
+
const isLastCell = cell.column.parent?.columns.at(-1)?.id === cell.column.id
|
89
90
|
|
90
91
|
return (
|
91
92
|
<td
|
@@ -93,7 +94,8 @@ export const TableBody = ({
|
|
93
94
|
className={classnames(
|
94
95
|
`${cell.id}-cell position_relative`,
|
95
96
|
isChrome() ? "chrome-styles" : "",
|
96
|
-
isPinnedLeft && 'pinned-left'
|
97
|
+
isPinnedLeft && 'pinned-left',
|
98
|
+
isLastCell && 'last-cell',
|
97
99
|
)}
|
98
100
|
key={`${cell.id}-data`}
|
99
101
|
>
|
@@ -31,6 +31,43 @@
|
|
31
31
|
min-width: 180px;
|
32
32
|
}
|
33
33
|
|
34
|
+
.pb_advanced_table_header {
|
35
|
+
> tr:not(:first-child) {
|
36
|
+
.last-header-cell {
|
37
|
+
border-right: 1px solid $border_light !important;
|
38
|
+
}
|
39
|
+
|
40
|
+
th {
|
41
|
+
border-radius: 0px !important;
|
42
|
+
border-width: 0 0 1px 0 !important;
|
43
|
+
}
|
44
|
+
th:first-child {
|
45
|
+
border-left-width: 1px !important;
|
46
|
+
@media only screen and (max-width: $screen-xl-min) {
|
47
|
+
border-left-width: 0 !important;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
th:last-child {
|
51
|
+
border-right-width: 1px !important;
|
52
|
+
@media only screen and (max-width: $screen-xl-min) {
|
53
|
+
border-right-width: 0 !important;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
th[colspan]:not([colspan="1"]) {
|
58
|
+
border-right: 1px solid $border_light;
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
}
|
63
|
+
|
64
|
+
.pb_advanced_table_body {
|
65
|
+
.last-cell {
|
66
|
+
border-right: 1px solid $border_light !important;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
|
34
71
|
.table-header-cells-active:first-child {
|
35
72
|
color: $primary !important;
|
36
73
|
}
|
@@ -142,27 +142,41 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
142
142
|
}
|
143
143
|
return columnCells
|
144
144
|
}
|
145
|
-
|
146
|
-
const
|
147
|
-
|
145
|
+
|
146
|
+
const buildColumns = (columnDefinitions: GenericObject[]): any => {
|
147
|
+
return (
|
148
|
+
columnDefinitions &&
|
148
149
|
columnDefinitions.map((column, index) => {
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
150
|
+
//Checking to see if grouped column or not
|
151
|
+
if (column.columns && column.columns.length > 0) {
|
152
|
+
return {
|
153
|
+
header: column.label || "",
|
154
|
+
columns: buildColumns(column.columns),
|
155
|
+
};
|
156
|
+
} else {
|
157
|
+
// Define the base column structure
|
158
|
+
const columnStructure = {
|
159
|
+
...columnHelper.accessor(column.accessor, {
|
160
|
+
header: column.label || "",
|
161
|
+
}),
|
162
|
+
};
|
155
163
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
164
|
+
if (column.cellAccessors || column.customRenderer) {
|
165
|
+
columnStructure.cell = createCellFunction(
|
166
|
+
column.cellAccessors,
|
167
|
+
column.customRenderer,
|
168
|
+
index
|
169
|
+
);
|
170
|
+
}
|
171
|
+
|
172
|
+
return columnStructure;
|
173
|
+
}
|
174
|
+
})
|
175
|
+
);
|
176
|
+
};
|
163
177
|
|
164
|
-
|
165
|
-
|
178
|
+
//Create column array in format needed by Tanstack
|
179
|
+
const columns = buildColumns(columnDefinitions);
|
166
180
|
|
167
181
|
//Syntax for sorting Array if we want to manage state ourselves
|
168
182
|
const sorting = [
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { AdvancedTable } from "playbook-ui"
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableColumnHeaders = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
label: "Enrollment Data",
|
14
|
+
columns: [
|
15
|
+
{
|
16
|
+
accessor: "newEnrollments",
|
17
|
+
label: "New Enrollments",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
accessor: "scheduledMeetings",
|
21
|
+
label: "Scheduled Meetings",
|
22
|
+
},
|
23
|
+
],
|
24
|
+
},
|
25
|
+
{
|
26
|
+
label: "Performance Data",
|
27
|
+
columns: [
|
28
|
+
{
|
29
|
+
accessor: "attendanceRate",
|
30
|
+
label: "Attendance Rate",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
accessor: "completedClasses",
|
34
|
+
label: "Completed Classes",
|
35
|
+
},
|
36
|
+
{
|
37
|
+
accessor: "classCompletionRate",
|
38
|
+
label: "Class Completion Rate",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
accessor: "graduatedStudents",
|
42
|
+
label: "Graduated Students",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
},
|
46
|
+
];
|
47
|
+
|
48
|
+
|
49
|
+
return (
|
50
|
+
<>
|
51
|
+
<AdvancedTable
|
52
|
+
columnDefinitions={columnDefinitions}
|
53
|
+
tableData={MOCK_DATA}
|
54
|
+
{...props}
|
55
|
+
/>
|
56
|
+
</>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
|
60
|
+
export default AdvancedTableColumnHeaders
|
@@ -0,0 +1 @@
|
|
1
|
+
Use a nested `columns` array in your columnDefinitions to create multiple header rows. Any column with `columns` is treated as a grouped header, and its child columns are displayed beneath it.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "playbook-ui";
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json";
|
4
|
+
|
5
|
+
const AdvancedTableColumnHeadersMultiple = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
label: "Enrollment Data",
|
14
|
+
columns: [
|
15
|
+
{
|
16
|
+
label: "Enrollment Stats",
|
17
|
+
columns: [
|
18
|
+
{
|
19
|
+
accessor: "newEnrollments",
|
20
|
+
label: "New Enrollments",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
accessor: "scheduledMeetings",
|
24
|
+
label: "Scheduled Meetings",
|
25
|
+
},
|
26
|
+
],
|
27
|
+
},
|
28
|
+
],
|
29
|
+
},
|
30
|
+
{
|
31
|
+
label: "Performance Data",
|
32
|
+
columns: [
|
33
|
+
{
|
34
|
+
label: "Completion Metrics",
|
35
|
+
columns: [
|
36
|
+
{
|
37
|
+
accessor: "completedClasses",
|
38
|
+
label: "Completed Classes",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
accessor: "classCompletionRate",
|
42
|
+
label: "Class Completion Rate",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "Attendance",
|
48
|
+
columns: [
|
49
|
+
{
|
50
|
+
accessor: "attendanceRate",
|
51
|
+
label: "Attendance Rate",
|
52
|
+
},
|
53
|
+
{
|
54
|
+
accessor: "scheduledMeetings",
|
55
|
+
label: "Scheduled Meetings",
|
56
|
+
},
|
57
|
+
],
|
58
|
+
},
|
59
|
+
],
|
60
|
+
},
|
61
|
+
];
|
62
|
+
|
63
|
+
return (
|
64
|
+
<>
|
65
|
+
<AdvancedTable
|
66
|
+
columnDefinitions={columnDefinitions}
|
67
|
+
tableData={MOCK_DATA}
|
68
|
+
{...props}
|
69
|
+
/>
|
70
|
+
</>
|
71
|
+
);
|
72
|
+
};
|
73
|
+
|
74
|
+
export default AdvancedTableColumnHeadersMultiple;
|
@@ -0,0 +1 @@
|
|
1
|
+
Multiple levels of column headers can also be rendered as seen here.
|
@@ -21,3 +21,5 @@ examples:
|
|
21
21
|
- advanced_table_custom_cell: Custom Components for Cells
|
22
22
|
- advanced_table_pagination: Pagination
|
23
23
|
- advanced_table_pagination_with_props: Pagination Props
|
24
|
+
- advanced_table_column_headers: Multi-Header Columns
|
25
|
+
- advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
|
@@ -12,3 +12,5 @@ export { default as AdvancedTableResponsive } from './_advanced_table_responsive
|
|
12
12
|
export { default as AdvancedTableCustomCell } from './_advanced_table_custom_cell.jsx'
|
13
13
|
export { default as AdvancedTablePagination } from './_advanced_table_pagination.jsx'
|
14
14
|
export { default as AdvancedTablePaginationWithProps } from './_advanced_table_pagination_with_props.jsx'
|
15
|
+
export { default as AdvancedTableColumnHeaders } from './_advanced_table_column_headers.jsx'
|
16
|
+
export { default as AdvancedTableColumnHeadersMultiple } from './_advanced_table_column_headers_multiple.jsx'
|