playbook_ui 14.14.0.pre.rc.5 → 14.15.0.pre.alpha.PBNTR617addgriddisplayglobalprop6700

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