playbook_ui 14.9.0 → 14.10.0.pre.alpha.PBNTR662stickyrightcolumnreact5160
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/CollapsibleTrail.tsx +1 -6
- 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 +48 -3
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +94 -36
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb +36 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.md +1 -0
- 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/_advanced_table_pagination.jsx +50 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_pagination_mock_data.json +5600 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +5 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +8 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +8 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +2 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +0 -2
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.jsx +53 -49
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom_rails.html.erb +29 -36
- data/app/pb_kits/playbook/pb_body/_body.scss +14 -13
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +22 -16
- data/app/pb_kits/playbook/pb_bread_crumbs/docs/_bread_crumbs_default.jsx +6 -0
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -1
- data/app/pb_kits/playbook/pb_card/_card.tsx +7 -7
- data/app/pb_kits/playbook/pb_card/_card_mixin.scss +2 -2
- data/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb +21 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_header.jsx +50 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +3 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +1 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.html.erb +8 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.jsx +9 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.md +1 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +9 -4
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +2 -2
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +2 -2
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +2 -2
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +5 -0
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +7 -2
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +8 -2
- data/app/pb_kits/playbook/pb_form_group/_error_state_mixin.scss +57 -0
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +11 -2
- data/app/pb_kits/playbook/pb_gauge/_gauge.scss +31 -1
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +3 -3
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +25 -5
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +17 -1
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.html.erb +17 -1
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.jsx +15 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_emphasis.md +2 -1
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +15 -1
- data/app/pb_kits/playbook/pb_home_address_street/none_emphasis.html.erb +32 -0
- data/app/pb_kits/playbook/pb_home_address_street/none_emphasis.rb +29 -0
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +30 -11
- data/app/pb_kits/playbook/pb_link/_link.scss +3 -3
- data/app/pb_kits/playbook/pb_nav/_bold_mixin.scss +11 -1
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +16 -2
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +2 -2
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +4 -4
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_filter.jsx +166 -0
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx +2 -0
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_user.jsx +89 -0
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_stat_change/_stat_change.tsx +44 -36
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +4 -4
- data/app/pb_kits/playbook/pb_table/_table.tsx +73 -24
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.jsx +88 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_react.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.html.erb +77 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +4 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.jsx +87 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_react.md +5 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.jsx +75 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.jsx +108 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.jsx +94 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.md +0 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows.jsx +83 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.jsx +120 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +7 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +5 -0
- data/app/pb_kits/playbook/pb_table/index.ts +102 -26
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +2 -1
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +35 -0
- data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +44 -3
- data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +17 -4
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +106 -1
- data/app/pb_kits/playbook/pb_table/table.html.erb +8 -2
- data/app/pb_kits/playbook/pb_table/table.rb +21 -2
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +35 -3
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx +88 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +64 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +139 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +6 -5
- data/app/pb_kits/playbook/pb_title/_title_mixin.scss +13 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +115 -46
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +9 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +3 -2
- data/app/pb_kits/playbook/tokens/_titles.scss +0 -8
- data/app/pb_kits/playbook/utilities/_hover.scss +11 -2
- data/app/pb_kits/playbook/utilities/globalProps.ts +2 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +15 -0
- data/dist/chunks/_typeahead-aym7Ky_O.js +22 -0
- data/dist/chunks/_weekday_stacked-BZj1pop-.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/{lib-SyD3buPZ.js → lib-B7sgJtGS.js} +3 -3
- data/dist/chunks/{pb_form_validation-Dt8UJgrJ.js → pb_form_validation-C5Cc0-1v.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/hover.rb +7 -1
- data/lib/playbook/version.rb +2 -2
- metadata +46 -10
- data/dist/chunks/_typeahead-B8fkIeXA.js +0 -22
- data/dist/chunks/_weekday_stacked-CVYxBYHe.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff11190f99fd3526f682637bab45adc5e4c6622abc098105e921812d32865a0d
|
4
|
+
data.tar.gz: 82f35cf6cbaa49b39804d96662fef1f95d1bf94a6ef505d9ae629a7b55ec27bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddd191fb90d1c45fb7c29aa490b5468ea44d0b3f75dfcac06ec498710571a771ae15892f6629123488c979881fba11f5aa1a0dce6e40d964a45020e4bd3df181
|
7
|
+
data.tar.gz: 37e12958a52b826dfceb58a28a8840fceb209ad9138b54d3d192e02cee52f59a4b8bd1f7994461812aa7ebc179302a91b4069ff256101a6d0b61a848c4a4ca5d
|
@@ -3,18 +3,13 @@ import React from "react"
|
|
3
3
|
//CollapsibleTrail component
|
4
4
|
const CollapsibleTrail = ({ leftOffset }: { leftOffset: number }) => {
|
5
5
|
const style: { [key: string]: string | number } = {
|
6
|
-
position: "absolute",
|
7
6
|
left: `${leftOffset}em`,
|
8
|
-
top: 0,
|
9
|
-
bottom: 0,
|
10
|
-
width: "2px",
|
11
|
-
backgroundColor: "#E4E8F0",
|
12
7
|
}
|
13
8
|
|
14
9
|
return (
|
15
10
|
<div
|
16
11
|
className="collapsible-trail"
|
17
|
-
style={style}
|
12
|
+
style={style}
|
18
13
|
/>
|
19
14
|
)
|
20
15
|
}
|
@@ -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
|
}
|
@@ -110,9 +147,17 @@
|
|
110
147
|
height: auto;
|
111
148
|
}
|
112
149
|
|
150
|
+
.collapsible-trail {
|
151
|
+
background-color: $border_light;
|
152
|
+
position: absolute;
|
153
|
+
top: 0;
|
154
|
+
bottom: 0;
|
155
|
+
width: 2px;
|
156
|
+
}
|
157
|
+
|
113
158
|
// Responsive Styles
|
114
159
|
@media only screen and (max-width: $screen-xl-min) {
|
115
|
-
&[class*="table-responsive-scroll"] {
|
160
|
+
&[class*="advanced-table-responsive-scroll"] {
|
116
161
|
border-radius: 4px;
|
117
162
|
box-shadow: 1px 0 0 0px $border_light,
|
118
163
|
-1px 0 0 0px $border_light;
|
@@ -150,7 +195,7 @@
|
|
150
195
|
}
|
151
196
|
}
|
152
197
|
@media only screen and (min-width: $screen-xl-min) {
|
153
|
-
&[class*="table-responsive-scroll"] {
|
198
|
+
&[class*="advanced-table-responsive-scroll"] {
|
154
199
|
overflow-x: visible;
|
155
200
|
}
|
156
201
|
}
|
@@ -200,7 +245,7 @@
|
|
200
245
|
}
|
201
246
|
// Dark Mode Responsive Styles
|
202
247
|
@media only screen and (max-width: $screen-xl-min) {
|
203
|
-
&[class*="table-responsive-scroll"] {
|
248
|
+
&[class*="advanced-table-responsive-scroll"] {
|
204
249
|
border-radius: 4px;
|
205
250
|
box-shadow: 1px 0 0 0px $border_dark,
|
206
251
|
-1px 0 0 0px $border_dark;
|
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
createColumnHelper,
|
8
8
|
getCoreRowModel,
|
9
9
|
getExpandedRowModel,
|
10
|
+
getPaginationRowModel,
|
10
11
|
getSortedRowModel,
|
11
12
|
Row,
|
12
13
|
useReactTable,
|
@@ -25,6 +26,7 @@ import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelper
|
|
25
26
|
import { CustomCell } from "./Components/CustomCell"
|
26
27
|
import { TableHeader } from "./SubKits/TableHeader"
|
27
28
|
import { TableBody } from "./SubKits/TableBody"
|
29
|
+
import Pagination from "../pb_pagination/_pagination"
|
28
30
|
|
29
31
|
type AdvancedTableProps = {
|
30
32
|
aria?: { [key: string]: string }
|
@@ -42,6 +44,8 @@ type AdvancedTableProps = {
|
|
42
44
|
loading?: boolean | string
|
43
45
|
onRowToggleClick?: (arg: Row<GenericObject>) => void
|
44
46
|
onToggleExpansionClick?: (arg: Row<GenericObject>) => void
|
47
|
+
pagination?: boolean,
|
48
|
+
paginationProps?: GenericObject
|
45
49
|
responsive?: "scroll" | "none",
|
46
50
|
sortControl?: GenericObject
|
47
51
|
tableData: GenericObject[]
|
@@ -67,6 +71,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
67
71
|
loading,
|
68
72
|
onRowToggleClick,
|
69
73
|
onToggleExpansionClick,
|
74
|
+
pagination = false,
|
75
|
+
paginationProps,
|
70
76
|
responsive = "scroll",
|
71
77
|
sortControl,
|
72
78
|
tableData,
|
@@ -136,27 +142,41 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
136
142
|
}
|
137
143
|
return columnCells
|
138
144
|
}
|
139
|
-
|
140
|
-
const
|
141
|
-
|
145
|
+
|
146
|
+
const buildColumns = (columnDefinitions: GenericObject[]): any => {
|
147
|
+
return (
|
148
|
+
columnDefinitions &&
|
142
149
|
columnDefinitions.map((column, index) => {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
+
};
|
149
163
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
164
|
+
if (column.cellAccessors || column.customRenderer) {
|
165
|
+
columnStructure.cell = createCellFunction(
|
166
|
+
column.cellAccessors,
|
167
|
+
column.customRenderer,
|
168
|
+
index
|
169
|
+
);
|
170
|
+
}
|
157
171
|
|
158
|
-
|
159
|
-
}
|
172
|
+
return columnStructure;
|
173
|
+
}
|
174
|
+
})
|
175
|
+
);
|
176
|
+
};
|
177
|
+
|
178
|
+
//Create column array in format needed by Tanstack
|
179
|
+
const columns = buildColumns(columnDefinitions);
|
160
180
|
|
161
181
|
//Syntax for sorting Array if we want to manage state ourselves
|
162
182
|
const sorting = [
|
@@ -177,6 +197,17 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
177
197
|
}
|
178
198
|
}
|
179
199
|
|
200
|
+
const paginationInitializer = pagination ? {
|
201
|
+
getPaginationRowModel: getPaginationRowModel(),
|
202
|
+
paginateExpandedRows: false,
|
203
|
+
initialState: {
|
204
|
+
pagination: {
|
205
|
+
pageIndex: paginationProps?.pageIndex ?? 0,
|
206
|
+
pageSize: paginationProps?.pageSize ?? 20,
|
207
|
+
},
|
208
|
+
},
|
209
|
+
} : {}
|
210
|
+
|
180
211
|
//initialize table
|
181
212
|
const table = useReactTable({
|
182
213
|
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
@@ -189,6 +220,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
189
220
|
enableSortingRemoval: false,
|
190
221
|
sortDescFirst: true,
|
191
222
|
...expandAndSortState(),
|
223
|
+
... paginationInitializer,
|
192
224
|
...tableOptions,
|
193
225
|
})
|
194
226
|
|
@@ -222,11 +254,15 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
222
254
|
const htmlProps = buildHtmlProps(htmlOptions)
|
223
255
|
const classes = classnames(
|
224
256
|
buildCss("pb_advanced_table"),
|
225
|
-
`table-responsive-${responsive}`,
|
257
|
+
`advanced-table-responsive-${responsive}`,
|
226
258
|
globalProps(props),
|
227
259
|
className
|
228
260
|
)
|
229
261
|
|
262
|
+
const onPageChange = (page: number) => {
|
263
|
+
table.setPageIndex(page - 1)
|
264
|
+
}
|
265
|
+
|
230
266
|
return (
|
231
267
|
<div {...ariaProps}
|
232
268
|
{...dataProps}
|
@@ -250,23 +286,45 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
250
286
|
toggleExpansionIcon,
|
251
287
|
}}
|
252
288
|
>
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
289
|
+
<>
|
290
|
+
{pagination &&
|
291
|
+
<Pagination
|
292
|
+
current={table.getState().pagination.pageIndex + 1}
|
293
|
+
key={`pagination-top-${table.getState().pagination.pageIndex + 1}`}
|
294
|
+
marginBottom="xs"
|
295
|
+
onChange={onPageChange}
|
296
|
+
range={paginationProps?.range ? paginationProps?.range : 5}
|
297
|
+
total={table.getPageCount()}
|
298
|
+
/>
|
299
|
+
}
|
300
|
+
<Table
|
301
|
+
className={`${loading ? "content-loading" : ""}`}
|
302
|
+
dark={dark}
|
303
|
+
dataTable
|
304
|
+
numberSpacing="tabular"
|
305
|
+
responsive="none"
|
306
|
+
{...tableProps}
|
307
|
+
>
|
308
|
+
{children ? (
|
309
|
+
children
|
310
|
+
) : (
|
311
|
+
<>
|
312
|
+
<TableHeader />
|
313
|
+
<TableBody />
|
314
|
+
</>
|
315
|
+
)}
|
316
|
+
</Table>
|
317
|
+
{pagination &&
|
318
|
+
<Pagination
|
319
|
+
current={table.getState().pagination.pageIndex + 1}
|
320
|
+
key={`pagination-bottom-${table.getState().pagination.pageIndex + 1}`}
|
321
|
+
marginTop="xs"
|
322
|
+
onChange={onPageChange}
|
323
|
+
range={paginationProps?.range ? paginationProps?.range : 5}
|
324
|
+
total={table.getPageCount()}
|
325
|
+
/>
|
326
|
+
}
|
327
|
+
</>
|
270
328
|
</AdvancedTableContext.Provider>
|
271
329
|
</div>
|
272
330
|
)
|
@@ -468,7 +468,7 @@ test("responsive prop functions as expected", () => {
|
|
468
468
|
)
|
469
469
|
|
470
470
|
const kit = screen.getByTestId(testId)
|
471
|
-
expect(kit).toHaveClass("pb_advanced_table table-responsive-scroll")
|
471
|
+
expect(kit).toHaveClass("pb_advanced_table advanced-table-responsive-scroll")
|
472
472
|
})
|
473
473
|
|
474
474
|
test("responsive none prop functions as expected", () => {
|
@@ -483,7 +483,7 @@ test("responsive none prop functions as expected", () => {
|
|
483
483
|
)
|
484
484
|
|
485
485
|
const kit = screen.getByTestId(testId)
|
486
|
-
expect(kit).toHaveClass("pb_advanced_table table-responsive-none")
|
486
|
+
expect(kit).toHaveClass("pb_advanced_table advanced-table-responsive-none")
|
487
487
|
})
|
488
488
|
|
489
489
|
test("customRenderer prop functions as expected", () => {
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
<% column_definitions = [
|
2
|
+
{
|
3
|
+
accessor: "year",
|
4
|
+
label: "Year",
|
5
|
+
cellAccessors: ["quarter", "month", "day"],
|
6
|
+
},
|
7
|
+
{
|
8
|
+
accessor: "newEnrollments",
|
9
|
+
label: "New Enrollments",
|
10
|
+
},
|
11
|
+
{
|
12
|
+
accessor: "scheduledMeetings",
|
13
|
+
label: "Scheduled Meetings",
|
14
|
+
},
|
15
|
+
{
|
16
|
+
accessor: "attendanceRate",
|
17
|
+
label: "Attendance Rate",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
accessor: "completedClasses",
|
21
|
+
label: "Completed Classes",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
accessor: "classCompletionRate",
|
25
|
+
label: "Class Completion Rate",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
accessor: "graduatedStudents",
|
29
|
+
label: "Graduated Students",
|
30
|
+
}
|
31
|
+
] %>
|
32
|
+
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "collapsible_trail", table_data: @table_data, column_definitions: column_definitions }) do %>
|
34
|
+
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
35
|
+
<%= pb_rails("advanced_table/table_body", props: { table_data: @table_data, column_definitions: column_definitions, collapsible_trail: false }) %>
|
36
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
`collapsible_trail` is an optional prop that is set to 'true' by default. If set to 'false', it will remove the trail on the left of the rows when subRows are toggled open.
|
@@ -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.
|