playbook_ui 13.21.0.pre.alpha.pbntr220improveexpansionspeed2451 → 13.22.0.pre.alpha.playbookgemspecrailsversion2608

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +23 -17
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +6 -3
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +12 -8
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +14 -9
  6. data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +9 -5
  7. data/app/pb_kits/playbook/pb_advanced_table/README.md +2 -2
  8. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +15 -11
  9. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +12 -8
  10. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +3 -2
  11. data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +0 -2
  12. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -9
  13. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +83 -78
  14. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +14 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +19 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +54 -54
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +7 -7
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +7 -7
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +12 -7
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +2 -0
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +7 -7
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +1 -1
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +7 -7
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +7 -7
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +7 -7
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +7 -7
  27. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +7 -7
  28. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +7 -7
  29. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading.js +1 -1
  30. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data.json +278 -0
  31. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  32. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_chrome_styles.scss +13 -0
  33. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +9 -0
  34. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +30 -0
  35. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +20 -0
  36. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +21 -0
  37. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +37 -0
  38. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +32 -0
  39. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +2 -1
  40. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +2 -1
  41. data/app/pb_kits/playbook/pb_background/background.html.erb +2 -1
  42. data/app/pb_kits/playbook/pb_badge/badge.html.erb +2 -1
  43. data/app/pb_kits/playbook/pb_body/body.html.erb +2 -1
  44. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.scss +0 -7
  45. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +2 -1
  46. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +2 -1
  47. data/app/pb_kits/playbook/pb_button/button.html.erb +2 -1
  48. data/app/pb_kits/playbook/pb_button/button.rb +2 -3
  49. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +2 -1
  50. data/app/pb_kits/playbook/pb_caption/caption.html.erb +2 -1
  51. data/app/pb_kits/playbook/pb_card/card.html.erb +2 -1
  52. data/app/pb_kits/playbook/pb_card/card_body.html.erb +2 -1
  53. data/app/pb_kits/playbook/pb_card/card_header.html.erb +2 -1
  54. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +3 -1
  55. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +2 -1
  56. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +2 -1
  57. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +2 -1
  58. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +2 -1
  59. data/app/pb_kits/playbook/pb_contact/contact.html.erb +2 -1
  60. data/app/pb_kits/playbook/pb_currency/currency.html.erb +2 -1
  61. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +2 -1
  62. data/app/pb_kits/playbook/pb_date/date.html.erb +2 -1
  63. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +1 -2
  64. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +3 -0
  65. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +4 -2
  66. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -1
  67. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +1 -1
  68. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +9 -7
  69. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.html.erb +0 -7
  70. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.jsx +0 -7
  71. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_margin_bottom.html.erb +7 -0
  72. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_margin_bottom.jsx +41 -0
  73. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.html.erb +7 -0
  74. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.jsx +7 -0
  75. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +4 -2
  76. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
  77. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +1 -2
  78. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +2 -1
  79. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +2 -1
  80. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +2 -1
  81. data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +2 -1
  82. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +3 -2
  83. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +2 -1
  84. data/app/pb_kits/playbook/pb_detail/detail.html.erb +2 -1
  85. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +2 -1
  86. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +3 -2
  87. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +3 -2
  88. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +5 -4
  89. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +2 -0
  90. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +2 -1
  91. data/app/pb_kits/playbook/pb_filter/filter.html.erb +2 -1
  92. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +8 -3
  93. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +1 -0
  94. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +51 -1
  95. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.jsx +62 -11
  96. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +7 -2
  97. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +4 -3
  98. data/app/pb_kits/playbook/pb_flex/docs/_flex_spacing.html.erb +0 -4
  99. data/app/pb_kits/playbook/pb_flex/flex.html.erb +2 -1
  100. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +2 -1
  101. data/app/pb_kits/playbook/pb_form_group/_form_group.scss +34 -0
  102. data/app/pb_kits/playbook/pb_form_group/docs/_form_group_select.html.erb +17 -1
  103. data/app/pb_kits/playbook/pb_form_group/docs/_form_group_select.jsx +18 -2
  104. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +2 -1
  105. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +2 -2
  106. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +2 -1
  107. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +2 -1
  108. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +2 -1
  109. data/app/pb_kits/playbook/pb_icon/_icon.tsx +1 -0
  110. data/app/pb_kits/playbook/pb_icon/icon.html.erb +2 -1
  111. data/app/pb_kits/playbook/pb_icon/icon.rb +3 -3
  112. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +14 -0
  113. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +1 -1
  114. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes.html.erb +5 -0
  115. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes.jsx +6 -0
  116. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +2 -1
  117. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +1 -1
  118. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +1 -0
  119. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +2 -1
  120. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +0 -2
  121. data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +2 -1
  122. data/app/pb_kits/playbook/pb_image/image.html.erb +2 -1
  123. data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +2 -1
  124. data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +3 -2
  125. data/app/pb_kits/playbook/pb_layout/body.html.erb +2 -1
  126. data/app/pb_kits/playbook/pb_layout/footer.html.erb +2 -1
  127. data/app/pb_kits/playbook/pb_layout/header.html.erb +2 -1
  128. data/app/pb_kits/playbook/pb_layout/item.html.erb +2 -1
  129. data/app/pb_kits/playbook/pb_layout/layout.html.erb +2 -1
  130. data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +2 -1
  131. data/app/pb_kits/playbook/pb_legend/legend.html.erb +2 -1
  132. data/app/pb_kits/playbook/pb_list/item.html.erb +2 -1
  133. data/app/pb_kits/playbook/pb_list/list.html.erb +2 -1
  134. data/app/pb_kits/playbook/pb_list/list.rb +0 -2
  135. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +2 -1
  136. data/app/pb_kits/playbook/pb_message/message.html.erb +2 -1
  137. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +3 -2
  138. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.md +2 -2
  139. data/app/pb_kits/playbook/pb_multi_level_select/docs/{_multi_level_select_selected_ids.jsx → _multi_level_select_selected_ids_react.jsx} +2 -2
  140. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids_react.md +5 -0
  141. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -1
  142. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
  143. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +2 -1
  144. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +2 -1
  145. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +2 -1
  146. data/app/pb_kits/playbook/pb_nav/item.html.erb +4 -2
  147. data/app/pb_kits/playbook/pb_nav/nav.html.erb +2 -1
  148. data/app/pb_kits/playbook/pb_online_status/_online_status.scss +1 -10
  149. data/app/pb_kits/playbook/pb_online_status/_online_status.tsx +1 -1
  150. data/app/pb_kits/playbook/pb_online_status/_online_status_mixins.scss +7 -13
  151. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.html.erb +6 -9
  152. data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.jsx +18 -7
  153. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +2 -1
  154. data/app/pb_kits/playbook/pb_online_status/online_status.rb +1 -1
  155. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.html.erb +2 -1
  156. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +2 -1
  157. data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
  158. data/app/pb_kits/playbook/pb_person/person.html.erb +2 -1
  159. data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +2 -1
  160. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +2 -2
  161. data/app/pb_kits/playbook/pb_pill/pill.html.erb +2 -1
  162. data/app/pb_kits/playbook/pb_popover/popover.html.erb +2 -1
  163. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +2 -1
  164. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +2 -1
  165. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +2 -1
  166. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +2 -1
  167. data/app/pb_kits/playbook/pb_radio/radio.html.erb +2 -1
  168. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +2 -1
  169. data/app/pb_kits/playbook/pb_select/select.html.erb +2 -1
  170. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +2 -1
  171. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +2 -1
  172. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +2 -1
  173. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +2 -1
  174. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +2 -1
  175. data/app/pb_kits/playbook/pb_source/source.html.erb +2 -1
  176. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +2 -1
  177. data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +2 -1
  178. data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +2 -1
  179. data/app/pb_kits/playbook/pb_table/table.html.erb +4 -2
  180. data/app/pb_kits/playbook/pb_table/table_body.html.erb +5 -3
  181. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +5 -3
  182. data/app/pb_kits/playbook/pb_table/table_head.html.erb +5 -3
  183. data/app/pb_kits/playbook/pb_table/table_header.html.erb +5 -3
  184. data/app/pb_kits/playbook/pb_table/table_row.html.erb +5 -3
  185. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +0 -1
  186. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +5 -1
  187. data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +2 -1
  188. data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -1
  189. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +1 -1
  190. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +2 -1
  191. data/app/pb_kits/playbook/pb_time/time.html.erb +2 -1
  192. data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +3 -2
  193. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +2 -1
  194. data/app/pb_kits/playbook/pb_timeline/item.html.erb +2 -1
  195. data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +2 -1
  196. data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +2 -1
  197. data/app/pb_kits/playbook/pb_title/title.html.erb +3 -2
  198. data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +2 -1
  199. data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +2 -1
  200. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +39 -6
  201. data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +17 -12
  202. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_disabled.html.erb +11 -0
  203. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_disabled.jsx +21 -0
  204. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +3 -1
  205. data/app/pb_kits/playbook/pb_toggle/docs/index.js +1 -0
  206. data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +2 -1
  207. data/app/pb_kits/playbook/pb_toggle/toggle.rb +2 -1
  208. data/app/pb_kits/playbook/pb_toggle/toggle.test.js +7 -0
  209. data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +2 -1
  210. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -1
  211. data/app/pb_kits/playbook/pb_user/user.html.erb +2 -1
  212. data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +2 -1
  213. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +2 -1
  214. data/app/pb_kits/playbook/utilities/_positioning.scss +23 -10
  215. data/app/pb_kits/playbook/utilities/globalProps.ts +26 -8
  216. data/dist/menu.yml +4 -0
  217. data/dist/playbook-rails.js +7 -7
  218. data/lib/playbook/bottom.rb +6 -3
  219. data/lib/playbook/kit_base.rb +18 -0
  220. data/lib/playbook/left.rb +6 -3
  221. data/lib/playbook/pb_doc_helper.rb +1 -1
  222. data/lib/playbook/position_props_css.rb +17 -0
  223. data/lib/playbook/props/percentage.rb +2 -2
  224. data/lib/playbook/right.rb +6 -3
  225. data/lib/playbook/top.rb +6 -3
  226. data/lib/playbook/version.rb +2 -2
  227. metadata +28 -41
  228. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +0 -278
@@ -1,8 +1,8 @@
1
- import React, { useState, useEffect, useCallback } from "react";
2
- import classnames from "classnames";
3
- import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
4
- import { globalProps, GlobalProps } from "../utilities/globalProps";
5
- import Table from "../pb_table/_table";
1
+ import React, { useState, useEffect, useCallback } from "react"
2
+ import classnames from "classnames"
3
+
4
+ import { GenericObject } from "../types"
5
+
6
6
  import {
7
7
  createColumnHelper,
8
8
  getCoreRowModel,
@@ -11,39 +11,43 @@ import {
11
11
  Row,
12
12
  useReactTable,
13
13
  Getter,
14
- } from "@tanstack/react-table";
14
+ } from "@tanstack/react-table"
15
+
16
+ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props"
17
+ import { globalProps, GlobalProps } from "../utilities/globalProps"
15
18
 
16
- import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers";
19
+ import Table from "../pb_table/_table"
17
20
 
18
- import { CustomCell } from "./Components/CustomCell";
19
- import AdvancedTableContext from "./Context/AdvancedTableContext";
20
- import { TableHeader } from "./SubKits/TableHeader";
21
- import { TableBody } from "./SubKits/TableBody";
21
+ import AdvancedTableContext from "./Context/AdvancedTableContext"
22
22
 
23
- import { DataType } from "./Utilities/types";
23
+ import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers"
24
+
25
+ import { CustomCell } from "./Components/CustomCell"
26
+ import { TableHeader } from "./SubKits/TableHeader"
27
+ import { TableBody } from "./SubKits/TableBody"
24
28
 
25
29
  type AdvancedTableProps = {
26
- aria?: { [key: string]: string };
27
- children?: React.ReactNode | React.ReactNode[];
28
- className?: string;
29
- columnDefinitions: DataType[];
30
- dark?: boolean,
31
- data?: { [key: string]: string };
32
- enableToggleExpansion?: "all" | "header" | "none";
33
- expandedControl?: DataType;
30
+ aria?: { [key: string]: string }
31
+ children?: React.ReactNode | React.ReactNode[]
32
+ className?: string
33
+ columnDefinitions: GenericObject[]
34
+ dark?: boolean
35
+ data?: { [key: string]: string }
36
+ enableToggleExpansion?: "all" | "header" | "none"
37
+ expandedControl?: GenericObject
34
38
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
35
- id?: string;
36
- initialLoadingRowsCount?: number;
37
- inlineRowLoading?: boolean;
38
- loading?: boolean | string;
39
- onRowToggleClick?: (arg: Row<DataType>) => void;
40
- onToggleExpansionClick?: (arg: Row<DataType>) => void;
41
- sortControl?: DataType;
42
- tableData: DataType[];
43
- tableOptions?: DataType;
44
- tableProps?: DataType;
45
- toggleExpansionIcon?: string | string[];
46
- } & GlobalProps;
39
+ id?: string
40
+ initialLoadingRowsCount?: number
41
+ inlineRowLoading?: boolean
42
+ loading?: boolean | string
43
+ onRowToggleClick?: (arg: Row<GenericObject>) => void
44
+ onToggleExpansionClick?: (arg: Row<GenericObject>) => void
45
+ sortControl?: GenericObject
46
+ tableData: GenericObject[]
47
+ tableOptions?: GenericObject
48
+ tableProps?: GenericObject
49
+ toggleExpansionIcon?: string | string[]
50
+ } & GlobalProps
47
51
 
48
52
  const AdvancedTable = (props: AdvancedTableProps) => {
49
53
  const {
@@ -67,22 +71,22 @@ const AdvancedTable = (props: AdvancedTableProps) => {
67
71
  tableOptions,
68
72
  tableProps,
69
73
  toggleExpansionIcon = "arrows-from-line",
70
- } = props;
74
+ } = props
71
75
 
72
76
  const [loadingStateRowCount, setLoadingStateRowCount] = useState(
73
77
  initialLoadingRowsCount
74
- );
78
+ )
75
79
 
76
80
  // Create a local state for expanded and setExpanded if expandedControl not used
77
- const [localExpanded, setLocalExpanded] = useState({});
81
+ const [localExpanded, setLocalExpanded] = useState({})
78
82
 
79
83
  // Determine whether to use the prop or the local state
80
- const expanded = expandedControl ? expandedControl.value : localExpanded;
84
+ const expanded = expandedControl ? expandedControl.value : localExpanded
81
85
  const setExpanded = expandedControl
82
86
  ? expandedControl.onChange
83
- : setLocalExpanded;
87
+ : setLocalExpanded
84
88
 
85
- const columnHelper = createColumnHelper();
89
+ const columnHelper = createColumnHelper()
86
90
 
87
91
  //Create cells for first columns
88
92
  const createCellFunction = (cellAccessors: string[]) => {
@@ -90,10 +94,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
90
94
  row,
91
95
  getValue,
92
96
  }: {
93
- row: Row<DataType>;
94
- getValue: Getter<string>;
97
+ row: Row<GenericObject>
98
+ getValue: Getter<string>
95
99
  }) => {
96
- const rowData = row.original;
100
+ const rowData = row.original
97
101
 
98
102
  switch (row.depth) {
99
103
  case 0: {
@@ -103,12 +107,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
103
107
  onRowToggleClick={onRowToggleClick}
104
108
  row={row}
105
109
  />
106
- );
110
+ )
107
111
  }
108
112
  default: {
109
113
  // Handle other depths based on cellAccessors
110
- const depthAccessor = cellAccessors[row.depth - 1]; // Adjust index for depth
111
- const accessorValue = rowData[depthAccessor];
114
+ const depthAccessor = cellAccessors[row.depth - 1] // Adjust index for depth
115
+ const accessorValue = rowData[depthAccessor]
112
116
  return accessorValue ? (
113
117
  <CustomCell
114
118
  onRowToggleClick={onRowToggleClick}
@@ -117,13 +121,13 @@ const AdvancedTable = (props: AdvancedTableProps) => {
117
121
  />
118
122
  ) : (
119
123
  "N/A"
120
- );
124
+ )
121
125
  }
122
126
  }
123
- };
127
+ }
124
128
 
125
- return columnCells;
126
- };
129
+ return columnCells
130
+ }
127
131
 
128
132
  //Create column array in format needed by Tanstack
129
133
  const columns =
@@ -134,12 +138,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
134
138
  ...columnHelper.accessor(column.accessor, {
135
139
  header: column.label,
136
140
  }),
137
- };
141
+ }
138
142
  if (column.cellAccessors) {
139
- columnStructure.cell = createCellFunction(column.cellAccessors);
143
+ columnStructure.cell = createCellFunction(column.cellAccessors)
140
144
  }
141
- return columnStructure;
142
- });
145
+ return columnStructure
146
+ })
143
147
 
144
148
  //Syntax for sorting Array if we want to manage state ourselves
145
149
  const sorting = [
@@ -150,22 +154,22 @@ const AdvancedTable = (props: AdvancedTableProps) => {
150
154
  ? !sortControl.value.desc
151
155
  : false,
152
156
  },
153
- ];
157
+ ]
154
158
 
155
159
  const expandAndSortState = () => {
156
160
  if (sortControl) {
157
- return { state: { expanded, sorting } };
161
+ return { state: { expanded, sorting } }
158
162
  } else {
159
- return { state: { expanded } };
163
+ return { state: { expanded } }
160
164
  }
161
- };
165
+ }
162
166
 
163
167
  //initialize table
164
168
  const table = useReactTable({
165
169
  data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
166
170
  columns,
167
171
  onExpandedChange: setExpanded,
168
- getSubRows: (row: DataType) => row.children,
172
+ getSubRows: (row: GenericObject) => row.children,
169
173
  getCoreRowModel: getCoreRowModel(),
170
174
  getExpandedRowModel: getExpandedRowModel(),
171
175
  getSortedRowModel: getSortedRowModel(),
@@ -173,41 +177,41 @@ const AdvancedTable = (props: AdvancedTableProps) => {
173
177
  sortDescFirst: true,
174
178
  ...expandAndSortState(),
175
179
  ...tableOptions,
176
- });
180
+ })
177
181
 
178
- const tableRows = table.getRowModel();
182
+ const tableRows = table.getRowModel()
179
183
 
180
184
  // Set table row count for loading state
181
185
  const updateLoadingStateRowCount = useCallback(() => {
182
- const rowsCount = table.getRowModel().rows.length;
186
+ const rowsCount = table.getRowModel().rows.length
183
187
  if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
184
- setLoadingStateRowCount(rowsCount);
188
+ setLoadingStateRowCount(rowsCount)
185
189
  }
186
- }, [tableData, loadingStateRowCount]);
190
+ }, [tableData, loadingStateRowCount])
187
191
 
188
192
  useEffect(() => {
189
193
  if (!loading) {
190
- updateLoadingStateRowCount();
194
+ updateLoadingStateRowCount()
191
195
  }
192
- }, [loading, updateLoadingStateRowCount]);
196
+ }, [loading, updateLoadingStateRowCount])
193
197
 
194
- const handleExpandOrCollapse = async (row: Row<DataType>) => {
195
- onToggleExpansionClick && onToggleExpansionClick(row);
198
+ const handleExpandOrCollapse = async (row: Row<GenericObject>) => {
199
+ onToggleExpansionClick && onToggleExpansionClick(row)
196
200
 
197
201
  const expandedState = expanded;
198
202
  const targetParent = row?.parentId;
199
- const updatedRows = await updateExpandAndCollapseState(tableRows, expandedState, targetParent);
200
- setExpanded(updatedRows);
201
- };
203
+ const updatedRows = await updateExpandAndCollapseState(tableRows, expandedState, targetParent)
204
+ setExpanded(updatedRows)
205
+ }
202
206
 
203
- const ariaProps = buildAriaProps(aria);
204
- const dataProps = buildDataProps(data);
205
- const htmlProps = buildHtmlProps(htmlOptions);
207
+ const ariaProps = buildAriaProps(aria)
208
+ const dataProps = buildDataProps(data)
209
+ const htmlProps = buildHtmlProps(htmlOptions)
206
210
  const classes = classnames(
207
211
  buildCss("pb_advanced_table"),
208
212
  globalProps(props),
209
213
  className
210
- );
214
+ )
211
215
 
212
216
  return (
213
217
  <div {...ariaProps}
@@ -221,6 +225,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
221
225
  columnDefinitions,
222
226
  enableToggleExpansion,
223
227
  expanded,
228
+ expandedControl,
224
229
  handleExpandOrCollapse,
225
230
  inlineRowLoading,
226
231
  loading,
@@ -249,10 +254,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
249
254
  </Table>
250
255
  </AdvancedTableContext.Provider>
251
256
  </div>
252
- );
253
- };
257
+ )
258
+ }
254
259
 
255
- AdvancedTable.Header = TableHeader;
256
- AdvancedTable.Body = TableBody;
260
+ AdvancedTable.Header = TableHeader
261
+ AdvancedTable.Body = TableBody
257
262
 
258
- export default AdvancedTable;
263
+ export default AdvancedTable
@@ -0,0 +1,14 @@
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id) do %>
6
+ <%= pb_rails("table", props: { size: "sm", tag:"div", data_table: true, number_spacing:"tabular", responsive:"none" }) do %>
7
+ <% if content.present? %>
8
+ <% content.presence %>
9
+ <% else %>
10
+ <%= pb_rails("advanced_table/table_header", props: {column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion }) %>
11
+ <%= pb_rails("advanced_table/table_body", props: {table_data: object.table_data, column_definitions: object.column_definitions}) %>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbAdvancedTable
5
+ class AdvancedTable < Playbook::KitBase
6
+ prop :table_data, type: Playbook::Props::Array,
7
+ default: []
8
+ prop :column_definitions, type: Playbook::Props::Array,
9
+ default: []
10
+ prop :enable_toggle_expansion, type: Playbook::Props::Enum,
11
+ values: %w[all header none],
12
+ default: "header"
13
+
14
+ def classname
15
+ generate_classname("pb_advanced_table")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,7 +1,7 @@
1
- import React, {useState} from "react";
2
- import { render, screen, waitFor } from "../utilities/test-utils";
1
+ import React, {useState} from "react"
2
+ import { render, screen, waitFor } from "../utilities/test-utils"
3
3
 
4
- import { AdvancedTable } from "../";
4
+ import { AdvancedTable } from "../"
5
5
 
6
6
  const MOCK_DATA = [
7
7
  {
@@ -40,7 +40,7 @@ const MOCK_DATA = [
40
40
  },
41
41
  ],
42
42
  },
43
- ];
43
+ ]
44
44
 
45
45
  const MOCK_DATA_LOADING = [
46
46
  {
@@ -70,7 +70,7 @@ const MOCK_DATA_LOADING = [
70
70
  },
71
71
  ],
72
72
  },
73
- ];
73
+ ]
74
74
 
75
75
  const columnDefinitions = [
76
76
  {
@@ -86,11 +86,11 @@ const columnDefinitions = [
86
86
  accessor: "scheduledMeetings",
87
87
  label: "Scheduled Meetings",
88
88
  },
89
- ];
89
+ ]
90
90
 
91
91
  const subRowHeaders = ["Quarter"]
92
92
 
93
- const testId = "advanced_table";
93
+ const testId = "advanced_table"
94
94
 
95
95
  const AdvancedTableExpandControl = () => {
96
96
  const [expanded, setExpanded] = useState({'0': true})
@@ -109,7 +109,7 @@ return (
109
109
  tableData={MOCK_DATA}
110
110
  />
111
111
  </div>
112
- );
112
+ )
113
113
  }
114
114
 
115
115
  const AdvancedTableSortControl = () => {
@@ -132,7 +132,7 @@ return (
132
132
  <AdvancedTable.Body />
133
133
  </AdvancedTable>
134
134
  </div>
135
- );
135
+ )
136
136
  }
137
137
 
138
138
  const tableOptions = {
@@ -158,12 +158,12 @@ test("Generates default kit and classname", () => {
158
158
  data={{ testid: testId }}
159
159
  tableData={MOCK_DATA}
160
160
  />
161
- );
161
+ )
162
162
 
163
- const kit = screen.getByTestId(testId);
164
- expect(kit).toBeInTheDocument();
163
+ const kit = screen.getByTestId(testId)
164
+ expect(kit).toBeInTheDocument()
165
165
  expect(kit).toHaveClass('pb_advanced_table')
166
- });
166
+ })
167
167
 
168
168
  test("Generates aria label", () => {
169
169
  render(
@@ -173,11 +173,11 @@ test("Generates aria label", () => {
173
173
  data={{ testid: testId }}
174
174
  tableData={MOCK_DATA}
175
175
  />
176
- );
176
+ )
177
177
 
178
- const kit = screen.getByTestId(testId);
178
+ const kit = screen.getByTestId(testId)
179
179
  expect(kit).toHaveAttribute('aria-label', testId)
180
- });
180
+ })
181
181
 
182
182
  test("Row toggle button exists and toggles subrows open and closed", () => {
183
183
  render(
@@ -186,9 +186,9 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
186
186
  data={{ testid: testId }}
187
187
  tableData={MOCK_DATA}
188
188
  />
189
- );
189
+ )
190
190
 
191
- const kit = screen.getByTestId(testId);
191
+ const kit = screen.getByTestId(testId)
192
192
  const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
193
193
  expect(rowButton).toBeInTheDocument()
194
194
  const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
@@ -196,7 +196,7 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
196
196
  rowButton.click()
197
197
  const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
198
198
  expect(subRow).toBeInTheDocument()
199
- });
199
+ })
200
200
 
201
201
  test("toggleExpansionAll button exists and toggles subrows open and closed", async () => {
202
202
  render(
@@ -205,7 +205,7 @@ test("toggleExpansionAll button exists and toggles subrows open and closed", asy
205
205
  data={{ testid: testId }}
206
206
  tableData={MOCK_DATA}
207
207
  />
208
- );
208
+ )
209
209
 
210
210
  const kit = screen.getByTestId(testId);
211
211
  const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon");
@@ -219,8 +219,8 @@ test("toggleExpansionAll button exists and toggles subrows open and closed", asy
219
219
  await waitFor(() => {
220
220
  const subRow = kit.querySelector(".bg-white.depth-sub-row-1");
221
221
  expect(subRow).toBeInTheDocument();
222
- });
223
- });
222
+ })
223
+ })
224
224
 
225
225
 
226
226
  test("loading state + initialLoadingRowCount prop", () => {
@@ -232,16 +232,16 @@ test("loading state + initialLoadingRowCount prop", () => {
232
232
  loading
233
233
  tableData={MOCK_DATA}
234
234
  />
235
- );
235
+ )
236
236
 
237
- const kit = screen.getByTestId(testId);
237
+ const kit = screen.getByTestId(testId)
238
238
  const table = kit.querySelector('table')
239
239
  expect(table).toHaveClass('pb_table table-sm table-responsive-none table-card data_table ns_tabular content-loading')
240
240
 
241
241
  const tableBody = kit.querySelector('tbody')
242
242
  const tableRows = tableBody.getElementsByTagName('tr')
243
243
  expect(tableRows).toHaveLength(13)
244
- });
244
+ })
245
245
 
246
246
  test("subRowHeaders are rendered", () => {
247
247
  render(
@@ -253,21 +253,21 @@ test("subRowHeaders are rendered", () => {
253
253
  <AdvancedTable.Header />
254
254
  <AdvancedTable.Body subRowHeaders={subRowHeaders}/>
255
255
  </AdvancedTable>
256
- );
256
+ )
257
257
 
258
- const kit = screen.getByTestId(testId);
258
+ const kit = screen.getByTestId(testId)
259
259
 
260
260
  const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
261
261
  rowButton.click()
262
262
 
263
263
  const subRowHeader = kit.querySelector(".custom-row.bg-silver")
264
264
  expect(subRowHeader).toBeInTheDocument()
265
- });
265
+ })
266
266
 
267
267
  test("expandControl prop works as expected", () => {
268
268
  render (<AdvancedTableExpandControl/>)
269
269
 
270
- const kit = screen.getByTestId(testId);
270
+ const kit = screen.getByTestId(testId)
271
271
  const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
272
272
  expect(subRow).toBeInTheDocument()
273
273
  })
@@ -280,13 +280,13 @@ test("tableOptions prop functions as expected", () => {
280
280
  tableData={MOCK_DATA}
281
281
  tableOptions={tableOptions}
282
282
  />
283
- );
283
+ )
284
284
 
285
- const kit = screen.getByTestId(testId);
285
+ const kit = screen.getByTestId(testId)
286
286
  const row1 = kit.getElementsByTagName('tr')[1]
287
287
 
288
288
  expect(row1.id).toBe("1-1-0-row")
289
- });
289
+ })
290
290
 
291
291
  test("tableProps prop functions as expected", () => {
292
292
  render(
@@ -296,12 +296,12 @@ test("tableProps prop functions as expected", () => {
296
296
  tableData={MOCK_DATA}
297
297
  tableProps={tableProps}
298
298
  />
299
- );
299
+ )
300
300
 
301
- const kit = screen.getByTestId(testId);
301
+ const kit = screen.getByTestId(testId)
302
302
  const table = kit.querySelector('table')
303
303
  expect(table).toHaveClass("pb_table table-sm table-responsive-none data_table sticky-header ns_tabular")
304
- });
304
+ })
305
305
 
306
306
  test("enableExpansionIcon changes icon", () => {
307
307
  render(
@@ -312,13 +312,13 @@ test("enableExpansionIcon changes icon", () => {
312
312
  tableProps={tableProps}
313
313
  toggleExpansionIcon= "chevron-up"
314
314
  />
315
- );
315
+ )
316
316
 
317
- const kit = screen.getByTestId(testId);
317
+ const kit = screen.getByTestId(testId)
318
318
  const tableHead = kit.querySelector('table')
319
319
  const toggleIcon= tableHead.querySelector(".pb_icon_kit")
320
320
  expect(toggleIcon).toHaveClass("fa-chevron-up")
321
- });
321
+ })
322
322
 
323
323
  test("sortIcon changes icon", () => {
324
324
  render(
@@ -334,18 +334,18 @@ test("sortIcon changes icon", () => {
334
334
  />
335
335
  <AdvancedTable.Body />
336
336
  </AdvancedTable>
337
- );
337
+ )
338
338
 
339
- const kit = screen.getByTestId(testId);
339
+ const kit = screen.getByTestId(testId)
340
340
  const sortIcon = kit.querySelector('.sort-button-icon')
341
341
  const icon= sortIcon.querySelector(".pb_icon_kit")
342
342
  expect(icon).toHaveClass("fa-chevron-down")
343
- });
343
+ })
344
344
 
345
345
  test("Sort icon renders with enableSorting + sortControl works as expected", () => {
346
346
  render (<AdvancedTableSortControl/>)
347
347
 
348
- const kit = screen.getByTestId(testId);
348
+ const kit = screen.getByTestId(testId)
349
349
  const sortIcon = kit.querySelector(".sort-button-icon")
350
350
  expect(sortIcon).toBeInTheDocument()
351
351
 
@@ -364,9 +364,9 @@ test("sort button exists and sorts column data", () => {
364
364
  <AdvancedTable.Header enableSorting />
365
365
  <AdvancedTable.Body />
366
366
  </AdvancedTable>
367
- );
367
+ )
368
368
 
369
- const kit = screen.getByTestId(testId);
369
+ const kit = screen.getByTestId(testId)
370
370
 
371
371
  const sortButton= kit.querySelector(".pb_flex_kit_orientation_row_justify_content_between_align_items_top_spacing_none.pl_xxs.cursor_pointer.header-sort-button.pb_th_link")
372
372
  expect(sortButton).toBeInTheDocument()
@@ -378,7 +378,7 @@ test("sort button exists and sorts column data", () => {
378
378
 
379
379
  const row2 = kit.getElementsByTagName('tr')[2]
380
380
  expect(row2.id).toBe("0-0-0-row")
381
- });
381
+ })
382
382
 
383
383
  test("Generates Table.Header default + custom classname", () => {
384
384
  render(
@@ -391,12 +391,12 @@ test("Generates Table.Header default + custom classname", () => {
391
391
  <AdvancedTable.Body />
392
392
 
393
393
  </AdvancedTable>
394
- );
394
+ )
395
395
 
396
- const kit = screen.getByTestId(testId);
396
+ const kit = screen.getByTestId(testId)
397
397
  const tableHeader = kit.querySelector('thead')
398
398
  expect(tableHeader).toHaveClass('pb_advanced_table_header custom-header')
399
- });
399
+ })
400
400
 
401
401
  test("Generates Table.Body default + custom classname", () => {
402
402
  render(
@@ -409,12 +409,12 @@ test("Generates Table.Body default + custom classname", () => {
409
409
  <AdvancedTable.Body className="custom-body-classname"/>
410
410
 
411
411
  </AdvancedTable>
412
- );
412
+ )
413
413
 
414
- const kit = screen.getByTestId(testId);
414
+ const kit = screen.getByTestId(testId)
415
415
  const tableHeader = kit.querySelector('tbody')
416
416
  expect(tableHeader).toHaveClass('pb_advanced_table_body custom-body-classname')
417
- });
417
+ })
418
418
 
419
419
  test("inlineRowLoading prop renders inline loading if true", () => {
420
420
  render(
@@ -424,12 +424,12 @@ test("inlineRowLoading prop renders inline loading if true", () => {
424
424
  inlineRowLoading
425
425
  tableData={MOCK_DATA_LOADING}
426
426
  />
427
- );
427
+ )
428
428
 
429
- const kit = screen.getByTestId(testId);
429
+ const kit = screen.getByTestId(testId)
430
430
  const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
431
431
  expect(rowButton).toBeInTheDocument()
432
432
  rowButton.click()
433
433
  const inlineLoading = kit.querySelector(".fa-spinner")
434
434
  expect(inlineLoading).toBeInTheDocument()
435
- });
435
+ })
@@ -1,6 +1,6 @@
1
- import React from "react";
2
- import { AdvancedTable } from "../../";
3
- import { MOCK_DATA } from "./_mock_data";
1
+ import React from "react"
2
+ import { AdvancedTable } from "../../"
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
4
 
5
5
  const AdvancedTableCollapsibleTrail = (props) => {
6
6
  const columnDefinitions = [
@@ -33,7 +33,7 @@ const AdvancedTableCollapsibleTrail = (props) => {
33
33
  accessor: "graduatedStudents",
34
34
  label: "Graduated Students",
35
35
  },
36
- ];
36
+ ]
37
37
 
38
38
  return (
39
39
  <div>
@@ -46,7 +46,7 @@ const AdvancedTableCollapsibleTrail = (props) => {
46
46
  <AdvancedTable.Body collapsibleTrail={false} />
47
47
  </AdvancedTable>
48
48
  </div>
49
- );
50
- };
49
+ )
50
+ }
51
51
 
52
- export default AdvancedTableCollapsibleTrail;
52
+ export default AdvancedTableCollapsibleTrail