playbook_ui 14.20.0.pre.alpha.PLAY22408048 → 14.20.0.pre.alpha.play2168firstcolumnborderbug7950
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/RegularTableView.tsx +49 -116
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +2 -58
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +4 -16
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +3 -7
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +3 -10
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +0 -61
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +0 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +11 -4
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +6 -10
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +48 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +4 -13
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +58 -17
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +3 -12
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +2 -108
- data/app/pb_kits/playbook/pb_dropdown/index.js +0 -24
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +10 -14
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +15 -26
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +0 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_only_countries.jsx +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -3
- data/app/pb_kits/playbook/pb_popover/index.ts +4 -9
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +51 -3
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +1 -1
- data/dist/chunks/{_typeahead-C0OGBz_9.js → _typeahead-BmOWdDtp.js} +2 -2
- data/dist/chunks/_weekday_stacked-CvcuQyr9.js +45 -0
- data/dist/chunks/{lib-CLDGEByA.js → lib-D5R1BjUn.js} +1 -1
- data/dist/chunks/{pb_form_validation-C-ccDsK6.js → pb_form_validation-BZ2AVAi_.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/version.rb +1 -1
- metadata +6 -15
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows.jsx +0 -57
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_react.md +0 -5
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +0 -1
- data/app/pb_kits/playbook/pb_checkbox/index.js +0 -56
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.jsx +0 -42
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_close_on_select.md +0 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.html.erb +0 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.jsx +0 -15
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.md +0 -1
- data/dist/chunks/_weekday_stacked-BbY_mMKV.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: fcf6c9b4cc1f09fe9f4ad71387108d0a83305a79498d68a455660c8a1d877d9a
|
4
|
+
data.tar.gz: c95645d5f485724ecc9af73bdfd15701be9aac3b11e3626dead28ce4767ec149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46969b38f920b5c13d33d8f2287a56942f8f20f833734a1c282c36cd8328f693ee134a4af557d03d60cd91be39c099c816c088a070f4041cad0ee4a95d16f15
|
7
|
+
data.tar.gz: 05fae68a0a62be4ec28dec7c2d46b8e16f8998309da8064566003b8b7bc9471cef8f36605dbd475627fcadd1c1988d41acd513f356278d0941ab5da354dfafe9
|
@@ -19,71 +19,6 @@ type RegularTableViewProps = {
|
|
19
19
|
subRowHeaders?: string[]
|
20
20
|
}
|
21
21
|
|
22
|
-
// Helper function for Table Rendering
|
23
|
-
const TableCellRenderer = ({
|
24
|
-
row,
|
25
|
-
collapsibleTrail = true,
|
26
|
-
loading = false,
|
27
|
-
stickyLeftColumn,
|
28
|
-
columnPinning
|
29
|
-
}: {
|
30
|
-
row: Row<GenericObject>
|
31
|
-
collapsibleTrail?: boolean
|
32
|
-
loading?: boolean | string
|
33
|
-
stickyLeftColumn?: string[]
|
34
|
-
columnPinning: { left: string[] }
|
35
|
-
}) => {
|
36
|
-
return (
|
37
|
-
<>
|
38
|
-
{row.getVisibleCells().map((cell: Cell<GenericObject, unknown>, i: number) => {
|
39
|
-
const isPinnedLeft = columnPinning.left.includes(cell.column.id);
|
40
|
-
const isLastCell = (() => {
|
41
|
-
const parent = cell.column.parent;
|
42
|
-
if (!parent) {
|
43
|
-
const last = row.getVisibleCells().at(-1);
|
44
|
-
return last?.column.id === cell.column.id;
|
45
|
-
}
|
46
|
-
|
47
|
-
const visibleSiblings = parent.columns.filter(col => col.getIsVisible());
|
48
|
-
return visibleSiblings.at(-1)?.id === cell.column.id;
|
49
|
-
})();
|
50
|
-
|
51
|
-
const { column } = cell;
|
52
|
-
|
53
|
-
return (
|
54
|
-
<td
|
55
|
-
align="right"
|
56
|
-
className={classnames(
|
57
|
-
`${cell.id}-cell position_relative`,
|
58
|
-
isChrome() ? "chrome-styles" : "",
|
59
|
-
isPinnedLeft && 'pinned-left',
|
60
|
-
stickyLeftColumn && stickyLeftColumn.length > 0 && isPinnedLeft && 'sticky-left',
|
61
|
-
isLastCell && 'last-cell',
|
62
|
-
)}
|
63
|
-
key={`${cell.id}-data`}
|
64
|
-
style={{
|
65
|
-
left: isPinnedLeft
|
66
|
-
? i === 1 // Accounting for set min-width for first column
|
67
|
-
? '180px'
|
68
|
-
: `${column.getStart("left")}px`
|
69
|
-
: undefined,
|
70
|
-
}}
|
71
|
-
>
|
72
|
-
{collapsibleTrail && i === 0 && row.depth > 0 && renderCollapsibleTrail(row.depth)}
|
73
|
-
<span id={`${cell.id}-span`}>
|
74
|
-
{loading ? (
|
75
|
-
<LoadingCell />
|
76
|
-
) : (
|
77
|
-
flexRender(cell.column.columnDef.cell, cell.getContext())
|
78
|
-
)}
|
79
|
-
</span>
|
80
|
-
</td>
|
81
|
-
);
|
82
|
-
})}
|
83
|
-
</>
|
84
|
-
)
|
85
|
-
}
|
86
|
-
|
87
22
|
export const RegularTableView = ({
|
88
23
|
collapsibleTrail = true,
|
89
24
|
subRowHeaders,
|
@@ -93,14 +28,11 @@ export const RegularTableView = ({
|
|
93
28
|
handleExpandOrCollapse,
|
94
29
|
inlineRowLoading,
|
95
30
|
loading,
|
31
|
+
responsive,
|
96
32
|
table,
|
97
33
|
selectableRows,
|
98
34
|
hasAnySubRows,
|
99
|
-
stickyLeftColumn
|
100
|
-
pinnedRows,
|
101
|
-
headerHeight,
|
102
|
-
rowHeight,
|
103
|
-
sampleRowRef,
|
35
|
+
stickyLeftColumn
|
104
36
|
} = useContext(AdvancedTableContext)
|
105
37
|
|
106
38
|
|
@@ -118,44 +50,9 @@ export const RegularTableView = ({
|
|
118
50
|
const columnPinning = table.getState().columnPinning || { left: [] };
|
119
51
|
const columnDefinitions = table.options.meta?.columnDefinitions || [];
|
120
52
|
|
121
|
-
// Row pinning
|
122
|
-
function PinnedRow({ row }: { row: Row<any> }) {
|
123
|
-
return (
|
124
|
-
<tr
|
125
|
-
className={classnames(
|
126
|
-
`pinned-row`,
|
127
|
-
)}
|
128
|
-
style={{
|
129
|
-
backgroundColor: 'white',
|
130
|
-
position: 'sticky',
|
131
|
-
top:
|
132
|
-
row.getIsPinned() === 'top'
|
133
|
-
? `${row.getPinnedIndex() * rowHeight + headerHeight}px`
|
134
|
-
: undefined,
|
135
|
-
zIndex: '3'
|
136
|
-
}}
|
137
|
-
>
|
138
|
-
<TableCellRenderer
|
139
|
-
collapsibleTrail={collapsibleTrail}
|
140
|
-
columnPinning={columnPinning}
|
141
|
-
loading={loading}
|
142
|
-
row={row}
|
143
|
-
stickyLeftColumn={stickyLeftColumn}
|
144
|
-
/>
|
145
|
-
</tr>
|
146
|
-
)
|
147
|
-
}
|
148
|
-
|
149
|
-
const totalRows = pinnedRows ? table.getCenterRows() : table.getRowModel().rows
|
150
|
-
|
151
53
|
return (
|
152
54
|
<>
|
153
|
-
{
|
154
|
-
<PinnedRow key={row.id}
|
155
|
-
row={row}
|
156
|
-
/>
|
157
|
-
))}
|
158
|
-
{totalRows.map((row: Row<GenericObject>, rowIndex: number) => {
|
55
|
+
{table.getRowModel().rows.map((row: Row<GenericObject>) => {
|
159
56
|
const isExpandable = row.getIsExpanded();
|
160
57
|
const isFirstChildofSubrow = row.depth > 0 && row.index === 0;
|
161
58
|
const rowHasNoChildren = row.original?.children && !row.original.children.length ? true : false;
|
@@ -163,7 +60,6 @@ export const RegularTableView = ({
|
|
163
60
|
const isDataLoading = isExpandable && (inlineRowLoading && rowHasNoChildren) && (row.depth < columnDefinitions[0]?.cellAccessors?.length);
|
164
61
|
const rowBackground = isExpandable && ((!inlineRowLoading && row.getCanExpand()) || (inlineRowLoading && rowHasNoChildren));
|
165
62
|
const rowColor = row.getIsSelected() ? "bg-row-selection" : rowBackground ? "bg-silver" : "bg-white";
|
166
|
-
const isFirstRegularRow = rowIndex === 0 && !row.getIsPinned();
|
167
63
|
|
168
64
|
return (
|
169
65
|
<React.Fragment key={`${row.index}-${row.id}-${row.depth}-row`}>
|
@@ -181,7 +77,6 @@ export const RegularTableView = ({
|
|
181
77
|
<tr
|
182
78
|
className={`${rowColor} ${row.depth > 0 ? `depth-sub-row-${row.depth}` : ""}`}
|
183
79
|
id={`${row.index}-${row.id}-${row.depth}-row`}
|
184
|
-
ref={isFirstRegularRow ? sampleRowRef : null}
|
185
80
|
>
|
186
81
|
{/* Render custom checkbox column when we want selectableRows for non-expanding tables */}
|
187
82
|
{selectableRows && !hasAnySubRows && (
|
@@ -195,13 +90,51 @@ export const RegularTableView = ({
|
|
195
90
|
/>
|
196
91
|
</td>
|
197
92
|
)}
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
93
|
+
|
94
|
+
{row.getVisibleCells().map((cell: Cell<GenericObject, unknown>, i: number) => {
|
95
|
+
const isPinnedLeft = columnPinning.left.includes(cell.column.id);
|
96
|
+
const isLastCell = (() => {
|
97
|
+
const parent = cell.column.parent;
|
98
|
+
if (!parent) {
|
99
|
+
const last = row.getVisibleCells().at(-1);
|
100
|
+
return last?.column.id === cell.column.id;
|
101
|
+
}
|
102
|
+
|
103
|
+
const visibleSiblings = parent.columns.filter(col => col.getIsVisible());
|
104
|
+
return visibleSiblings.at(-1)?.id === cell.column.id;
|
105
|
+
})();
|
106
|
+
|
107
|
+
const { column } = cell;
|
108
|
+
return (
|
109
|
+
<td
|
110
|
+
align="right"
|
111
|
+
className={classnames(
|
112
|
+
`${cell.id}-cell position_relative`,
|
113
|
+
isChrome() ? "chrome-styles" : "",
|
114
|
+
isPinnedLeft && 'pinned-left',
|
115
|
+
stickyLeftColumn && stickyLeftColumn.length > 0 && isPinnedLeft && 'sticky-left',
|
116
|
+
isLastCell && 'last-cell',
|
117
|
+
)}
|
118
|
+
key={`${cell.id}-data`}
|
119
|
+
style={{
|
120
|
+
left: isPinnedLeft
|
121
|
+
? i === 1 //Accounting for set min-width for first column
|
122
|
+
? '180px'
|
123
|
+
: `${column.getStart("left")}px`
|
124
|
+
: undefined,
|
125
|
+
}}
|
126
|
+
>
|
127
|
+
{collapsibleTrail && i === 0 && row.depth > 0 && renderCollapsibleTrail(row.depth)}
|
128
|
+
<span id={`${cell.id}-span`}>
|
129
|
+
{loading ? (
|
130
|
+
<LoadingCell />
|
131
|
+
) : (
|
132
|
+
flexRender(cell.column.columnDef.cell, cell.getContext())
|
133
|
+
)}
|
134
|
+
</span>
|
135
|
+
</td>
|
136
|
+
);
|
137
|
+
})}
|
205
138
|
</tr>
|
206
139
|
|
207
140
|
{/* Display LoadingInline if Row Data is querying and there are no children already */}
|
@@ -221,4 +154,4 @@ export const RegularTableView = ({
|
|
221
154
|
);
|
222
155
|
}
|
223
156
|
|
224
|
-
export default RegularTableView;
|
157
|
+
export default RegularTableView;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { createContext, useRef, useMemo, useEffect
|
1
|
+
import React, { createContext, useRef, useMemo, useEffect } from 'react';
|
2
2
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
3
3
|
|
4
4
|
import { Row } from "@tanstack/react-table";
|
@@ -23,54 +23,6 @@ export const AdvancedTableProvider = ({ children, ...props }: {
|
|
23
23
|
|
24
24
|
const table = props.table;
|
25
25
|
const isVirtualized = props.virtualizedRows || props.enableVirtualization;
|
26
|
-
|
27
|
-
// Pinned Row: height calculations for Header and Row
|
28
|
-
const headerRef = useRef(null);
|
29
|
-
const sampleRowRef = useRef(null);
|
30
|
-
|
31
|
-
const [headerHeight, setHeaderHeight] = useState(44);
|
32
|
-
const [rowHeight, setRowHeight] = useState(38);
|
33
|
-
|
34
|
-
const measureHeights = useCallback(() => {
|
35
|
-
if (headerRef.current) {
|
36
|
-
const headerRect = headerRef.current.getBoundingClientRect();
|
37
|
-
if (headerRect.height > 0) {
|
38
|
-
setHeaderHeight(headerRect.height);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
if (sampleRowRef.current) {
|
42
|
-
const rowRect = sampleRowRef.current.getBoundingClientRect();
|
43
|
-
if (rowRect.height > 0) {
|
44
|
-
setRowHeight(rowRect.height);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}, []);
|
48
|
-
|
49
|
-
useEffect(() => {
|
50
|
-
const resizeObserver = new ResizeObserver(() => {
|
51
|
-
measureHeights();
|
52
|
-
});
|
53
|
-
|
54
|
-
if (headerRef.current) {
|
55
|
-
resizeObserver.observe(headerRef.current);
|
56
|
-
}
|
57
|
-
|
58
|
-
if (sampleRowRef.current) {
|
59
|
-
resizeObserver.observe(sampleRowRef.current);
|
60
|
-
}
|
61
|
-
|
62
|
-
const timeoutId = setTimeout(measureHeights, 100);
|
63
|
-
|
64
|
-
return () => {
|
65
|
-
resizeObserver.disconnect();
|
66
|
-
clearTimeout(timeoutId);
|
67
|
-
};
|
68
|
-
}, [measureHeights]);
|
69
|
-
|
70
|
-
useEffect(() => {
|
71
|
-
measureHeights();
|
72
|
-
}, [table?.getRowModel().rows.length, measureHeights]);
|
73
|
-
|
74
26
|
|
75
27
|
// Create a flattened data array that includes ALL components for virtualization
|
76
28
|
const flattenedItems = useMemo(() => {
|
@@ -180,15 +132,7 @@ export const AdvancedTableProvider = ({ children, ...props }: {
|
|
180
132
|
virtualizer: isVirtualized ? virtualizer : null,
|
181
133
|
flattenedItems,
|
182
134
|
virtualizedRows: isVirtualized,
|
183
|
-
enableVirtualization: isVirtualized
|
184
|
-
rowPinning: props.rowPinning,
|
185
|
-
setRowPinning: props.setRowPinning,
|
186
|
-
keepPinnedRows: props.keepPinnedRows,
|
187
|
-
headerHeight,
|
188
|
-
rowHeight,
|
189
|
-
headerRef,
|
190
|
-
sampleRowRef,
|
191
|
-
measureHeights,
|
135
|
+
enableVirtualization: isVirtualized
|
192
136
|
};
|
193
137
|
|
194
138
|
return (
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useCallback, useEffect } from 'react';
|
2
|
-
import { Row
|
2
|
+
import { Row } from "@tanstack/react-table";
|
3
3
|
import { GenericObject } from "../../types";
|
4
4
|
import { updateExpandAndCollapseState } from "../Utilities/ExpansionControlHelpers";
|
5
5
|
|
@@ -6,8 +6,7 @@ import {
|
|
6
6
|
getPaginationRowModel,
|
7
7
|
getSortedRowModel,
|
8
8
|
RowSelectionState,
|
9
|
-
Row
|
10
|
-
RowPinningState
|
9
|
+
Row
|
11
10
|
} from "@tanstack/react-table";
|
12
11
|
import { GenericObject } from "../../types";
|
13
12
|
import { createColumnHelper } from "@tanstack/react-table";
|
@@ -24,14 +23,11 @@ interface UseTableStateProps {
|
|
24
23
|
loading?: boolean | string;
|
25
24
|
pagination?: boolean;
|
26
25
|
paginationProps?: GenericObject;
|
27
|
-
pinnedRows?: {
|
28
|
-
value?: RowPinningState;
|
29
|
-
onChange?: (value: RowPinningState) => void;
|
30
|
-
};
|
31
26
|
virtualizedRows?: boolean;
|
32
27
|
tableOptions?: GenericObject;
|
33
28
|
onRowSelectionChange?: (arg: RowSelectionState) => void;
|
34
29
|
columnVisibilityControl?: GenericObject;
|
30
|
+
|
35
31
|
}
|
36
32
|
|
37
33
|
export function useTableState({
|
@@ -47,24 +43,18 @@ export function useTableState({
|
|
47
43
|
paginationProps,
|
48
44
|
virtualizedRows = false,
|
49
45
|
tableOptions,
|
50
|
-
columnVisibilityControl
|
51
|
-
pinnedRows,
|
46
|
+
columnVisibilityControl
|
52
47
|
}: UseTableStateProps) {
|
53
48
|
// Create a local state for expanded and setExpanded if expandedControl not used
|
54
49
|
const [localExpanded, setLocalExpanded] = useState({});
|
55
50
|
const [loadingStateRowCount, setLoadingStateRowCount] = useState(initialLoadingRowsCount);
|
56
51
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
57
52
|
const [localColumnVisibility, setLocalColumnVisibility] = useState({});
|
58
|
-
const [localRowPinning, setLocalRowPinning] = useState<RowPinningState>({
|
59
|
-
top: [],
|
60
|
-
});
|
61
53
|
// Determine whether to use the prop or the local state
|
62
54
|
const expanded = expandedControl ? expandedControl.value : localExpanded;
|
63
55
|
const setExpanded = expandedControl ? expandedControl.onChange : setLocalExpanded;
|
64
56
|
const columnVisibility = (columnVisibilityControl && columnVisibilityControl.value) ? columnVisibilityControl.value : localColumnVisibility;
|
65
57
|
const setColumnVisibility = (columnVisibilityControl && columnVisibilityControl.onChange) ? columnVisibilityControl.onChange : setLocalColumnVisibility;
|
66
|
-
const rowPinning = pinnedRows && pinnedRows.value || localRowPinning;
|
67
|
-
const setRowPinning = (pinnedRows && pinnedRows.onChange) ? pinnedRows.onChange : setLocalRowPinning;
|
68
58
|
|
69
59
|
// Virtualized data handling (chunked loading)
|
70
60
|
const fetchSize = 20; // Number of rows per "page"
|
@@ -125,7 +115,6 @@ export function useTableState({
|
|
125
115
|
...(sortControl && { sorting }),
|
126
116
|
...(selectableRows && { rowSelection }),
|
127
117
|
...(columnVisibility && { columnVisibility }),
|
128
|
-
...(pinnedRows && { rowPinning }),
|
129
118
|
},
|
130
119
|
}), [
|
131
120
|
expanded,
|
@@ -134,7 +123,6 @@ export function useTableState({
|
|
134
123
|
selectableRows,
|
135
124
|
rowSelection,
|
136
125
|
columnVisibility,
|
137
|
-
rowPinning,
|
138
126
|
]);
|
139
127
|
|
140
128
|
// Pagination configuration
|
@@ -165,7 +153,7 @@ export function useTableState({
|
|
165
153
|
enableSortingRemoval: false,
|
166
154
|
sortDescFirst: true,
|
167
155
|
onRowSelectionChange: setRowSelection,
|
168
|
-
getRowId:
|
156
|
+
getRowId: selectableRows ? row => row.id : undefined,
|
169
157
|
onColumnVisibilityChange: setColumnVisibility,
|
170
158
|
meta: {
|
171
159
|
columnDefinitions
|
@@ -39,8 +39,7 @@ export const TableHeader = ({
|
|
39
39
|
hasAnySubRows,
|
40
40
|
showActionsBar,
|
41
41
|
selectableRows,
|
42
|
-
responsive
|
43
|
-
headerRef
|
42
|
+
responsive
|
44
43
|
} = useContext(AdvancedTableContext)
|
45
44
|
|
46
45
|
const classes = classnames(
|
@@ -63,11 +62,8 @@ export const TableHeader = ({
|
|
63
62
|
id={id}
|
64
63
|
>
|
65
64
|
{/* Get the header groups (only one in this example) */}
|
66
|
-
{table.getHeaderGroups().map((headerGroup: HeaderGroup<GenericObject
|
67
|
-
<tr
|
68
|
-
key={`${headerGroup.id}-headerGroup`}
|
69
|
-
ref={index === 0 ? headerRef : null}
|
70
|
-
>
|
65
|
+
{table.getHeaderGroups().map((headerGroup: HeaderGroup<GenericObject>) => (
|
66
|
+
<tr key={`${headerGroup.id}-headerGroup`}>
|
71
67
|
{!hasAnySubRows && selectableRows && (
|
72
68
|
<th className={customCellClassnames}>
|
73
69
|
<Checkbox
|
@@ -588,11 +588,6 @@
|
|
588
588
|
}
|
589
589
|
}
|
590
590
|
|
591
|
-
// Row Pinning - additional inline styles in RegularTableView.tsx
|
592
|
-
.pinned-row {
|
593
|
-
box-shadow: 0 4px 10px 0 rgba($shadow, 0.16) !important;
|
594
|
-
}
|
595
|
-
|
596
591
|
&.dark {
|
597
592
|
// Override default border color for dark mode
|
598
593
|
--column-border-color: #{$border_dark};
|
@@ -2,7 +2,7 @@ import React, { useRef, useEffect, useState, useCallback } from "react";
|
|
2
2
|
import classnames from "classnames";
|
3
3
|
|
4
4
|
import { GenericObject } from "../types";
|
5
|
-
import { Row, RowSelectionState
|
5
|
+
import { Row, RowSelectionState } from "@tanstack/react-table";
|
6
6
|
|
7
7
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
8
8
|
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
@@ -51,11 +51,7 @@ type AdvancedTableProps = {
|
|
51
51
|
onRowToggleClick?: (arg: Row<GenericObject>) => void
|
52
52
|
onToggleExpansionClick?: (arg: Row<GenericObject>) => void
|
53
53
|
pagination?: boolean,
|
54
|
-
paginationProps?: GenericObject
|
55
|
-
pinnedRows?: {
|
56
|
-
value?: RowPinningState;
|
57
|
-
onChange?: (value: RowPinningState) => void;
|
58
|
-
};
|
54
|
+
paginationProps?: GenericObject
|
59
55
|
responsive?: "scroll" | "none",
|
60
56
|
selectableRows?: boolean,
|
61
57
|
showActionsBar?: boolean,
|
@@ -95,7 +91,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
95
91
|
onToggleExpansionClick,
|
96
92
|
pagination = false,
|
97
93
|
paginationProps,
|
98
|
-
pinnedRows,
|
99
94
|
responsive = "scroll",
|
100
95
|
showActionsBar = true,
|
101
96
|
selectableRows,
|
@@ -141,7 +136,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
141
136
|
tableOptions,
|
142
137
|
onRowSelectionChange,
|
143
138
|
columnVisibilityControl,
|
144
|
-
pinnedRows,
|
145
139
|
});
|
146
140
|
|
147
141
|
// Initialize table actions
|
@@ -247,7 +241,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
247
241
|
maxHeight ? `advanced-table-max-height-${maxHeight}` : '',
|
248
242
|
{
|
249
243
|
'advanced-table-fullscreen': isFullscreen,
|
250
|
-
'advanced-table-allow-fullscreen': allowFullScreen
|
244
|
+
'advanced-table-allow-fullscreen': allowFullScreen
|
251
245
|
},
|
252
246
|
{'advanced-table-sticky-left-columns': stickyLeftColumn && stickyLeftColumn.length > 0},
|
253
247
|
columnGroupBorderColor ? `column-group-border-${columnGroupBorderColor}` : '',
|
@@ -308,7 +302,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
308
302
|
isFullscreen={isFullscreen}
|
309
303
|
loading={loading}
|
310
304
|
onExpandByDepthClick={onExpandByDepthClick}
|
311
|
-
pinnedRows={pinnedRows}
|
312
305
|
responsive={responsive}
|
313
306
|
selectableRows={selectableRows}
|
314
307
|
setExpanded={setExpanded}
|
@@ -3,12 +3,6 @@ import { render, screen, waitFor } from "../utilities/test-utils"
|
|
3
3
|
|
4
4
|
import { AdvancedTable, Pill } from "playbook-ui"
|
5
5
|
|
6
|
-
global.ResizeObserver = class {
|
7
|
-
observe() {}
|
8
|
-
unobserve() {}
|
9
|
-
disconnect() {}
|
10
|
-
};
|
11
|
-
|
12
6
|
const MOCK_DATA = [
|
13
7
|
{
|
14
8
|
year: "2021",
|
@@ -78,36 +72,6 @@ const MOCK_DATA_LOADING = [
|
|
78
72
|
},
|
79
73
|
]
|
80
74
|
|
81
|
-
const MOCK_DATA_WITH_ID = [
|
82
|
-
{
|
83
|
-
id: "1",
|
84
|
-
year: "2021",
|
85
|
-
quarter: null,
|
86
|
-
month: null,
|
87
|
-
day: null,
|
88
|
-
newEnrollments: "20",
|
89
|
-
scheduledMeetings: "10",
|
90
|
-
},
|
91
|
-
{
|
92
|
-
id: "2",
|
93
|
-
year: "2022",
|
94
|
-
quarter: null,
|
95
|
-
month: null,
|
96
|
-
day: null,
|
97
|
-
newEnrollments: "25",
|
98
|
-
scheduledMeetings: "15",
|
99
|
-
},
|
100
|
-
{
|
101
|
-
id: "3",
|
102
|
-
year: "2023",
|
103
|
-
quarter: null,
|
104
|
-
month: null,
|
105
|
-
day: null,
|
106
|
-
newEnrollments: "30",
|
107
|
-
scheduledMeetings: "20",
|
108
|
-
},
|
109
|
-
]
|
110
|
-
|
111
75
|
const columnDefinitions = [
|
112
76
|
{
|
113
77
|
accessor: "year",
|
@@ -548,28 +512,3 @@ test("allowFullScreen prop adds fullscreen class", () => {
|
|
548
512
|
const tableContainer = screen.getByRole("table").closest("div")
|
549
513
|
expect(tableContainer).toHaveClass("advanced-table-allow-fullscreen")
|
550
514
|
})
|
551
|
-
|
552
|
-
test("pinnedRows prop renders pinned rows at top", () => {
|
553
|
-
const pinnedRowsControl = {
|
554
|
-
value: { top: ["1", "3"] },
|
555
|
-
onChange: jest.fn()
|
556
|
-
}
|
557
|
-
|
558
|
-
render(
|
559
|
-
<AdvancedTable
|
560
|
-
columnDefinitions={columnDefinitions}
|
561
|
-
data={{ testid: testId }}
|
562
|
-
pinnedRows={pinnedRowsControl}
|
563
|
-
tableData={MOCK_DATA_WITH_ID}
|
564
|
-
/>
|
565
|
-
)
|
566
|
-
|
567
|
-
const kit = screen.getByTestId(testId)
|
568
|
-
const pinnedRows = kit.querySelectorAll(".pinned-row")
|
569
|
-
|
570
|
-
expect(pinnedRows).toHaveLength(2)
|
571
|
-
|
572
|
-
const firstPinnedRow = pinnedRows[0]
|
573
|
-
expect(firstPinnedRow).toHaveStyle("position: sticky")
|
574
|
-
expect(firstPinnedRow).toHaveStyle("background-color: white")
|
575
|
-
})
|
@@ -30,4 +30,4 @@
|
|
30
30
|
}
|
31
31
|
] %>
|
32
32
|
|
33
|
-
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: {
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { container: false }}) %>
|
@@ -52,5 +52,4 @@ examples:
|
|
52
52
|
- advanced_table_column_visibility: Column Visibility Control
|
53
53
|
- advanced_table_column_visibility_with_state: Column Visibility Control With State
|
54
54
|
- advanced_table_column_visibility_custom: Column Visibility Control with Custom Dropdown
|
55
|
-
- advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
|
56
|
-
- advanced_table_pinned_rows: Pinned Rows
|
55
|
+
- advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
|
@@ -31,5 +31,4 @@ export { default as AdvancedTableColumnBorderColor} from './_advanced_table_colu
|
|
31
31
|
export { default as AdvancedTableColumnVisibility } from './_advanced_table_column_visibility.jsx'
|
32
32
|
export { default as AdvancedTableColumnVisibilityCustom } from './_advanced_table_column_visibility_custom.jsx'
|
33
33
|
export { default as AdvancedTableColumnVisibilityMulti } from './_advanced_table_column_visibility_multi.jsx'
|
34
|
-
export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
|
35
|
-
export { default as AdvancedTablePinnedRows } from './_advanced_table_pinned_rows.jsx'
|
34
|
+
export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
|
@@ -569,8 +569,6 @@ class PbAdvancedTableActionBar {
|
|
569
569
|
actionBar.style.height = 'auto';
|
570
570
|
actionBar.style.overflow = 'visible';
|
571
571
|
actionBar.style.opacity = '1';
|
572
|
-
actionBar.style.transitionProperty = 'all';
|
573
|
-
actionBar.style.transitionTimingFunction = 'ease-in-out';
|
574
572
|
actionBar.classList.remove("p_none");
|
575
573
|
actionBar.classList.add("p_xs", "is-visible", "show-action-card");
|
576
574
|
|
@@ -1,9 +1,16 @@
|
|
1
1
|
<%= pb_content_tag(:label) do %>
|
2
2
|
<%= content.presence || object.input %>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
<% if object.indeterminate %>
|
4
|
+
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_indeterminate">
|
5
|
+
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon", fixed_width: true}) %>
|
6
|
+
<%= pb_rails("icon", props: { icon: "check", classname: "check_icon hidden", fixed_width: true}) %>
|
7
|
+
</span>
|
8
|
+
<% else %>
|
9
|
+
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_checkmark">
|
10
|
+
<%= pb_rails("icon", props: { icon: "check", classname: "check_icon", fixed_width: true}) %>
|
11
|
+
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon hidden", fixed_width: true}) %>
|
12
|
+
</span>
|
13
|
+
<% end %>
|
7
14
|
<span class="pb_checkbox_label">
|
8
15
|
<%= pb_rails("body", props: { status: object.checkbox_label_status, text: object.text, dark: object.dark, margin_right: object.form_spacing ? "xs" : "" }) %>
|
9
16
|
</span>
|
@@ -5,8 +5,7 @@ module Playbook
|
|
5
5
|
class Checkbox < Playbook::KitBase
|
6
6
|
prop :error, type: Playbook::Props::Boolean, default: false
|
7
7
|
prop :checked, type: Playbook::Props::Boolean, default: false
|
8
|
-
prop :
|
9
|
-
prop :indeterminate_parent
|
8
|
+
prop :indeterminate, type: Playbook::Props::Boolean, default: false
|
10
9
|
prop :text
|
11
10
|
prop :value
|
12
11
|
prop :name
|
@@ -20,7 +19,7 @@ module Playbook
|
|
20
19
|
default: false
|
21
20
|
|
22
21
|
def classname
|
23
|
-
generate_classname("pb_checkbox_kit", checked_class) + error_class
|
22
|
+
generate_classname("pb_checkbox_kit", checked_class) + indeterminate_class + error_class
|
24
23
|
end
|
25
24
|
|
26
25
|
def input
|
@@ -31,13 +30,6 @@ module Playbook
|
|
31
30
|
error ? "negative" : nil
|
32
31
|
end
|
33
32
|
|
34
|
-
def data
|
35
|
-
Hash(prop(:data)).merge(
|
36
|
-
pb_checkbox_indeterminate_main: indeterminate_main,
|
37
|
-
pb_checkbox_indeterminate_parent: indeterminate_parent
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
33
|
private
|
42
34
|
|
43
35
|
def error_class
|
@@ -47,6 +39,10 @@ module Playbook
|
|
47
39
|
def checked_class
|
48
40
|
checked ? "on" : "off"
|
49
41
|
end
|
42
|
+
|
43
|
+
def indeterminate_class
|
44
|
+
indeterminate ? " indeterminate" : ""
|
45
|
+
end
|
50
46
|
end
|
51
47
|
end
|
52
48
|
end
|