playbook_ui 13.18.0.pre.alpha.useexactnodejsversionghactions2183 → 13.19.0.pre.alpha.PBNTR200addadvancedtablekitdarkmodestyles2346
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/_reset.scss +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx +6 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +5 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +9 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +17 -11
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +31 -5
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +20 -4
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +3 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +30 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +24 -11
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +84 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +58 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading.js +200 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +4 -1
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +6 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.html.erb +49 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.jsx +68 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.tsx +3 -1
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +3 -1
- data/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.tsx +4 -2
- data/app/pb_kits/playbook/pb_filter/Filter/index.tsx +1 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_height.html.erb +42 -0
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_height.jsx +83 -0
- data/app/pb_kits/playbook/pb_filter/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_filter/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +2 -2
- data/app/pb_kits/playbook/pb_filter/filter.rb +2 -1
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +4 -0
- data/app/pb_kits/playbook/pb_form_group/form_group.rb +5 -1
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +28 -16
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb +5 -11
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.jsx +44 -18
- data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.md +4 -8
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +6 -4
- data/app/pb_kits/playbook/pb_icon/icon.rb +27 -10
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +4 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +86 -67
- data/app/pb_kits/playbook/pb_table/docs/_table_div.html.erb +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_div.jsx +47 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents.html.erb +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents.md +7 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents_as_divs.html.erb +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_subcomponents_as_divs.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_content.scss +3 -3
- data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +3 -3
- data/app/pb_kits/playbook/pb_table/styles/_hover.scss +11 -11
- data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_reset.scss +3 -3
- data/app/pb_kits/playbook/pb_table/styles/_side_highlight.scss +2 -2
- data/app/pb_kits/playbook/pb_table/styles/_single-line.scss +4 -4
- data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +2 -2
- data/app/pb_kits/playbook/pb_table/styles/_striped.scss +4 -4
- data/app/pb_kits/playbook/pb_table/styles/_structure.scss +22 -8
- data/app/pb_kits/playbook/pb_table/styles/_table-card.scss +7 -7
- data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +14 -14
- data/app/pb_kits/playbook/pb_table/styles/_table_header.scss +2 -2
- data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +15 -15
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +3 -4
- data/app/pb_kits/playbook/pb_table/table.html.erb +12 -2
- data/app/pb_kits/playbook/pb_table/table.rb +3 -0
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +17 -0
- data/app/pb_kits/playbook/pb_table/table_body.rb +15 -0
- data/app/pb_kits/playbook/pb_table/table_cell.html.erb +17 -0
- data/app/pb_kits/playbook/pb_table/table_cell.rb +17 -0
- data/app/pb_kits/playbook/pb_table/table_head.html.erb +17 -0
- data/app/pb_kits/playbook/pb_table/table_head.rb +15 -0
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +49 -39
- data/app/pb_kits/playbook/pb_table/table_header.rb +8 -1
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +17 -7
- data/app/pb_kits/playbook/pb_table/table_row.rb +8 -1
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +9 -5
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_add_on.jsx +20 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_presence_indicator_swift.md +30 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_props_table.md +2 -1
- data/app/pb_kits/playbook/pb_user/docs/example.yml +1 -0
- data/dist/menu.yml +1 -1
- data/dist/playbook-rails.js +4 -4
- data/lib/playbook/version.rb +2 -2
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e92276b817648438498c23e0ecd061e7c98a9475ad753f40cc7e5c9fb0af6d7
|
4
|
+
data.tar.gz: f4140309f468eed4a83eceeb5f7615dba9a2a36b8b98304adaeed0dc094b6a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8af07f55548723f7ec6ea94fc068ce0159eac619cbd0c48dbee56256dcfa9e1598c2aaf5a5518ba82005a8d01c927902dd76f59abefa151d54edf33e90083d65
|
7
|
+
data.tar.gz: '0299fa636b48f91f847ba704349dd639d9a412e354ac81508f744b85bfbb2d0d109885e3047aa126099a651875be533142b1e52f8232f99ca76244b614fed8db'
|
@@ -11,7 +11,12 @@ const CollapsibleTrail = ({ leftOffset }: { leftOffset: number }) => {
|
|
11
11
|
backgroundColor: "#E4E8F0",
|
12
12
|
}
|
13
13
|
|
14
|
-
return
|
14
|
+
return (
|
15
|
+
<div
|
16
|
+
className="collapsible-trail"
|
17
|
+
style={style}
|
18
|
+
/>
|
19
|
+
)
|
15
20
|
}
|
16
21
|
|
17
22
|
// Updated function to render multiple trails depending on depth
|
@@ -22,13 +22,14 @@ export const CustomCell = ({
|
|
22
22
|
row,
|
23
23
|
value,
|
24
24
|
}: CustomCellProps & GlobalProps) => {
|
25
|
-
const { setExpanded, expanded } = useContext(AdvancedTableContext);
|
26
|
-
const RowWithoutChildren = row.originalSubRows === undefined;
|
25
|
+
const { setExpanded, expanded, inlineRowLoading } = useContext(AdvancedTableContext);
|
27
26
|
|
28
27
|
const handleOnExpand = (row: Row<DataType>) => {
|
29
28
|
onRowToggleClick && onRowToggleClick(row);
|
30
29
|
setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
|
31
30
|
};
|
31
|
+
const RowHasChildren = row.original.children ? true : false
|
32
|
+
const renderButton = inlineRowLoading ? RowHasChildren : row.getCanExpand()
|
32
33
|
|
33
34
|
return (
|
34
35
|
<div style={{ paddingLeft: `${row.depth * 1.25}em` }}>
|
@@ -36,7 +37,7 @@ export const CustomCell = ({
|
|
36
37
|
columnGap="xs"
|
37
38
|
orientation="row"
|
38
39
|
>
|
39
|
-
{
|
40
|
+
{renderButton ? (
|
40
41
|
<button
|
41
42
|
className="gray-icon expand-toggle-icon"
|
42
43
|
onClick={() => handleOnExpand(row)}
|
@@ -53,7 +54,7 @@ export const CustomCell = ({
|
|
53
54
|
)}
|
54
55
|
</button>
|
55
56
|
) : null}
|
56
|
-
<FlexItem paddingLeft={
|
57
|
+
<FlexItem paddingLeft={renderButton? "none" : "xs"}>
|
57
58
|
{row.depth === 0 ? getValue() : value}
|
58
59
|
</FlexItem>
|
59
60
|
</Flex>
|
@@ -1,8 +1,9 @@
|
|
1
|
-
import React from "react"
|
1
|
+
import React, { useContext } from "react"
|
2
2
|
import Flex from "../../pb_flex/_flex"
|
3
3
|
import Caption from "../../pb_caption/_caption"
|
4
4
|
import { Row, Table } from "@tanstack/react-table"
|
5
5
|
|
6
|
+
import AdvancedTableContext from "../Context/AdvancedTableContext";
|
6
7
|
import { ToggleIconButton } from "./ToggleIconButton"
|
7
8
|
import { renderCollapsibleTrail } from "./CollapsibleTrail"
|
8
9
|
|
@@ -12,7 +13,7 @@ import { GlobalProps } from "../../utilities/globalProps"
|
|
12
13
|
|
13
14
|
interface SubRowHeaderRowProps {
|
14
15
|
collapsibleTrail?: boolean
|
15
|
-
enableToggleExpansion?: "all" | "header"
|
16
|
+
enableToggleExpansion?: "all" | "header" | "none"
|
16
17
|
onClick: (row: Row<DataType>) => void
|
17
18
|
row: Row<DataType>
|
18
19
|
subRowHeaders?: string[]
|
@@ -27,7 +28,11 @@ export const SubRowHeaderRow = ({
|
|
27
28
|
subRowHeaders,
|
28
29
|
table,
|
29
30
|
}: SubRowHeaderRowProps & GlobalProps) => {
|
31
|
+
const { inlineRowLoading } = useContext(AdvancedTableContext);
|
32
|
+
|
30
33
|
const numberOfColumns = table.getAllFlatColumns().length
|
34
|
+
const rowHasChildren = row.original.children ? true : false
|
35
|
+
const canExpand = inlineRowLoading ? rowHasChildren : row.getCanExpand()
|
31
36
|
|
32
37
|
return (
|
33
38
|
<tr className="custom-row bg-silver">
|
@@ -42,13 +47,13 @@ export const SubRowHeaderRow = ({
|
|
42
47
|
<Flex align="center"
|
43
48
|
columnGap="xs"
|
44
49
|
>
|
45
|
-
{enableToggleExpansion === "all" &&
|
50
|
+
{enableToggleExpansion === "all" && canExpand ? (
|
46
51
|
<ToggleIconButton onClick={onClick}
|
47
52
|
row={row}
|
48
53
|
/>
|
49
54
|
) : null}
|
50
55
|
<Caption
|
51
|
-
marginLeft={
|
56
|
+
marginLeft={canExpand ? "none" : "xs"}
|
52
57
|
text={subRowHeaders[row.depth - 1]}
|
53
58
|
/>
|
54
59
|
</Flex>
|
@@ -12,11 +12,10 @@ import { GlobalProps } from "../../utilities/globalProps"
|
|
12
12
|
|
13
13
|
type TableHeaderCellProps = {
|
14
14
|
enableSorting?: boolean
|
15
|
-
enableToggleExpansion?: "all" | "header"
|
15
|
+
enableToggleExpansion?: "all" | "header" | "none"
|
16
16
|
handleExpandOrCollapse?: () => void
|
17
17
|
header?: Header<DataType, unknown>
|
18
18
|
headerChildren?: React.ReactNode | React.ReactNode[]
|
19
|
-
headerId?: string
|
20
19
|
loading?: boolean
|
21
20
|
sortIcon?: string | string[]
|
22
21
|
} & GlobalProps
|
@@ -27,7 +26,6 @@ export const TableHeaderCell = ({
|
|
27
26
|
handleExpandOrCollapse,
|
28
27
|
header,
|
29
28
|
headerChildren,
|
30
|
-
headerId,
|
31
29
|
loading,
|
32
30
|
sortIcon,
|
33
31
|
}: TableHeaderCellProps) => {
|
@@ -50,10 +48,22 @@ const cellClassName = classnames("table-header-cells",
|
|
50
48
|
);
|
51
49
|
|
52
50
|
const cellId = `${loading ?
|
53
|
-
`loading-${header.id}
|
54
|
-
: `${header.id}
|
51
|
+
`loading-${header.id}`
|
52
|
+
: `${header.id}`
|
55
53
|
}`;
|
56
54
|
|
55
|
+
const isToggleExpansionEnabledLoading =
|
56
|
+
header.index === 0 &&
|
57
|
+
loading &&
|
58
|
+
(enableToggleExpansion === "all" || "header") &&
|
59
|
+
enableToggleExpansion !== "none";
|
60
|
+
|
61
|
+
const isToggleExpansionEnabled =
|
62
|
+
header.index === 0 &&
|
63
|
+
!loading &&
|
64
|
+
(enableToggleExpansion === "all" || "header") &&
|
65
|
+
enableToggleExpansion !== "none";
|
66
|
+
|
57
67
|
return (
|
58
68
|
<th
|
59
69
|
align="right"
|
@@ -73,15 +83,11 @@ const cellId = `${loading ?
|
|
73
83
|
alignItems="center"
|
74
84
|
justify={header.index === 0 && enableSorting ? "between" : header.index === 0 && !enableSorting ? "start" : "end"}
|
75
85
|
>
|
76
|
-
{
|
77
|
-
!loading &&
|
78
|
-
(enableToggleExpansion === "all" || "header") && (
|
86
|
+
{isToggleExpansionEnabled && (
|
79
87
|
<ToggleIconButton onClick={handleExpandOrCollapse} />
|
80
88
|
)}
|
81
89
|
|
82
|
-
{
|
83
|
-
loading &&
|
84
|
-
(enableToggleExpansion === "all" || "header") && (
|
90
|
+
{isToggleExpansionEnabledLoading &&(
|
85
91
|
<div className="loading-toggle-icon header-toggle-icon" />
|
86
92
|
)}
|
87
93
|
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import React, { useContext } from "react"
|
2
|
+
import classnames from "classnames";
|
3
|
+
import { buildCss } from "../../utilities/props";
|
4
|
+
import { globalProps } from "../../utilities/globalProps";
|
2
5
|
import LoadingInline from "../../pb_loading_inline/_loading_inline"
|
3
6
|
import { flexRender, Row } from "@tanstack/react-table"
|
4
7
|
|
@@ -10,28 +13,49 @@ import { isChrome } from "../Utilities/BrowserCheck"
|
|
10
13
|
import { DataType } from "../Utilities/types"
|
11
14
|
|
12
15
|
type TableBodyProps = {
|
16
|
+
className?: string;
|
13
17
|
collapsibleTrail?: boolean
|
18
|
+
dark?: boolean,
|
19
|
+
id?: string;
|
14
20
|
subRowHeaders?: string[]
|
15
21
|
}
|
16
22
|
|
17
23
|
export const TableBody = ({
|
24
|
+
className,
|
18
25
|
collapsibleTrail = true,
|
26
|
+
dark = false,
|
27
|
+
id,
|
19
28
|
subRowHeaders,
|
29
|
+
...props
|
20
30
|
}: TableBodyProps) => {
|
31
|
+
|
21
32
|
const {
|
33
|
+
columnDefinitions,
|
22
34
|
enableToggleExpansion,
|
23
35
|
handleExpandOrCollapse,
|
36
|
+
inlineRowLoading,
|
24
37
|
loading,
|
25
38
|
table,
|
26
39
|
} = useContext(AdvancedTableContext)
|
40
|
+
|
41
|
+
const classes = classnames(
|
42
|
+
buildCss("pb_advanced_table_body"),
|
43
|
+
globalProps(props),
|
44
|
+
className
|
45
|
+
);
|
46
|
+
|
27
47
|
return (
|
28
48
|
<>
|
29
|
-
<tbody
|
49
|
+
<tbody className={classes}
|
50
|
+
id={id}
|
51
|
+
>
|
30
52
|
{table.getRowModel().rows.map((row: Row<DataType>) => {
|
31
53
|
const isExpandable = row.getIsExpanded()
|
32
54
|
const isFirstChildofSubrow = row.depth > 0 && row.index === 0
|
33
|
-
const rowHasNoChildren = !row.original.children
|
55
|
+
const rowHasNoChildren = row.original.children && !row.original.children.length ? true : false
|
34
56
|
const numberOfColumns = table.getAllFlatColumns().length
|
57
|
+
const isDataLoading = isExpandable && (inlineRowLoading && rowHasNoChildren) && (row.depth < columnDefinitions[0].cellAccessors?.length)
|
58
|
+
const rowBackground = isExpandable && ((!inlineRowLoading && row.getCanExpand()) || (inlineRowLoading && rowHasNoChildren))
|
35
59
|
|
36
60
|
return (
|
37
61
|
<React.Fragment key={`${row.index}-${row.id}-${row.depth}-row`}>
|
@@ -47,7 +71,7 @@ export const TableBody = ({
|
|
47
71
|
)}
|
48
72
|
|
49
73
|
<tr
|
50
|
-
className={`${
|
74
|
+
className={`${rowBackground ? "bg-silver" : "bg-white"} ${
|
51
75
|
row.depth > 0 ? `depth-sub-row-${row.depth}` : ""
|
52
76
|
}`}
|
53
77
|
id={`${row.index}-${row.id}-${row.depth}-row`}
|
@@ -79,9 +103,11 @@ export const TableBody = ({
|
|
79
103
|
</tr>
|
80
104
|
|
81
105
|
{/* Display LoadingInline if Row Data is querying and there are no children already */}
|
82
|
-
{
|
106
|
+
{isDataLoading ? (
|
83
107
|
<tr key={`${row.id}-row`}>
|
84
|
-
<td colSpan={numberOfColumns}
|
108
|
+
<td colSpan={numberOfColumns}
|
109
|
+
style={{ paddingLeft: `${row.depth === 0 ? 0.5 : (row.depth * 2)}em` }}
|
110
|
+
>
|
85
111
|
<LoadingInline />
|
86
112
|
</td>
|
87
113
|
</tr>
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import React, { useContext } from "react"
|
2
|
+
import classnames from "classnames";
|
3
|
+
import { buildCss } from "../../utilities/props";
|
4
|
+
import { globalProps } from "../../utilities/globalProps";
|
2
5
|
import { HeaderGroup } from "@tanstack/react-table"
|
3
6
|
import AdvancedTableContext from "../Context/AdvancedTableContext"
|
4
7
|
import { TableHeaderCell } from "../Components/TableHeaderCell"
|
@@ -6,16 +9,21 @@ import { DataType } from "../Utilities/types"
|
|
6
9
|
|
7
10
|
type TableHeaderProps = {
|
8
11
|
children?: React.ReactNode | React.ReactNode[]
|
12
|
+
className?: string
|
13
|
+
dark?: boolean,
|
9
14
|
enableSorting?: boolean
|
10
|
-
|
15
|
+
id?: string;
|
11
16
|
sortIcon?: string | string[]
|
12
17
|
}
|
13
18
|
|
14
19
|
export const TableHeader = ({
|
15
20
|
children,
|
21
|
+
className,
|
22
|
+
dark = false,
|
16
23
|
enableSorting = false,
|
17
|
-
|
24
|
+
id,
|
18
25
|
sortIcon = ["arrow-up-short-wide", "arrow-down-short-wide"],
|
26
|
+
...props
|
19
27
|
}: TableHeaderProps) => {
|
20
28
|
const {
|
21
29
|
enableToggleExpansion,
|
@@ -24,9 +32,18 @@ export const TableHeader = ({
|
|
24
32
|
table,
|
25
33
|
} = useContext(AdvancedTableContext)
|
26
34
|
|
35
|
+
const classes = classnames(
|
36
|
+
buildCss("pb_advanced_table_header"),
|
37
|
+
globalProps(props),
|
38
|
+
className
|
39
|
+
);
|
40
|
+
|
41
|
+
|
27
42
|
return (
|
28
43
|
<>
|
29
|
-
<thead
|
44
|
+
<thead className={classes}
|
45
|
+
id={id}
|
46
|
+
>
|
30
47
|
{/* Get the header groups (only one in this example) */}
|
31
48
|
{table.getHeaderGroups().map((headerGroup: HeaderGroup<DataType>) => (
|
32
49
|
<tr key={`${headerGroup.id}-headerGroup`}>
|
@@ -37,7 +54,6 @@ export const TableHeader = ({
|
|
37
54
|
handleExpandOrCollapse={handleExpandOrCollapse}
|
38
55
|
header={header}
|
39
56
|
headerChildren={children}
|
40
|
-
headerId={headerId}
|
41
57
|
key={`${header.id}-header`}
|
42
58
|
loading={loading}
|
43
59
|
sortIcon={sortIcon}
|
@@ -24,10 +24,9 @@ export const updateExpandAndCollapseState = (
|
|
24
24
|
// Update isExpansionConsistent variable
|
25
25
|
for (const row of rows) {
|
26
26
|
if (
|
27
|
-
|
28
|
-
(targetParent === undefined
|
27
|
+
targetParent === undefined
|
29
28
|
? row.depth === 0
|
30
|
-
: targetParent === row.parentId
|
29
|
+
: targetParent === row.parentId
|
31
30
|
) {
|
32
31
|
areRowsExpanded.add(row.getIsExpanded())
|
33
32
|
if (areRowsExpanded.size > 1) {
|
@@ -48,7 +47,7 @@ export const updateExpandAndCollapseState = (
|
|
48
47
|
})
|
49
48
|
} else {
|
50
49
|
for (const row of rows) {
|
51
|
-
if (
|
50
|
+
if (targetParent === row.parentId) {
|
52
51
|
updateExpandedRows[row.id] = !isExpansionConsistent
|
53
52
|
? true
|
54
53
|
: !row.getIsExpanded()
|
@@ -95,4 +95,34 @@
|
|
95
95
|
border-right: $transparent !important;
|
96
96
|
}
|
97
97
|
}
|
98
|
+
|
99
|
+
&.dark {
|
100
|
+
.bg-white {
|
101
|
+
background: $bg_dark_card;
|
102
|
+
}
|
103
|
+
|
104
|
+
.bg-silver {
|
105
|
+
background: $bg_dark;
|
106
|
+
}
|
107
|
+
|
108
|
+
.table-header-cells:first-child, td:first-child {
|
109
|
+
box-shadow: 1px 0px 0px 0px $border_dark !important;
|
110
|
+
}
|
111
|
+
|
112
|
+
.collapsible-trail {
|
113
|
+
background-color: $border_dark !important;
|
114
|
+
}
|
115
|
+
|
116
|
+
.sort-button-icon, .header-sort-button > div {
|
117
|
+
color: $white !important;
|
118
|
+
}
|
119
|
+
|
120
|
+
.gray-icon {
|
121
|
+
color: $text_dk_light !important;
|
122
|
+
}
|
123
|
+
|
124
|
+
.sticky-header {
|
125
|
+
background-color: $bg_dark_card;
|
126
|
+
}
|
127
|
+
}
|
98
128
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState, useEffect, useCallback } from "react";
|
2
2
|
import classnames from "classnames";
|
3
|
-
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
3
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
4
4
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
5
5
|
import Table from "../pb_table/_table";
|
6
6
|
import {
|
@@ -20,18 +20,21 @@ import AdvancedTableContext from "./Context/AdvancedTableContext";
|
|
20
20
|
import { TableHeader } from "./SubKits/TableHeader";
|
21
21
|
import { TableBody } from "./SubKits/TableBody";
|
22
22
|
|
23
|
-
import { DataType
|
23
|
+
import { DataType } from "./Utilities/types";
|
24
24
|
|
25
25
|
type AdvancedTableProps = {
|
26
26
|
aria?: { [key: string]: string };
|
27
27
|
children?: React.ReactNode | React.ReactNode[];
|
28
28
|
className?: string;
|
29
29
|
columnDefinitions: DataType[];
|
30
|
+
dark?: boolean,
|
30
31
|
data?: { [key: string]: string };
|
31
|
-
enableToggleExpansion?: "all" | "header";
|
32
|
+
enableToggleExpansion?: "all" | "header" | "none";
|
32
33
|
expandedControl?: DataType;
|
34
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
33
35
|
id?: string;
|
34
36
|
initialLoadingRowsCount?: number;
|
37
|
+
inlineRowLoading?: boolean;
|
35
38
|
loading?: boolean | string;
|
36
39
|
onRowToggleClick?: (arg: Row<DataType>) => void;
|
37
40
|
onToggleExpansionClick?: (arg: Row<DataType>) => void;
|
@@ -48,11 +51,14 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
48
51
|
children,
|
49
52
|
className,
|
50
53
|
columnDefinitions,
|
54
|
+
dark = false,
|
51
55
|
data = {},
|
52
56
|
enableToggleExpansion = "header",
|
53
57
|
expandedControl,
|
58
|
+
htmlOptions = {},
|
54
59
|
id,
|
55
60
|
initialLoadingRowsCount = 10,
|
61
|
+
inlineRowLoading = false,
|
56
62
|
loading,
|
57
63
|
onRowToggleClick,
|
58
64
|
onToggleExpansionClick,
|
@@ -76,7 +82,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
76
82
|
? expandedControl.onChange
|
77
83
|
: setLocalExpanded;
|
78
84
|
|
79
|
-
const columnHelper = createColumnHelper
|
85
|
+
const columnHelper = createColumnHelper();
|
80
86
|
|
81
87
|
//Create cells for first columns
|
82
88
|
const createCellFunction = (cellAccessors: string[]) => {
|
@@ -104,7 +110,9 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
104
110
|
const depthAccessor = cellAccessors[row.depth - 1]; // Adjust index for depth
|
105
111
|
const accessorValue = rowData[depthAccessor];
|
106
112
|
return accessorValue ? (
|
107
|
-
<CustomCell
|
113
|
+
<CustomCell
|
114
|
+
onRowToggleClick={onRowToggleClick}
|
115
|
+
row={row}
|
108
116
|
value={accessorValue}
|
109
117
|
/>
|
110
118
|
) : (
|
@@ -157,7 +165,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
157
165
|
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
158
166
|
columns,
|
159
167
|
onExpandedChange: setExpanded,
|
160
|
-
getSubRows: (row) => row.children,
|
168
|
+
getSubRows: (row: DataType) => row.children,
|
161
169
|
getCoreRowModel: getCoreRowModel(),
|
162
170
|
getExpandedRowModel: getExpandedRowModel(),
|
163
171
|
getSortedRowModel: getSortedRowModel(),
|
@@ -186,7 +194,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
186
194
|
const handleExpandOrCollapse = (row: Row<DataType>) => {
|
187
195
|
onToggleExpansionClick && onToggleExpansionClick(row);
|
188
196
|
|
189
|
-
const expandedState = expanded
|
197
|
+
const expandedState = expanded;
|
190
198
|
const targetParent = row?.parentId;
|
191
199
|
return setExpanded(
|
192
200
|
updateExpandAndCollapseState(tableRows, expandedState, targetParent)
|
@@ -195,6 +203,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
195
203
|
|
196
204
|
const ariaProps = buildAriaProps(aria);
|
197
205
|
const dataProps = buildDataProps(data);
|
206
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
198
207
|
const classes = classnames(
|
199
208
|
buildCss("pb_advanced_table"),
|
200
209
|
globalProps(props),
|
@@ -204,23 +213,27 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
204
213
|
return (
|
205
214
|
<div {...ariaProps}
|
206
215
|
{...dataProps}
|
216
|
+
{...htmlProps}
|
207
217
|
className={classes}
|
208
218
|
id={id}
|
209
219
|
>
|
210
220
|
<AdvancedTableContext.Provider
|
211
221
|
value={{
|
212
|
-
|
222
|
+
columnDefinitions,
|
223
|
+
enableToggleExpansion,
|
224
|
+
expanded,
|
213
225
|
handleExpandOrCollapse,
|
226
|
+
inlineRowLoading,
|
214
227
|
loading,
|
215
|
-
enableToggleExpansion,
|
216
|
-
toggleExpansionIcon,
|
217
228
|
setExpanded,
|
218
|
-
expanded,
|
219
229
|
sortControl,
|
230
|
+
table,
|
231
|
+
toggleExpansionIcon,
|
220
232
|
}}
|
221
233
|
>
|
222
234
|
<Table
|
223
235
|
className={`${loading ? "content-loading" : ""}`}
|
236
|
+
dark={dark}
|
224
237
|
dataTable
|
225
238
|
numberSpacing="tabular"
|
226
239
|
responsive="none"
|
@@ -42,6 +42,36 @@ const MOCK_DATA = [
|
|
42
42
|
},
|
43
43
|
];
|
44
44
|
|
45
|
+
const MOCK_DATA_LOADING = [
|
46
|
+
{
|
47
|
+
year: "2021",
|
48
|
+
quarter: null,
|
49
|
+
month: null,
|
50
|
+
day: null,
|
51
|
+
newEnrollments: "20",
|
52
|
+
scheduledMeetings: "10",
|
53
|
+
children: [],
|
54
|
+
},
|
55
|
+
{
|
56
|
+
year: "2022",
|
57
|
+
quarter: null,
|
58
|
+
month: null,
|
59
|
+
day: null,
|
60
|
+
newEnrollments: "20",
|
61
|
+
scheduledMeetings: "10",
|
62
|
+
children: [
|
63
|
+
{
|
64
|
+
year: "2022",
|
65
|
+
quarter: "Q1",
|
66
|
+
month: null,
|
67
|
+
day: null,
|
68
|
+
newEnrollments: "2",
|
69
|
+
scheduledMeetings: "35",
|
70
|
+
},
|
71
|
+
],
|
72
|
+
},
|
73
|
+
];
|
74
|
+
|
45
75
|
const columnDefinitions = [
|
46
76
|
{
|
47
77
|
accessor: "year",
|
@@ -343,3 +373,57 @@ test("sort button exists and sorts column data", () => {
|
|
343
373
|
const row2 = kit.getElementsByTagName('tr')[2]
|
344
374
|
expect(row2.id).toBe("0-0-0-row")
|
345
375
|
});
|
376
|
+
|
377
|
+
test("Generates Table.Header default + custom classname", () => {
|
378
|
+
render(
|
379
|
+
<AdvancedTable
|
380
|
+
columnDefinitions={columnDefinitions}
|
381
|
+
data={{ testid: testId }}
|
382
|
+
tableData={MOCK_DATA}
|
383
|
+
>
|
384
|
+
<AdvancedTable.Header className="custom-header" />
|
385
|
+
<AdvancedTable.Body />
|
386
|
+
|
387
|
+
</AdvancedTable>
|
388
|
+
);
|
389
|
+
|
390
|
+
const kit = screen.getByTestId(testId);
|
391
|
+
const tableHeader = kit.querySelector('thead')
|
392
|
+
expect(tableHeader).toHaveClass('pb_advanced_table_header custom-header')
|
393
|
+
});
|
394
|
+
|
395
|
+
test("Generates Table.Body default + custom classname", () => {
|
396
|
+
render(
|
397
|
+
<AdvancedTable
|
398
|
+
columnDefinitions={columnDefinitions}
|
399
|
+
data={{ testid: testId }}
|
400
|
+
tableData={MOCK_DATA}
|
401
|
+
>
|
402
|
+
<AdvancedTable.Header />
|
403
|
+
<AdvancedTable.Body className="custom-body-classname"/>
|
404
|
+
|
405
|
+
</AdvancedTable>
|
406
|
+
);
|
407
|
+
|
408
|
+
const kit = screen.getByTestId(testId);
|
409
|
+
const tableHeader = kit.querySelector('tbody')
|
410
|
+
expect(tableHeader).toHaveClass('pb_advanced_table_body custom-body-classname')
|
411
|
+
});
|
412
|
+
|
413
|
+
test("inlineRowLoading prop renders inline loading if true", () => {
|
414
|
+
render(
|
415
|
+
<AdvancedTable
|
416
|
+
columnDefinitions={columnDefinitions}
|
417
|
+
data={{ testid: testId }}
|
418
|
+
inlineRowLoading
|
419
|
+
tableData={MOCK_DATA_LOADING}
|
420
|
+
/>
|
421
|
+
);
|
422
|
+
|
423
|
+
const kit = screen.getByTestId(testId);
|
424
|
+
const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
|
425
|
+
expect(rowButton).toBeInTheDocument()
|
426
|
+
rowButton.click()
|
427
|
+
const inlineLoading = kit.querySelector(".fa-spinner")
|
428
|
+
expect(inlineLoading).toBeInTheDocument()
|
429
|
+
});
|
@@ -1 +1 @@
|
|
1
|
-
`collapsibleTrail` is an optional prop that is set to 'true' by default. If set to 'false', it will remove the trail on the left of rows when subRows are toggled open.
|
1
|
+
`collapsibleTrail` 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.
|
@@ -8,7 +8,7 @@ For a visual of the data structure needed for `tableData`, see [here](https://gi
|
|
8
8
|
|
9
9
|
### columnDefinitions
|
10
10
|
|
11
|
-
`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
|
11
|
+
`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 an array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
|
12
12
|
|
13
13
|
- `accessor`: this is the key from your data for the value you want rendered in that column
|
14
14
|
- `label`: this is what will be rendered as the column header label
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "../..";
|
3
|
+
import { MOCK_DATA_INLINE_LOADING } from "./_mock_data_inline_loading";
|
4
|
+
|
5
|
+
const AdvancedTableInlineRowLoading = (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
|
+
},
|
16
|
+
{
|
17
|
+
accessor: "scheduledMeetings",
|
18
|
+
label: "Scheduled Meetings",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
accessor: "attendanceRate",
|
22
|
+
label: "Attendance Rate",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
accessor: "completedClasses",
|
26
|
+
label: "Completed Classes",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
accessor: "classCompletionRate",
|
30
|
+
label: "Class Completion Rate",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
accessor: "graduatedStudents",
|
34
|
+
label: "Graduated Students",
|
35
|
+
},
|
36
|
+
];
|
37
|
+
|
38
|
+
//Render the subRow header rows
|
39
|
+
const subRowHeaders = ["Quarter", "Month", "Day"]
|
40
|
+
|
41
|
+
|
42
|
+
return (
|
43
|
+
<div>
|
44
|
+
<AdvancedTable
|
45
|
+
columnDefinitions={columnDefinitions}
|
46
|
+
enableToggleExpansion="all"
|
47
|
+
inlineRowLoading
|
48
|
+
tableData={MOCK_DATA_INLINE_LOADING}
|
49
|
+
{...props}
|
50
|
+
>
|
51
|
+
<AdvancedTable.Header />
|
52
|
+
<AdvancedTable.Body subRowHeaders={subRowHeaders}/>
|
53
|
+
</AdvancedTable>
|
54
|
+
</div>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
export default AdvancedTableInlineRowLoading;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
As a default, the kit assumes that the initial dataset is complete, and it renders all expansion buttons/controls based on that data; if no children are present, no expansion controls are rendered. If, however, you want to change the initial dataset to omit some or all of its children (to improve load times of a complex dataset, perhaps), and you implement a querying logic that loads children only when its parent is expanded, then you must use the `inlineRowLoading` prop to ensure your expansion controls are rendered even though your child data is not yet loaded. You must also pass an empty `children` array to any node that will have children to ensure its parent maintains its ability to expand. If this prop is called AND your data contains empty `children` arrays, the kit will render expansion controls on any row with empty children, and then add an inline loading state within the expanded subrow until those child row(s) are returned to the page [by your query logic].
|
2
|
+
|
3
|
+
In this code example, 2021 has an empty children array. Toggle it open to see the inline loading state. Once the correct data loads, this state will be replaced with the correct data rows.
|
4
|
+
|
5
|
+
This prop is set to `false` by default.
|