playbook_ui 14.14.0.pre.rc.5 → 14.15.0.pre.alpha.PBNTR902multilevelselecthiddeninputbug6580
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 +127 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +275 -0
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +143 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +66 -0
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +195 -0
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +45 -99
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +73 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +52 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +126 -7
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +153 -298
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +8 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx +75 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +50 -0
- 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/_advanced_table_table_props_rails.md +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +33 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +152002 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_card/_card.tsx +2 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +17 -8
- data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +16 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.jsx +69 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +46 -31
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +15 -8
- data/app/pb_kits/playbook/pb_currency/currency.rb +17 -2
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +22 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.jsx +34 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +1 -0
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_currency/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +4 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
- data/app/pb_kits/playbook/pb_date_picker/index.ts +38 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +5 -6
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +2 -0
- data/app/pb_kits/playbook/pb_dialog/index.js +75 -0
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +43 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +8 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +33 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +20 -37
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +20 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +24 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +21 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +1 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +1 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +49 -0
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +20 -12
- data/app/pb_kits/playbook/pb_drawer/drawer.rb +49 -1
- data/app/pb_kits/playbook/pb_drawer/index.js +257 -0
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +5 -4
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +3 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +9 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +4 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +40 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +50 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +3 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +7 -1
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +71 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +17 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +61 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_icon_button/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +39 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +7 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +25 -3
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +72 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +7 -1
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +13 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +11 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +11 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +37 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +11 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +37 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional_react.md +1 -0
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_overlay/index.js +61 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +5 -3
- data/app/pb_kits/playbook/pb_overlay/overlay.rb +16 -1
- data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +12 -0
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +48 -10
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +1 -6
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +1 -5
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -5
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +3 -7
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +85 -74
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +60 -0
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +6 -11
- data/app/pb_kits/playbook/pb_radio/radio.test.js +16 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +58 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/index.js +38 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +3 -5
- data/app/pb_kits/playbook/pb_select/select.rb +8 -0
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -5
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -4
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -5
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +32 -0
- data/app/pb_kits/playbook/pb_title/_title.tsx +10 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +1 -2
- data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +7 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +54 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +1 -0
- data/app/pb_kits/playbook/pb_title/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_title/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_title/title.rb +10 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +0 -3
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +25 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +39 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +3 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +26 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +69 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +3 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +282 -0
- data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +10 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +36 -2
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +5 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +45 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +5 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +33 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/index.ts +61 -8
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +17 -2
- data/app/pb_kits/playbook/utilities/object.test.js +99 -0
- data/app/pb_kits/playbook/utilities/object.ts +29 -1
- data/dist/chunks/_typeahead-CaXmU2Fm.js +36 -0
- data/dist/chunks/_weekday_stacked-C7auj4WH.js +45 -0
- data/dist/chunks/{lib-D3us1bGD.js → lib-5OzNgeeu.js} +2 -2
- data/dist/chunks/{pb_form_validation-BpihMSOQ.js → pb_form_validation-DGhKbZtO.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +3 -3
- 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/forms/builder/time_zone_select_field.rb +19 -0
- data/lib/playbook/forms/builder.rb +1 -0
- data/lib/playbook/version.rb +2 -2
- metadata +75 -6
- data/dist/chunks/_typeahead-CAIQfP7X.js +0 -36
- data/dist/chunks/_weekday_stacked-DstwbGUv.js +0 -45
@@ -1,38 +1,23 @@
|
|
1
|
-
import React, {
|
2
|
-
import classnames from "classnames"
|
1
|
+
import React, { useRef, useEffect } from "react";
|
2
|
+
import classnames from "classnames";
|
3
3
|
|
4
|
-
import { GenericObject } from "../types"
|
4
|
+
import { GenericObject } from "../types";
|
5
|
+
import { Row, RowSelectionState } from "@tanstack/react-table";
|
5
6
|
|
6
|
-
import {
|
7
|
-
|
8
|
-
getCoreRowModel,
|
9
|
-
getExpandedRowModel,
|
10
|
-
getPaginationRowModel,
|
11
|
-
getSortedRowModel,
|
12
|
-
Row,
|
13
|
-
useReactTable,
|
14
|
-
Getter,
|
15
|
-
RowSelectionState
|
16
|
-
} from "@tanstack/react-table"
|
7
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
8
|
+
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
17
9
|
|
18
|
-
import
|
19
|
-
import {
|
10
|
+
import Table from "../pb_table/_table";
|
11
|
+
import { AdvancedTableProvider } from "./Context/AdvancedTableContext";
|
12
|
+
import { getVirtualizedContainerStyles } from "./Utilities/TableContainerStyles";
|
20
13
|
|
21
|
-
import
|
22
|
-
import
|
23
|
-
import
|
24
|
-
import
|
25
|
-
import FlexItem from "../pb_flex/_flex_item"
|
14
|
+
import { TableHeader } from "./SubKits/TableHeader";
|
15
|
+
import { TableBody } from "./SubKits/TableBody";
|
16
|
+
import TablePagination from "./Components/TablePagination";
|
17
|
+
import TableActionBar from "./Components/TableActionBar";
|
26
18
|
|
27
|
-
import
|
28
|
-
|
29
|
-
import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers"
|
30
|
-
import { showActionBar, hideActionBar } from "./Utilities/ActionBarAnimationHelper"
|
31
|
-
|
32
|
-
import { CustomCell } from "./Components/CustomCell"
|
33
|
-
import { TableHeader } from "./SubKits/TableHeader"
|
34
|
-
import { TableBody } from "./SubKits/TableBody"
|
35
|
-
import Pagination from "../pb_pagination/_pagination"
|
19
|
+
import { useTableState } from "./Hooks/useTableState";
|
20
|
+
import { useTableActions } from "./Hooks/useTableActions";
|
36
21
|
|
37
22
|
type AdvancedTableProps = {
|
38
23
|
aria?: { [key: string]: string }
|
@@ -63,7 +48,8 @@ type AdvancedTableProps = {
|
|
63
48
|
tableProps?: GenericObject
|
64
49
|
toggleExpansionIcon?: string | string[]
|
65
50
|
onRowSelectionChange?: (arg: RowSelectionState) => void
|
66
|
-
|
51
|
+
virtualizedRows?: boolean
|
52
|
+
} & GlobalProps;
|
67
53
|
|
68
54
|
const AdvancedTable = (props: AdvancedTableProps) => {
|
69
55
|
const {
|
@@ -95,281 +81,149 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
95
81
|
tableProps,
|
96
82
|
toggleExpansionIcon = "arrows-from-line",
|
97
83
|
onRowSelectionChange,
|
98
|
-
|
99
|
-
|
100
|
-
const [loadingStateRowCount, setLoadingStateRowCount] = useState(
|
101
|
-
initialLoadingRowsCount
|
102
|
-
)
|
103
|
-
|
104
|
-
// Create a local state for expanded and setExpanded if expandedControl not used
|
105
|
-
const [localExpanded, setLocalExpanded] = useState({})
|
106
|
-
|
107
|
-
// Determine whether to use the prop or the local state
|
108
|
-
const expanded = expandedControl ? expandedControl.value : localExpanded
|
109
|
-
const setExpanded = expandedControl
|
110
|
-
? expandedControl.onChange
|
111
|
-
: setLocalExpanded
|
112
|
-
|
113
|
-
const columnHelper = createColumnHelper()
|
114
|
-
|
115
|
-
//Row Selection
|
116
|
-
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
117
|
-
|
118
|
-
//Create cells for columns, with customization for first column
|
119
|
-
const createCellFunction = (cellAccessors: string[], customRenderer?: (row: Row<GenericObject>, value: any) => JSX.Element, index?: number) => {
|
120
|
-
const columnCells = ({
|
121
|
-
row,
|
122
|
-
getValue,
|
123
|
-
}: {
|
124
|
-
row: Row<GenericObject>
|
125
|
-
getValue: Getter<string>
|
126
|
-
}) => {
|
127
|
-
const rowData = row.original
|
128
|
-
|
129
|
-
if (index === 0) {
|
130
|
-
switch (row.depth) {
|
131
|
-
case 0: {
|
132
|
-
return (
|
133
|
-
<CustomCell
|
134
|
-
customRenderer={customRenderer}
|
135
|
-
getValue={getValue}
|
136
|
-
onRowToggleClick={onRowToggleClick}
|
137
|
-
row={row}
|
138
|
-
selectableRows={selectableRows}
|
139
|
-
/>
|
140
|
-
)
|
141
|
-
}
|
142
|
-
default: {
|
143
|
-
// Handle other depths based on cellAccessors
|
144
|
-
const depthAccessor = cellAccessors[row.depth - 1] // Adjust index for depth
|
145
|
-
const accessorValue = rowData[depthAccessor]
|
146
|
-
return accessorValue ? (
|
147
|
-
<CustomCell
|
148
|
-
customRenderer={customRenderer}
|
149
|
-
onRowToggleClick={onRowToggleClick}
|
150
|
-
row={row}
|
151
|
-
selectableRows={selectableRows}
|
152
|
-
value={accessorValue}
|
153
|
-
/>
|
154
|
-
) : (
|
155
|
-
"N/A"
|
156
|
-
)
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}
|
160
|
-
return customRenderer
|
161
|
-
? customRenderer(row, getValue())
|
162
|
-
: getValue()
|
163
|
-
}
|
164
|
-
return columnCells
|
165
|
-
}
|
84
|
+
virtualizedRows = false,
|
85
|
+
} = props;
|
166
86
|
|
167
|
-
|
168
|
-
|
169
|
-
columnDefinitions &&
|
170
|
-
columnDefinitions.map((column, index) => {
|
171
|
-
//Checking to see if grouped column or not
|
172
|
-
if (column.columns && column.columns.length > 0) {
|
173
|
-
return {
|
174
|
-
header: column.label || "",
|
175
|
-
columns: buildColumns(column.columns),
|
176
|
-
};
|
177
|
-
} else {
|
178
|
-
// Define the base column structure
|
179
|
-
const columnStructure = {
|
180
|
-
...columnHelper.accessor(column.accessor, {
|
181
|
-
header: column.label || "",
|
182
|
-
}),
|
183
|
-
};
|
87
|
+
// Component refs
|
88
|
+
const tableWrapperRef = useRef<HTMLDivElement>(null);
|
184
89
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
}
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
const customState = () => {
|
214
|
-
if (sortControl && selectableRows) {
|
215
|
-
return { state: { expanded, sorting, rowSelection } }
|
216
|
-
} else if (sortControl) {
|
217
|
-
return { state: { expanded, sorting } }
|
218
|
-
} else if (selectableRows) {
|
219
|
-
return { state: { expanded, rowSelection } }
|
220
|
-
} else {
|
221
|
-
return { state: { expanded } }
|
222
|
-
}
|
223
|
-
}
|
224
|
-
|
225
|
-
const paginationInitializer = pagination ? {
|
226
|
-
getPaginationRowModel: getPaginationRowModel(),
|
227
|
-
paginateExpandedRows: false,
|
228
|
-
initialState: {
|
229
|
-
pagination: {
|
230
|
-
pageIndex: paginationProps?.pageIndex ?? 0,
|
231
|
-
pageSize: paginationProps?.pageSize ?? 20,
|
232
|
-
},
|
233
|
-
},
|
234
|
-
} : {}
|
235
|
-
|
236
|
-
//initialize table
|
237
|
-
const table = useReactTable({
|
238
|
-
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
239
|
-
columns,
|
240
|
-
onExpandedChange: setExpanded,
|
241
|
-
getSubRows: (row: GenericObject) => row.children,
|
242
|
-
getCoreRowModel: getCoreRowModel(),
|
243
|
-
getExpandedRowModel: getExpandedRowModel(),
|
244
|
-
getSortedRowModel: getSortedRowModel(),
|
245
|
-
enableSortingRemoval: false,
|
246
|
-
sortDescFirst: true,
|
247
|
-
onRowSelectionChange: setRowSelection,
|
248
|
-
getRowId: selectableRows ? row => row.id : undefined,
|
249
|
-
...customState(),
|
250
|
-
...paginationInitializer,
|
251
|
-
...tableOptions,
|
252
|
-
})
|
253
|
-
|
254
|
-
const tableRows = table.getRowModel()
|
255
|
-
|
256
|
-
const hasAnySubRows = tableRows.rows.some(row => row.subRows && row.subRows.length > 0);
|
257
|
-
const selectedRowsLength = Object.keys(table.getState().rowSelection).length
|
90
|
+
// Initialize table state
|
91
|
+
const {
|
92
|
+
table,
|
93
|
+
expanded,
|
94
|
+
setExpanded,
|
95
|
+
hasAnySubRows,
|
96
|
+
selectedRowsLength,
|
97
|
+
fetchNextPage,
|
98
|
+
updateLoadingStateRowCount,
|
99
|
+
fullData,
|
100
|
+
totalFetched,
|
101
|
+
isFetching
|
102
|
+
} = useTableState({
|
103
|
+
tableData,
|
104
|
+
columnDefinitions,
|
105
|
+
expandedControl,
|
106
|
+
sortControl,
|
107
|
+
onRowToggleClick,
|
108
|
+
selectableRows,
|
109
|
+
initialLoadingRowsCount,
|
110
|
+
loading,
|
111
|
+
pagination,
|
112
|
+
paginationProps,
|
113
|
+
virtualizedRows,
|
114
|
+
tableOptions,
|
115
|
+
onRowSelectionChange
|
116
|
+
});
|
258
117
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
118
|
+
// Initialize table actions
|
119
|
+
const {
|
120
|
+
handleExpandOrCollapse,
|
121
|
+
onPageChange,
|
122
|
+
fetchMoreOnBottomReached
|
123
|
+
} = useTableActions({
|
124
|
+
table,
|
125
|
+
expanded,
|
126
|
+
setExpanded,
|
127
|
+
onToggleExpansionClick,
|
128
|
+
onRowSelectionChange
|
129
|
+
});
|
264
130
|
|
265
131
|
// Set table row count for loading state
|
266
|
-
const updateLoadingStateRowCount = useCallback(() => {
|
267
|
-
const rowsCount = table.getRowModel().rows.length
|
268
|
-
if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
|
269
|
-
setLoadingStateRowCount(rowsCount)
|
270
|
-
}
|
271
|
-
}, [tableData, loadingStateRowCount])
|
272
|
-
|
273
132
|
useEffect(() => {
|
274
133
|
if (!loading) {
|
275
|
-
updateLoadingStateRowCount()
|
134
|
+
updateLoadingStateRowCount();
|
276
135
|
}
|
277
|
-
}, [loading, updateLoadingStateRowCount])
|
136
|
+
}, [loading, updateLoadingStateRowCount]);
|
278
137
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
138
|
+
// Check for infinite scroll
|
139
|
+
useEffect(() => {
|
140
|
+
fetchMoreOnBottomReached(
|
141
|
+
tableWrapperRef.current,
|
142
|
+
fetchNextPage,
|
143
|
+
isFetching,
|
144
|
+
totalFetched,
|
145
|
+
fullData.length
|
146
|
+
);
|
147
|
+
}, [fetchMoreOnBottomReached, fetchNextPage, isFetching, totalFetched, fullData.length]);
|
287
148
|
|
288
|
-
|
289
|
-
const
|
290
|
-
const
|
149
|
+
// Build CSS classes and props
|
150
|
+
const ariaProps = buildAriaProps(aria);
|
151
|
+
const dataProps = buildDataProps(data);
|
152
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
291
153
|
const classes = classnames(
|
292
154
|
buildCss("pb_advanced_table"),
|
293
155
|
`advanced-table-responsive-${responsive}`,
|
294
|
-
maxHeight ? `advanced-table-max-height-${maxHeight}` : '',
|
156
|
+
maxHeight ? `advanced-table-max-height-${maxHeight}` : '',
|
295
157
|
globalProps(props),
|
296
158
|
className
|
297
|
-
)
|
159
|
+
);
|
298
160
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0
|
161
|
+
// Table wrapper styling with virtualization support
|
162
|
+
const tableWrapperStyle = virtualizedRows
|
163
|
+
? getVirtualizedContainerStyles(maxHeight)
|
164
|
+
: {};
|
304
165
|
|
305
|
-
//
|
306
|
-
const
|
307
|
-
useEffect(() => {
|
308
|
-
if (cardRef.current) {
|
309
|
-
if (isActionBarVisible) {
|
310
|
-
showActionBar(cardRef.current);
|
311
|
-
} else {
|
312
|
-
hideActionBar(cardRef.current);
|
313
|
-
}
|
314
|
-
}
|
315
|
-
}, [isActionBarVisible]);
|
166
|
+
// Visibility flag for action bar
|
167
|
+
const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0;
|
316
168
|
|
317
169
|
return (
|
318
|
-
<div
|
319
|
-
{...
|
170
|
+
<div
|
171
|
+
{...ariaProps}
|
172
|
+
{...dataProps}
|
320
173
|
{...htmlProps}
|
321
|
-
className={classes}
|
174
|
+
className={classes}
|
322
175
|
id={id}
|
176
|
+
onScroll={virtualizedRows ? e => fetchMoreOnBottomReached(
|
177
|
+
e.currentTarget,
|
178
|
+
fetchNextPage,
|
179
|
+
isFetching,
|
180
|
+
totalFetched,
|
181
|
+
fullData.length
|
182
|
+
) : undefined}
|
183
|
+
ref={tableWrapperRef}
|
184
|
+
style={tableWrapperStyle as React.CSSProperties}
|
323
185
|
>
|
324
|
-
<
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
}
|
186
|
+
<AdvancedTableProvider
|
187
|
+
columnDefinitions={columnDefinitions}
|
188
|
+
enableToggleExpansion={enableToggleExpansion}
|
189
|
+
enableVirtualization={virtualizedRows}
|
190
|
+
expanded={expanded}
|
191
|
+
expandedControl={expandedControl}
|
192
|
+
handleExpandOrCollapse={handleExpandOrCollapse}
|
193
|
+
hasAnySubRows={hasAnySubRows}
|
194
|
+
inlineRowLoading={inlineRowLoading}
|
195
|
+
isActionBarVisible={isActionBarVisible}
|
196
|
+
loading={loading}
|
197
|
+
responsive={responsive}
|
198
|
+
selectableRows={selectableRows}
|
199
|
+
setExpanded={setExpanded}
|
200
|
+
showActionsBar={showActionsBar}
|
201
|
+
sortControl={sortControl}
|
202
|
+
subRowHeaders={tableOptions?.subRowHeaders}
|
203
|
+
table={table}
|
204
|
+
tableContainerRef={tableWrapperRef}
|
205
|
+
toggleExpansionIcon={toggleExpansionIcon}
|
206
|
+
virtualizedRows={virtualizedRows}
|
343
207
|
>
|
344
|
-
|
345
|
-
{
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
>
|
364
|
-
<Caption color="light"
|
365
|
-
paddingLeft="xs"
|
366
|
-
size="xs"
|
367
|
-
>
|
368
|
-
{selectedRowsLength} Selected
|
369
|
-
</Caption>
|
370
|
-
<FlexItem>{actions}</FlexItem>
|
371
|
-
</Flex>
|
372
|
-
</Card>
|
208
|
+
<React.Fragment>
|
209
|
+
{/* Top Pagination */}
|
210
|
+
{pagination && (
|
211
|
+
<TablePagination
|
212
|
+
onChange={onPageChange}
|
213
|
+
position="top"
|
214
|
+
range={paginationProps?.range}
|
215
|
+
table={table}
|
216
|
+
/>
|
217
|
+
)}
|
218
|
+
|
219
|
+
{/* Selection Action Bar */}
|
220
|
+
<TableActionBar
|
221
|
+
actions={actions}
|
222
|
+
isVisible={isActionBarVisible}
|
223
|
+
selectedCount={selectedRowsLength}
|
224
|
+
/>
|
225
|
+
|
226
|
+
{/* Main Table */}
|
373
227
|
<Table
|
374
228
|
className={`${loading ? "content-loading" : ""}`}
|
375
229
|
dark={dark}
|
@@ -387,23 +241,24 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
387
241
|
</>
|
388
242
|
)}
|
389
243
|
</Table>
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
marginTop="xs"
|
244
|
+
|
245
|
+
{/* Bottom Pagination */}
|
246
|
+
{pagination && (
|
247
|
+
<TablePagination
|
395
248
|
onChange={onPageChange}
|
396
|
-
|
397
|
-
|
249
|
+
position="bottom"
|
250
|
+
range={paginationProps?.range}
|
251
|
+
table={table}
|
398
252
|
/>
|
399
|
-
}
|
400
|
-
|
401
|
-
</
|
253
|
+
)}
|
254
|
+
</React.Fragment>
|
255
|
+
</AdvancedTableProvider>
|
402
256
|
</div>
|
403
|
-
)
|
404
|
-
}
|
257
|
+
);
|
258
|
+
};
|
405
259
|
|
406
|
-
|
407
|
-
AdvancedTable.
|
260
|
+
// Re-export sub-components
|
261
|
+
AdvancedTable.Header = TableHeader;
|
262
|
+
AdvancedTable.Body = TableBody;
|
408
263
|
|
409
|
-
export default AdvancedTable
|
264
|
+
export default AdvancedTable;
|
@@ -17,14 +17,21 @@ module Playbook
|
|
17
17
|
default: "scroll"
|
18
18
|
prop :table_props, type: Playbook::Props::HashProp,
|
19
19
|
default: {}
|
20
|
+
prop :max_height, type: Playbook::Props::Enum,
|
21
|
+
values: %w[auto xs sm md lg xl xxl xxxl],
|
22
|
+
default: "auto"
|
20
23
|
|
21
24
|
def classname
|
22
|
-
generate_classname("pb_advanced_table", responsive_classname, separator: " ")
|
25
|
+
generate_classname("pb_advanced_table", responsive_classname, max_height_classname, separator: " ")
|
23
26
|
end
|
24
27
|
|
25
28
|
def responsive_classname
|
26
29
|
responsive == "scroll" ? "advanced-table-responsive-scroll" : "advanced-table-responsive-none"
|
27
30
|
end
|
31
|
+
|
32
|
+
def max_height_classname
|
33
|
+
max_height.present? ? "advanced-table-max-height-#{max_height}" : ""
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { AdvancedTable, Pill } from "playbook-ui"
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
|
+
|
5
|
+
const AdvancedTableColumnHeadersCustomCell = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
label: "Enrollment Data",
|
14
|
+
columns: [
|
15
|
+
{
|
16
|
+
accessor: "newEnrollments",
|
17
|
+
label: "New Enrollments",
|
18
|
+
customRenderer: (row, value) => (
|
19
|
+
<Pill text={value}
|
20
|
+
variant="success"
|
21
|
+
/>
|
22
|
+
),
|
23
|
+
},
|
24
|
+
{
|
25
|
+
accessor: "scheduledMeetings",
|
26
|
+
label: "Scheduled Meetings",
|
27
|
+
customRenderer: (row, value) => (
|
28
|
+
<Pill text={value}
|
29
|
+
variant="info"
|
30
|
+
/>
|
31
|
+
),
|
32
|
+
},
|
33
|
+
],
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: "Performance Data",
|
37
|
+
columns: [
|
38
|
+
{
|
39
|
+
accessor: "attendanceRate",
|
40
|
+
label: "Attendance Rate",
|
41
|
+
},
|
42
|
+
{
|
43
|
+
accessor: "completedClasses",
|
44
|
+
label: "Completed Classes",
|
45
|
+
customRenderer: (row, value) => (
|
46
|
+
<Pill text={value}
|
47
|
+
variant="error"
|
48
|
+
/>
|
49
|
+
),
|
50
|
+
},
|
51
|
+
{
|
52
|
+
accessor: "classCompletionRate",
|
53
|
+
label: "Class Completion Rate",
|
54
|
+
},
|
55
|
+
{
|
56
|
+
accessor: "graduatedStudents",
|
57
|
+
label: "Graduated Students",
|
58
|
+
},
|
59
|
+
],
|
60
|
+
},
|
61
|
+
];
|
62
|
+
|
63
|
+
|
64
|
+
return (
|
65
|
+
<>
|
66
|
+
<AdvancedTable
|
67
|
+
columnDefinitions={columnDefinitions}
|
68
|
+
tableData={MOCK_DATA}
|
69
|
+
{...props}
|
70
|
+
/>
|
71
|
+
</>
|
72
|
+
)
|
73
|
+
}
|
74
|
+
|
75
|
+
export default AdvancedTableColumnHeadersCustomCell
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { AdvancedTable } from "playbook-ui"
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data_infinite_scroll.json"
|
4
|
+
|
5
|
+
const AdvancedTableInfiniteScroll = (props) => {
|
6
|
+
const columnDefinitions = [
|
7
|
+
{
|
8
|
+
accessor: "year",
|
9
|
+
label: "Year",
|
10
|
+
cellAccessors: ["quarter", "month", "day"],
|
11
|
+
},
|
12
|
+
{
|
13
|
+
accessor: "newEnrollments",
|
14
|
+
label: "New Enrollments",
|
15
|
+
},
|
16
|
+
{
|
17
|
+
accessor: "scheduledMeetings",
|
18
|
+
label: "Scheduled Meetings",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
accessor: "attendanceRate",
|
22
|
+
label: "Attendance Rate",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
accessor: "completedClasses",
|
26
|
+
label: "Completed Classes",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
accessor: "classCompletionRate",
|
30
|
+
label: "Class Completion Rate",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
accessor: "graduatedStudents",
|
34
|
+
label: "Graduated Students",
|
35
|
+
},
|
36
|
+
]
|
37
|
+
|
38
|
+
return (
|
39
|
+
<div>
|
40
|
+
<AdvancedTable
|
41
|
+
columnDefinitions={columnDefinitions}
|
42
|
+
tableData={MOCK_DATA}
|
43
|
+
virtualizedRows
|
44
|
+
{...props}
|
45
|
+
/>
|
46
|
+
</div>
|
47
|
+
)
|
48
|
+
}
|
49
|
+
|
50
|
+
export default AdvancedTableInfiniteScroll
|
@@ -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: { container: false, sticky: true }}) %>
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, responsive: "none", table_props: { container: false, sticky: true }}) %>
|
@@ -1 +1,3 @@
|
|
1
|
-
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table) under the hood which comes with
|
1
|
+
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table) under the hood which comes with its own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `table_props` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table).
|
2
|
+
|
3
|
+
This doc example showcases how to set a sticky header for a nonresponsive table. To achieve sticky header AND responsive functionality, see the ["Table Props Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table#table-props-sticky-header) doc example below.
|
@@ -1,3 +1,3 @@
|
|
1
|
-
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with
|
1
|
+
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with its own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `tableProps` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table/react).
|
2
2
|
|
3
3
|
This doc example showcases how to set a sticky header for a nonresponsive table. To achieve sticky header AND responsive functionality, see the ["Table Props Sticky Header"](https://playbook.powerapp.cloud/kits/advanced_table/react#table-props-sticky-header) doc example below.
|