playbook_ui 14.14.0.pre.alpha.PBNTR907reactfilterpopoverpropswidthbug6557 → 14.14.0.pre.alpha.pbntr500currencykithandlingofnullvalues6275
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/Context/AdvancedTableContext.tsx +3 -143
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +99 -45
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -123
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +299 -153
- data/app/pb_kits/playbook/pb_card/_card.tsx +1 -2
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +2 -1
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -1
- data/app/pb_kits/playbook/pb_currency/currency.rb +2 -14
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +1 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -2
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +3 -43
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +37 -20
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +1 -20
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +0 -6
- data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +12 -20
- data/app/pb_kits/playbook/pb_drawer/drawer.rb +1 -49
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +4 -5
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -9
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +0 -4
- data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -7
- data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +0 -7
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -13
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -6
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +0 -13
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -7
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +3 -5
- data/app/pb_kits/playbook/pb_overlay/overlay.rb +1 -16
- data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +0 -12
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +2 -2
- data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +2 -2
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +74 -85
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -16
- data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +5 -3
- data/app/pb_kits/playbook/pb_select/select.rb +0 -8
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +0 -32
- data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
- data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_title/title.rb +1 -10
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +3 -0
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -25
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -36
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -17
- data/app/pb_kits/playbook/utilities/object.ts +1 -29
- data/dist/chunks/_typeahead-PqkcDf1H.js +36 -0
- data/dist/chunks/_weekday_stacked-BhC8Xp9l.js +45 -0
- data/dist/chunks/{lib-5OzNgeeu.js → lib-D3us1bGD.js} +2 -2
- data/dist/chunks/{pb_form_validation-DGhKbZtO.js → pb_form_validation-BpihMSOQ.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/version.rb +1 -1
- metadata +6 -64
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +0 -127
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +0 -55
- data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +0 -33
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +0 -275
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +0 -66
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +0 -195
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +0 -73
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +0 -52
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +0 -80
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +0 -50
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +0 -152002
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +0 -1
- data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +0 -1
- data/app/pb_kits/playbook/pb_date_picker/index.ts +0 -38
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +0 -8
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +0 -33
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +0 -24
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +0 -21
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +0 -49
- data/app/pb_kits/playbook/pb_drawer/index.js +0 -257
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +0 -40
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +0 -50
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +0 -3
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +0 -71
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +0 -17
- data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +0 -61
- data/app/pb_kits/playbook/pb_icon_button/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +0 -39
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +0 -72
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +0 -91
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +0 -11
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +0 -37
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +0 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +0 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +0 -11
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +0 -1
- data/app/pb_kits/playbook/pb_overlay/index.js +0 -61
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +0 -60
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +0 -58
- data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +0 -1
- data/app/pb_kits/playbook/pb_select/index.js +0 -38
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
- data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +0 -39
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +0 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +0 -26
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +0 -69
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +0 -3
- data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +0 -3
- data/app/pb_kits/playbook/utilities/object.test.js +0 -99
- data/dist/chunks/_typeahead-F4bG5YsC.js +0 -36
- data/dist/chunks/_weekday_stacked-CaWVQMMq.js +0 -45
@@ -1,23 +1,38 @@
|
|
1
|
-
import React, {
|
2
|
-
import classnames from "classnames"
|
1
|
+
import React, { useState, useEffect, useCallback, useRef } from "react"
|
2
|
+
import classnames from "classnames"
|
3
3
|
|
4
|
-
import { GenericObject } from "../types"
|
5
|
-
import { Row, RowSelectionState } from "@tanstack/react-table";
|
4
|
+
import { GenericObject } from "../types"
|
6
5
|
|
7
|
-
import {
|
8
|
-
|
6
|
+
import {
|
7
|
+
createColumnHelper,
|
8
|
+
getCoreRowModel,
|
9
|
+
getExpandedRowModel,
|
10
|
+
getPaginationRowModel,
|
11
|
+
getSortedRowModel,
|
12
|
+
Row,
|
13
|
+
useReactTable,
|
14
|
+
Getter,
|
15
|
+
RowSelectionState
|
16
|
+
} from "@tanstack/react-table"
|
9
17
|
|
10
|
-
import
|
11
|
-
import {
|
12
|
-
import { getVirtualizedContainerStyles } from "./Utilities/TableContainerStyles";
|
18
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props"
|
19
|
+
import { globalProps, GlobalProps } from "../utilities/globalProps"
|
13
20
|
|
14
|
-
import
|
15
|
-
import
|
16
|
-
import
|
17
|
-
import
|
21
|
+
import Table from "../pb_table/_table"
|
22
|
+
import Card from "../pb_card/_card"
|
23
|
+
import Caption from "../pb_caption/_caption"
|
24
|
+
import Flex from "../pb_flex/_flex"
|
25
|
+
import FlexItem from "../pb_flex/_flex_item"
|
18
26
|
|
19
|
-
import
|
20
|
-
|
27
|
+
import AdvancedTableContext from "./Context/AdvancedTableContext"
|
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"
|
21
36
|
|
22
37
|
type AdvancedTableProps = {
|
23
38
|
aria?: { [key: string]: string }
|
@@ -48,8 +63,7 @@ type AdvancedTableProps = {
|
|
48
63
|
tableProps?: GenericObject
|
49
64
|
toggleExpansionIcon?: string | string[]
|
50
65
|
onRowSelectionChange?: (arg: RowSelectionState) => void
|
51
|
-
|
52
|
-
} & GlobalProps;
|
66
|
+
} & GlobalProps
|
53
67
|
|
54
68
|
const AdvancedTable = (props: AdvancedTableProps) => {
|
55
69
|
const {
|
@@ -81,149 +95,282 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
81
95
|
tableProps,
|
82
96
|
toggleExpansionIcon = "arrows-from-line",
|
83
97
|
onRowSelectionChange,
|
84
|
-
|
85
|
-
} = props;
|
98
|
+
} = props
|
86
99
|
|
87
|
-
|
88
|
-
|
100
|
+
const [loadingStateRowCount, setLoadingStateRowCount] = useState(
|
101
|
+
initialLoadingRowsCount
|
102
|
+
)
|
89
103
|
|
90
|
-
//
|
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
|
-
});
|
104
|
+
// Create a local state for expanded and setExpanded if expandedControl not used
|
105
|
+
const [localExpanded, setLocalExpanded] = useState({})
|
117
106
|
|
118
|
-
//
|
119
|
-
const
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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, isFirstColumn?: boolean) => {
|
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 (isFirstColumn) {
|
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
|
+
}
|
166
|
+
|
167
|
+
const buildColumns = (columnDefinitions: GenericObject[], isRoot= true): any => {
|
168
|
+
return (
|
169
|
+
columnDefinitions &&
|
170
|
+
columnDefinitions.map((column, index) => {
|
171
|
+
const isFirstColumn = isRoot && index === 0;
|
172
|
+
//Checking to see if grouped column or not
|
173
|
+
if (column.columns && column.columns.length > 0) {
|
174
|
+
return {
|
175
|
+
header: column.label || "",
|
176
|
+
columns: buildColumns(column.columns, false),
|
177
|
+
};
|
178
|
+
} else {
|
179
|
+
// Define the base column structure
|
180
|
+
const columnStructure = {
|
181
|
+
...columnHelper.accessor(column.accessor, {
|
182
|
+
header: column.label || "",
|
183
|
+
}),
|
184
|
+
};
|
185
|
+
|
186
|
+
if (column.cellAccessors || column.customRenderer) {
|
187
|
+
columnStructure.cell = createCellFunction(
|
188
|
+
column.cellAccessors,
|
189
|
+
column.customRenderer,
|
190
|
+
isFirstColumn
|
191
|
+
);
|
192
|
+
}
|
193
|
+
|
194
|
+
return columnStructure;
|
195
|
+
}
|
196
|
+
})
|
197
|
+
);
|
198
|
+
};
|
199
|
+
|
200
|
+
//Create column array in format needed by Tanstack
|
201
|
+
const columns = buildColumns(columnDefinitions);
|
202
|
+
|
203
|
+
//Syntax for sorting Array if we want to manage state ourselves
|
204
|
+
const sorting = [
|
205
|
+
{
|
206
|
+
id: columnDefinitions[0].accessor,
|
207
|
+
desc:
|
208
|
+
sortControl && sortControl.value !== null
|
209
|
+
? !sortControl.value.desc
|
210
|
+
: false,
|
211
|
+
},
|
212
|
+
]
|
213
|
+
|
214
|
+
const customState = () => {
|
215
|
+
if (sortControl && selectableRows) {
|
216
|
+
return { state: { expanded, sorting, rowSelection } }
|
217
|
+
} else if (sortControl) {
|
218
|
+
return { state: { expanded, sorting } }
|
219
|
+
} else if (selectableRows) {
|
220
|
+
return { state: { expanded, rowSelection } }
|
221
|
+
} else {
|
222
|
+
return { state: { expanded } }
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
const paginationInitializer = pagination ? {
|
227
|
+
getPaginationRowModel: getPaginationRowModel(),
|
228
|
+
paginateExpandedRows: false,
|
229
|
+
initialState: {
|
230
|
+
pagination: {
|
231
|
+
pageIndex: paginationProps?.pageIndex ?? 0,
|
232
|
+
pageSize: paginationProps?.pageSize ?? 20,
|
233
|
+
},
|
234
|
+
},
|
235
|
+
} : {}
|
236
|
+
|
237
|
+
//initialize table
|
238
|
+
const table = useReactTable({
|
239
|
+
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
240
|
+
columns,
|
241
|
+
onExpandedChange: setExpanded,
|
242
|
+
getSubRows: (row: GenericObject) => row.children,
|
243
|
+
getCoreRowModel: getCoreRowModel(),
|
244
|
+
getExpandedRowModel: getExpandedRowModel(),
|
245
|
+
getSortedRowModel: getSortedRowModel(),
|
246
|
+
enableSortingRemoval: false,
|
247
|
+
sortDescFirst: true,
|
248
|
+
onRowSelectionChange: setRowSelection,
|
249
|
+
getRowId: selectableRows ? row => row.id : undefined,
|
250
|
+
...customState(),
|
251
|
+
...paginationInitializer,
|
252
|
+
...tableOptions,
|
253
|
+
})
|
254
|
+
|
255
|
+
const tableRows = table.getRowModel()
|
256
|
+
|
257
|
+
const hasAnySubRows = tableRows.rows.some(row => row.subRows && row.subRows.length > 0);
|
258
|
+
const selectedRowsLength = Object.keys(table.getState().rowSelection).length
|
259
|
+
|
260
|
+
useEffect(() => {
|
261
|
+
if (onRowSelectionChange) {
|
262
|
+
onRowSelectionChange(table.getState().rowSelection)
|
263
|
+
}
|
264
|
+
} , [table.getState().rowSelection, onRowSelectionChange])
|
130
265
|
|
131
266
|
// Set table row count for loading state
|
267
|
+
const updateLoadingStateRowCount = useCallback(() => {
|
268
|
+
const rowsCount = table.getRowModel().rows.length
|
269
|
+
if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
|
270
|
+
setLoadingStateRowCount(rowsCount)
|
271
|
+
}
|
272
|
+
}, [tableData, loadingStateRowCount])
|
273
|
+
|
132
274
|
useEffect(() => {
|
133
275
|
if (!loading) {
|
134
|
-
updateLoadingStateRowCount()
|
276
|
+
updateLoadingStateRowCount()
|
135
277
|
}
|
136
|
-
}, [loading, updateLoadingStateRowCount])
|
278
|
+
}, [loading, updateLoadingStateRowCount])
|
137
279
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
);
|
147
|
-
}, [fetchMoreOnBottomReached, fetchNextPage, isFetching, totalFetched, fullData.length]);
|
280
|
+
const handleExpandOrCollapse = async (row: Row<GenericObject>) => {
|
281
|
+
onToggleExpansionClick && onToggleExpansionClick(row)
|
282
|
+
|
283
|
+
const expandedState = expanded;
|
284
|
+
const targetParent = row?.parentId;
|
285
|
+
const updatedRows = await updateExpandAndCollapseState(tableRows, expandedState, targetParent)
|
286
|
+
setExpanded(updatedRows)
|
287
|
+
}
|
148
288
|
|
149
|
-
|
150
|
-
const
|
151
|
-
const
|
152
|
-
const htmlProps = buildHtmlProps(htmlOptions);
|
289
|
+
const ariaProps = buildAriaProps(aria)
|
290
|
+
const dataProps = buildDataProps(data)
|
291
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
153
292
|
const classes = classnames(
|
154
293
|
buildCss("pb_advanced_table"),
|
155
294
|
`advanced-table-responsive-${responsive}`,
|
156
|
-
maxHeight ? `advanced-table-max-height-${maxHeight}` : '',
|
295
|
+
maxHeight ? `advanced-table-max-height-${maxHeight}` : '', // max height as kit prop not global prop to control overflow-y
|
157
296
|
globalProps(props),
|
158
297
|
className
|
159
|
-
)
|
298
|
+
)
|
160
299
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
300
|
+
const onPageChange = (page: number) => {
|
301
|
+
table.setPageIndex(page - 1)
|
302
|
+
}
|
303
|
+
//When to show the actions bar as a whole
|
304
|
+
const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0
|
165
305
|
|
166
|
-
//
|
167
|
-
const
|
306
|
+
//Ref and useEffect for animating the actions bar
|
307
|
+
const cardRef = useRef(null);
|
308
|
+
useEffect(() => {
|
309
|
+
if (cardRef.current) {
|
310
|
+
if (isActionBarVisible) {
|
311
|
+
showActionBar(cardRef.current);
|
312
|
+
} else {
|
313
|
+
hideActionBar(cardRef.current);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
}, [isActionBarVisible]);
|
168
317
|
|
169
318
|
return (
|
170
|
-
<div
|
171
|
-
{...
|
172
|
-
{...dataProps}
|
319
|
+
<div {...ariaProps}
|
320
|
+
{...dataProps}
|
173
321
|
{...htmlProps}
|
174
|
-
className={classes}
|
322
|
+
className={classes}
|
175
323
|
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}
|
185
324
|
>
|
186
|
-
<
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
toggleExpansionIcon={toggleExpansionIcon}
|
206
|
-
virtualizedRows={virtualizedRows}
|
325
|
+
<AdvancedTableContext.Provider
|
326
|
+
value={{
|
327
|
+
columnDefinitions,
|
328
|
+
enableToggleExpansion,
|
329
|
+
expanded,
|
330
|
+
expandedControl,
|
331
|
+
handleExpandOrCollapse,
|
332
|
+
inlineRowLoading,
|
333
|
+
isActionBarVisible,
|
334
|
+
loading,
|
335
|
+
responsive,
|
336
|
+
setExpanded,
|
337
|
+
sortControl,
|
338
|
+
table,
|
339
|
+
toggleExpansionIcon,
|
340
|
+
showActionsBar,
|
341
|
+
selectableRows,
|
342
|
+
hasAnySubRows
|
343
|
+
}}
|
207
344
|
>
|
208
|
-
|
209
|
-
{
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
345
|
+
<>
|
346
|
+
{pagination &&
|
347
|
+
<Pagination
|
348
|
+
current={table.getState().pagination.pageIndex + 1}
|
349
|
+
key={`pagination-top-${table.getState().pagination.pageIndex + 1}`}
|
350
|
+
marginBottom="xs"
|
351
|
+
onChange={onPageChange}
|
352
|
+
range={paginationProps?.range ? paginationProps?.range : 5}
|
353
|
+
total={table.getPageCount()}
|
354
|
+
/>
|
355
|
+
}
|
356
|
+
<Card
|
357
|
+
borderNone={!isActionBarVisible}
|
358
|
+
className={`${isActionBarVisible && "show-action-card row-selection-actions-card"}`}
|
359
|
+
htmlOptions={{ ref: cardRef as any }}
|
360
|
+
padding={`${isActionBarVisible ? "xs" : "none"}`}
|
361
|
+
>
|
362
|
+
<Flex alignItems="center"
|
363
|
+
justify="between"
|
364
|
+
>
|
365
|
+
<Caption color="light"
|
366
|
+
paddingLeft="xs"
|
367
|
+
size="xs"
|
368
|
+
>
|
369
|
+
{selectedRowsLength} Selected
|
370
|
+
</Caption>
|
371
|
+
<FlexItem>{actions}</FlexItem>
|
372
|
+
</Flex>
|
373
|
+
</Card>
|
227
374
|
<Table
|
228
375
|
className={`${loading ? "content-loading" : ""}`}
|
229
376
|
dark={dark}
|
@@ -241,24 +388,23 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
241
388
|
</>
|
242
389
|
)}
|
243
390
|
</Table>
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
391
|
+
{pagination &&
|
392
|
+
<Pagination
|
393
|
+
current={table.getState().pagination.pageIndex + 1}
|
394
|
+
key={`pagination-bottom-${table.getState().pagination.pageIndex + 1}`}
|
395
|
+
marginTop="xs"
|
248
396
|
onChange={onPageChange}
|
249
|
-
|
250
|
-
|
251
|
-
table={table}
|
397
|
+
range={paginationProps?.range ? paginationProps?.range : 5}
|
398
|
+
total={table.getPageCount()}
|
252
399
|
/>
|
253
|
-
|
254
|
-
|
255
|
-
</
|
400
|
+
}
|
401
|
+
</>
|
402
|
+
</AdvancedTableContext.Provider>
|
256
403
|
</div>
|
257
|
-
)
|
258
|
-
}
|
404
|
+
)
|
405
|
+
}
|
259
406
|
|
260
|
-
|
261
|
-
AdvancedTable.
|
262
|
-
AdvancedTable.Body = TableBody;
|
407
|
+
AdvancedTable.Header = TableHeader
|
408
|
+
AdvancedTable.Body = TableBody
|
263
409
|
|
264
|
-
export default AdvancedTable
|
410
|
+
export default AdvancedTable
|
@@ -1,8 +1,7 @@
|
|
1
1
|
/* eslint-disable react/no-multi-comp */
|
2
2
|
|
3
3
|
import React from 'react'
|
4
|
-
import { get } from '
|
5
|
-
|
4
|
+
import { get } from 'lodash'
|
6
5
|
import classnames from 'classnames'
|
7
6
|
|
8
7
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
@@ -120,6 +120,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
|
|
120
120
|
id={id}
|
121
121
|
>
|
122
122
|
<Caption dark={dark}>{label}</Caption>
|
123
|
+
|
123
124
|
<div className={`pb_currency_wrapper${variantClass || emphasizedClass}`}>
|
124
125
|
{unstyled ? (
|
125
126
|
nullDisplay && !amount ? (
|
@@ -174,7 +175,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
|
|
174
175
|
)}
|
175
176
|
</div>
|
176
177
|
</div>
|
177
|
-
)
|
178
|
+
);
|
178
179
|
}
|
179
180
|
|
180
181
|
export default Currency
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<% end %>
|
12
12
|
<% else %>
|
13
13
|
<% if object.null_display && object.amount.blank? %>
|
14
|
-
<%= pb_rails("title", props: object.
|
14
|
+
<%= pb_rails("title", props: {text: object.null_display}) %>
|
15
15
|
<% else %>
|
16
16
|
<%= pb_rails("body", props: object.currency_wrapper_props) do %>
|
17
17
|
<%= object.negative_sign %><%= object.symbol %>
|
@@ -68,20 +68,10 @@ module Playbook
|
|
68
68
|
}
|
69
69
|
end
|
70
70
|
|
71
|
-
def title_text
|
72
|
-
if null_display
|
73
|
-
null_display
|
74
|
-
elsif swap_negative
|
75
|
-
absolute_amount(abbr_or_format_amount)
|
76
|
-
else
|
77
|
-
abbr_or_format_amount
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
71
|
def title_props
|
82
72
|
{
|
83
73
|
size: size_value,
|
84
|
-
text:
|
74
|
+
text: swap_negative ? absolute_amount(abbr_or_format_amount) : abbr_or_format_amount,
|
85
75
|
classname: "pb_currency_value",
|
86
76
|
dark: dark,
|
87
77
|
}
|
@@ -158,10 +148,8 @@ module Playbook
|
|
158
148
|
1
|
159
149
|
when "md"
|
160
150
|
3
|
161
|
-
when "sm"
|
162
|
-
4
|
163
151
|
else
|
164
|
-
|
152
|
+
4
|
165
153
|
end
|
166
154
|
end
|
167
155
|
|
@@ -3,7 +3,6 @@
|
|
3
3
|
label: "Nil",
|
4
4
|
margin_bottom: "md",
|
5
5
|
null_display: "--",
|
6
|
-
size: "sm"
|
7
6
|
}) %>
|
8
7
|
|
9
8
|
<%= pb_rails("currency", props: {
|
@@ -11,12 +10,11 @@
|
|
11
10
|
label: "Nil",
|
12
11
|
margin_bottom: "md",
|
13
12
|
null_display: "$0.00",
|
14
|
-
size: "sm"
|
15
13
|
}) %>
|
16
14
|
|
17
15
|
<%= pb_rails("currency", props: {
|
18
16
|
amount: "",
|
19
17
|
label: "Nil",
|
18
|
+
margin_bottom: "md",
|
20
19
|
null_display: " ",
|
21
|
-
size: "sm"
|
22
20
|
}) %>
|
@@ -1,8 +1,5 @@
|
|
1
1
|
<%= pb_content_tag(:div,
|
2
|
-
class: object.classname + object.error_class
|
3
|
-
'data-pb-date-picker' => true,
|
4
|
-
'data-validation-message' => object.validation_message,
|
5
|
-
) do %>
|
2
|
+
class: object.classname + object.error_class) do %>
|
6
3
|
<div class="input_wrapper">
|
7
4
|
<% if content.present? %>
|
8
5
|
<%= content %>
|
@@ -75,8 +75,6 @@ module Playbook
|
|
75
75
|
default: [1900, 2100]
|
76
76
|
prop :custom_event_type, type: Playbook::Props::String,
|
77
77
|
default: ""
|
78
|
-
prop :validation_message, type: Playbook::Props::String,
|
79
|
-
default: ""
|
80
78
|
|
81
79
|
def classname
|
82
80
|
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
|