playbook_ui 14.13.0.pre.rc.10 → 14.14.0.pre.alpha.PBNTR866finalizecssendlessscroll6462

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 (213) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +127 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +55 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/TablePagination.tsx +33 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +275 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +143 -3
  8. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +66 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +195 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +45 -99
  11. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +73 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +52 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +80 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +190 -6
  15. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +155 -297
  16. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +8 -1
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_custom_cell.jsx +75 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.jsx +50 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -0
  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 +3 -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.jsx +55 -0
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +3 -0
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -0
  27. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data_infinite_scroll.json +152002 -0
  28. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +5 -1
  29. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +4 -1
  30. data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +58 -0
  31. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +64 -0
  32. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +1 -0
  33. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -0
  34. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +17 -8
  36. data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +16 -0
  37. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.jsx +69 -0
  38. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_react_hook.md +1 -0
  39. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -1
  40. data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_currency/_currency.tsx +46 -31
  42. data/app/pb_kits/playbook/pb_currency/currency.html.erb +15 -8
  43. data/app/pb_kits/playbook/pb_currency/currency.rb +17 -2
  44. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.html.erb +22 -0
  45. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display.jsx +34 -0
  46. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_rails.md +1 -0
  47. data/app/pb_kits/playbook/pb_currency/docs/_currency_null_display_react.md +1 -0
  48. data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
  49. data/app/pb_kits/playbook/pb_currency/docs/index.js +2 -1
  50. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +3 -1
  51. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.html.erb +99 -0
  52. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.md +1 -0
  53. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb +61 -0
  54. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md +4 -0
  55. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.jsx +90 -0
  56. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table_react.md +5 -0
  57. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +4 -5
  58. data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
  59. data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +2 -2
  60. data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +5 -0
  61. data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +1 -1
  62. data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +4 -0
  63. data/app/pb_kits/playbook/pb_draggable/index.js +151 -15
  64. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +7 -4
  65. data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +6 -3
  66. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +32 -8
  67. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.html.erb +8 -0
  68. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.html.erb +33 -0
  69. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.html.erb +0 -0
  70. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +20 -1
  71. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.html.erb +24 -0
  72. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.html.erb +21 -0
  73. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.md +1 -0
  74. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.html.erb +49 -0
  75. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +5 -0
  76. data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +20 -12
  77. data/app/pb_kits/playbook/pb_drawer/drawer.rb +49 -1
  78. data/app/pb_kits/playbook/pb_drawer/index.js +257 -0
  79. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -0
  80. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +2 -1
  81. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +11 -7
  82. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.html.erb +11 -0
  83. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.jsx +22 -0
  84. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_rails.md +1 -0
  85. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_react.md +1 -0
  86. data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +2 -0
  87. data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +1 -0
  88. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +13 -2
  89. data/app/pb_kits/playbook/pb_icon/icon.html.erb +2 -6
  90. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +71 -0
  91. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.html.erb +1 -2
  92. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_default.jsx +17 -0
  93. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.html.erb +27 -0
  94. data/app/pb_kits/playbook/pb_icon_button/docs/_icon_button_sizes.jsx +61 -0
  95. data/app/pb_kits/playbook/pb_icon_button/docs/example.yml +5 -3
  96. data/app/pb_kits/playbook/pb_icon_button/docs/index.js +2 -0
  97. data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
  98. data/app/pb_kits/playbook/pb_icon_button/icon_button.rb +3 -0
  99. data/app/pb_kits/playbook/pb_icon_button/icon_button.test.jsx +39 -0
  100. data/app/pb_kits/playbook/pb_layout/body.html.erb +1 -5
  101. data/app/pb_kits/playbook/pb_layout/footer.html.erb +1 -5
  102. data/app/pb_kits/playbook/pb_layout/header.html.erb +1 -5
  103. data/app/pb_kits/playbook/pb_layout/item.html.erb +1 -5
  104. data/app/pb_kits/playbook/pb_layout/layout.html.erb +1 -5
  105. data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +1 -5
  106. data/app/pb_kits/playbook/pb_legend/legend.html.erb +1 -6
  107. data/app/pb_kits/playbook/pb_message/message.html.erb +1 -6
  108. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +1 -6
  109. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +1 -6
  110. data/app/pb_kits/playbook/pb_nav/item.html.erb +7 -19
  111. data/app/pb_kits/playbook/pb_nav/nav.html.erb +3 -8
  112. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -6
  113. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +13 -0
  114. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +11 -1
  115. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +11 -0
  116. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +37 -0
  117. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +1 -0
  118. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +1 -0
  119. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.html.erb +11 -0
  120. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +37 -0
  121. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.md +1 -0
  122. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional_react.md +1 -0
  123. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +4 -0
  124. data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
  125. data/app/pb_kits/playbook/pb_overlay/index.js +61 -0
  126. data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +5 -3
  127. data/app/pb_kits/playbook/pb_overlay/overlay.rb +16 -1
  128. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +12 -0
  129. data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +48 -10
  130. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -6
  131. data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.scss +6 -1
  132. data/app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx +7 -5
  133. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.html.erb +1 -0
  134. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.jsx +7 -0
  135. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_default.md +1 -0
  136. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.html.erb +1 -0
  137. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width.jsx +18 -0
  138. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_rails.md +1 -0
  139. data/app/pb_kits/playbook/pb_progress_pills/docs/_progress_pills_full_width_react.md +1 -0
  140. data/app/pb_kits/playbook/pb_progress_pills/docs/example.yml +2 -0
  141. data/app/pb_kits/playbook/pb_progress_pills/docs/index.js +1 -0
  142. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +2 -7
  143. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.rb +6 -0
  144. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.test.js +26 -1
  145. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +1 -5
  146. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -5
  147. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +3 -7
  148. data/app/pb_kits/playbook/pb_radio/radio.html.erb +6 -11
  149. data/app/pb_kits/playbook/pb_select/index.js +38 -0
  150. data/app/pb_kits/playbook/pb_select/select.rb +8 -0
  151. data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.html.erb +47 -0
  152. data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.jsx +88 -0
  153. data/app/pb_kits/playbook/pb_table/docs/_table_with_clickable_rows.md +1 -0
  154. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.jsx +1 -1
  155. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.html.erb +51 -0
  156. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click_rails.md +2 -0
  157. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +96 -0
  158. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.jsx +101 -0
  159. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.md +1 -0
  160. data/app/pb_kits/playbook/pb_table/docs/example.yml +5 -0
  161. data/app/pb_kits/playbook/pb_table/docs/index.js +3 -1
  162. data/app/pb_kits/playbook/pb_table/index.ts +41 -9
  163. data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +4 -0
  164. data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +29 -2
  165. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +31 -3
  166. data/app/pb_kits/playbook/pb_table/table_body.html.erb +13 -7
  167. data/app/pb_kits/playbook/pb_table/table_body.rb +2 -0
  168. data/app/pb_kits/playbook/pb_table/table_row.html.erb +14 -7
  169. data/app/pb_kits/playbook/pb_table/table_row.rb +14 -1
  170. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +15 -1
  171. data/app/pb_kits/playbook/pb_text_input/index.js +60 -82
  172. data/app/pb_kits/playbook/pb_text_input/text_input.rb +5 -2
  173. data/app/pb_kits/playbook/pb_tooltip/_tooltip.scss +0 -3
  174. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.html.erb +39 -0
  175. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_delay_rails.md +3 -0
  176. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_interaction.html.erb +26 -0
  177. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +2 -0
  178. data/app/pb_kits/playbook/pb_tooltip/floating_ui.js +282 -0
  179. data/app/pb_kits/playbook/pb_tooltip/index.js +2 -2
  180. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +10 -2
  181. data/dist/chunks/_typeahead-B1p_cPQJ.js +36 -0
  182. data/dist/chunks/_weekday_stacked-DTN9JLqd.js +45 -0
  183. data/dist/chunks/{lib-DjpLC8uO.js → lib-Fr78pbpF.js} +2 -2
  184. data/dist/chunks/{pb_form_validation-S56UaHZl.js → pb_form_validation-CN51bfsD.js} +1 -1
  185. data/dist/chunks/vendor.js +1 -1
  186. data/dist/menu.yml +3 -10
  187. data/dist/playbook-doc.js +1 -1
  188. data/dist/playbook-rails-react-bindings.js +1 -1
  189. data/dist/playbook-rails.js +1 -1
  190. data/dist/playbook.css +1 -1
  191. data/lib/playbook/forms/builder/time_zone_select_field.rb +19 -0
  192. data/lib/playbook/forms/builder.rb +1 -0
  193. data/lib/playbook/version.rb +2 -2
  194. metadata +84 -23
  195. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +0 -66
  196. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.tsx +0 -98
  197. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +0 -28
  198. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.rb +0 -42
  199. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.html.erb +0 -19
  200. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_actions.jsx +0 -26
  201. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.html.erb +0 -10
  202. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_default.jsx +0 -17
  203. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_on_click.jsx +0 -19
  204. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_onclick.html.erb +0 -16
  205. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.html.erb +0 -35
  206. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_placement.jsx +0 -42
  207. data/app/pb_kits/playbook/pb_avatar_action_button/docs/_avatar_action_button_tooltip.html.erb +0 -13
  208. data/app/pb_kits/playbook/pb_avatar_action_button/docs/example.yml +0 -15
  209. data/app/pb_kits/playbook/pb_avatar_action_button/docs/index.js +0 -4
  210. data/app/pb_kits/playbook/pb_avatar_action_button/pb_avatar_action_button.test.js +0 -31
  211. data/dist/chunks/_typeahead-CkemExmL.js +0 -36
  212. data/dist/chunks/_weekday_stacked-CtSzPEH0.js +0 -45
  213. /data/app/pb_kits/playbook/pb_table/docs/{_table_with_collapsible_with_custom_click.md → _table_with_collapsible_with_custom_click_react.md} +0 -0
@@ -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 }
@@ -49,6 +34,7 @@ type AdvancedTableProps = {
49
34
  initialLoadingRowsCount?: number
50
35
  inlineRowLoading?: boolean
51
36
  loading?: boolean | string
37
+ maxHeight?: "auto" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | "xxxl"
52
38
  onRowToggleClick?: (arg: Row<GenericObject>) => void
53
39
  onToggleExpansionClick?: (arg: Row<GenericObject>) => void
54
40
  pagination?: boolean,
@@ -62,7 +48,8 @@ type AdvancedTableProps = {
62
48
  tableProps?: GenericObject
63
49
  toggleExpansionIcon?: string | string[]
64
50
  onRowSelectionChange?: (arg: RowSelectionState) => void
65
- } & GlobalProps
51
+ virtualizedRows?: boolean
52
+ } & GlobalProps;
66
53
 
67
54
  const AdvancedTable = (props: AdvancedTableProps) => {
68
55
  const {
@@ -80,6 +67,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
80
67
  initialLoadingRowsCount = 10,
81
68
  inlineRowLoading = false,
82
69
  loading,
70
+ maxHeight,
83
71
  onRowToggleClick,
84
72
  onToggleExpansionClick,
85
73
  pagination = false,
@@ -93,280 +81,149 @@ const AdvancedTable = (props: AdvancedTableProps) => {
93
81
  tableProps,
94
82
  toggleExpansionIcon = "arrows-from-line",
95
83
  onRowSelectionChange,
96
- } = props
97
-
98
- const [loadingStateRowCount, setLoadingStateRowCount] = useState(
99
- initialLoadingRowsCount
100
- )
101
-
102
- // Create a local state for expanded and setExpanded if expandedControl not used
103
- const [localExpanded, setLocalExpanded] = useState({})
104
-
105
- // Determine whether to use the prop or the local state
106
- const expanded = expandedControl ? expandedControl.value : localExpanded
107
- const setExpanded = expandedControl
108
- ? expandedControl.onChange
109
- : setLocalExpanded
110
-
111
- const columnHelper = createColumnHelper()
112
-
113
- //Row Selection
114
- const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
115
-
116
- //Create cells for columns, with customization for first column
117
- const createCellFunction = (cellAccessors: string[], customRenderer?: (row: Row<GenericObject>, value: any) => JSX.Element, index?: number) => {
118
- const columnCells = ({
119
- row,
120
- getValue,
121
- }: {
122
- row: Row<GenericObject>
123
- getValue: Getter<string>
124
- }) => {
125
- const rowData = row.original
126
-
127
- if (index === 0) {
128
- switch (row.depth) {
129
- case 0: {
130
- return (
131
- <CustomCell
132
- customRenderer={customRenderer}
133
- getValue={getValue}
134
- onRowToggleClick={onRowToggleClick}
135
- row={row}
136
- selectableRows={selectableRows}
137
- />
138
- )
139
- }
140
- default: {
141
- // Handle other depths based on cellAccessors
142
- const depthAccessor = cellAccessors[row.depth - 1] // Adjust index for depth
143
- const accessorValue = rowData[depthAccessor]
144
- return accessorValue ? (
145
- <CustomCell
146
- customRenderer={customRenderer}
147
- onRowToggleClick={onRowToggleClick}
148
- row={row}
149
- selectableRows={selectableRows}
150
- value={accessorValue}
151
- />
152
- ) : (
153
- "N/A"
154
- )
155
- }
156
- }
157
- }
158
- return customRenderer
159
- ? customRenderer(row, getValue())
160
- : getValue()
161
- }
162
- return columnCells
163
- }
84
+ virtualizedRows = false,
85
+ } = props;
164
86
 
165
- const buildColumns = (columnDefinitions: GenericObject[]): any => {
166
- return (
167
- columnDefinitions &&
168
- columnDefinitions.map((column, index) => {
169
- //Checking to see if grouped column or not
170
- if (column.columns && column.columns.length > 0) {
171
- return {
172
- header: column.label || "",
173
- columns: buildColumns(column.columns),
174
- };
175
- } else {
176
- // Define the base column structure
177
- const columnStructure = {
178
- ...columnHelper.accessor(column.accessor, {
179
- header: column.label || "",
180
- }),
181
- };
87
+ // Component refs
88
+ const tableWrapperRef = useRef<HTMLDivElement>(null);
182
89
 
183
- if (column.cellAccessors || column.customRenderer) {
184
- columnStructure.cell = createCellFunction(
185
- column.cellAccessors,
186
- column.customRenderer,
187
- index
188
- );
189
- }
190
-
191
- return columnStructure;
192
- }
193
- })
194
- );
195
- };
196
-
197
- //Create column array in format needed by Tanstack
198
- const columns = buildColumns(columnDefinitions);
199
-
200
- //Syntax for sorting Array if we want to manage state ourselves
201
- const sorting = [
202
- {
203
- id: columnDefinitions[0].accessor,
204
- desc:
205
- sortControl && sortControl.value !== null
206
- ? !sortControl.value.desc
207
- : false,
208
- },
209
- ]
210
-
211
- const customState = () => {
212
- if (sortControl && selectableRows) {
213
- return { state: { expanded, sorting, rowSelection } }
214
- } else if (sortControl) {
215
- return { state: { expanded, sorting } }
216
- } else if (selectableRows) {
217
- return { state: { expanded, rowSelection } }
218
- } else {
219
- return { state: { expanded } }
220
- }
221
- }
222
-
223
- const paginationInitializer = pagination ? {
224
- getPaginationRowModel: getPaginationRowModel(),
225
- paginateExpandedRows: false,
226
- initialState: {
227
- pagination: {
228
- pageIndex: paginationProps?.pageIndex ?? 0,
229
- pageSize: paginationProps?.pageSize ?? 20,
230
- },
231
- },
232
- } : {}
233
-
234
- //initialize table
235
- const table = useReactTable({
236
- data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
237
- columns,
238
- onExpandedChange: setExpanded,
239
- getSubRows: (row: GenericObject) => row.children,
240
- getCoreRowModel: getCoreRowModel(),
241
- getExpandedRowModel: getExpandedRowModel(),
242
- getSortedRowModel: getSortedRowModel(),
243
- enableSortingRemoval: false,
244
- sortDescFirst: true,
245
- onRowSelectionChange: setRowSelection,
246
- getRowId: selectableRows ? row => row.id : undefined,
247
- ...customState(),
248
- ...paginationInitializer,
249
- ...tableOptions,
250
- })
251
-
252
- const tableRows = table.getRowModel()
253
-
254
- const hasAnySubRows = tableRows.rows.some(row => row.subRows && row.subRows.length > 0);
255
- 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
+ });
256
117
 
257
- useEffect(() => {
258
- if (onRowSelectionChange) {
259
- onRowSelectionChange(table.getState().rowSelection)
260
- }
261
- } , [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
+ });
262
130
 
263
131
  // Set table row count for loading state
264
- const updateLoadingStateRowCount = useCallback(() => {
265
- const rowsCount = table.getRowModel().rows.length
266
- if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
267
- setLoadingStateRowCount(rowsCount)
268
- }
269
- }, [tableData, loadingStateRowCount])
270
-
271
132
  useEffect(() => {
272
133
  if (!loading) {
273
- updateLoadingStateRowCount()
134
+ updateLoadingStateRowCount();
274
135
  }
275
- }, [loading, updateLoadingStateRowCount])
136
+ }, [loading, updateLoadingStateRowCount]);
276
137
 
277
- const handleExpandOrCollapse = async (row: Row<GenericObject>) => {
278
- onToggleExpansionClick && onToggleExpansionClick(row)
279
-
280
- const expandedState = expanded;
281
- const targetParent = row?.parentId;
282
- const updatedRows = await updateExpandAndCollapseState(tableRows, expandedState, targetParent)
283
- setExpanded(updatedRows)
284
- }
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]);
285
148
 
286
- const ariaProps = buildAriaProps(aria)
287
- const dataProps = buildDataProps(data)
288
- 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);
289
153
  const classes = classnames(
290
154
  buildCss("pb_advanced_table"),
291
155
  `advanced-table-responsive-${responsive}`,
156
+ maxHeight ? `advanced-table-max-height-${maxHeight}` : '',
292
157
  globalProps(props),
293
158
  className
294
- )
159
+ );
295
160
 
296
- const onPageChange = (page: number) => {
297
- table.setPageIndex(page - 1)
298
- }
299
- //When to show the actions bar as a whole
300
- const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0
161
+ // Table wrapper styling with virtualization support
162
+ const tableWrapperStyle = virtualizedRows
163
+ ? getVirtualizedContainerStyles(maxHeight)
164
+ : {};
301
165
 
302
- //Ref and useEffect for animating the actions bar
303
- const cardRef = useRef(null);
304
- useEffect(() => {
305
- if (cardRef.current) {
306
- if (isActionBarVisible) {
307
- showActionBar(cardRef.current);
308
- } else {
309
- hideActionBar(cardRef.current);
310
- }
311
- }
312
- }, [isActionBarVisible]);
166
+ // Visibility flag for action bar
167
+ const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0;
313
168
 
314
169
  return (
315
- <div {...ariaProps}
316
- {...dataProps}
170
+ <div
171
+ {...ariaProps}
172
+ {...dataProps}
317
173
  {...htmlProps}
318
- className={classes}
174
+ className={classes}
319
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}
320
185
  >
321
- <AdvancedTableContext.Provider
322
- value={{
323
- columnDefinitions,
324
- enableToggleExpansion,
325
- expanded,
326
- expandedControl,
327
- handleExpandOrCollapse,
328
- inlineRowLoading,
329
- isActionBarVisible,
330
- loading,
331
- responsive,
332
- setExpanded,
333
- sortControl,
334
- table,
335
- toggleExpansionIcon,
336
- showActionsBar,
337
- selectableRows,
338
- hasAnySubRows
339
- }}
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}
340
207
  >
341
- <>
342
- {pagination &&
343
- <Pagination
344
- current={table.getState().pagination.pageIndex + 1}
345
- key={`pagination-top-${table.getState().pagination.pageIndex + 1}`}
346
- marginBottom="xs"
347
- onChange={onPageChange}
348
- range={paginationProps?.range ? paginationProps?.range : 5}
349
- total={table.getPageCount()}
350
- />
351
- }
352
- <Card
353
- borderNone={!isActionBarVisible}
354
- className={`${isActionBarVisible && "show-action-card row-selection-actions-card"}`}
355
- htmlOptions={{ ref: cardRef as any }}
356
- padding={`${isActionBarVisible ? "xs" : "none"}`}
357
- >
358
- <Flex alignItems="center"
359
- justify="between"
360
- >
361
- <Caption color="light"
362
- paddingLeft="xs"
363
- size="xs"
364
- >
365
- {selectedRowsLength} Selected
366
- </Caption>
367
- <FlexItem>{actions}</FlexItem>
368
- </Flex>
369
- </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 */}
370
227
  <Table
371
228
  className={`${loading ? "content-loading" : ""}`}
372
229
  dark={dark}
@@ -384,23 +241,24 @@ const AdvancedTable = (props: AdvancedTableProps) => {
384
241
  </>
385
242
  )}
386
243
  </Table>
387
- {pagination &&
388
- <Pagination
389
- current={table.getState().pagination.pageIndex + 1}
390
- key={`pagination-bottom-${table.getState().pagination.pageIndex + 1}`}
391
- marginTop="xs"
244
+
245
+ {/* Bottom Pagination */}
246
+ {pagination && (
247
+ <TablePagination
392
248
  onChange={onPageChange}
393
- range={paginationProps?.range ? paginationProps?.range : 5}
394
- total={table.getPageCount()}
249
+ position="bottom"
250
+ range={paginationProps?.range}
251
+ table={table}
395
252
  />
396
- }
397
- </>
398
- </AdvancedTableContext.Provider>
253
+ )}
254
+ </React.Fragment>
255
+ </AdvancedTableProvider>
399
256
  </div>
400
- )
401
- }
257
+ );
258
+ };
402
259
 
403
- AdvancedTable.Header = TableHeader
404
- AdvancedTable.Body = TableBody
260
+ // Re-export sub-components
261
+ AdvancedTable.Header = TableHeader;
262
+ AdvancedTable.Body = TableBody;
405
263
 
406
- 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
@@ -30,4 +30,4 @@
30
30
  }
31
31
  ] %>
32
32
 
33
- <%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { container: false, sticky: true }}) %>
33
+ <%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, responsive: "none", table_props: { container: false, sticky: true }}) %>
@@ -44,6 +44,7 @@ const AdvancedTableTableProps = (props) => {
44
44
  <div>
45
45
  <AdvancedTable
46
46
  columnDefinitions={columnDefinitions}
47
+ responsive="none"
47
48
  tableData={MOCK_DATA}
48
49
  tableProps={tableProps}
49
50
  {...props}