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.
Files changed (156) 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_bar_graph/_bar_graph.tsx +1 -1
  7. data/app/pb_kits/playbook/pb_card/_card.tsx +1 -2
  8. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +1 -1
  9. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -4
  10. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -2
  11. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -5
  12. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +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_filter/Filter/SortMenu.tsx +1 -2
  25. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -2
  26. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +2 -9
  27. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +0 -4
  28. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +0 -2
  29. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +0 -1
  30. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -7
  31. data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +1 -1
  32. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slide.tsx +1 -1
  33. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +1 -1
  34. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnails.tsx +1 -1
  35. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +1 -1
  36. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +0 -7
  37. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -13
  38. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -2
  39. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
  40. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -6
  41. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +0 -13
  42. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -7
  43. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -3
  44. data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
  45. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +3 -5
  46. data/app/pb_kits/playbook/pb_overlay/overlay.rb +1 -16
  47. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +0 -12
  48. data/app/pb_kits/playbook/pb_popover/_popover.tsx +2 -2
  49. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  50. data/app/pb_kits/playbook/pb_radio/_radio.tsx +74 -85
  51. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -2
  52. data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
  53. data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -16
  54. data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -1
  55. data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
  56. data/app/pb_kits/playbook/pb_select/select.html.erb +5 -3
  57. data/app/pb_kits/playbook/pb_select/select.rb +0 -8
  58. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
  59. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
  60. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
  61. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +3 -2
  62. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +2 -2
  63. data/app/pb_kits/playbook/pb_title/_title.scss +0 -32
  64. data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
  65. data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
  66. data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
  67. data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
  68. data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
  69. data/app/pb_kits/playbook/pb_title/title.rb +1 -10
  70. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +3 -0
  71. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +0 -25
  72. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +10 -0
  73. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -4
  74. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +0 -1
  75. data/app/pb_kits/playbook/pb_tooltip/index.js +1 -1
  76. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +2 -10
  77. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -1
  78. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +5 -51
  79. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -5
  80. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
  81. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
  82. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -3
  83. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +0 -1
  84. data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
  85. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -17
  86. data/app/pb_kits/playbook/utilities/object.ts +1 -103
  87. data/app/pb_kits/playbook/utilities/text.ts +1 -1
  88. data/dist/chunks/_typeahead-PqkcDf1H.js +36 -0
  89. data/dist/chunks/_weekday_stacked-BrSrpj7J.js +45 -0
  90. data/dist/chunks/{lib-e7oBFFDo.js → lib-D3us1bGD.js} +2 -2
  91. data/dist/chunks/{pb_form_validation-CMXevI1t.js → pb_form_validation-BpihMSOQ.js} +1 -1
  92. data/dist/chunks/vendor.js +1 -1
  93. data/dist/menu.yml +2 -2
  94. data/dist/playbook-doc.js +1 -1
  95. data/dist/playbook-rails-react-bindings.js +1 -1
  96. data/dist/playbook-rails.js +1 -1
  97. data/dist/playbook.css +1 -1
  98. data/lib/playbook/version.rb +2 -2
  99. metadata +7 -61
  100. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +0 -127
  101. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +0 -55
  102. data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +0 -33
  103. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +0 -275
  104. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +0 -66
  105. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +0 -195
  106. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +0 -73
  107. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +0 -52
  108. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +0 -80
  109. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +0 -50
  110. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +0 -152002
  111. data/app/pb_kits/playbook/pb_date_picker/index.ts +0 -38
  112. data/app/pb_kits/playbook/pb_dialog/index.js +0 -75
  113. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +0 -8
  114. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +0 -33
  115. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
  116. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +0 -24
  117. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +0 -21
  118. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +0 -1
  119. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +0 -49
  120. data/app/pb_kits/playbook/pb_drawer/index.js +0 -257
  121. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.html.erb +0 -40
  122. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.jsx +0 -50
  123. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_wrapped.md +0 -3
  124. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +0 -72
  125. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +0 -91
  126. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +0 -11
  127. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +0 -37
  128. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +0 -1
  129. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +0 -1
  130. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +0 -11
  131. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +0 -1
  132. data/app/pb_kits/playbook/pb_overlay/index.js +0 -61
  133. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +0 -60
  134. data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +0 -1
  135. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.jsx +0 -58
  136. data/app/pb_kits/playbook/pb_select/docs/_select_react_hook.md +0 -1
  137. data/app/pb_kits/playbook/pb_select/index.js +0 -38
  138. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
  139. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
  140. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
  141. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +0 -39
  142. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +0 -3
  143. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +0 -22
  144. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +0 -26
  145. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.jsx +0 -69
  146. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_sizing.md +0 -3
  147. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +0 -282
  148. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
  149. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
  150. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
  151. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +0 -3
  152. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +0 -66
  153. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +0 -1
  154. data/app/pb_kits/playbook/utilities/object.test.js +0 -237
  155. data/dist/chunks/_typeahead-CdVbIURO.js +0 -36
  156. data/dist/chunks/_weekday_stacked-BSTKfYPJ.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
@@ -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 '../utilities/object'
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 '../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'
@@ -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 '../utilities/object'
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 .pb_drawer {
137
+ .pb_drawer_lg_left.pb_drawer {
138
138
  transform: translateX(-100%);
139
139
  }
140
140
 
141
- .pb_drawer_lg_right .pb_drawer {
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
  }