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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +3 -143
  3. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +99 -45
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -123
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +299 -153
  6. data/app/pb_kits/playbook/pb_card/_card.tsx +1 -2
  7. data/app/pb_kits/playbook/pb_currency/_currency.tsx +2 -1
  8. data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -1
  9. data/app/pb_kits/playbook/pb_currency/currency.rb +2 -14
  10. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +1 -3
  11. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -4
  12. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -2
  13. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +3 -43
  14. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -3
  15. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +37 -20
  16. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +1 -20
  17. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +6 -6
  18. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +0 -1
  19. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +0 -6
  20. data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +12 -20
  21. data/app/pb_kits/playbook/pb_drawer/drawer.rb +1 -49
  22. data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +4 -5
  23. data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
  24. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -2
  25. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -9
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +0 -4
  27. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +0 -2
  28. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +0 -1
  29. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -7
  30. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +0 -4
  31. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +0 -7
  32. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -13
  33. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -2
  34. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
  35. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -6
  36. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +0 -13
  37. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -7
  38. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -3
  39. data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
  40. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +3 -5
  41. data/app/pb_kits/playbook/pb_overlay/overlay.rb +1 -16
  42. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +0 -12
  43. data/app/pb_kits/playbook/pb_popover/_popover.tsx +2 -2
  44. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  45. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +2 -2
  46. data/app/pb_kits/playbook/pb_radio/_radio.tsx +74 -85
  47. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -2
  48. data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
  49. data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -16
  50. data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -1
  51. data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
  52. data/app/pb_kits/playbook/pb_select/select.html.erb +5 -3
  53. data/app/pb_kits/playbook/pb_select/select.rb +0 -8
  54. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
  55. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
  56. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
  57. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
  58. data/app/pb_kits/playbook/pb_title/_title.scss +0 -32
  59. data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
  60. data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
  61. data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
  62. data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
  63. data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
  64. data/app/pb_kits/playbook/pb_title/title.rb +1 -10
  65. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +3 -0
  66. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -25
  67. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -3
  68. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +0 -1
  69. data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
  70. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
  71. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -36
  72. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -5
  73. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
  74. data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
  75. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -17
  76. data/app/pb_kits/playbook/utilities/object.ts +1 -29
  77. data/dist/chunks/_typeahead-PqkcDf1H.js +36 -0
  78. data/dist/chunks/_weekday_stacked-BhC8Xp9l.js +45 -0
  79. data/dist/chunks/{lib-5OzNgeeu.js → lib-D3us1bGD.js} +2 -2
  80. data/dist/chunks/{pb_form_validation-DGhKbZtO.js → pb_form_validation-BpihMSOQ.js} +1 -1
  81. data/dist/chunks/vendor.js +1 -1
  82. data/dist/menu.yml +3 -3
  83. data/dist/playbook-doc.js +1 -1
  84. data/dist/playbook-rails-react-bindings.js +1 -1
  85. data/dist/playbook-rails.js +1 -1
  86. data/dist/playbook.css +1 -1
  87. data/lib/playbook/version.rb +1 -1
  88. metadata +6 -64
  89. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +0 -127
  90. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +0 -55
  91. data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +0 -33
  92. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +0 -275
  93. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +0 -66
  94. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +0 -195
  95. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +0 -73
  96. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +0 -52
  97. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +0 -80
  98. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +0 -50
  99. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +0 -152002
  100. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +0 -1
  101. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +0 -1
  102. data/app/pb_kits/playbook/pb_date_picker/index.ts +0 -38
  103. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +0 -8
  104. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +0 -33
  105. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
  106. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +0 -24
  107. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +0 -21
  108. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +0 -1
  109. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +0 -49
  110. data/app/pb_kits/playbook/pb_drawer/index.js +0 -257
  111. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +0 -40
  112. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +0 -50
  113. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +0 -3
  114. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +0 -71
  115. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +0 -17
  116. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +0 -61
  117. data/app/pb_kits/playbook/pb_icon_button/docs/index.js +0 -2
  118. data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +0 -39
  119. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +0 -72
  120. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +0 -91
  121. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +0 -11
  122. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +0 -37
  123. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +0 -1
  124. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +0 -1
  125. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +0 -11
  126. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +0 -1
  127. data/app/pb_kits/playbook/pb_overlay/index.js +0 -61
  128. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +0 -60
  129. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +0 -1
  130. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +0 -58
  131. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +0 -1
  132. data/app/pb_kits/playbook/pb_select/index.js +0 -38
  133. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
  134. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
  135. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
  136. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +0 -39
  137. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +0 -3
  138. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +0 -26
  139. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +0 -69
  140. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +0 -3
  141. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
  142. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
  143. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
  144. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
  145. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +0 -3
  146. data/app/pb_kits/playbook/utilities/object.test.js +0 -99
  147. data/dist/chunks/_typeahead-F4bG5YsC.js +0 -36
  148. data/dist/chunks/_weekday_stacked-CaWVQMMq.js +0 -45
@@ -1,23 +1,38 @@
1
- import React, { useRef, useEffect } from "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 { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
8
- import { globalProps, GlobalProps } from "../utilities/globalProps";
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 Table from "../pb_table/_table";
11
- import { AdvancedTableProvider } from "./Context/AdvancedTableContext";
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 { TableHeader } from "./SubKits/TableHeader";
15
- import { TableBody } from "./SubKits/TableBody";
16
- import TablePagination from "./Components/TablePagination";
17
- import TableActionBar from "./Components/TableActionBar";
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 { useTableState } from "./Hooks/useTableState";
20
- import { useTableActions } from "./Hooks/useTableActions";
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
- virtualizedRows?: boolean
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
- virtualizedRows = false,
85
- } = props;
98
+ } = props
86
99
 
87
- // Component refs
88
- const tableWrapperRef = useRef<HTMLDivElement>(null);
100
+ const [loadingStateRowCount, setLoadingStateRowCount] = useState(
101
+ initialLoadingRowsCount
102
+ )
89
103
 
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
- });
104
+ // Create a local state for expanded and setExpanded if expandedControl not used
105
+ const [localExpanded, setLocalExpanded] = useState({})
117
106
 
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
- });
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
- // 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]);
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
- // Build CSS classes and props
150
- const ariaProps = buildAriaProps(aria);
151
- const dataProps = buildDataProps(data);
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
- // Table wrapper styling with virtualization support
162
- const tableWrapperStyle = virtualizedRows
163
- ? getVirtualizedContainerStyles(maxHeight)
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
- // Visibility flag for action bar
167
- const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0;
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
- {...ariaProps}
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
- <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}
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
- <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 */}
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
- {/* Bottom Pagination */}
246
- {pagination && (
247
- <TablePagination
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
- position="bottom"
250
- range={paginationProps?.range}
251
- table={table}
397
+ range={paginationProps?.range ? paginationProps?.range : 5}
398
+ total={table.getPageCount()}
252
399
  />
253
- )}
254
- </React.Fragment>
255
- </AdvancedTableProvider>
400
+ }
401
+ </>
402
+ </AdvancedTableContext.Provider>
256
403
  </div>
257
- );
258
- };
404
+ )
405
+ }
259
406
 
260
- // Re-export sub-components
261
- AdvancedTable.Header = TableHeader;
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 '../utilities/object'
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.title_props) %>
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: title_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
- 3
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"