playbook_ui 14.23.0.pre.alpha.PLAY2205atborderbug9085 → 14.23.0.pre.alpha.PLAY2283multiheaderverticalbordersdoc9335
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +7 -6
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +24 -25
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +11 -12
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +7 -4
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +25 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +34 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.html.erb +43 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx +64 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.jsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +107 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.md +1 -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/flat_advanced_table.js +4 -11
- data/app/pb_kits/playbook/pb_advanced_table/index.js +108 -125
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +5 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +10 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +22 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +12 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +2 -1
- data/app/pb_kits/playbook/pb_checkbox/index.js +218 -26
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +17 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +6 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown_mixin.scss +36 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options.jsx +90 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +4 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_radio_options.jsx +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_radio_options_react.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +24 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +11 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +18 -9
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.html.erb +75 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx +94 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md +3 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +3 -0
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +4 -0
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_rails.md +3 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_react.md +3 -1
- data/app/pb_kits/playbook/pb_select/select.rb +4 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +1 -0
- data/dist/chunks/{_line_graph-BfCo79KE.js → _line_graph-D7DgMqnT.js} +1 -1
- data/dist/chunks/{_typeahead-Db4YQA5c.js → _typeahead-BzYZCpJO.js} +2 -2
- data/dist/chunks/_weekday_stacked-CCn-qLh_.js +37 -0
- data/dist/chunks/{lib-DnQyMxO1.js → lib-CY5ZPzic.js} +2 -2
- data/dist/chunks/{pb_form_validation-kl-4Jv4t.js → pb_form_validation-D3b0JKHH.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +3 -10
- data/dist/playbook-doc.js +2 -2
- 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/version.rb +1 -1
- metadata +21 -18
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.scss +0 -0
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +0 -202
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_continuous.jsx +0 -69
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_default.jsx +0 -71
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_multi_beacon.jsx +0 -110
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_no_beacon.jsx +0 -76
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_no_overlay.jsx +0 -76
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_styled.jsx +0 -76
- data/app/pb_kits/playbook/pb_walkthrough/docs/example.yml +0 -10
- data/app/pb_kits/playbook/pb_walkthrough/docs/index.js +0 -6
- data/app/pb_kits/playbook/pb_walkthrough/walkthrough.test.jsx +0 -34
- data/dist/chunks/_weekday_stacked-BNHSKTSw.js +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8139114c4c2408005bbcefb07dcd6822fd88ea9d7f26e2b03b7c0bd3ec16d329
|
4
|
+
data.tar.gz: 7299fe01d10983473ca28781b053295e94b51dfb665c12da294910f74f636e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8bccc7b982a31fd8a4287021af07a9ab10ccb1613413a05b2ac77c818147ccd329585ed29ca78fc1f47fc1a32ee8b1bf1fb045675e67adb2e0e77b1a304f645
|
7
|
+
data.tar.gz: c5ce85fb28afb5f6b058f067ef6d86c9f7114c4d5e9534c94577786f9733eea41d7ab94907a6bd75197dd35b7f55dc8fbecebd26dbb94c4af4835bdda9eb1eee
|
@@ -107,7 +107,6 @@
|
|
107
107
|
@import 'pb_typeahead/typeahead';
|
108
108
|
@import 'pb_user/user';
|
109
109
|
@import 'pb_user_badge/user_badge';
|
110
|
-
@import 'pb_walkthrough/walkthrough';
|
111
110
|
@import 'pb_weekday_stacked/weekday_stacked';
|
112
111
|
@import 'pb_empty_state/empty_state';
|
113
112
|
@import 'utilities/mixins';
|
@@ -20,7 +20,7 @@ interface CustomCellProps {
|
|
20
20
|
customRenderer?: (row: Row<GenericObject>, value: string | undefined) => React.ReactNode
|
21
21
|
selectableRows?: boolean
|
22
22
|
customStyle?: GenericObject
|
23
|
-
}
|
23
|
+
}
|
24
24
|
|
25
25
|
export const CustomCell = ({
|
26
26
|
getValue,
|
@@ -35,7 +35,7 @@ export const CustomCell = ({
|
|
35
35
|
|
36
36
|
const handleOnExpand = (row: Row<GenericObject>) => {
|
37
37
|
onRowToggleClick && onRowToggleClick(row);
|
38
|
-
|
38
|
+
|
39
39
|
if (!expandedControl) {
|
40
40
|
setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
|
41
41
|
}
|
@@ -46,8 +46,8 @@ export const CustomCell = ({
|
|
46
46
|
|
47
47
|
return (
|
48
48
|
<div style={{ paddingLeft: `${row.depth * 1.25}em`}}>
|
49
|
-
<Flex
|
50
|
-
alignItems="center"
|
49
|
+
<Flex
|
50
|
+
alignItems="center"
|
51
51
|
columnGap="xs"
|
52
52
|
justify="start"
|
53
53
|
orientation="row"
|
@@ -71,11 +71,12 @@ export const CustomCell = ({
|
|
71
71
|
>
|
72
72
|
{row.getIsExpanded() ? (
|
73
73
|
<Icon cursor="pointer"
|
74
|
-
icon="circle-play
|
74
|
+
icon="circle-play"
|
75
|
+
rotation={90}
|
75
76
|
/>
|
76
77
|
) : (
|
77
78
|
<Icon cursor="pointer"
|
78
|
-
icon="circle-play"
|
79
|
+
icon="circle-play"
|
79
80
|
/>
|
80
81
|
)}
|
81
82
|
</button>
|
@@ -4,49 +4,48 @@ import { Header } from "@tanstack/react-table"
|
|
4
4
|
import { GenericObject } from "../../types"
|
5
5
|
|
6
6
|
import Icon from "../../pb_icon/_icon"
|
7
|
-
import { getAllIcons } from "../../utilities/icons/allicons"
|
8
7
|
|
9
8
|
import { displayIcon } from "../Utilities/IconHelpers"
|
10
9
|
|
11
10
|
type SortIconButtonProps = {
|
12
11
|
header: Header<GenericObject, unknown>
|
13
12
|
sortIcon?: string | string[]
|
13
|
+
enableSortingRemoval?: boolean
|
14
14
|
}
|
15
15
|
|
16
|
-
export const SortIconButton = ({ header, sortIcon }: SortIconButtonProps) => {
|
17
|
-
|
18
|
-
const
|
19
|
-
const secondIcon = displayIcon(sortIcon)[1]
|
20
|
-
const upIcon = getAllIcons()["arrowUpShortWide"].icon as unknown as { [key: string]: SVGElement }
|
21
|
-
const downIcon = getAllIcons()["arrowDownShortWide"].icon as unknown as { [key: string]: SVGElement }
|
16
|
+
export const SortIconButton = ({ header, sortIcon, enableSortingRemoval }: SortIconButtonProps) => {
|
17
|
+
const firstIcon = displayIcon(sortIcon)[0]
|
18
|
+
const secondIcon = displayIcon(sortIcon)[1]
|
22
19
|
|
23
20
|
return (
|
24
21
|
<>
|
25
|
-
{header.column.getIsSorted() === "desc"
|
26
|
-
<div
|
22
|
+
{header.column.getIsSorted() === "desc" && (
|
23
|
+
<div
|
24
|
+
className="sort-button-icon"
|
27
25
|
key={firstIcon}
|
26
|
+
style={{ paddingLeft: `${header?.index === 0 ? "2px" : "4px"}` }}
|
28
27
|
>
|
29
|
-
{ firstIcon === "arrow-up-short-wide" ? (
|
30
|
-
<Icon
|
31
|
-
className="svg-inline--fa"
|
32
|
-
customIcon={upIcon}
|
33
|
-
/> ) : (
|
34
28
|
<Icon icon={firstIcon} />
|
35
|
-
)}
|
36
29
|
</div>
|
37
|
-
)
|
38
|
-
|
30
|
+
)}
|
31
|
+
{header.column.getIsSorted() === "asc" && (
|
32
|
+
<div
|
33
|
+
className="sort-button-icon"
|
39
34
|
key={secondIcon}
|
35
|
+
style={{ paddingLeft: `${header?.index === 0 ? "2px" : "4px"}` }}
|
40
36
|
>
|
41
|
-
{ secondIcon === "arrow-down-short-wide" ? (
|
42
|
-
<Icon
|
43
|
-
className="svg-inline--fa"
|
44
|
-
customIcon={downIcon}
|
45
|
-
/> ) : (
|
46
37
|
<Icon icon={secondIcon} />
|
47
|
-
|
38
|
+
</div>
|
39
|
+
)}
|
40
|
+
{header.column.getIsSorted() === false && (
|
41
|
+
<div
|
42
|
+
className="sort-button-icon"
|
43
|
+
key={enableSortingRemoval ? "arrow-up-arrow-down" : secondIcon}
|
44
|
+
style={{ paddingLeft: `${header?.index === 0 ? "2px" : "4px"}` }}
|
45
|
+
>
|
46
|
+
<Icon icon={enableSortingRemoval ? "arrow-up-arrow-down" : secondIcon} />
|
48
47
|
</div>
|
49
48
|
)}
|
50
49
|
</>
|
51
|
-
)
|
52
|
-
}
|
50
|
+
);
|
51
|
+
};
|
@@ -50,6 +50,7 @@ export const TableHeaderCell = ({
|
|
50
50
|
expanded,
|
51
51
|
setExpanded,
|
52
52
|
expandByDepth,
|
53
|
+
enableSortingRemoval,
|
53
54
|
onExpandByDepthClick,
|
54
55
|
toggleExpansionIcon,
|
55
56
|
sortControl,
|
@@ -64,6 +65,7 @@ export const TableHeaderCell = ({
|
|
64
65
|
|
65
66
|
type justifyTypes = "none" | "center" | "start" | "end" | "between" | "around" | "evenly"
|
66
67
|
|
68
|
+
|
67
69
|
const toggleSortButton = (event: React.SyntheticEvent) => {
|
68
70
|
if (sortControl) {
|
69
71
|
const sortIsDesc = header?.column.getIsSorted() === "desc"
|
@@ -101,7 +103,6 @@ export const TableHeaderCell = ({
|
|
101
103
|
if (!header) return false;
|
102
104
|
|
103
105
|
if (header.colSpan > 1 && header.column.parent !== undefined) return true;
|
104
|
-
|
105
106
|
const parent = header.column.parent;
|
106
107
|
|
107
108
|
if (!parent) {
|
@@ -111,7 +112,8 @@ export const TableHeaderCell = ({
|
|
111
112
|
const visibleSiblings = parent.columns.filter(columnHasVisibleLeaf);
|
112
113
|
return visibleSiblings.at(-1) === header.column;
|
113
114
|
})();
|
114
|
-
|
115
|
+
|
116
|
+
|
115
117
|
const cellClassName = classnames(
|
116
118
|
"table-header-cells",
|
117
119
|
`${showActionsBar && isActionBarVisible && "header-cells-with-actions"}`,
|
@@ -257,12 +259,9 @@ const isToggleExpansionEnabled =
|
|
257
259
|
)}
|
258
260
|
|
259
261
|
<Flex
|
260
|
-
className={`${header?.index === 0 &&
|
261
|
-
|
262
|
-
|
263
|
-
cursor={header?.index === 0 && enableSorting ? "pointer" : "default"}
|
264
|
-
{...(header?.index === 0 &&
|
265
|
-
enableSorting && {
|
262
|
+
className={`${header?.index === 0 && enableSorting && "header-sort-button pb_th_link"} ${header?.index !== 0 && header?.column.getCanSort() && "header-sort-secondary-columns"}`}
|
263
|
+
cursor={((header?.index !== 0 && header?.column.getCanSort()) || (header?.index === 0 && enableSorting) ? "pointer" : "default")}
|
264
|
+
{...(((header?.index !== 0 && header?.column.getCanSort()) || (header?.index === 0 && enableSorting)) && {
|
266
265
|
htmlOptions: {
|
267
266
|
onClick: (event: React.MouseEvent) => toggleSortButton(event),
|
268
267
|
onKeyDown: (event: React.KeyboardEvent) => {
|
@@ -280,13 +279,13 @@ const isToggleExpansionEnabled =
|
|
280
279
|
{flexRender(header?.column.columnDef.header, header?.getContext())}
|
281
280
|
</div>
|
282
281
|
|
283
|
-
{header?.index === 0 &&
|
284
|
-
header.column.getCanSort() &&
|
285
|
-
enableSorting &&
|
282
|
+
{((header?.index !== 0 && header?.column.getCanSort()) || (header?.index === 0 && enableSorting)) &&
|
286
283
|
(loading ? (
|
287
284
|
<div className="loading-toggle-icon" />
|
288
285
|
) : (
|
289
|
-
<SortIconButton
|
286
|
+
<SortIconButton
|
287
|
+
enableSortingRemoval={enableSortingRemoval}
|
288
|
+
header={header}
|
290
289
|
sortIcon={sortIcon}
|
291
290
|
/>
|
292
291
|
))}
|
@@ -16,8 +16,10 @@ import { createCellFunction } from "../Utilities/CellRendererUtils";
|
|
16
16
|
interface UseTableStateProps {
|
17
17
|
tableData: GenericObject[];
|
18
18
|
columnDefinitions: GenericObject[];
|
19
|
+
enableSortingRemoval?: boolean;
|
19
20
|
expandedControl?: GenericObject;
|
20
21
|
sortControl?: GenericObject;
|
22
|
+
firstColumnSort?: boolean;
|
21
23
|
onRowToggleClick?: (arg: Row<GenericObject>) => void;
|
22
24
|
selectableRows?: boolean;
|
23
25
|
initialLoadingRowsCount?: number;
|
@@ -38,6 +40,7 @@ interface UseTableStateProps {
|
|
38
40
|
export function useTableState({
|
39
41
|
tableData,
|
40
42
|
columnDefinitions,
|
43
|
+
enableSortingRemoval,
|
41
44
|
expandedControl,
|
42
45
|
sortControl,
|
43
46
|
onRowToggleClick,
|
@@ -83,19 +86,19 @@ export function useTableState({
|
|
83
86
|
const buildColumns = useCallback((columnDefinitions: GenericObject[], isRoot = true): any[] => {
|
84
87
|
return columnDefinitions?.map((column, index) => {
|
85
88
|
const isFirstColumn = isRoot && index === 0;
|
86
|
-
|
87
89
|
// Handle grouped columns
|
88
90
|
if (column.columns && column.columns.length > 0) {
|
89
91
|
return {
|
90
|
-
header: column.header
|
92
|
+
header: column.header ?? column.label ?? "",
|
93
|
+
id: column.id ?? column.label ?? `group-${index}`,
|
91
94
|
columns: buildColumns(column.columns, false),
|
92
95
|
};
|
93
96
|
}
|
94
|
-
|
95
97
|
// Define the base column structure
|
96
98
|
const columnStructure = {
|
97
99
|
...columnHelper.accessor(column.accessor, {
|
98
100
|
header: column.header ?? column.label ?? "",
|
101
|
+
enableSorting: isFirstColumn || column.enableSort === true,
|
99
102
|
}),
|
100
103
|
};
|
101
104
|
|
@@ -166,7 +169,7 @@ export function useTableState({
|
|
166
169
|
getCoreRowModel: getCoreRowModel(),
|
167
170
|
getExpandedRowModel: getExpandedRowModel(),
|
168
171
|
getSortedRowModel: getSortedRowModel(),
|
169
|
-
enableSortingRemoval:
|
172
|
+
enableSortingRemoval: enableSortingRemoval,
|
170
173
|
sortDescFirst: true,
|
171
174
|
onRowSelectionChange: setRowSelection,
|
172
175
|
onRowPinningChange,
|
@@ -422,6 +422,15 @@
|
|
422
422
|
padding: 2px;
|
423
423
|
}
|
424
424
|
|
425
|
+
.header-sort-secondary-columns {
|
426
|
+
color: $primary !important;
|
427
|
+
|
428
|
+
&:hover {
|
429
|
+
background-color: rgba($primary, 0.03);
|
430
|
+
border-radius: $border_radius_md;
|
431
|
+
}
|
432
|
+
}
|
433
|
+
|
425
434
|
.toggle-all-icon {
|
426
435
|
@extend .button-icon;
|
427
436
|
@extend %primary-color-pseudo;
|
@@ -967,4 +976,19 @@
|
|
967
976
|
// Outside of the pb_advanced_table class for popover
|
968
977
|
.pb-advanced-table-popover-option:hover {
|
969
978
|
background-color: $bg_light;
|
970
|
-
}
|
979
|
+
}
|
980
|
+
// Removes borders when Wrapped inside the Card Kit
|
981
|
+
[class^=pb_card_kit] > .pb_advanced_table .pb_advanced_table_body .last-cell,
|
982
|
+
[class^=pb_card_kit] > .pb_advanced_table .pb_advanced_table_header .last-header-cell,
|
983
|
+
[class^=pb_card_kit] > .pb_advanced_table .pb_advanced_table_body tr td:last-child,
|
984
|
+
[class^=pb_card_kit] > .pb_advanced_table .pb_advanced_table_header tr th:last-child {
|
985
|
+
border-right: none !important;
|
986
|
+
}
|
987
|
+
|
988
|
+
// Removes borders when Wrapped inside the Card Kit
|
989
|
+
[class^=pb_card_kit] > .pb_advanced_table tr:last-child,
|
990
|
+
[class^=pb_card_kit] > .pb_advanced_table .last-row-cell {
|
991
|
+
td {
|
992
|
+
border-bottom: none !important;
|
993
|
+
}
|
994
|
+
}
|
@@ -40,6 +40,7 @@ type AdvancedTableProps = {
|
|
40
40
|
dark?: boolean
|
41
41
|
data?: { [key: string]: string }
|
42
42
|
enableToggleExpansion?: "all" | "header" | "none"
|
43
|
+
enableSortingRemoval?: boolean
|
43
44
|
expandedControl?: GenericObject
|
44
45
|
expandByDepth?: { [key: string]: string | number }
|
45
46
|
onExpandByDepthClick?: (arg: number, arg1: any) => void
|
@@ -87,6 +88,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
87
88
|
dark = false,
|
88
89
|
data = {},
|
89
90
|
enableToggleExpansion = "header",
|
91
|
+
enableSortingRemoval = false,
|
90
92
|
expandedControl,
|
91
93
|
expandByDepth,
|
92
94
|
onExpandByDepthClick,
|
@@ -122,7 +124,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
122
124
|
// Component refs
|
123
125
|
const tableWrapperRef = useRef<HTMLDivElement>(null);
|
124
126
|
|
125
|
-
// Initialize table state
|
126
127
|
const {
|
127
128
|
table,
|
128
129
|
expanded,
|
@@ -137,6 +138,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
137
138
|
} = useTableState({
|
138
139
|
tableData,
|
139
140
|
columnDefinitions,
|
141
|
+
enableSortingRemoval,
|
140
142
|
expandedControl,
|
141
143
|
sortControl,
|
142
144
|
onRowToggleClick,
|
@@ -333,6 +335,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
333
335
|
columnGroupBorderColor={columnGroupBorderColor}
|
334
336
|
columnVisibilityControl={columnVisibilityControl}
|
335
337
|
customSort={customSort}
|
338
|
+
enableSortingRemoval={enableSortingRemoval}
|
336
339
|
enableToggleExpansion={enableToggleExpansion}
|
337
340
|
enableVirtualization={virtualizedRows}
|
338
341
|
expandByDepth={expandByDepth}
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<% if content.present? %>
|
12
12
|
<% content.presence %>
|
13
13
|
<% else %>
|
14
|
-
<%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
|
14
|
+
<%= pb_rails("advanced_table/table_header", props: { id: object.id, column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
|
15
15
|
<%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion, row_styling: object.row_styling }) %>
|
16
16
|
<% end %>
|
17
17
|
<% end %>
|
@@ -124,6 +124,23 @@ const columnDefinitions = [
|
|
124
124
|
},
|
125
125
|
]
|
126
126
|
|
127
|
+
const columnDefinitionsSort = [
|
128
|
+
{
|
129
|
+
accessor: "year",
|
130
|
+
label: "Year",
|
131
|
+
cellAccessors: ["quarter", "month", "day"],
|
132
|
+
},
|
133
|
+
{
|
134
|
+
accessor: "newEnrollments",
|
135
|
+
label: "New Enrollments",
|
136
|
+
enableSort: true,
|
137
|
+
},
|
138
|
+
{
|
139
|
+
accessor: "scheduledMeetings",
|
140
|
+
label: "Scheduled Meetings",
|
141
|
+
},
|
142
|
+
];
|
143
|
+
|
127
144
|
const columnDefinitionsCustomRenderer = [
|
128
145
|
{
|
129
146
|
accessor: "year",
|
@@ -676,3 +693,20 @@ test("rowStyling prop works as expected", () => {
|
|
676
693
|
const row1 = tableBody.querySelector('tr:nth-child(1)')
|
677
694
|
expect(row1).toHaveStyle({backgroundColor: colors.white, color: colors.black})
|
678
695
|
})
|
696
|
+
|
697
|
+
test("Sort icon renders with enableSort on individual columns", () => {
|
698
|
+
render(
|
699
|
+
<AdvancedTable
|
700
|
+
columnDefinitions={columnDefinitionsSort}
|
701
|
+
data={{ testid: testId }}
|
702
|
+
tableData={MOCK_DATA}
|
703
|
+
/>
|
704
|
+
);
|
705
|
+
|
706
|
+
const kit = screen.getByTestId(testId);
|
707
|
+
const sortIcon = kit.querySelector(".sort-button-icon");
|
708
|
+
expect(sortIcon).toBeInTheDocument();
|
709
|
+
const sortButton = kit.querySelector(".header-sort-secondary-columns");
|
710
|
+
expect(sortButton).toBeInTheDocument();
|
711
|
+
});
|
712
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% column_definitions = [
|
2
|
+
{
|
3
|
+
accessor: "year",
|
4
|
+
label: "Year",
|
5
|
+
cellAccessors: ["quarter", "month", "day"],
|
6
|
+
},
|
7
|
+
{
|
8
|
+
label: "Enrollment Data",
|
9
|
+
columns: [
|
10
|
+
{
|
11
|
+
accessor: "newEnrollments",
|
12
|
+
label: "New Enrollments",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
accessor: "scheduledMeetings",
|
16
|
+
label: "Scheduled Meetings",
|
17
|
+
},
|
18
|
+
],
|
19
|
+
},
|
20
|
+
{
|
21
|
+
label: "Performance Data",
|
22
|
+
columns: [
|
23
|
+
{
|
24
|
+
accessor: "attendanceRate",
|
25
|
+
label: "Attendance Rate",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
accessor: "completedClasses",
|
29
|
+
label: "Completed Classes",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
accessor: "classCompletionRate",
|
33
|
+
label: "Class Completion Rate",
|
34
|
+
},
|
35
|
+
{
|
36
|
+
accessor: "graduatedStudents",
|
37
|
+
label: "Graduated Students",
|
38
|
+
},
|
39
|
+
],
|
40
|
+
},
|
41
|
+
] %>
|
42
|
+
|
43
|
+
<%= pb_rails("advanced_table", props: { id: "table_multi_headers_vertical_borders", table_data: @table_data, column_definitions: column_definitions, table_props: { vertical_border: true } }) %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableColumnHeadersVerticalBorder = (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
|
+
const tableProps = {
|
49
|
+
verticalBorder: true
|
50
|
+
}
|
51
|
+
|
52
|
+
return (
|
53
|
+
<>
|
54
|
+
<AdvancedTable
|
55
|
+
columnDefinitions={columnDefinitions}
|
56
|
+
tableData={MOCK_DATA}
|
57
|
+
tableProps={tableProps}
|
58
|
+
{...props}
|
59
|
+
/>
|
60
|
+
</>
|
61
|
+
)
|
62
|
+
}
|
63
|
+
|
64
|
+
export default AdvancedTableColumnHeadersVerticalBorder
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb
CHANGED
@@ -34,6 +34,6 @@
|
|
34
34
|
%>
|
35
35
|
|
36
36
|
<%= pb_rails("advanced_table", props: { id: "selectable_rows", table_data: @table_data_with_id, column_definitions: column_definitions, selectable_rows: true }) do %>
|
37
|
-
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions, selectable_rows: true }) %>
|
37
|
+
<%= pb_rails("advanced_table/table_header", props: { id: "selectable_rows", column_definitions: column_definitions, selectable_rows: true }) %>
|
38
38
|
<%= pb_rails("advanced_table/table_body", props: { id: "selectable_rows", table_data: @table_data_with_id, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all", selectable_rows: true }) %>
|
39
39
|
<% end %>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableSortPerColumn = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
accessor: "newEnrollments",
|
14
|
+
label: "New Enrollments",
|
15
|
+
enableSort: true,
|
16
|
+
},
|
17
|
+
{
|
18
|
+
accessor: "scheduledMeetings",
|
19
|
+
label: "Scheduled Meetings",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
accessor: "attendanceRate",
|
23
|
+
label: "Attendance Rate",
|
24
|
+
enableSort: true,
|
25
|
+
},
|
26
|
+
{
|
27
|
+
accessor: "completedClasses",
|
28
|
+
label: "Completed Classes",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
accessor: "classCompletionRate",
|
32
|
+
label: "Class Completion Rate",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
accessor: "graduatedStudents",
|
36
|
+
label: "Graduated Students",
|
37
|
+
},
|
38
|
+
]
|
39
|
+
|
40
|
+
return (
|
41
|
+
<div>
|
42
|
+
<AdvancedTable
|
43
|
+
columnDefinitions={columnDefinitions}
|
44
|
+
enableSortingRemoval
|
45
|
+
tableData={MOCK_DATA}
|
46
|
+
{...props}
|
47
|
+
>
|
48
|
+
<AdvancedTable.Header />
|
49
|
+
<AdvancedTable.Body />
|
50
|
+
</AdvancedTable>
|
51
|
+
</div>
|
52
|
+
)
|
53
|
+
}
|
54
|
+
|
55
|
+
export default AdvancedTableSortPerColumn;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Sorting can now be enabled on any of the columns. To do this, add `enableSort:true` to the columnDefinition of the column you want sorting enabled on. Once enabled, clicking on the header will toggle sort between ascending and descending.
|
2
|
+
|
3
|
+
The optional `enableSortingRemoval` prop can also be used in conjunction with sorting functionality. This prop is set to 'false' by default but if set to 'true' sorting order will circle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ...
|
4
|
+
It is recommended that `enableSortingRemoval` be set to 'true' when sort is enabled on mutiple columns so that sorting direction is always clear via the sort icon.
|
5
|
+
|
6
|
+
__NOTE:__ For sort on the first column, continue to use the separate `enableSorting` prop on AdvancedTable.Header as [shown here](https://playbook.powerapp.cloud/kits/advanced_table/sorting/react#enable-sorting).
|