playbook_ui 15.3.0.pre.alpha.PLAY2565formkitsubmitfix11681 → 15.3.0.pre.alpha.PLAY2569advancedtablecolumnstylingfontcolor11977
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 +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +18 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +71 -14
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +122 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +16 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +6 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +28 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +11 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +9 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_columns_and_header.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading_empty_children.js +42 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +31 -2
- data/app/pb_kits/playbook/pb_background/background.html.erb +10 -2
- data/app/pb_kits/playbook/pb_background/docs/_background_category.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_background.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +11 -30
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +1 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_width.md +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -1
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.md +1 -1
- data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.md +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.html.erb +7 -14
- data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.jsx +6 -15
- data/app/pb_kits/playbook/pb_layout/docs/_layout_collection.md +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_item_spacing.md +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.md +1 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_layout.md +1 -1
- data/app/pb_kits/playbook/pb_pill/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +69 -34
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.jsx +68 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to_react.md +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_popover/popover.test.js +80 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_section_separator/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +29 -0
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_rails.md +1 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_react.md +1 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sm.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.html.erb +63 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.jsx +89 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_rails.md +4 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_react.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +41 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +23 -9
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.html.erb +64 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.jsx +70 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_options.html.erb +67 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.jsx +68 -6
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.md +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -1
- data/dist/chunks/{_line_graph-h5H-imfn.js → _line_graph-CqE0-dq5.js} +1 -1
- data/dist/chunks/_typeahead-3ZAbZUqU.js +6 -0
- data/dist/chunks/{_weekday_stacked-CbCUYuuZ.js → _weekday_stacked-D32ib52e.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- 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 +16 -6
- data/dist/chunks/_typeahead-U8AjZIIW.js +0 -6
- /data/app/pb_kits/playbook/pb_popover/docs/{_popover_append_to.md → _popover_append_to_rails.md} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7027d2274da1d6dfe8a9a052e05a16cc070fbaf06eabfda49503f29921061e1
|
|
4
|
+
data.tar.gz: 2da447f782a24df2caefdc1d1fdfca1d7d00c59b4d183b81019bbd14329e5a42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 676423ddeb1ef4fd2ce294e898b9743737c49653cf20ce175b9030c56aaf9188dce399d0154fb86aeba902069042bdc4d30e346c41ea878fbe9f006363d977e3
|
|
7
|
+
data.tar.gz: d2c1a619d69683cc0f1d8673f6b704cbaa2ad89d0d3520f7288e72129b4136b709acd7b81dc3cfcd968301be5dc3ccf51ecab300251c2f57916aae38d8b2f26d
|
|
@@ -66,6 +66,7 @@ const TableCellRenderer = ({
|
|
|
66
66
|
// Find the “owning” colDefinition by accessor. Needed for multi column logic
|
|
67
67
|
const colDef = findColumnDefByAccessor(columnDefinitions ?? [], column.id)
|
|
68
68
|
const cellAlignment = colDef?.columnStyling?.cellAlignment ?? "right"
|
|
69
|
+
const cellFontColor = colDef?.columnStyling?.fontColor
|
|
69
70
|
const paddingValue = colDef?.columnStyling?.cellPadding ?? customRowStyle?.cellPadding
|
|
70
71
|
const paddingClass = paddingValue ? `p_${paddingValue}` : undefined
|
|
71
72
|
|
|
@@ -88,7 +89,7 @@ const TableCellRenderer = ({
|
|
|
88
89
|
: `${column.getStart("left")}px`
|
|
89
90
|
: undefined,
|
|
90
91
|
backgroundColor: i === 0 && customRowStyle?.backgroundColor,
|
|
91
|
-
color: customRowStyle?.fontColor,
|
|
92
|
+
color: cellFontColor || customRowStyle?.fontColor,
|
|
92
93
|
}}
|
|
93
94
|
>
|
|
94
95
|
{collapsibleTrail && i === 0 && row.depth > 0 && renderCollapsibleTrail(row.depth)}
|
|
@@ -30,6 +30,7 @@ type TableHeaderCellProps = {
|
|
|
30
30
|
headerChildren?: React.ReactNode | React.ReactNode[]
|
|
31
31
|
isPinnedLeft?: boolean
|
|
32
32
|
loading?: boolean
|
|
33
|
+
persistToggleExpansionButton?: boolean
|
|
33
34
|
sortIcon?: string | string[]
|
|
34
35
|
table?: Table<GenericObject>
|
|
35
36
|
} & GlobalProps
|
|
@@ -58,6 +59,7 @@ export const TableHeaderCell = ({
|
|
|
58
59
|
selectableRows,
|
|
59
60
|
hasAnySubRows,
|
|
60
61
|
showActionsBar,
|
|
62
|
+
persistToggleExpansionButton,
|
|
61
63
|
stickyLeftColumn,
|
|
62
64
|
inlineRowLoading,
|
|
63
65
|
isActionBarVisible,
|
|
@@ -220,7 +222,7 @@ const isToggleExpansionEnabled =
|
|
|
220
222
|
/>
|
|
221
223
|
)
|
|
222
224
|
}
|
|
223
|
-
{isToggleExpansionEnabled &&
|
|
225
|
+
{isToggleExpansionEnabled && ((hasAnySubRows) || (inlineRowLoading && persistToggleExpansionButton)) && !expandByDepth && (
|
|
224
226
|
<ToggleIconButton onClick={handleExpandOrCollapse} />
|
|
225
227
|
)}
|
|
226
228
|
{isToggleExpansionEnabled && hasAnySubRows && expandByDepth && (
|
|
@@ -9,6 +9,9 @@ interface UseTableActionsProps {
|
|
|
9
9
|
setExpanded: (expanded: GenericObject) => void;
|
|
10
10
|
onToggleExpansionClick?: (arg: Row<GenericObject>) => void;
|
|
11
11
|
onRowSelectionChange?: (rowSelection: any) => void;
|
|
12
|
+
inlineRowLoading?: boolean;
|
|
13
|
+
localPagination?: { pageIndex: number; pageSize: number };
|
|
14
|
+
setLocalPagination?: (pagination: { pageIndex: number; pageSize: number }) => void;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export function useTableActions({
|
|
@@ -16,7 +19,10 @@ export function useTableActions({
|
|
|
16
19
|
expanded,
|
|
17
20
|
setExpanded,
|
|
18
21
|
onToggleExpansionClick,
|
|
19
|
-
onRowSelectionChange
|
|
22
|
+
onRowSelectionChange,
|
|
23
|
+
inlineRowLoading = false,
|
|
24
|
+
localPagination,
|
|
25
|
+
setLocalPagination
|
|
20
26
|
}: UseTableActionsProps) {
|
|
21
27
|
|
|
22
28
|
// State to achieve 1 second delay before fetching more rows
|
|
@@ -38,8 +44,17 @@ export function useTableActions({
|
|
|
38
44
|
|
|
39
45
|
// Handle pagination
|
|
40
46
|
const onPageChange = useCallback((page: number) => {
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
if (inlineRowLoading && setLocalPagination && localPagination) {
|
|
48
|
+
// Use manual pagination state for inlineRowLoading
|
|
49
|
+
setLocalPagination({
|
|
50
|
+
...localPagination,
|
|
51
|
+
pageIndex: page - 1
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
// Use tanstack's built-in pagination
|
|
55
|
+
table.setPageIndex(page - 1);
|
|
56
|
+
}
|
|
57
|
+
}, [table, inlineRowLoading, setLocalPagination, localPagination]);
|
|
43
58
|
|
|
44
59
|
// Handle scroll detection for infinite scroll/virtualization
|
|
45
60
|
const fetchMoreOnBottomReached = useCallback((
|
|
@@ -35,6 +35,7 @@ interface UseTableStateProps {
|
|
|
35
35
|
onRowSelectionChange?: (arg: RowSelectionState) => void;
|
|
36
36
|
columnVisibilityControl?: GenericObject;
|
|
37
37
|
rowStyling?: GenericObject;
|
|
38
|
+
inlineRowLoading?: boolean;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export function useTableState({
|
|
@@ -53,7 +54,8 @@ export function useTableState({
|
|
|
53
54
|
tableOptions,
|
|
54
55
|
columnVisibilityControl,
|
|
55
56
|
pinnedRows,
|
|
56
|
-
rowStyling
|
|
57
|
+
rowStyling,
|
|
58
|
+
inlineRowLoading = false
|
|
57
59
|
}: UseTableStateProps) {
|
|
58
60
|
|
|
59
61
|
// Create a local state for expanded and setExpanded if expandedControl not used
|
|
@@ -64,6 +66,12 @@ export function useTableState({
|
|
|
64
66
|
const [localRowPinning, setLocalRowPinning] = useState<RowPinningState>({
|
|
65
67
|
top: [],
|
|
66
68
|
});
|
|
69
|
+
// Manage local state to preserve current page index when inlineRowLoading is enabled so it does not boot table to page 1
|
|
70
|
+
// We can extend this for more usecases, but for now scoping it only for inlineRowLoading
|
|
71
|
+
const [localPagination, setLocalPagination] = useState({
|
|
72
|
+
pageIndex: paginationProps?.pageIndex ?? 0,
|
|
73
|
+
pageSize: paginationProps?.pageSize ?? 20,
|
|
74
|
+
});
|
|
67
75
|
// Determine whether to use the prop or the local state
|
|
68
76
|
const expanded = expandedControl ? expandedControl.value : localExpanded;
|
|
69
77
|
const setExpanded = expandedControl ? expandedControl.onChange : setLocalExpanded;
|
|
@@ -133,6 +141,7 @@ export function useTableState({
|
|
|
133
141
|
...(selectableRows && { rowSelection }),
|
|
134
142
|
...(columnVisibility && { columnVisibility }),
|
|
135
143
|
...(pinnedRows && { rowPinning }),
|
|
144
|
+
...(inlineRowLoading && { pagination: localPagination }),
|
|
136
145
|
},
|
|
137
146
|
}), [
|
|
138
147
|
expanded,
|
|
@@ -142,23 +151,36 @@ export function useTableState({
|
|
|
142
151
|
rowSelection,
|
|
143
152
|
columnVisibility,
|
|
144
153
|
rowPinning,
|
|
154
|
+
inlineRowLoading,
|
|
155
|
+
localPagination
|
|
145
156
|
]);
|
|
146
157
|
|
|
147
158
|
// Pagination configuration
|
|
148
159
|
const paginationInitializer = useMemo(() => {
|
|
149
160
|
if (!pagination) return {};
|
|
150
161
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
if (inlineRowLoading) {
|
|
163
|
+
// Use manual pagination state when inlineRowLoading is enabled (see https://tanstack.com/table/latest/docs/guide/pagination#client-side-pagination)
|
|
164
|
+
return {
|
|
165
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
166
|
+
paginateExpandedRows: false,
|
|
167
|
+
onPaginationChange: setLocalPagination,
|
|
168
|
+
autoResetPageIndex: false, // This is what prevent auto-reset of page index
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
// Use normal pagination initialization for non- inlineRowLoading usecases
|
|
172
|
+
return {
|
|
173
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
174
|
+
paginateExpandedRows: false,
|
|
175
|
+
initialState: {
|
|
176
|
+
pagination: {
|
|
177
|
+
pageIndex: paginationProps?.pageIndex ?? 0,
|
|
178
|
+
pageSize: paginationProps?.pageSize ?? 20,
|
|
179
|
+
},
|
|
158
180
|
},
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}, [pagination, paginationProps]);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}, [pagination, paginationProps, inlineRowLoading]);
|
|
162
184
|
|
|
163
185
|
// Initialize the table
|
|
164
186
|
const table = useReactTable({
|
|
@@ -206,9 +228,42 @@ export function useTableState({
|
|
|
206
228
|
// Set pagination state when pagination is enabled
|
|
207
229
|
useEffect(() => {
|
|
208
230
|
if (pagination && paginationProps?.pageSize) {
|
|
209
|
-
|
|
231
|
+
if (inlineRowLoading) {
|
|
232
|
+
// Update local pagination state for inlineRowLoading
|
|
233
|
+
setLocalPagination(prev => ({
|
|
234
|
+
...prev,
|
|
235
|
+
pageSize: paginationProps.pageSize
|
|
236
|
+
}));
|
|
237
|
+
} else {
|
|
238
|
+
table.setPageSize(paginationProps.pageSize);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}, [pagination, paginationProps?.pageSize, table, inlineRowLoading]);
|
|
242
|
+
|
|
243
|
+
// Update local pagination when paginationProps change and inlineRowLoading is enabled
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (pagination && inlineRowLoading && paginationProps) {
|
|
246
|
+
setLocalPagination({
|
|
247
|
+
pageIndex: paginationProps.pageIndex ?? localPagination.pageIndex,
|
|
248
|
+
pageSize: paginationProps.pageSize ?? localPagination.pageSize,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}, [pagination, inlineRowLoading, paginationProps?.pageIndex, paginationProps?.pageSize]);
|
|
252
|
+
|
|
253
|
+
// Call the callback with the new page index when localPagination.pageIndex changes (with inlineRowLoading)
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (pagination && inlineRowLoading && paginationProps?.onPageChange) {
|
|
256
|
+
paginationProps.onPageChange(localPagination.pageIndex);
|
|
257
|
+
}
|
|
258
|
+
}, [localPagination.pageIndex, pagination, inlineRowLoading, paginationProps]);
|
|
259
|
+
|
|
260
|
+
// Call the callback with the new page index when localPagination.pageIndex changes (without inlineRowLoading)
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
if (pagination && !inlineRowLoading && paginationProps?.onPageChange) {
|
|
263
|
+
const currentPageIndex = table.getState().pagination.pageIndex;
|
|
264
|
+
paginationProps.onPageChange(currentPageIndex);
|
|
210
265
|
}
|
|
211
|
-
}, [pagination,
|
|
266
|
+
}, [table.getState().pagination.pageIndex, pagination, inlineRowLoading, paginationProps]);
|
|
212
267
|
|
|
213
268
|
// Check if table has any sub-rows
|
|
214
269
|
const hasAnySubRows = table.getRowModel().rows.some(row => row.subRows && row.subRows.length > 0);
|
|
@@ -247,6 +302,8 @@ export function useTableState({
|
|
|
247
302
|
rowSelection,
|
|
248
303
|
fullData,
|
|
249
304
|
totalFetched,
|
|
250
|
-
isFetching
|
|
305
|
+
isFetching,
|
|
306
|
+
localPagination,
|
|
307
|
+
setLocalPagination
|
|
251
308
|
};
|
|
252
309
|
}
|
|
@@ -39,6 +39,7 @@ export const TableHeader = ({
|
|
|
39
39
|
hasAnySubRows,
|
|
40
40
|
showActionsBar,
|
|
41
41
|
selectableRows,
|
|
42
|
+
persistToggleExpansionButton,
|
|
42
43
|
responsive,
|
|
43
44
|
headerRef,
|
|
44
45
|
virtualizedRows,
|
|
@@ -92,6 +93,7 @@ export const TableHeader = ({
|
|
|
92
93
|
isPinnedLeft={isPinnedLeft}
|
|
93
94
|
key={`${header.id}-header`}
|
|
94
95
|
loading={loading}
|
|
96
|
+
persistToggleExpansionButton={persistToggleExpansionButton}
|
|
95
97
|
sortIcon={sortIcon}
|
|
96
98
|
table={table}
|
|
97
99
|
/>
|
|
@@ -136,6 +138,7 @@ export const TableHeader = ({
|
|
|
136
138
|
isVirtualized
|
|
137
139
|
key={`${header.id}-header-virtualized`}
|
|
138
140
|
loading={loading}
|
|
141
|
+
persistToggleExpansionButton={persistToggleExpansionButton}
|
|
139
142
|
sortIcon={sortIcon}
|
|
140
143
|
table={table}
|
|
141
144
|
/>
|
|
@@ -63,6 +63,7 @@ type AdvancedTableProps = {
|
|
|
63
63
|
scrollBarNone?: boolean,
|
|
64
64
|
selectableRows?: boolean,
|
|
65
65
|
showActionsBar?: boolean,
|
|
66
|
+
persistToggleExpansionButton?: boolean,
|
|
66
67
|
sortControl?: GenericObject
|
|
67
68
|
tableData: GenericObject[]
|
|
68
69
|
tableOptions?: GenericObject
|
|
@@ -109,6 +110,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
109
110
|
scrollBarNone= false,
|
|
110
111
|
showActionsBar = true,
|
|
111
112
|
selectableRows,
|
|
113
|
+
persistToggleExpansionButton = false,
|
|
112
114
|
sortControl,
|
|
113
115
|
stickyLeftColumn,
|
|
114
116
|
tableData,
|
|
@@ -134,7 +136,9 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
134
136
|
updateLoadingStateRowCount,
|
|
135
137
|
fullData,
|
|
136
138
|
totalFetched,
|
|
137
|
-
isFetching
|
|
139
|
+
isFetching,
|
|
140
|
+
localPagination,
|
|
141
|
+
setLocalPagination
|
|
138
142
|
} = useTableState({
|
|
139
143
|
tableData,
|
|
140
144
|
columnDefinitions,
|
|
@@ -152,7 +156,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
152
156
|
onRowSelectionChange,
|
|
153
157
|
columnVisibilityControl,
|
|
154
158
|
pinnedRows,
|
|
155
|
-
rowStyling
|
|
159
|
+
rowStyling,
|
|
160
|
+
inlineRowLoading
|
|
156
161
|
});
|
|
157
162
|
|
|
158
163
|
// Initialize table actions
|
|
@@ -165,7 +170,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
165
170
|
expanded,
|
|
166
171
|
setExpanded,
|
|
167
172
|
onToggleExpansionClick,
|
|
168
|
-
onRowSelectionChange
|
|
173
|
+
onRowSelectionChange,
|
|
174
|
+
inlineRowLoading,
|
|
175
|
+
localPagination,
|
|
176
|
+
setLocalPagination
|
|
169
177
|
});
|
|
170
178
|
|
|
171
179
|
// Set table row count for loading state
|
|
@@ -349,6 +357,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
349
357
|
loading={loading}
|
|
350
358
|
onCustomSortClick={onCustomSortClick}
|
|
351
359
|
onExpandByDepthClick={onExpandByDepthClick}
|
|
360
|
+
persistToggleExpansionButton={persistToggleExpansionButton}
|
|
352
361
|
pinnedRows={pinnedRows}
|
|
353
362
|
responsive={responsive}
|
|
354
363
|
rowStyling={rowStyling}
|
|
@@ -108,6 +108,48 @@ const MOCK_DATA_WITH_ID = [
|
|
|
108
108
|
},
|
|
109
109
|
]
|
|
110
110
|
|
|
111
|
+
const MOCK_DATA_NO_SUBROWS = [
|
|
112
|
+
{
|
|
113
|
+
year: "2021",
|
|
114
|
+
quarter: null,
|
|
115
|
+
month: null,
|
|
116
|
+
day: null,
|
|
117
|
+
newEnrollments: "20",
|
|
118
|
+
scheduledMeetings: "10",
|
|
119
|
+
attendanceRate: "51%",
|
|
120
|
+
completedClasses: "3",
|
|
121
|
+
classCompletionRate: "33%",
|
|
122
|
+
graduatedStudents: "19",
|
|
123
|
+
children: [],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
year: "2022",
|
|
127
|
+
quarter: null,
|
|
128
|
+
month: null,
|
|
129
|
+
day: null,
|
|
130
|
+
newEnrollments: "25",
|
|
131
|
+
scheduledMeetings: "17",
|
|
132
|
+
attendanceRate: "75%",
|
|
133
|
+
completedClasses: "5",
|
|
134
|
+
classCompletionRate: "45%",
|
|
135
|
+
graduatedStudents: "32",
|
|
136
|
+
children: [],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
year: "2023",
|
|
140
|
+
quarter: null,
|
|
141
|
+
month: null,
|
|
142
|
+
day: null,
|
|
143
|
+
newEnrollments: "30",
|
|
144
|
+
scheduledMeetings: "22",
|
|
145
|
+
attendanceRate: "80%",
|
|
146
|
+
completedClasses: "7",
|
|
147
|
+
classCompletionRate: "55%",
|
|
148
|
+
graduatedStudents: "45",
|
|
149
|
+
children: [],
|
|
150
|
+
},
|
|
151
|
+
]
|
|
152
|
+
|
|
111
153
|
const columnDefinitions = [
|
|
112
154
|
{
|
|
113
155
|
accessor: "year",
|
|
@@ -509,6 +551,23 @@ test("inlineRowLoading prop renders inline loading if true", () => {
|
|
|
509
551
|
expect(inlineLoading).toBeInTheDocument()
|
|
510
552
|
})
|
|
511
553
|
|
|
554
|
+
test("persistToggleExpansionButton prop shows header toggle when inlineRowLoading is true", () => {
|
|
555
|
+
render(
|
|
556
|
+
<AdvancedTable
|
|
557
|
+
columnDefinitions={columnDefinitions}
|
|
558
|
+
data={{ testid: testId }}
|
|
559
|
+
enableToggleExpansion="all"
|
|
560
|
+
inlineRowLoading
|
|
561
|
+
persistToggleExpansionButton
|
|
562
|
+
tableData={MOCK_DATA_NO_SUBROWS}
|
|
563
|
+
/>
|
|
564
|
+
)
|
|
565
|
+
|
|
566
|
+
const kit = screen.getByTestId(testId)
|
|
567
|
+
const headerToggleButton = kit.querySelector(".gray-icon.toggle-all-icon")
|
|
568
|
+
expect(headerToggleButton).toBeInTheDocument()
|
|
569
|
+
})
|
|
570
|
+
|
|
512
571
|
test("responsive prop functions as expected", () => {
|
|
513
572
|
render(
|
|
514
573
|
<AdvancedTable
|
|
@@ -681,6 +740,69 @@ test("columnStyling.cellPadding sets cell padding", () => {
|
|
|
681
740
|
expect(firstEnrollmentCell).toHaveClass('p_none')
|
|
682
741
|
});
|
|
683
742
|
|
|
743
|
+
test("columnStyling.fontColor sets cell font color", () => {
|
|
744
|
+
const styledColumnDefs = [
|
|
745
|
+
{
|
|
746
|
+
accessor: "year",
|
|
747
|
+
label: "Year",
|
|
748
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
accessor: "newEnrollments",
|
|
752
|
+
label: "New Enrollments",
|
|
753
|
+
columnStyling: { fontColor: colors.category_1 },
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
accessor: "scheduledMeetings",
|
|
757
|
+
label: "Scheduled Meetings",
|
|
758
|
+
},
|
|
759
|
+
];
|
|
760
|
+
|
|
761
|
+
render(
|
|
762
|
+
<AdvancedTable
|
|
763
|
+
columnDefinitions={styledColumnDefs}
|
|
764
|
+
data={{ testid: testId }}
|
|
765
|
+
tableData={MOCK_DATA}
|
|
766
|
+
/>
|
|
767
|
+
);
|
|
768
|
+
|
|
769
|
+
const firstEnrollmentCell = screen.getAllByText("20")[0].closest("td");
|
|
770
|
+
expect(firstEnrollmentCell).toHaveStyle({ color: colors.category_1 });
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
test("columnStyling.fontColor works with background color", () => {
|
|
774
|
+
const styledColumnDefs = [
|
|
775
|
+
{
|
|
776
|
+
accessor: "year",
|
|
777
|
+
label: "Year",
|
|
778
|
+
cellAccessors: ["quarter", "month", "day"],
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
accessor: "newEnrollments",
|
|
782
|
+
label: "New Enrollments",
|
|
783
|
+
columnStyling: {
|
|
784
|
+
cellBackgroundColor: (row) => row.newEnrollments > 20 ? "success_secondary" : "warning_secondary",
|
|
785
|
+
fontColor: colors.white
|
|
786
|
+
},
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
accessor: "scheduledMeetings",
|
|
790
|
+
label: "Scheduled Meetings",
|
|
791
|
+
},
|
|
792
|
+
];
|
|
793
|
+
|
|
794
|
+
render(
|
|
795
|
+
<AdvancedTable
|
|
796
|
+
columnDefinitions={styledColumnDefs}
|
|
797
|
+
data={{ testid: testId }}
|
|
798
|
+
tableData={MOCK_DATA}
|
|
799
|
+
/>
|
|
800
|
+
);
|
|
801
|
+
|
|
802
|
+
const firstEnrollmentCell = screen.getAllByText("20")[0].closest("td");
|
|
803
|
+
expect(firstEnrollmentCell).toHaveStyle({ color: colors.white });
|
|
804
|
+
});
|
|
805
|
+
|
|
684
806
|
test("renders virtualized table rows and header", () => {
|
|
685
807
|
render(
|
|
686
808
|
<AdvancedTable
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
`column_styling` can also be used to control the background color on all cells in a given column via the use of the `cell_background_color` key/value pair. Use `cell_background_color` to achieve custom background colors for individual cells as seen here.
|
|
1
|
+
`column_styling` can also be used to control the background color on all cells in a given column via the use of the `cell_background_color` key/value pair. Use `cell_background_color` to achieve custom background colors for individual cells as seen here. Use `font_color` to achieve better contrast between cell content and background for darker backgrounds.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
The borders of column groups can be set to a different color using the `columnGroupBorderColor` prop. In order for these borders to be visible, this prop must be used with `tableProps` and `verticalBorder` set to true.
|
|
2
2
|
|
|
3
|
-
The available colors for the border are Playbook's Text Colors, which can be found [here](https://playbook.powerapp.cloud/
|
|
3
|
+
The available colors for the border are Playbook's Text Colors, which can be found [here](https://playbook.powerapp.cloud/tokens/colors).
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
The borders of column groups can be set to a different color using the `column_group_border_color` prop. In order for these borders to be visible, this prop must be used with `table_props` and `vertical_border` set to true.
|
|
2
2
|
|
|
3
|
-
The available colors for the border are Playbook's Text Colors, which can be found [here](https://playbook.powerapp.cloud/
|
|
3
|
+
The available colors for the border are Playbook's Text Colors, which can be found [here](https://playbook.powerapp.cloud/tokens/colors).
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import AdvancedTable from
|
|
2
|
+
import { AdvancedTable, colors } from "playbook-ui"
|
|
3
3
|
import MOCK_DATA from "./advanced_table_mock_data.json"
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
const AdvancedTableColumnStyling = (props) => {
|
|
6
7
|
const columnDefinitions = [
|
|
7
8
|
{
|
|
@@ -34,6 +35,7 @@ const AdvancedTableColumnStyling = (props) => {
|
|
|
34
35
|
{
|
|
35
36
|
accessor: "graduatedStudents",
|
|
36
37
|
label: "Graduated Students",
|
|
38
|
+
columnStyling:{fontColor: colors.data_8},
|
|
37
39
|
},
|
|
38
40
|
]
|
|
39
41
|
|
|
@@ -4,4 +4,6 @@ The `columnStyling` prop is an optional item that can be used within `columnDefi
|
|
|
4
4
|
|
|
5
5
|
2) `cellAlignment`: This will allow you to control alignment of content within all cells in the given column. This is set to right aligned by default. you can set this to `left`, `right` or `center`.
|
|
6
6
|
|
|
7
|
+
3) `fontColor`: This will allow you to control the font color for a given column.
|
|
8
|
+
|
|
7
9
|
`columnStyling` can be used within the columnDefinition of all the columns or some of them, as shown. Each column has its own individual control in this way.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import AdvancedTable from
|
|
2
|
+
import { AdvancedTable, Background,colors } from "playbook-ui";
|
|
3
3
|
import MOCK_DATA from "./advanced_table_mock_data.json";
|
|
4
4
|
|
|
5
5
|
const AdvancedTableColumnStylingColumnHeaders = (props) => {
|
|
@@ -38,11 +38,24 @@ const AdvancedTableColumnStylingColumnHeaders = (props) => {
|
|
|
38
38
|
{
|
|
39
39
|
accessor: "completedClasses",
|
|
40
40
|
label: "Completed Classes",
|
|
41
|
-
columnStyling:{
|
|
41
|
+
columnStyling:{
|
|
42
|
+
headerAlignment: "center",
|
|
43
|
+
cellAlignment: "center",
|
|
44
|
+
fontColor: colors.success,
|
|
45
|
+
},
|
|
42
46
|
},
|
|
43
47
|
{
|
|
44
48
|
accessor: "classCompletionRate",
|
|
45
49
|
label: "Class Completion Rate",
|
|
50
|
+
columnStyling: { cellPadding: "none", fontColor: colors.error },
|
|
51
|
+
customRenderer: (row, value) => (
|
|
52
|
+
<Background
|
|
53
|
+
backgroundColor={"warning_secondary"}
|
|
54
|
+
padding="xs"
|
|
55
|
+
>
|
|
56
|
+
{value}
|
|
57
|
+
</Background>
|
|
58
|
+
),
|
|
46
59
|
},
|
|
47
60
|
],
|
|
48
61
|
},
|
|
@@ -52,6 +65,7 @@ const AdvancedTableColumnStylingColumnHeaders = (props) => {
|
|
|
52
65
|
{
|
|
53
66
|
accessor: "attendanceRate",
|
|
54
67
|
label: "Attendance Rate",
|
|
68
|
+
columnStyling: { fontColor: colors.category_1 },
|
|
55
69
|
},
|
|
56
70
|
{
|
|
57
71
|
accessor: "scheduledMeetings",
|
|
@@ -32,11 +32,15 @@
|
|
|
32
32
|
{
|
|
33
33
|
accessor: "completedClasses",
|
|
34
34
|
label: "Completed Classes",
|
|
35
|
-
column_styling:{header_alignment:"center", cell_alignment:"center"}
|
|
35
|
+
column_styling:{header_alignment:"center", cell_alignment:"center", font_color:"#28A745"}
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
accessor: "classCompletionRate",
|
|
39
39
|
label: "Class Completion Rate",
|
|
40
|
+
column_styling: {
|
|
41
|
+
cell_background_color: "warning_secondary",
|
|
42
|
+
font_color: "red"
|
|
43
|
+
}
|
|
40
44
|
},
|
|
41
45
|
],
|
|
42
46
|
},
|
|
@@ -46,6 +50,7 @@
|
|
|
46
50
|
{
|
|
47
51
|
accessor: "attendanceRate",
|
|
48
52
|
label: "Attendance Rate",
|
|
53
|
+
column_styling: { font_color: "#0056CF" }
|
|
49
54
|
},
|
|
50
55
|
{
|
|
51
56
|
accessor: "scheduledMeetings",
|
|
@@ -4,4 +4,6 @@ The `column_styling` prop is an optional item that can be used within `column_de
|
|
|
4
4
|
|
|
5
5
|
2) `cell_alignment`: This will allow you to control alignment of content within all cells in the given column. This is set to right aligned by default. you can set this to `left`, `right` or `center`.
|
|
6
6
|
|
|
7
|
+
3) `font_color`: This will allow you to control the font color for a given column.
|
|
8
|
+
|
|
7
9
|
`column_styling` can be used within the column_definition of all the columns or some of them, as shown. Each column has its own individual control in this way.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import AdvancedTable from '../../pb_advanced_table/_advanced_table'
|
|
3
|
+
import Caption from '../../pb_caption/_caption'
|
|
3
4
|
import { MOCK_DATA_INLINE_LOADING } from "./_mock_data_inline_loading"
|
|
5
|
+
import { MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN } from "./_mock_data_inline_loading_empty_children"
|
|
4
6
|
|
|
5
7
|
const AdvancedTableInlineRowLoading = (props) => {
|
|
6
8
|
const columnDefinitions = [
|
|
@@ -41,16 +43,42 @@ const AdvancedTableInlineRowLoading = (props) => {
|
|
|
41
43
|
|
|
42
44
|
return (
|
|
43
45
|
<div>
|
|
46
|
+
<Caption text="Inline Row Loading - Demonstrated in Row 1 (Rows 2 and 3 have data)" />
|
|
44
47
|
<AdvancedTable
|
|
45
48
|
columnDefinitions={columnDefinitions}
|
|
46
49
|
enableToggleExpansion="all"
|
|
47
50
|
inlineRowLoading
|
|
51
|
+
marginBottom="md"
|
|
48
52
|
tableData={MOCK_DATA_INLINE_LOADING}
|
|
49
53
|
{...props}
|
|
50
54
|
>
|
|
51
55
|
<AdvancedTable.Header />
|
|
52
56
|
<AdvancedTable.Body subRowHeaders={subRowHeaders}/>
|
|
53
57
|
</AdvancedTable>
|
|
58
|
+
<Caption text="Inline Row Loading with No Subrow Data - All Rows Display Inline Row Loading and the Toggle All Button is not rendered" />
|
|
59
|
+
<AdvancedTable
|
|
60
|
+
columnDefinitions={columnDefinitions}
|
|
61
|
+
enableToggleExpansion="all"
|
|
62
|
+
inlineRowLoading
|
|
63
|
+
marginBottom="md"
|
|
64
|
+
tableData={MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
<AdvancedTable.Header />
|
|
68
|
+
<AdvancedTable.Body subRowHeaders={subRowHeaders}/>
|
|
69
|
+
</AdvancedTable>
|
|
70
|
+
<Caption text="Inline Row Loading and Persist Toggle Expansion Button with No Subrow Data - All Rows Display Inline Row Loading and the Toggle All Button is rendered" />
|
|
71
|
+
<AdvancedTable
|
|
72
|
+
columnDefinitions={columnDefinitions}
|
|
73
|
+
enableToggleExpansion="all"
|
|
74
|
+
inlineRowLoading
|
|
75
|
+
persistToggleExpansionButton
|
|
76
|
+
tableData={MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
<AdvancedTable.Header />
|
|
80
|
+
<AdvancedTable.Body subRowHeaders={subRowHeaders}/>
|
|
81
|
+
</AdvancedTable>
|
|
54
82
|
</div>
|
|
55
83
|
)
|
|
56
84
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
### inlineRowLoading
|
|
1
2
|
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
|
|
|
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
|
+
In the first Advanced Table 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
|
|
|
5
|
-
This prop is set to `false` by default.
|
|
6
|
+
This prop is set to `false` by default.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### persistToggleExpansion
|
|
10
|
+
The `persistToggleExpansionButton` is a boolean prop that renders the toggle-all icon in the top left header cell for complex datasets with empty `children` arrays and advanced querying logic explained in the preceeding doc example. Your logic may require an additional query helper file to update data specifically from requerying via toggle all buttons.
|
|
11
|
+
|
|
12
|
+
In the second and third Advanced Tables in this code example, all 3 rows have empty children arrays. The second Advanced Table demonstrates that the toggle all button does not render (prior to an initial row expansion) without `persistToggleExpansionButton` in place. The third Advanced Table shows the toggle all button due to `persistToggleExpansionButton`.
|
|
13
|
+
|
|
14
|
+
This prop is set to false by default and should only be used in conjunction with `inlineRowLoading`.
|