playbook_ui 15.3.0 → 15.4.0.pre.alpha.PLAY2429datepickeropenonscreenstatic12263

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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +2 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +18 -3
  5. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +71 -14
  6. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +3 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +1 -1
  8. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -4
  9. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -3
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +127 -5
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +4 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -1
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +1 -1
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +1 -1
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +3 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +2 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +1 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +2 -0
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +28 -0
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +11 -2
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +9 -1
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +1 -1
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +4 -1
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +3 -2
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_columns_and_header.md +1 -1
  27. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +1 -1
  28. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +1 -1
  29. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +16 -0
  30. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.html.erb +104 -0
  31. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.md +1 -0
  32. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +1 -1
  33. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading_empty_children.js +42 -0
  34. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  35. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +2 -2
  36. data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -7
  37. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +2 -2
  38. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +90 -20
  39. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +32 -3
  40. data/app/pb_kits/playbook/pb_background/background.html.erb +10 -2
  41. data/app/pb_kits/playbook/pb_background/docs/_background_category.md +1 -1
  42. data/app/pb_kits/playbook/pb_badge/_badge.tsx +4 -1
  43. data/app/pb_kits/playbook/pb_badge/badge.test.js +13 -0
  44. data/app/pb_kits/playbook/pb_card/docs/_card_background.md +1 -1
  45. data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
  46. data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
  47. data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -1
  48. data/app/pb_kits/playbook/pb_currency/_currency.tsx +20 -7
  49. data/app/pb_kits/playbook/pb_currency/currency.rb +35 -8
  50. data/app/pb_kits/playbook/pb_currency/currency.test.js +47 -0
  51. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  52. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +1 -1
  53. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.md +1 -0
  54. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -0
  55. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +60 -7
  56. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.jsx +38 -0
  57. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.md +14 -0
  58. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -1
  59. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
  60. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +11 -30
  61. data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
  62. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -0
  63. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +111 -6
  64. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.jsx +18 -0
  65. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.md +4 -0
  66. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.jsx +18 -0
  67. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.md +1 -0
  68. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.jsx +19 -0
  69. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.md +1 -0
  70. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.jsx +38 -0
  71. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.md +14 -0
  72. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +1 -1
  73. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
  74. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -1
  75. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +148 -2
  76. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +60 -0
  77. data/app/pb_kits/playbook/pb_filter/docs/_filter_max_width.md +1 -1
  78. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +15 -1
  79. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +9 -8
  80. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +11 -10
  81. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  82. data/app/pb_kits/playbook/pb_form/formHelper.js +1 -1
  83. data/app/pb_kits/playbook/pb_form/pb_form_validation.js +44 -11
  84. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +1 -1
  85. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +1 -1
  86. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -1
  87. data/app/pb_kits/playbook/pb_icon/docs/_icon_color.md +1 -1
  88. data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.md +1 -1
  89. data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.html.erb +7 -14
  90. data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.jsx +6 -15
  91. data/app/pb_kits/playbook/pb_layout/docs/_layout_collection.md +1 -1
  92. data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_item_spacing.md +1 -1
  93. data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.md +1 -1
  94. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_layout.md +1 -1
  95. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +110 -17
  96. data/app/pb_kits/playbook/pb_pill/docs/_description.md +1 -1
  97. data/app/pb_kits/playbook/pb_popover/_popover.tsx +69 -34
  98. data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.jsx +68 -0
  99. data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to_react.md +1 -0
  100. data/app/pb_kits/playbook/pb_popover/docs/example.yml +1 -0
  101. data/app/pb_kits/playbook/pb_popover/docs/index.js +1 -0
  102. data/app/pb_kits/playbook/pb_popover/popover.test.js +80 -0
  103. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_description.md +1 -1
  104. data/app/pb_kits/playbook/pb_section_separator/docs/_description.md +1 -1
  105. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +29 -0
  106. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_rails.md +1 -1
  107. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_react.md +1 -1
  108. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +1 -1
  109. data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.md +1 -1
  110. data/app/pb_kits/playbook/pb_table/docs/_table_sm.md +1 -1
  111. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.html.erb +63 -0
  112. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.jsx +89 -0
  113. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_rails.md +4 -0
  114. data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_react.md +3 -0
  115. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  116. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  117. data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -2
  118. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +7 -0
  119. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +105 -1
  120. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +23 -9
  121. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +33 -1
  122. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.html.erb +64 -0
  123. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.jsx +70 -0
  124. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.md +1 -0
  125. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_options.html.erb +67 -1
  126. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.jsx +68 -6
  127. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.md +1 -1
  128. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  129. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -1
  130. data/dist/chunks/{_line_graph-0IiTB9gA.js → _line_graph-W9CX7Xbp.js} +1 -1
  131. data/dist/chunks/_typeahead-L4SF9E6a.js +6 -0
  132. data/dist/chunks/_weekday_stacked-DOs7l1vE.js +37 -0
  133. data/dist/chunks/{lib-izYrkvOQ.js → lib-COXg9aPA.js} +2 -2
  134. data/dist/chunks/pb_form_validation-DR765aoq.js +1 -0
  135. data/dist/chunks/vendor.js +1 -1
  136. data/dist/playbook-doc.js +2 -2
  137. data/dist/playbook-rails-react-bindings.js +1 -1
  138. data/dist/playbook-rails.js +1 -1
  139. data/dist/playbook.css +1 -1
  140. data/lib/playbook/version.rb +2 -2
  141. metadata +32 -8
  142. data/dist/chunks/_typeahead-BvV7a9cR.js +0 -6
  143. data/dist/chunks/_weekday_stacked-BZ7z8ukT.js +0 -37
  144. data/dist/chunks/pb_form_validation-Cah5Z5J3.js +0 -1
  145. /data/app/pb_kits/playbook/pb_popover/docs/{_popover_append_to.md → _popover_append_to_rails.md} +0 -0
@@ -1,6 +1,8 @@
1
1
  import React from "react"
2
2
  import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import Caption from '../../pb_caption/_caption'
3
4
  import { MOCK_DATA_INLINE_LOADING } from "./_mock_data_inline_loading"
5
+ import { MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN } from "./_mock_data_inline_loading_empty_children"
4
6
 
5
7
  const AdvancedTableInlineRowLoading = (props) => {
6
8
  const columnDefinitions = [
@@ -41,16 +43,42 @@ const AdvancedTableInlineRowLoading = (props) => {
41
43
 
42
44
  return (
43
45
  <div>
46
+ <Caption text="Inline Row Loading - Demonstrated in Row 1 (Rows 2 and 3 have data)" />
44
47
  <AdvancedTable
45
48
  columnDefinitions={columnDefinitions}
46
49
  enableToggleExpansion="all"
47
50
  inlineRowLoading
51
+ marginBottom="md"
48
52
  tableData={MOCK_DATA_INLINE_LOADING}
49
53
  {...props}
50
54
  >
51
55
  <AdvancedTable.Header />
52
56
  <AdvancedTable.Body subRowHeaders={subRowHeaders}/>
53
57
  </AdvancedTable>
58
+ <Caption text="Inline Row Loading with No Subrow Data - All Rows Display Inline Row Loading and the Toggle All Button is not rendered" />
59
+ <AdvancedTable
60
+ columnDefinitions={columnDefinitions}
61
+ enableToggleExpansion="all"
62
+ inlineRowLoading
63
+ marginBottom="md"
64
+ tableData={MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN}
65
+ {...props}
66
+ >
67
+ <AdvancedTable.Header />
68
+ <AdvancedTable.Body subRowHeaders={subRowHeaders}/>
69
+ </AdvancedTable>
70
+ <Caption text="Inline Row Loading and Persist Toggle Expansion Button with No Subrow Data - All Rows Display Inline Row Loading and the Toggle All Button is rendered" />
71
+ <AdvancedTable
72
+ columnDefinitions={columnDefinitions}
73
+ enableToggleExpansion="all"
74
+ inlineRowLoading
75
+ persistToggleExpansionButton
76
+ tableData={MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN}
77
+ {...props}
78
+ >
79
+ <AdvancedTable.Header />
80
+ <AdvancedTable.Body subRowHeaders={subRowHeaders}/>
81
+ </AdvancedTable>
54
82
  </div>
55
83
  )
56
84
  }
@@ -1,5 +1,14 @@
1
+ ### inlineRowLoading
1
2
  As a default, the kit assumes that the initial dataset is complete, and it renders all expansion buttons/controls based on that data; if no children are present, no expansion controls are rendered. If, however, you want to change the initial dataset to omit some or all of its children (to improve load times of a complex dataset, perhaps), and you implement a querying logic that loads children only when its parent is expanded, then you must use the `inlineRowLoading` prop to ensure your expansion controls are rendered even though your child data is not yet loaded. You must also pass an empty `children` array to any node that will have children to ensure its parent maintains its ability to expand. If this prop is called AND your data contains empty `children` arrays, the kit will render expansion controls on any row with empty children, and then add an inline loading state within the expanded subrow until those child row(s) are returned to the page [by your query logic].
2
3
 
3
- In this code example, 2021 has an empty children array. Toggle it open to see the inline loading state. Once the correct data loads, this state will be replaced with the correct data rows.
4
+ In the first Advanced Table in this code example, 2021 has an empty children array. Toggle it open to see the inline loading state. Once the correct data loads, this state will be replaced with the correct data rows.
4
5
 
5
- This prop is set to `false` by default.
6
+ This prop is set to `false` by default.
7
+
8
+
9
+ ### persistToggleExpansion
10
+ The `persistToggleExpansionButton` is a boolean prop that renders the toggle-all icon in the top left header cell for complex datasets with empty `children` arrays and advanced querying logic explained in the preceeding doc example. Your logic may require an additional query helper file to update data specifically from requerying via toggle all buttons.
11
+
12
+ In the second and third Advanced Tables in this code example, all 3 rows have empty children arrays. The second Advanced Table demonstrates that the toggle all button does not render (prior to an initial row expansion) without `persistToggleExpansionButton` in place. The third Advanced Table shows the toggle all button due to `persistToggleExpansionButton`.
13
+
14
+ This prop is set to false by default and should only be used in conjunction with `inlineRowLoading`.
@@ -22,7 +22,6 @@ const AdvancedTablePaddingControl = (props) => {
22
22
  {value}
23
23
  </Background>
24
24
  ),
25
-
26
25
  },
27
26
  {
28
27
  accessor: "scheduledMeetings",
@@ -39,6 +38,15 @@ const AdvancedTablePaddingControl = (props) => {
39
38
  {
40
39
  accessor: "classCompletionRate",
41
40
  label: "Class Completion Rate",
41
+ columnStyling:{cellPadding: "none", fontColor: "white"},
42
+ customRenderer: (row, value) => (
43
+ <Background
44
+ backgroundColor={"category_1"}
45
+ padding="xs"
46
+ >
47
+ {value}
48
+ </Background>
49
+ ),
42
50
  },
43
51
  {
44
52
  accessor: "graduatedStudents",
@@ -1,3 +1,3 @@
1
1
  `columnStyling` can also be used to control padding on all cells in a given column via the use of the `cellPadding` key/value pair. `cellPadding` lets you use 'xxs', 'xs', 'sm', 'md', 'lg', 'xl' and 'none'.
2
2
 
3
- This control can be used in conjunction with the `customRenderer` item within each columnDefinition to achieve custom background colors for individual cells as seen here.
3
+ This control can be used in conjunction with the `customRenderer` item within each columnDefinition to achieve custom background colors for individual cells as seen here. Use `fontColor` to achieve better contrast between cell content and background for darker backgrounds.
@@ -38,7 +38,10 @@ const AdvancedTablePaginationWithProps = (props) => {
38
38
  const paginationProps = {
39
39
  pageIndex: 1,
40
40
  pageSize: 10,
41
- range: 2
41
+ range: 2,
42
+ onPageChange: (pageIndex) => {
43
+ console.log('Current page index:', pageIndex);
44
+ }
42
45
  }
43
46
 
44
47
  return (
@@ -1,5 +1,6 @@
1
- `paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with 2 optional items:
1
+ `paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with the following optional items:
2
2
 
3
3
  - `pageIndex`: An optional prop to set which page is set to open on initial load. Default is '0'
4
4
  - `pageSize`: An optional prop to set total number of rows for each page before the Table paginates. Default is '20'
5
- - `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5'
5
+ - `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5'
6
+ - `onPageChange`: A callback function that gives to access to the current page index.
@@ -1,7 +1,7 @@
1
1
  To achieve a sticky header AND sticky columns together, in addition to the `stickyLeftColumn` logic outlined above, you can:
2
2
 
3
3
  - Set `sticky: true` via `tableProps`
4
- - Give the AdvancedTable a `maxHeight` using our [Max Height](https://playbook.powerapp.cloud/visual_guidelines/max_height) global prop.
4
+ - Give the AdvancedTable a `maxHeight` using our [Max Height](https://playbook.powerapp.cloud//global_props/max_height) global prop.
5
5
 
6
6
  **NOTE**: This behavior requires a `maxHeight` to work. The header is sticky within the table container, allowing for it to work along with the column stickiness.
7
7
 
@@ -1,4 +1,4 @@
1
- Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `table_props` and giving the AdvancedTable a `max_height` using our [Max Height](https://playbook.powerapp.cloud/visual_guidelines/max_height) global prop.
1
+ Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `table_props` and giving the AdvancedTable a `max_height` using our [Max Height](https://playbook.powerapp.cloud/global_props/max_height) global prop.
2
2
 
3
3
  **NOTE**: This behavior requires a `max_height` to work. The header is sticky within the table container, allowing for it to work along with the first column stickiness of a responsive table on smaller screen sizes.
4
4
 
@@ -1,4 +1,4 @@
1
- Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `tableProps` and giving the AdvancedTable a `maxHeight` using our [Max Height](https://playbook.powerapp.cloud/visual_guidelines/max_height) global prop.
1
+ Create a sticky header that works for responsive Advanced Tables by setting `sticky: true` via `tableProps` and giving the AdvancedTable a `maxHeight` using our [Max Height](https://playbook.powerapp.cloud/global_props/max_height) global prop.
2
2
 
3
3
  **NOTE**: This behavior requires a `maxHeight` to work. The header is sticky within the table container, allowing for it to work along with the first column stickiness of a responsive table on smaller screen sizes.
4
4
 
@@ -76,6 +76,22 @@ const columnDefinitions = [
76
76
  {
77
77
  label: "Attendance",
78
78
  id: "attendance",
79
+ header: () => (
80
+ <Flex alignItems="center"
81
+ justifyContent="center"
82
+ >
83
+ <Caption marginRight="xs">Attendance</Caption>
84
+ <Tooltip placement="top"
85
+ text="Whoa. I'm a Tooltip Too!"
86
+ zIndex={10}
87
+ >
88
+ <Icon cursor="pointer"
89
+ icon="info"
90
+ size="xs"
91
+ />
92
+ </Tooltip>
93
+ </Flex>
94
+ ),
79
95
  columns: [
80
96
  {
81
97
  accessor: "attendanceRate",
@@ -0,0 +1,104 @@
1
+ <%
2
+ column_definitions = [
3
+ {
4
+ accessor: "year",
5
+ label: "Year",
6
+ id: "year",
7
+ cellAccessors: ["quarter", "month", "day"],
8
+ },
9
+ {
10
+ label: "Enrollment Data",
11
+ id: "enrollmentData",
12
+ header: ->(cell, label) {
13
+ capture do
14
+ pb_rails("flex", props: { align_items: "center", justify_content: "center" }) do
15
+ pb_rails("caption", props: { margin_right: "xs", text: "Enrollment Data" }) +
16
+ pb_rails("icon", props: { id: "tooltip-interact-multi", icon: "info", size: "xs", cursor: "pointer" }) +
17
+ pb_rails("tooltip", props: {
18
+ trigger_element_id: "tooltip-interact-multi",
19
+ tooltip_id: "example-custom-tooltip-multi",
20
+ position: "top",
21
+ z_index: "10"
22
+ }) do
23
+ "Whoa. I'm a Tooltip"
24
+ end
25
+ end
26
+ end
27
+ },
28
+ columns: [
29
+ {
30
+ label: "Enrollment Stats",
31
+ id: "enrollmentStats",
32
+ columns: [
33
+ {
34
+ accessor: "newEnrollments",
35
+ id: "newEnrollments",
36
+ label: "New Enrollments",
37
+ },
38
+ {
39
+ accessor: "scheduledMeetings",
40
+ id: "scheduledMeetings",
41
+ label: "Scheduled Meetings",
42
+ },
43
+ ],
44
+ },
45
+ ],
46
+ },
47
+ {
48
+ label: "Performance Data",
49
+ id: "performanceData",
50
+ columns: [
51
+ {
52
+ label: "Completion Metrics",
53
+ id: "completionMetrics",
54
+ columns: [
55
+ {
56
+ accessor: "completedClasses",
57
+ id: "completedClasses",
58
+ label: "Completed Classes",
59
+ },
60
+ {
61
+ accessor: "classCompletionRate",
62
+ id: "classCompletionRate",
63
+ label: "Class Completion Rate",
64
+ },
65
+ ],
66
+ },
67
+ {
68
+ label: "Attendance",
69
+ id: "attendance",
70
+ header: ->(cell, label) {
71
+ capture do
72
+ pb_rails("flex", props: { align_items: "center", justify_content: "center" }) do
73
+ pb_rails("caption", props: { margin_right: "xs", text: "Attendance" }) +
74
+ pb_rails("icon", props: { id: "tooltip-interact-multi-2", icon: "info", size: "xs", cursor: "pointer" }) +
75
+ pb_rails("tooltip", props: {
76
+ trigger_element_id: "tooltip-interact-multi-2",
77
+ tooltip_id: "example-custom-tooltip-multi-2",
78
+ position: "top",
79
+ z_index: "10"
80
+ }) do
81
+ "Whoa. I'm a Tooltip Too!"
82
+ end
83
+ end
84
+ end
85
+ },
86
+ columns: [
87
+ {
88
+ accessor: "attendanceRate",
89
+ id: "attendanceRate",
90
+ label: "Attendance Rate",
91
+ },
92
+ {
93
+ accessor: "scheduledMeetings",
94
+ id: "scheduledMeetings",
95
+ label: "Scheduled Meetings",
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ },
101
+ ]
102
+ %>
103
+
104
+ <%= pb_rails("advanced_table", props: { id: "custom_header_multi_header_table", table_data: @table_data, column_definitions: column_definitions }) %>
@@ -0,0 +1 @@
1
+ The optional `header` item within `column_definitions` can also be used with multi headers as seen here.
@@ -12,7 +12,7 @@
12
12
  capture do
13
13
  pb_rails("flex", props: { align_items: "center", justify_content: "center" }) do
14
14
  pb_rails("caption", props: { margin_right: "xs", text: "New Enrollments" }) +
15
- pb_rails("icon", props: { id: "tooltip-interact", icon: "info", size: "xs" }) +
15
+ pb_rails("icon", props: { id: "tooltip-interact", icon: "info", size: "xs", cursor: "pointer" }) +
16
16
  pb_rails("tooltip", props: {
17
17
  trigger_element_id: "tooltip-interact",
18
18
  tooltip_id: "example-custom-tooltip",
@@ -0,0 +1,42 @@
1
+ export const MOCK_DATA_INLINE_LOADING_EMPTY_CHILDREN = [
2
+ {
3
+ year: "2021",
4
+ quarter: null,
5
+ month: null,
6
+ day: null,
7
+ newEnrollments: "20",
8
+ scheduledMeetings: "10",
9
+ attendanceRate: "51%",
10
+ completedClasses: "3",
11
+ classCompletionRate: "33%",
12
+ graduatedStudents: "19",
13
+ children: [],
14
+ },
15
+ {
16
+ year: "2022",
17
+ quarter: null,
18
+ month: null,
19
+ day: null,
20
+ newEnrollments: "25",
21
+ scheduledMeetings: "17",
22
+ attendanceRate: "75%",
23
+ completedClasses: "5",
24
+ classCompletionRate: "45%",
25
+ graduatedStudents: "32",
26
+ children: [],
27
+ },
28
+ {
29
+ year: "2023",
30
+ quarter: null,
31
+ month: null,
32
+ day: null,
33
+ newEnrollments: "10",
34
+ scheduledMeetings: "15",
35
+ attendanceRate: "65%",
36
+ completedClasses: "4",
37
+ classCompletionRate: "49%",
38
+ graduatedStudents: "29",
39
+ children: [],
40
+ },
41
+ ]
42
+
@@ -11,6 +11,7 @@ examples:
11
11
  - advanced_table_responsive: Responsive Tables
12
12
  - advanced_table_custom_cell_rails: Custom Components for Cells
13
13
  - advanced_table_with_custom_header_rails: Custom Header Cell
14
+ - advanced_table_with_custom_header_multi_header_rails: Custom Header with Multiple Headers
14
15
  - advanced_table_column_headers: Multi-Header Columns
15
16
  - advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
16
17
  - advanced_table_column_headers_vertical_border: Multi-Header Columns with Vertical Borders
@@ -51,7 +51,7 @@ export default class PbFlatAdvancedTable extends PbEnhancedElement {
51
51
 
52
52
  const tr = rowCb.closest("tr");
53
53
  tr?.classList.toggle("bg-row-selection", rowCb.checked);
54
- tr?.classList.toggle("bg-white", !rowCb.checked);
54
+ tr?.classList.toggle("pb-bg-row-white", !rowCb.checked);
55
55
  }
56
56
 
57
57
  if (allCb) {
@@ -62,7 +62,7 @@ export default class PbFlatAdvancedTable extends PbEnhancedElement {
62
62
  cb.checked = checked;
63
63
  const tr = cb.closest("tr");
64
64
  tr?.classList.toggle("bg-row-selection", checked);
65
- tr?.classList.toggle("bg-white", !checked);
65
+ tr?.classList.toggle("pb-bg-row-white", !checked);
66
66
  const id = cb.id;
67
67
  if (checked) this.selectedRows.add(id);
68
68
  else this.selectedRows.delete(id);
@@ -76,7 +76,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
76
76
  // Only apply styling if the checkbox is inside a table row
77
77
  if (rowEl) {
78
78
  rowEl.classList.add("bg-row-selection");
79
- rowEl.classList.remove("bg-white", "bg-silver");
79
+ rowEl.classList.remove("pb-bg-row-white", "bg-silver");
80
80
  }
81
81
  } else {
82
82
  // Only apply styling if the checkbox is inside a table row
@@ -85,9 +85,9 @@ export default class PbAdvancedTable extends PbEnhancedElement {
85
85
 
86
86
  if (this.isRowExpanded(rowEl)) {
87
87
  rowEl.classList.remove("bg-silver");
88
- rowEl.classList.add("bg-white");
88
+ rowEl.classList.add("pb-bg-row-white");
89
89
  } else {
90
- rowEl.classList.remove("bg-white");
90
+ rowEl.classList.remove("pb-bg-row-white");
91
91
  rowEl.classList.add("bg-silver");
92
92
  }
93
93
  }
@@ -120,7 +120,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
120
120
  if (isChecked) {
121
121
  PbAdvancedTable.selectedRows.add(rowId);
122
122
  rowEl.classList.add("bg-row-selection");
123
- rowEl.classList.remove("bg-white", "bg-silver");
123
+ rowEl.classList.remove("pb-bg-row-white", "bg-silver");
124
124
  } else {
125
125
  PbAdvancedTable.selectedRows.delete(rowId);
126
126
  }
@@ -130,9 +130,9 @@ export default class PbAdvancedTable extends PbEnhancedElement {
130
130
 
131
131
  if (this.isRowExpanded(rowEl)) {
132
132
  rowEl.classList.remove("bg-silver");
133
- rowEl.classList.add("bg-white");
133
+ rowEl.classList.add("pb-bg-row-white");
134
134
  } else {
135
- rowEl.classList.remove("bg-white");
135
+ rowEl.classList.remove("pb-bg-row-white");
136
136
  rowEl.classList.add("bg-silver");
137
137
  }
138
138
  }
@@ -407,7 +407,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
407
407
  const row = this.element.closest("tr");
408
408
  if (row) {
409
409
  row.classList.toggle("bg-silver", !isVisible);
410
- row.classList.toggle("bg-white", isVisible);
410
+ row.classList.toggle("pb-bg-row-white", isVisible);
411
411
  }
412
412
 
413
413
  this.addBorderRadiusOnLastVisibleRow();
@@ -52,7 +52,7 @@
52
52
  }
53
53
  }
54
54
 
55
- .bg-white {
55
+ .pb-bg-row-white {
56
56
  td:first-child,
57
57
  .sticky-left {
58
58
  background-color: $bg-main;
@@ -63,7 +63,7 @@
63
63
  &.bg-silver td:first-child {
64
64
  background-color: $bg-secondary;
65
65
  }
66
- &.bg-white td:first-child {
66
+ &.pb-bg-row-white td:first-child {
67
67
  background-color: $bg-main;
68
68
  }
69
69
  &.bg-row-selection td:first-child {
@@ -82,32 +82,62 @@ module Playbook
82
82
  end
83
83
  end
84
84
 
85
- # Get original column definition for custom rendering
85
+ # Get original column definition for custom rendering by accessor
86
86
  def find_original_column_def(accessor)
87
87
  find_column_def_by_accessor(column_definitions, accessor)
88
88
  end
89
89
 
90
+ # Get original column definition for custom rendering by id
91
+ def find_original_column_def_by_id(id)
92
+ find_column_def_by_id(column_definitions, id)
93
+ end
94
+
90
95
  # Check if a header cell has a custom renderer
91
96
  def has_header_renderer?(cell)
92
- return false unless cell[:accessor].present?
93
-
94
- original_def = find_original_column_def(cell[:accessor])
95
- original_def && original_def[:header].present?
97
+ original_def = find_original_column_def_for_cell(cell)
98
+ original_def&.dig(:header).present?
99
+ rescue
100
+ false
96
101
  end
97
102
 
98
103
  # Render custom header content
99
104
  def render_header(cell)
100
105
  return cell[:label] unless has_header_renderer?(cell)
101
106
 
102
- original_def = find_original_column_def(cell[:accessor])
107
+ original_def = find_original_column_def_for_cell(cell)
108
+ return cell[:label] unless original_def
109
+
103
110
  custom_renderer = original_def[:header]
111
+ return cell[:label] unless custom_renderer
104
112
 
105
113
  # Call the custom renderer with the cell data and label
106
- custom_renderer.call(cell, cell[:label])
114
+ begin
115
+ result = custom_renderer.call(cell, cell[:label])
116
+ result.present? ? result.to_s : cell[:label]
117
+ rescue
118
+ cell[:label]
119
+ end
107
120
  end
108
121
 
109
122
  private
110
123
 
124
+ # Find the original column definition for a cell
125
+ def find_original_column_def_for_cell(cell)
126
+ # Try accessor first (for leaf columns)
127
+ if cell[:accessor].present?
128
+ found = find_original_column_def(cell[:accessor])
129
+ return found if found
130
+ end
131
+
132
+ # Try id if accessor lookup didn't find it (for grouped columns or leaf columns with id)
133
+ if cell[:id].present?
134
+ found = find_original_column_def_by_id(cell[:id])
135
+ return found if found
136
+ end
137
+
138
+ nil
139
+ end
140
+
111
141
  def compute_max_depth(columns)
112
142
  columns.map do |col|
113
143
  col[:columns] ? 1 + compute_max_depth(col[:columns]) : 1
@@ -118,21 +148,24 @@ module Playbook
118
148
  total_columns = columns.size
119
149
  columns.each_with_index do |col, index|
120
150
  is_last = index == total_columns - 1
121
- if col[:columns]
122
- colspan = compute_leaf_columns(col[:columns])
123
- rows[current_depth] << {
151
+ nested_columns = col[:columns]
152
+ if nested_columns
153
+ colspan = compute_leaf_columns(nested_columns)
154
+ cell_hash = {
124
155
  label: col[:label],
125
156
  colspan: colspan,
126
157
  is_last_in_group: is_last && current_depth.positive?,
127
158
  }
159
+ cell_hash[:id] = col[:id] if col[:id].present?
160
+ rows[current_depth] << cell_hash
128
161
 
129
- process_columns(col[:columns], rows, current_depth + 1, max_depth)
162
+ process_columns(nested_columns, rows, current_depth + 1, max_depth)
130
163
  else
131
- raw_styling = col[:column_styling] || {}
132
- header_alignment = raw_styling[:header_alignment]
164
+ raw_styling = col[:column_styling] || {}
165
+ header_alignment = raw_styling[:header_alignment]
133
166
 
134
167
  colspan = 1
135
- rows[current_depth] << {
168
+ cell_hash = {
136
169
  label: col[:label],
137
170
  colspan: colspan,
138
171
  accessor: col[:accessor],
@@ -140,6 +173,8 @@ module Playbook
140
173
  is_last_in_group: is_last && current_depth.positive?,
141
174
  header_alignment: header_alignment,
142
175
  }
176
+ cell_hash[:id] = col[:id] if col[:id].present?
177
+ rows[current_depth] << cell_hash
143
178
  end
144
179
  end
145
180
  end
@@ -154,11 +189,15 @@ module Playbook
154
189
  max_depth = compute_max_depth(column_definitions)
155
190
 
156
191
  column_definitions.map do |col|
157
- if col.key?(:columns)
158
- {
192
+ if col[:columns]
193
+ nested_columns = col[:columns]
194
+ wrapped = {
159
195
  label: col[:label],
160
- columns: wrap_leaf_columns(col[:columns]),
196
+ columns: wrap_leaf_columns(nested_columns),
161
197
  }
198
+ wrapped[:id] = col[:id] if col[:id].present?
199
+ wrapped[:header] = col[:header] if col[:header].present?
200
+ wrapped
162
201
  else
163
202
  # For leaf columns, wrap with empty labels up to max depth to get proper structure
164
203
  wrap_leaf_column(col, max_depth)
@@ -173,6 +212,7 @@ module Playbook
173
212
  sort_menu: col[:sort_menu] || nil,
174
213
  column_styling: col[:column_styling] || {},
175
214
  }
215
+ wrapped[:id] = col[:id] if col[:id].present?
176
216
  (max_depth - 1).times do
177
217
  wrapped = { label: "", columns: [wrapped] }
178
218
  end
@@ -180,11 +220,41 @@ module Playbook
180
220
  end
181
221
 
182
222
  def find_column_def_by_accessor(defs, target_accessor)
223
+ return nil if target_accessor.blank?
224
+
183
225
  defs.each do |col|
184
- return col if col[:accessor] == target_accessor
226
+ col_accessor = col[:accessor]
227
+ next if col_accessor.blank?
228
+
229
+ return col if col_accessor.to_s == target_accessor.to_s
230
+
231
+ nested_columns = col[:columns]
232
+ if nested_columns.is_a?(Array)
233
+ found = find_column_def_by_accessor(nested_columns, target_accessor)
234
+ return found if found
235
+ end
236
+ end
237
+ nil
238
+ end
239
+
240
+ def find_column_def_by_id(defs, target_id)
241
+ return nil if target_id.blank?
242
+
243
+ defs.each do |col|
244
+ col_id = col[:id]
245
+
246
+ return col if col_id.present? && col_id.to_s == target_id.to_s
247
+
248
+ # Recursively search nested columns, even if current col has no id or doesn't match
249
+ nested_columns = col[:columns]
250
+
251
+ next unless nested_columns.present?
252
+
253
+ # Convert to array if needed (for edge cases where is_a?(Array) might fail)
254
+ array_columns = Array(nested_columns)
185
255
 
186
- if col[:columns].is_a?(Array)
187
- found = find_column_def_by_accessor(col[:columns], target_accessor)
256
+ if array_columns.any?
257
+ found = find_column_def_by_id(array_columns, target_id)
188
258
  return found if found
189
259
  end
190
260
  end