playbook_ui 15.3.0 → 15.4.0.pre.alpha.PLAY2429datepickeropenonscreenstatic12263
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/Utilities/RowUtils.ts +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -4
- 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 +127 -5
- 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 +1 -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/_advanced_table_with_custom_header_multi_header.jsx +16 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.html.erb +104 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +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/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +90 -20
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +32 -3
- 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_badge/_badge.tsx +4 -1
- data/app/pb_kits/playbook/pb_badge/badge.test.js +13 -0
- 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_currency/_currency.tsx +20 -7
- data/app/pb_kits/playbook/pb_currency/currency.rb +35 -8
- data/app/pb_kits/playbook/pb_currency/currency.test.js +47 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +1 -1
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.md +1 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +60 -7
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.jsx +38 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.md +14 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
- 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/_dropdown.scss +1 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +111 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.jsx +18 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.md +4 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.jsx +18 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.jsx +19 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.jsx +38 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.md +14 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +148 -2
- data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +60 -0
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_width.md +1 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +15 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +9 -8
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +11 -10
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/formHelper.js +1 -1
- data/app/pb_kits/playbook/pb_form/pb_form_validation.js +44 -11
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +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_phone_number_input/_phone_number_input.tsx +110 -17
- 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.scss +7 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +105 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +23 -9
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +33 -1
- 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-0IiTB9gA.js → _line_graph-W9CX7Xbp.js} +1 -1
- data/dist/chunks/_typeahead-L4SF9E6a.js +6 -0
- data/dist/chunks/_weekday_stacked-DOs7l1vE.js +37 -0
- data/dist/chunks/{lib-izYrkvOQ.js → lib-COXg9aPA.js} +2 -2
- data/dist/chunks/pb_form_validation-DR765aoq.js +1 -0
- 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 +2 -2
- metadata +32 -8
- data/dist/chunks/_typeahead-BvV7a9cR.js +0 -6
- data/dist/chunks/_weekday_stacked-BZ7z8ukT.js +0 -37
- data/dist/chunks/pb_form_validation-Cah5Z5J3.js +0 -1
- /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: '078ba558616f3d9652e67f43a347d3d8aefc110aa2d508a5733bd795b067c11c'
|
|
4
|
+
data.tar.gz: fa53a9d154f6087f72bd482dc68d75e152a25f59e156ca477afd7f9cadf2984f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f55d101f6dd2a8069ed1e2b4ff753360fc2f03242d3c6978a18789d41dca270a8f13286cc74a57ab8565d6fb7e4c58ef75e769206ff8a2ee2b45c21f091afbd
|
|
7
|
+
data.tar.gz: c0e5da234a64692508e34ace0559178733de1e0703cb553fdf0c1c61901d1332e9dc4074b5d895d08b157b2c35f5976103d94acd145a3189bfe51826e7bda940
|
|
@@ -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
|
/>
|
|
@@ -17,7 +17,7 @@ export const getRowColorClass = (
|
|
|
17
17
|
(inlineRowLoading && (rowHasNoChildren || row.getCanExpand()))
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
return row.getIsSelected() ? "bg-row-selection" : shouldShowExpandedBackground ? "bg-silver" : "bg-white";
|
|
20
|
+
return row.getIsSelected() ? "bg-row-selection" : shouldShowExpandedBackground ? "bg-silver" : "pb-bg-row-white";
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
background-color: lighten($silver, $opacity_7);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
.bg-white {
|
|
54
|
+
.pb-bg-row-white {
|
|
55
55
|
background-color: $white;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
&.bg-white {
|
|
281
|
+
&.pb-bg-row-white {
|
|
282
282
|
td:first-child {
|
|
283
283
|
background-color: $white;
|
|
284
284
|
}
|
|
@@ -756,7 +756,7 @@
|
|
|
756
756
|
border-bottom-color: $border_dark !important;
|
|
757
757
|
}
|
|
758
758
|
|
|
759
|
-
.bg-white {
|
|
759
|
+
.pb-bg-row-white {
|
|
760
760
|
background: $bg_dark_card;
|
|
761
761
|
}
|
|
762
762
|
|
|
@@ -766,7 +766,7 @@
|
|
|
766
766
|
|
|
767
767
|
// Dark mode virtualized rows
|
|
768
768
|
.virtualized-table-row {
|
|
769
|
-
&.bg-white {
|
|
769
|
+
&.pb-bg-row-white {
|
|
770
770
|
background: $bg_dark_card !important;
|
|
771
771
|
|
|
772
772
|
td:first-child {
|
|
@@ -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",
|
|
@@ -266,10 +308,10 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
|
|
|
266
308
|
const kit = screen.getByTestId(testId)
|
|
267
309
|
const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
|
|
268
310
|
expect(rowButton).toBeInTheDocument()
|
|
269
|
-
const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
|
|
311
|
+
const subRow1 = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
|
|
270
312
|
expect(subRow1).not.toBeInTheDocument()
|
|
271
313
|
rowButton.click()
|
|
272
|
-
const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
|
|
314
|
+
const subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
|
|
273
315
|
expect(subRow).toBeInTheDocument()
|
|
274
316
|
})
|
|
275
317
|
|
|
@@ -286,13 +328,13 @@ test("toggleExpansionAll button exists and toggles subrows open and closed", asy
|
|
|
286
328
|
const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon");
|
|
287
329
|
expect(toggleButton).toBeInTheDocument();
|
|
288
330
|
|
|
289
|
-
const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1");
|
|
331
|
+
const subRow1 = kit.querySelector(".pb-bg-row-white.depth-sub-row-1");
|
|
290
332
|
expect(subRow1).not.toBeInTheDocument();
|
|
291
333
|
|
|
292
334
|
toggleButton.click();
|
|
293
335
|
|
|
294
336
|
await waitFor(() => {
|
|
295
|
-
const subRow = kit.querySelector(".bg-white.depth-sub-row-1");
|
|
337
|
+
const subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1");
|
|
296
338
|
expect(subRow).toBeInTheDocument();
|
|
297
339
|
})
|
|
298
340
|
})
|
|
@@ -343,7 +385,7 @@ test("expandControl prop works as expected", () => {
|
|
|
343
385
|
render (<AdvancedTableExpandControl/>)
|
|
344
386
|
|
|
345
387
|
const kit = screen.getByTestId(testId)
|
|
346
|
-
const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
|
|
388
|
+
const subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
|
|
347
389
|
expect(subRow).toBeInTheDocument()
|
|
348
390
|
})
|
|
349
391
|
|
|
@@ -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.
|
|
@@ -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.
|