playbook_ui 14.15.0.pre.alpha.play1917lodashremoval2of36615 → 14.15.0.pre.rc.0
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_bar_graph/_bar_graph.tsx +1 -1
- data/app/pb_kits/playbook/pb_card/_card.tsx +1 -2
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
- 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_dialog/dialog.html.erb +6 -5
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +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_filter/Filter/SortMenu.tsx +1 -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_gauge/_gauge.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.tsx +1 -1
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +1 -1
- 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_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_text_input/inputMask.ts +3 -2
- 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/_tooltip_icon.erb +10 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -4
- data/app/pb_kits/playbook/pb_tooltip/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_tooltip/index.js +1 -1
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +5 -51
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -5
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +0 -1
- 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 -103
- data/app/pb_kits/playbook/utilities/text.ts +1 -1
- data/dist/chunks/_typeahead-PqkcDf1H.js +36 -0
- data/dist/chunks/_weekday_stacked-BrSrpj7J.js +45 -0
- data/dist/chunks/{lib-e7oBFFDo.js → lib-D3us1bGD.js} +2 -2
- data/dist/chunks/{pb_form_validation-CMXevI1t.js → pb_form_validation-BpihMSOQ.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +2 -2
- 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 +2 -2
- metadata +7 -61
- 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_date_picker/index.ts +0 -38
- data/app/pb_kits/playbook/pb_dialog/index.js +0 -75
- 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_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_icon_rails.html.erb +0 -22
- 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/pb_typeahead/docs/_typeahead_react_hook.jsx +0 -66
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +0 -1
- data/app/pb_kits/playbook/utilities/object.test.js +0 -237
- data/dist/chunks/_typeahead-CdVbIURO.js +0 -36
- data/dist/chunks/_weekday_stacked-BSTKfYPJ.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
|
@@ -7,7 +7,7 @@ import Highcharts from "highcharts";
|
|
7
7
|
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
8
8
|
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
9
9
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
10
|
-
import { merge } from '
|
10
|
+
import { merge } from 'lodash'
|
11
11
|
|
12
12
|
import classnames from "classnames";
|
13
13
|
|
@@ -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'
|
@@ -10,7 +10,7 @@ import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
|
10
10
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
11
|
import { globalProps } from "../utilities/globalProps";
|
12
12
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
13
|
-
import { merge } from '
|
13
|
+
import { merge } from 'lodash'
|
14
14
|
|
15
15
|
type CircleChartProps = {
|
16
16
|
align?: "left" | "right" | "center";
|
@@ -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"
|
@@ -1,8 +1,4 @@
|
|
1
|
-
<div
|
2
|
-
class="pb_dialog_wrapper_rails <%= object.full_height_style %>"
|
3
|
-
data-pb-dialog-wrapper="true"
|
4
|
-
data-overlay-click= <%= object.overlay_close %>
|
5
|
-
>
|
1
|
+
<div class="pb_dialog_wrapper_rails <%= object.full_height_style %>" data-overlay-click= <%= object.overlay_close %> >
|
6
2
|
<%= pb_content_tag(:dialog) do %>
|
7
3
|
<% if object.status === "" && object.title %>
|
8
4
|
<%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id }) %>
|
@@ -37,3 +33,8 @@
|
|
37
33
|
<%= content %>
|
38
34
|
<% end %>
|
39
35
|
</div>
|
36
|
+
|
37
|
+
<%= javascript_tag do %>
|
38
|
+
window.addEventListener("DOMContentLoaded", () => dialogHelper())
|
39
|
+
window.addEventListener("turbo:frame-load", () => dialogHelper())
|
40
|
+
<% end %>
|
@@ -1,5 +1,3 @@
|
|
1
|
-
// Three places in Nitro depend on this function inside the window scope.
|
2
|
-
// We will keep this file until we remove this dependency from Nitro.
|
3
1
|
const dialogHelper = () => {
|
4
2
|
const openTrigger = document.querySelectorAll("[data-open-dialog]");
|
5
3
|
const closeTrigger = document.querySelectorAll("[data-close-dialog]");
|
@@ -134,11 +134,11 @@ body.PBDrawer__Body--close {
|
|
134
134
|
transition: margin-left $animation-duration ease-out, margin-right $animation-duration ease-out;
|
135
135
|
}
|
136
136
|
|
137
|
-
.pb_drawer_lg_left
|
137
|
+
.pb_drawer_lg_left.pb_drawer {
|
138
138
|
transform: translateX(-100%);
|
139
139
|
}
|
140
140
|
|
141
|
-
.pb_drawer_lg_right
|
141
|
+
.pb_drawer_lg_right.pb_drawer {
|
142
142
|
transform: translateX(100%);
|
143
143
|
}
|
144
144
|
|
@@ -157,34 +157,6 @@ body.PBDrawer__Body--close {
|
|
157
157
|
animation-duration: $animation-duration;
|
158
158
|
outline: none;
|
159
159
|
|
160
|
-
&.pb_drawer_within_element_rails {
|
161
|
-
position: relative;
|
162
|
-
width: 100%;
|
163
|
-
display: block;
|
164
|
-
background-color: $white;
|
165
|
-
overflow: hidden;
|
166
|
-
|
167
|
-
// Use max-height for a smooth accordion-like animation
|
168
|
-
max-height: 0;
|
169
|
-
transition: max-height $animation-duration ease-in-out;
|
170
|
-
z-index: 1;
|
171
|
-
|
172
|
-
&.open {
|
173
|
-
max-height: 1000px;
|
174
|
-
}
|
175
|
-
|
176
|
-
&::before {
|
177
|
-
content: '';
|
178
|
-
position: absolute;
|
179
|
-
top: 0;
|
180
|
-
left: 0;
|
181
|
-
right: 0;
|
182
|
-
bottom: 0;
|
183
|
-
background-color: inherit;
|
184
|
-
z-index: -1;
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
160
|
&.pb_drawer_within_element {
|
189
161
|
position: relative;
|
190
162
|
width: 100%;
|
@@ -325,6 +297,7 @@ body.PBDrawer__Body--close {
|
|
325
297
|
display: flex;
|
326
298
|
background-color: rgba($bg_dark, $opacity_4);
|
327
299
|
z-index: $z-index;
|
300
|
+
opacity: 0;
|
328
301
|
animation: overlayFade $animation-duration ease-in-out forwards;
|
329
302
|
|
330
303
|
&[class*="_left"]{
|
@@ -352,23 +325,10 @@ body.PBDrawer__Body--close {
|
|
352
325
|
left: 0;
|
353
326
|
right: 0;
|
354
327
|
bottom: 0;
|
355
|
-
display: flex;
|
356
328
|
z-index: $z-index;
|
357
329
|
opacity: 1;
|
358
330
|
pointer-events: none;
|
359
331
|
|
360
|
-
&[class*="_right"]{
|
361
|
-
justify-content: flex-end;
|
362
|
-
}
|
363
|
-
|
364
|
-
&[class*="_left"]{
|
365
|
-
justify-content: flex-start;
|
366
|
-
}
|
367
|
-
|
368
|
-
&[class*="_center"]{
|
369
|
-
justify-content: center;
|
370
|
-
}
|
371
|
-
|
372
332
|
&_before_close {
|
373
333
|
height: 0;
|
374
334
|
}
|