playbook_ui 14.21.2.pre.alpha.PLAY2241tablestickycolumnsdatanotids8357 → 14.21.2.pre.alpha.PLAY18938263
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/pb_advanced_table/Components/VirtualizedTableView.tsx +16 -36
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +5 -18
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +17 -37
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +40 -91
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +2 -3
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -49
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +18 -32
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -20
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +2 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +0 -21
- data/app/pb_kits/playbook/pb_filter/Filter/index.tsx +0 -13
- data/app/pb_kits/playbook/pb_filter/_filter.scss +0 -4
- data/app/pb_kits/playbook/pb_filter/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_filter/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +8 -8
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.html.erb +12 -12
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +12 -12
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +2 -2
- data/app/pb_kits/playbook/pb_table/index.ts +4 -4
- data/dist/chunks/{_typeahead-BmfmVMFP.js → _typeahead-CoOpeYom.js} +3 -3
- data/dist/chunks/_weekday_stacked-JnoR3mIy.js +45 -0
- data/dist/chunks/{lib-C2o6nu8G.js → lib-D7Va7yqa.js} +1 -1
- data/dist/chunks/{pb_form_validation-EyK6DbAT.js → pb_form_validation-DSkdRDMf.js} +1 -1
- data/dist/chunks/vendor.js +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/version.rb +1 -1
- metadata +6 -10
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.md +0 -3
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSection.tsx +0 -49
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSidebar.tsx +0 -69
- data/app/pb_kits/playbook/pb_filter/docs/_filter_sidebar.jsx +0 -224
- data/dist/chunks/_weekday_stacked-DAC7yY_H.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: 79e1418032e3a7ddebd1c367b0623b34c597d5f3bdd150dcf1b674fc37249634
|
4
|
+
data.tar.gz: 745eed5d73220bcf2599935c70f19a103c52344f640afad7ad9fb0baceba5e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e048fea08b7564b2886bcad5151b1528a92f55e35bd7661fc058582be2b64851353f9c398634021197e860550ea0f7cb13d0bafefc7e5b1a9bc92ee15c7d431
|
7
|
+
data.tar.gz: a34cc6f295dcf69a9315853f1ba9c079154b83cd4f94e49b06ffbb810d405b522850ebd4673843ae580b862522cd038ddc4acfd4f05aeb3917b06ad61ec80225
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import React, { useContext, useLayoutEffect, useState, useEffect
|
1
|
+
import React, { useContext, useLayoutEffect, useState, useEffect } from "react"
|
2
2
|
import classnames from "classnames"
|
3
|
-
import { flexRender, Cell
|
3
|
+
import { flexRender, Cell } from "@tanstack/react-table"
|
4
4
|
import { VirtualItem } from "@tanstack/react-virtual"
|
5
5
|
|
6
6
|
import { GenericObject } from "../../types"
|
@@ -10,8 +10,6 @@ import { getVirtualizedRowStyle } from "../Utilities/TableContainerStyles"
|
|
10
10
|
|
11
11
|
import LoadingInline from "../../pb_loading_inline/_loading_inline"
|
12
12
|
import Checkbox from "../../pb_checkbox/_checkbox"
|
13
|
-
import Detail from "../../pb_detail/_detail"
|
14
|
-
import Flex from "../../pb_flex/_flex"
|
15
13
|
|
16
14
|
import { SubRowHeaderRow } from "../Components/SubRowHeaderRow"
|
17
15
|
import { LoadingCell } from "../Components/LoadingCell"
|
@@ -22,13 +20,11 @@ import AdvancedTableContext from "../Context/AdvancedTableContext"
|
|
22
20
|
type VirtualizedTableViewProps = {
|
23
21
|
collapsibleTrail?: boolean
|
24
22
|
subRowHeaders?: string[]
|
25
|
-
isFetching: boolean
|
26
23
|
}
|
27
24
|
|
28
25
|
export const VirtualizedTableView = ({
|
29
26
|
collapsibleTrail = true,
|
30
27
|
subRowHeaders,
|
31
|
-
isFetching,
|
32
28
|
}: VirtualizedTableViewProps) => {
|
33
29
|
const {
|
34
30
|
enableToggleExpansion,
|
@@ -40,7 +36,6 @@ export const VirtualizedTableView = ({
|
|
40
36
|
hasAnySubRows,
|
41
37
|
virtualizer,
|
42
38
|
flattenedItems,
|
43
|
-
totalAvailableCount,
|
44
39
|
} = useContext(AdvancedTableContext)
|
45
40
|
|
46
41
|
const columnPinning = table.getState().columnPinning || { left: [] };
|
@@ -126,7 +121,19 @@ export const VirtualizedTableView = ({
|
|
126
121
|
}
|
127
122
|
|
128
123
|
// Get virtual items
|
129
|
-
|
124
|
+
let virtualItems: VirtualItem[] = [];
|
125
|
+
try {
|
126
|
+
virtualItems = virtualizer.getVirtualItems();
|
127
|
+
} catch (err) {
|
128
|
+
return (
|
129
|
+
<tr>
|
130
|
+
<td colSpan={table.getAllFlatColumns().length || 1}>
|
131
|
+
Error loading virtualized data.
|
132
|
+
</td>
|
133
|
+
</tr>
|
134
|
+
);
|
135
|
+
}
|
136
|
+
|
130
137
|
if (!virtualItems.length) {
|
131
138
|
return (
|
132
139
|
<tr>
|
@@ -136,9 +143,6 @@ export const VirtualizedTableView = ({
|
|
136
143
|
</tr>
|
137
144
|
);
|
138
145
|
}
|
139
|
-
|
140
|
-
// Establish # of Parent Rows (so that Footer count does not include every single row)
|
141
|
-
const topLevelRowCount = table.getRowModel().flatRows.filter((row: Row<GenericObject>) => row.depth === 0).length;
|
142
146
|
|
143
147
|
return (
|
144
148
|
<>
|
@@ -173,7 +177,7 @@ export const VirtualizedTableView = ({
|
|
173
177
|
if (item.type === 'row') {
|
174
178
|
const row = item.row;
|
175
179
|
const isExpandable = row.getIsExpanded();
|
176
|
-
const rowHasNoChildren = row.original?.children && !row.original.children.length;
|
180
|
+
const rowHasNoChildren = row.original?.children && !row.original.children.length ? true : false;
|
177
181
|
const rowBackground = isExpandable && ((!inlineRowLoading && row.getCanExpand()) || (inlineRowLoading && rowHasNoChildren));
|
178
182
|
const rowColor = row.getIsSelected() ? "bg-row-selection" : rowBackground ? "bg-silver" : "bg-white";
|
179
183
|
|
@@ -262,30 +266,6 @@ export const VirtualizedTableView = ({
|
|
262
266
|
);
|
263
267
|
}
|
264
268
|
|
265
|
-
if (item.type === 'footer') {
|
266
|
-
// Render footer
|
267
|
-
return (
|
268
|
-
<tr
|
269
|
-
className="virtualized-table-row virtualized-footer"
|
270
|
-
key={`footer-row`}
|
271
|
-
style={virtualItemStyle}
|
272
|
-
>
|
273
|
-
<td colSpan={table.getAllFlatColumns().length}>
|
274
|
-
<Flex align="center"
|
275
|
-
justify="center"
|
276
|
-
>
|
277
|
-
|
278
|
-
{isFetching ? (
|
279
|
-
<LoadingInline />
|
280
|
-
) : (
|
281
|
-
<Detail text={`Showing ${topLevelRowCount} of ${totalAvailableCount} rows`} />
|
282
|
-
)}
|
283
|
-
</Flex>
|
284
|
-
</td>
|
285
|
-
</tr>
|
286
|
-
)
|
287
|
-
}
|
288
|
-
|
289
269
|
return null;
|
290
270
|
})}
|
291
271
|
</>
|
@@ -8,7 +8,7 @@ import { getRowHeightEstimate } from '../Utilities/TableContainerStyles';
|
|
8
8
|
const AdvancedTableContext = createContext<any>({});
|
9
9
|
|
10
10
|
interface FlattenedItem {
|
11
|
-
type: 'header' | 'row' | 'loading'
|
11
|
+
type: 'header' | 'row' | 'loading';
|
12
12
|
row: Row<GenericObject>;
|
13
13
|
id: string;
|
14
14
|
}
|
@@ -116,17 +116,6 @@ export const AdvancedTableProvider = ({ children, ...props }: {
|
|
116
116
|
}
|
117
117
|
});
|
118
118
|
|
119
|
-
const isFetching = props.isFetching || false;
|
120
|
-
const shouldAddFooter = table && !isFetching && tableRows.length > 0
|
121
|
-
|
122
|
-
if (shouldAddFooter) {
|
123
|
-
items.push({
|
124
|
-
type: 'footer',
|
125
|
-
row: {} as Row<GenericObject>,
|
126
|
-
id: `footer-row`,
|
127
|
-
});
|
128
|
-
}
|
129
|
-
|
130
119
|
return items;
|
131
120
|
}, [
|
132
121
|
isVirtualized,
|
@@ -170,11 +159,10 @@ export const AdvancedTableProvider = ({ children, ...props }: {
|
|
170
159
|
useEffect(() => {
|
171
160
|
if (isVirtualized && virtualizer && table && containerRef.current) {
|
172
161
|
// Force recalculation of all virtual items
|
173
|
-
virtualizer.setOptions({
|
174
|
-
...virtualizer.options,
|
175
|
-
count: flattenedItems.length,
|
176
|
-
});
|
177
162
|
virtualizer.measure();
|
163
|
+
|
164
|
+
// Reset scroll position when sorting changes
|
165
|
+
containerRef.current.scrollTop = 0;
|
178
166
|
}
|
179
167
|
}, [
|
180
168
|
isVirtualized,
|
@@ -182,8 +170,7 @@ export const AdvancedTableProvider = ({ children, ...props }: {
|
|
182
170
|
table,
|
183
171
|
containerRef,
|
184
172
|
JSON.stringify(table?.getState().sorting || []),
|
185
|
-
JSON.stringify(table?.getState().expanded || {})
|
186
|
-
flattenedItems.length,
|
173
|
+
JSON.stringify(table?.getState().expanded || {})
|
187
174
|
]);
|
188
175
|
|
189
176
|
const contextValue = {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useCallback, useEffect
|
1
|
+
import { useCallback, useEffect } from 'react';
|
2
2
|
import { Row, RowPinningState } from "@tanstack/react-table";
|
3
3
|
import { GenericObject } from "../../types";
|
4
4
|
import { updateExpandAndCollapseState } from "../Utilities/ExpansionControlHelpers";
|
@@ -19,21 +19,13 @@ export function useTableActions({
|
|
19
19
|
onRowSelectionChange
|
20
20
|
}: UseTableActionsProps) {
|
21
21
|
|
22
|
-
// State to achieve 1 second delay before fetching more rows
|
23
|
-
const [bottomReached, setBottomReached] = useState(false)
|
24
|
-
const bottomTimeout = useRef<NodeJS.Timeout | null>(null)
|
25
|
-
|
26
22
|
// Handle expand/collapse
|
27
23
|
const handleExpandOrCollapse = useCallback(async (row: Row<GenericObject>) => {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
undefined
|
34
|
-
)
|
35
|
-
|
36
|
-
setExpanded(updatedExpandedState)
|
24
|
+
onToggleExpansionClick && onToggleExpansionClick(row);
|
25
|
+
const expandedState = expanded;
|
26
|
+
const targetParent = row?.parentId;
|
27
|
+
const updatedRows = await updateExpandAndCollapseState(table.getRowModel(), expandedState, targetParent, undefined);
|
28
|
+
setExpanded(updatedRows);
|
37
29
|
}, [expanded, setExpanded, onToggleExpansionClick, table]);
|
38
30
|
|
39
31
|
// Handle pagination
|
@@ -43,32 +35,20 @@ export function useTableActions({
|
|
43
35
|
|
44
36
|
// Handle scroll detection for infinite scroll/virtualization
|
45
37
|
const fetchMoreOnBottomReached = useCallback((
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
containerRefElement: HTMLDivElement | null,
|
39
|
+
fetchNextPage: () => void,
|
40
|
+
isFetching: boolean,
|
41
|
+
totalFetched: number,
|
42
|
+
totalDBRowCount: number
|
51
43
|
) => {
|
52
|
-
if (
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if (!bottomReached) {
|
58
|
-
setBottomReached(true)
|
59
|
-
bottomTimeout.current = setTimeout(() => {
|
60
|
-
fetchNextPage()
|
61
|
-
setBottomReached(false)
|
62
|
-
}, 1000)
|
63
|
-
}
|
64
|
-
} else {
|
65
|
-
setBottomReached(false)
|
66
|
-
if (bottomTimeout.current) {
|
67
|
-
clearTimeout(bottomTimeout.current)
|
68
|
-
bottomTimeout.current = null
|
44
|
+
if (containerRefElement) {
|
45
|
+
const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
|
46
|
+
// If user scrolls near bottom, fetch more data
|
47
|
+
if (scrollHeight - scrollTop - clientHeight < 500 && !isFetching && totalFetched < totalDBRowCount) {
|
48
|
+
fetchNextPage();
|
69
49
|
}
|
70
50
|
}
|
71
|
-
},[
|
51
|
+
}, []);
|
72
52
|
|
73
53
|
// Update selection state
|
74
54
|
useEffect(() => {
|
@@ -16,7 +16,6 @@ type TableBodyProps = {
|
|
16
16
|
dark?: boolean
|
17
17
|
id?: string
|
18
18
|
subRowHeaders?: string[]
|
19
|
-
isFetching: boolean
|
20
19
|
}
|
21
20
|
|
22
21
|
export const TableBody = ({
|
@@ -25,7 +24,6 @@ export const TableBody = ({
|
|
25
24
|
dark = false,
|
26
25
|
id,
|
27
26
|
subRowHeaders,
|
28
|
-
isFetching,
|
29
27
|
...props
|
30
28
|
}: TableBodyProps) => {
|
31
29
|
|
@@ -65,7 +63,6 @@ export const TableBody = ({
|
|
65
63
|
// Virtualized table view
|
66
64
|
<VirtualizedTableView
|
67
65
|
collapsibleTrail={collapsibleTrail}
|
68
|
-
isFetching={isFetching}
|
69
66
|
subRowHeaders={subRowHeaders}
|
70
67
|
/>
|
71
68
|
) : (
|
@@ -40,13 +40,9 @@ export const TableHeader = ({
|
|
40
40
|
showActionsBar,
|
41
41
|
selectableRows,
|
42
42
|
responsive,
|
43
|
-
headerRef
|
44
|
-
virtualizedRows,
|
45
|
-
enableVirtualization,
|
43
|
+
headerRef
|
46
44
|
} = useContext(AdvancedTableContext)
|
47
45
|
|
48
|
-
const isVirtualized = virtualizedRows || enableVirtualization;
|
49
|
-
|
50
46
|
const classes = classnames(
|
51
47
|
buildCss("pb_advanced_table_header"),
|
52
48
|
globalProps(props),
|
@@ -61,93 +57,46 @@ export const TableHeader = ({
|
|
61
57
|
`${isChrome() ? "chrome-styles" : ""}`,
|
62
58
|
`${responsive === "scroll" && "pinned-left"}`,
|
63
59
|
);
|
64
|
-
|
65
|
-
const renderRegularTableHeader = () => (
|
66
|
-
<thead className={classes}
|
67
|
-
id={id}
|
68
|
-
>
|
69
|
-
{table.getHeaderGroups().map((headerGroup: HeaderGroup<GenericObject>, index: number) => (
|
70
|
-
<tr
|
71
|
-
key={`${headerGroup.id}-headerGroup`}
|
72
|
-
ref={index === 0 ? headerRef : null}
|
73
|
-
>
|
74
|
-
{!hasAnySubRows && selectableRows && (
|
75
|
-
<th className={customCellClassnames}>
|
76
|
-
<Checkbox
|
77
|
-
checked={table?.getIsAllRowsSelected()}
|
78
|
-
indeterminate={table?.getIsSomeRowsSelected()}
|
79
|
-
onChange={table?.getToggleAllRowsSelectedHandler()}
|
80
|
-
/>
|
81
|
-
</th>
|
82
|
-
)}
|
83
|
-
{headerGroup.headers.map(header => {
|
84
|
-
const isPinnedLeft = columnPinning.left.includes(header.id)
|
85
|
-
return (
|
86
|
-
<TableHeaderCell
|
87
|
-
enableSorting={enableSorting}
|
88
|
-
enableToggleExpansion={enableToggleExpansion}
|
89
|
-
handleExpandOrCollapse={handleExpandOrCollapse}
|
90
|
-
header={header}
|
91
|
-
headerChildren={children}
|
92
|
-
isPinnedLeft={isPinnedLeft}
|
93
|
-
key={`${header.id}-header`}
|
94
|
-
loading={loading}
|
95
|
-
sortIcon={sortIcon}
|
96
|
-
table={table}
|
97
|
-
/>
|
98
|
-
)
|
99
|
-
})}
|
100
|
-
</tr>
|
101
|
-
))}
|
102
|
-
</thead>
|
103
|
-
);
|
104
|
-
|
105
|
-
const renderVirtualizedTableHeader = () => (
|
106
|
-
<thead
|
107
|
-
className={classes}
|
108
|
-
data-virtualized="true"
|
109
|
-
id={id}
|
110
|
-
>
|
111
|
-
{table.getHeaderGroups().map((headerGroup: HeaderGroup<GenericObject>, index: number) => (
|
112
|
-
<tr
|
113
|
-
className="virtualized-header-row-header"
|
114
|
-
key={`${headerGroup.id}-headerGroup-virtualized`}
|
115
|
-
ref={index === 0 ? headerRef : null}
|
116
|
-
>
|
117
|
-
{!hasAnySubRows && selectableRows && (
|
118
|
-
<th className={classnames(customCellClassnames, "virtualized-header-cell")}>
|
119
|
-
<Checkbox
|
120
|
-
checked={table?.getIsAllRowsSelected()}
|
121
|
-
indeterminate={table?.getIsSomeRowsSelected()}
|
122
|
-
onChange={table?.getToggleAllRowsSelectedHandler()}
|
123
|
-
/>
|
124
|
-
</th>
|
125
|
-
)}
|
126
|
-
{headerGroup.headers.map(header => {
|
127
|
-
const isPinnedLeft = columnPinning.left.includes(header.id)
|
128
|
-
return (
|
129
|
-
<TableHeaderCell
|
130
|
-
enableSorting={enableSorting}
|
131
|
-
enableToggleExpansion={enableToggleExpansion}
|
132
|
-
handleExpandOrCollapse={handleExpandOrCollapse}
|
133
|
-
header={header}
|
134
|
-
headerChildren={children}
|
135
|
-
isPinnedLeft={isPinnedLeft}
|
136
|
-
isVirtualized
|
137
|
-
key={`${header.id}-header-virtualized`}
|
138
|
-
loading={loading}
|
139
|
-
sortIcon={sortIcon}
|
140
|
-
table={table}
|
141
|
-
/>
|
142
|
-
)
|
143
|
-
})}
|
144
|
-
</tr>
|
145
|
-
))}
|
146
|
-
</thead>
|
147
|
-
);
|
148
60
|
return (
|
149
|
-
<>
|
150
|
-
{
|
61
|
+
<>
|
62
|
+
<thead className={classes}
|
63
|
+
id={id}
|
64
|
+
>
|
65
|
+
{/* Get the header groups (only one in this example) */}
|
66
|
+
{table.getHeaderGroups().map((headerGroup: HeaderGroup<GenericObject>, index: number) => (
|
67
|
+
<tr
|
68
|
+
key={`${headerGroup.id}-headerGroup`}
|
69
|
+
ref={index === 0 ? headerRef : null}
|
70
|
+
>
|
71
|
+
{!hasAnySubRows && selectableRows && (
|
72
|
+
<th className={customCellClassnames}>
|
73
|
+
<Checkbox
|
74
|
+
checked={table?.getIsAllRowsSelected()}
|
75
|
+
indeterminate={table?.getIsSomeRowsSelected()}
|
76
|
+
onChange={table?.getToggleAllRowsSelectedHandler()}
|
77
|
+
/>
|
78
|
+
</th>
|
79
|
+
)}
|
80
|
+
{headerGroup.headers.map(header => {
|
81
|
+
const isPinnedLeft = columnPinning.left.includes(header.id)
|
82
|
+
return (
|
83
|
+
<TableHeaderCell
|
84
|
+
enableSorting={enableSorting}
|
85
|
+
enableToggleExpansion={enableToggleExpansion}
|
86
|
+
handleExpandOrCollapse={handleExpandOrCollapse}
|
87
|
+
header={header}
|
88
|
+
headerChildren={children}
|
89
|
+
isPinnedLeft={isPinnedLeft}
|
90
|
+
key={`${header.id}-header`}
|
91
|
+
loading={loading}
|
92
|
+
sortIcon={sortIcon}
|
93
|
+
table={table}
|
94
|
+
/>
|
95
|
+
)
|
96
|
+
})}
|
97
|
+
</tr>
|
98
|
+
))}
|
99
|
+
</thead>
|
151
100
|
</>
|
152
101
|
)
|
153
102
|
}
|
@@ -57,6 +57,7 @@ export const getVirtualizedContainerStyles = (maxHeight?: string): React.CSSProp
|
|
57
57
|
position: 'absolute',
|
58
58
|
top: 0,
|
59
59
|
left: 0,
|
60
|
+
width: '100%',
|
60
61
|
height: '40px', // Match standard table row height
|
61
62
|
transform: `translateY(${startPosition}px)`,
|
62
63
|
tableLayout: 'fixed',
|
@@ -66,14 +67,12 @@ export const getVirtualizedContainerStyles = (maxHeight?: string): React.CSSProp
|
|
66
67
|
/**
|
67
68
|
* Get height estimates for different row types
|
68
69
|
*/
|
69
|
-
export const getRowHeightEstimate = (rowType: 'header' | 'row' | 'loading'
|
70
|
+
export const getRowHeightEstimate = (rowType: 'header' | 'row' | 'loading') => {
|
70
71
|
switch (rowType) {
|
71
72
|
case 'header':
|
72
73
|
return 40; // Header height
|
73
74
|
case 'loading':
|
74
75
|
return 30; // Loading indicator height
|
75
|
-
case 'footer':
|
76
|
-
return 40
|
77
76
|
case 'row':
|
78
77
|
default:
|
79
78
|
return 40; // Standard row height - match this to your design system
|
@@ -63,30 +63,11 @@
|
|
63
63
|
width: 100%;
|
64
64
|
}
|
65
65
|
|
66
|
-
// Virtualized
|
67
|
-
scrollbar-gutter: stable right-edges;
|
68
|
-
.virtualized-header-row-header {
|
69
|
-
width: 100% !important;
|
70
|
-
.table-header-cells:first-child {
|
71
|
-
min-width: 180px;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
.virtualized-footer {
|
76
|
-
width: 100% !important;
|
77
|
-
td {
|
78
|
-
border-bottom-left-radius: 4px !important;
|
79
|
-
border-bottom-right-radius: 4px !important;
|
80
|
-
display: flex;
|
81
|
-
justify-content: center;
|
82
|
-
align-items: center;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
66
|
+
// Virtualized table styles
|
86
67
|
.virtualized-table-row {
|
87
68
|
display: table !important;
|
88
69
|
table-layout: fixed !important;
|
89
|
-
|
70
|
+
width: 100% !important;
|
90
71
|
|
91
72
|
td {
|
92
73
|
display: table-cell !important;
|
@@ -123,7 +104,7 @@
|
|
123
104
|
|
124
105
|
-ms-overflow-style: none !important;
|
125
106
|
scrollbar-width: none !important;
|
126
|
-
|
107
|
+
}
|
127
108
|
|
128
109
|
|
129
110
|
.row-selection-actions-card {
|
@@ -212,6 +193,7 @@
|
|
212
193
|
|
213
194
|
// Fix virtualized row borders
|
214
195
|
tr.virtualized-table-row {
|
196
|
+
border-bottom: 1px solid $border_light;
|
215
197
|
|
216
198
|
&.bg-silver {
|
217
199
|
td:first-child {
|
@@ -624,16 +606,6 @@
|
|
624
606
|
td.sticky-left {
|
625
607
|
border-right: 1px solid $border_light !important;
|
626
608
|
}
|
627
|
-
// Virtualized Table in Responsive Styles
|
628
|
-
.virtualized-header,
|
629
|
-
.virtualized-header-row-header,
|
630
|
-
.virtualized-table-row,
|
631
|
-
.virtualized-footer {
|
632
|
-
border-right: 1px solid $border_light !important;
|
633
|
-
.table-header-cells:first-child {
|
634
|
-
box-shadow: 0 0 10px 0 rgba($shadow, 0.16) !important;
|
635
|
-
}
|
636
|
-
}
|
637
609
|
}
|
638
610
|
}
|
639
611
|
}
|
@@ -649,23 +621,6 @@
|
|
649
621
|
box-shadow: 0 4px 10px 0 rgba($shadow, 0.16) !important;
|
650
622
|
}
|
651
623
|
|
652
|
-
// For Rails, we can't target the &:last-child since collapsed rows are display: none;
|
653
|
-
// With JS, we add a .last-visible-row class and add rounded corners to bottom row
|
654
|
-
.last-visible-row {
|
655
|
-
td, .pb_table_td {
|
656
|
-
border-width: 0 0 1px 0;
|
657
|
-
|
658
|
-
&:first-child {
|
659
|
-
border-radius: 0 0 0 4px;
|
660
|
-
border-width: 0 0 1px 1px;
|
661
|
-
}
|
662
|
-
&:last-child {
|
663
|
-
border-radius: 0 0 4px 0;
|
664
|
-
border-width: 0 1px 1px 0;
|
665
|
-
}
|
666
|
-
}
|
667
|
-
}
|
668
|
-
|
669
624
|
&.dark {
|
670
625
|
// Override default border color for dark mode
|
671
626
|
--column-border-color: #{$border_dark};
|
@@ -266,29 +266,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
266
266
|
// Visibility flag for action bar
|
267
267
|
const isActionBarVisible = (selectableRows && showActionsBar && selectedRowsLength > 0) || columnVisibilityControl;
|
268
268
|
|
269
|
-
// The actual Main <Table /> element
|
270
|
-
const tableElement = (
|
271
|
-
<Table
|
272
|
-
className={`${loading ? "content-loading" : ""}`}
|
273
|
-
dark={dark}
|
274
|
-
dataTable
|
275
|
-
numberSpacing="tabular"
|
276
|
-
responsive="none"
|
277
|
-
{...tableProps}
|
278
|
-
>
|
279
|
-
{children ? (
|
280
|
-
children
|
281
|
-
) : (
|
282
|
-
<>
|
283
|
-
<TableHeader />
|
284
|
-
<TableBody
|
285
|
-
isFetching={isFetching}
|
286
|
-
/>
|
287
|
-
</>
|
288
|
-
)}
|
289
|
-
</Table>
|
290
|
-
)
|
291
|
-
|
292
269
|
return (
|
293
270
|
<>
|
294
271
|
{/* Top Pagination */}
|
@@ -345,7 +322,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
345
322
|
table={table}
|
346
323
|
tableContainerRef={tableWrapperRef}
|
347
324
|
toggleExpansionIcon={toggleExpansionIcon}
|
348
|
-
totalAvailableCount={fullData.length}
|
349
325
|
virtualizedRows={virtualizedRows}
|
350
326
|
>
|
351
327
|
<React.Fragment>
|
@@ -357,14 +333,24 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
357
333
|
type={columnVisibilityControl ? "column-visibility" : "row-selection"}
|
358
334
|
/>
|
359
335
|
|
360
|
-
{/*
|
361
|
-
|
362
|
-
|
363
|
-
{
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
336
|
+
{/* Main Table */}
|
337
|
+
<Table
|
338
|
+
className={`${loading ? "content-loading" : ""}`}
|
339
|
+
dark={dark}
|
340
|
+
dataTable
|
341
|
+
numberSpacing="tabular"
|
342
|
+
responsive="none"
|
343
|
+
{...tableProps}
|
344
|
+
>
|
345
|
+
{children ? (
|
346
|
+
children
|
347
|
+
) : (
|
348
|
+
<>
|
349
|
+
<TableHeader />
|
350
|
+
<TableBody />
|
351
|
+
</>
|
352
|
+
)}
|
353
|
+
</Table>
|
368
354
|
</React.Fragment>
|
369
355
|
</AdvancedTableProvider>
|
370
356
|
|
@@ -632,23 +632,4 @@ test("columnStyling.cellAlignment sets each <td> align attribute as expected", (
|
|
632
632
|
|
633
633
|
const firstEnrollmentCell = screen.getAllByText("20")[0].closest("td");
|
634
634
|
expect(firstEnrollmentCell).toHaveAttribute("align", "left");
|
635
|
-
});
|
636
|
-
|
637
|
-
test("renders virtualized table rows and header", () => {
|
638
|
-
render(
|
639
|
-
<AdvancedTable
|
640
|
-
columnDefinitions={columnDefinitions}
|
641
|
-
data={{ testid: testId }}
|
642
|
-
tableData={MOCK_DATA_WITH_ID}
|
643
|
-
virtualizedRows
|
644
|
-
/>
|
645
|
-
)
|
646
|
-
|
647
|
-
const kit = screen.getByTestId(testId)
|
648
|
-
|
649
|
-
const virtualizedHeader = kit.querySelector('.virtualized-header-row-header')
|
650
|
-
expect(virtualizedHeader).toBeInTheDocument()
|
651
|
-
|
652
|
-
const virtualizedRows = kit.querySelectorAll('.virtualized-table-row')
|
653
|
-
expect(virtualizedRows.length).toBeLessThan(MOCK_DATA_WITH_ID.length)
|
654
|
-
})
|
635
|
+
});
|
@@ -51,7 +51,7 @@
|
|
51
51
|
]
|
52
52
|
%>
|
53
53
|
|
54
|
-
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions
|
54
|
+
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
|
55
55
|
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
56
56
|
<%= pb_rails("advanced_table/table_body", props: { id: "beta_sort", table_data: @table_data, column_definitions: column_definitions, enable_toggle_expansion: "all" }) %>
|
57
57
|
<% end %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
subrow_headers = ["Quarter", "Month", "Day"]
|
35
35
|
%>
|
36
36
|
|
37
|
-
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions
|
37
|
+
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
|
38
38
|
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
39
39
|
<%= pb_rails("advanced_table/table_body", props: { id: "test_table", table_data: @table_data, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
|
40
40
|
<% end %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.html.erb
CHANGED
@@ -55,4 +55,4 @@
|
|
55
55
|
},
|
56
56
|
] %>
|
57
57
|
|
58
|
-
<%= pb_rails("advanced_table", props: { id: "
|
58
|
+
<%= pb_rails("advanced_table", props: { id: "beta_table_with_muilti_headers", table_data: @table_data, column_definitions: column_definitions, column_group_border_color: "text_lt_default", table_props: { vertical_border: true } }) %>
|
@@ -30,4 +30,4 @@
|
|
30
30
|
}
|
31
31
|
] %>
|
32
32
|
|
33
|
-
<%= pb_rails("advanced_table", props: { id: "
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "beta_table", table_data: @table_data, column_definitions: column_definitions, loading: true }) %>
|