playbook_ui 14.20.0.pre.rc.2 → 14.21.0.pre.rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +61 -35
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +36 -22
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +6 -19
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +16 -8
  6. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +9 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +6 -2
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +1 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +3 -1
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +137 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.md +3 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +40 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.md +1 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/index.js +155 -12
  17. data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.html.erb +23 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.rb +19 -0
  19. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +4 -0
  20. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -1
  21. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +77 -19
  22. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_rails.html.erb +31 -0
  23. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_rails.md +5 -0
  24. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select.jsx +56 -0
  25. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select.md +3 -0
  26. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display.jsx +58 -0
  27. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display.md +3 -0
  28. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display_rails.html.erb +20 -0
  29. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_display_rails.md +1 -0
  30. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_rails.html.erb +19 -0
  31. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_rails.md +3 -0
  32. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_autocomplete.html.erb +20 -0
  33. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_autocomplete.jsx +57 -0
  34. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_autocomplete.md +1 -0
  35. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_custom_options.html.erb +50 -0
  36. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_custom_options.jsx +105 -0
  37. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_default.html.erb +22 -0
  38. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_multi_select_with_default.jsx +67 -0
  39. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +11 -1
  40. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -0
  41. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +3 -3
  42. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +16 -2
  43. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +34 -13
  44. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +3 -1
  45. data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +0 -6
  46. data/app/pb_kits/playbook/pb_dropdown/index.js +334 -41
  47. data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +39 -12
  48. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +16 -12
  49. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +78 -12
  50. data/app/pb_kits/playbook/pb_dropdown/subcomponents/MultiSelectTriggerDisplay.tsx +58 -0
  51. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -0
  52. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -0
  53. data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.html.erb +12 -0
  54. data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.jsx +31 -0
  55. data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.md +1 -0
  56. data/app/pb_kits/playbook/pb_select/docs/example.yml +2 -0
  57. data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
  58. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +73 -3
  59. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input.jsx +23 -0
  60. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input.md +1 -0
  61. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
  62. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  63. data/dist/chunks/_typeahead-BmOWdDtp.js +22 -0
  64. data/dist/chunks/_weekday_stacked-CvcuQyr9.js +45 -0
  65. data/dist/chunks/lib-D5R1BjUn.js +29 -0
  66. data/dist/chunks/{pb_form_validation-WWvUXPKD.js → pb_form_validation-BZ2AVAi_.js} +1 -1
  67. data/dist/chunks/vendor.js +1 -1
  68. data/dist/playbook-doc.js +2 -2
  69. data/dist/playbook-rails-react-bindings.js +1 -1
  70. data/dist/playbook-rails.js +1 -1
  71. data/dist/playbook.css +1 -1
  72. data/lib/playbook/kit_base.rb +3 -3
  73. data/lib/playbook/version.rb +2 -2
  74. metadata +35 -7
  75. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.html.erb +0 -10
  76. data/dist/chunks/_typeahead-B9-s4j4U.js +0 -22
  77. data/dist/chunks/_weekday_stacked-CvzpmXD5.js +0 -45
  78. data/dist/chunks/lib-B20MXZcW.js +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 550eb9cf8486549b50d70381987dc8b6df78f8aa7dea1524b5e2b9d7142966e6
4
- data.tar.gz: 8ad49a6bd0a8b792998a24292872458ff0af0b0fd65c98c93aec4b37b40ffa3d
3
+ metadata.gz: '089f2d5e50071995fbeb82f232ac14472c4c49a03c48faa73b02d5ac0aeefc37'
4
+ data.tar.gz: 96af6bdb569351940f255651df148973b9b57255d1ac5808c14768973de46d7f
5
5
  SHA512:
6
- metadata.gz: 3c12a7c65488cb05d4652474347af12ccaf4ae4cdf3e5631cdd38d55d449533807f44ced11e23b163ba2f194f4b016216c189730f6c92050e889497a54b6a443
7
- data.tar.gz: 7a92df587607e3ba5944e69d790a6433bde32b15d3c1626004e2e34d0eeb3489a14d468dc6322d73391bdf0acecf5581f137d371d387f1d0e2b49b9928758a6a
6
+ metadata.gz: 889152570ef15c2e40194250f9a56a5fbb18913fa8bc8adcbdb855011bd5d8228611352756cccd1639fbecb171bf5e095018c6f1a2af08e22eab2aec98b11b64
7
+ data.tar.gz: 7ffc106c82f3f7edab864ab35ce95b789f1e4957b4b6ba9fbcb3eddaf5b8c08e821610e8ac72faa98642b481619b229ee1ef120f6ae3210a91e99016b2277515
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, useContext } from "react";
1
+ import React, { useEffect, useRef, useContext, useState } from "react";
2
2
 
3
3
  import AdvancedTableContext from "../Context/AdvancedTableContext";
4
4
  import { buildVisibilityTree } from "../Utilities/VisibilityTree";
@@ -7,13 +7,11 @@ import Card from "../../pb_card/_card";
7
7
  import Caption from "../../pb_caption/_caption";
8
8
  import Flex from "../../pb_flex/_flex";
9
9
  import FlexItem from "../../pb_flex/_flex_item";
10
- import Dropdown from "../../pb_dropdown/_dropdown";
11
- import DropdownContainer from "../../pb_dropdown/subcomponents/DropdownContainer";
12
- import DropdownTrigger from "../../pb_dropdown/subcomponents/DropdownTrigger";
13
10
  import Icon from "../../pb_icon/_icon";
14
11
  import Checkbox from "../../pb_checkbox/_checkbox";
15
12
  import SectionSeparator from "../../pb_section_separator/_section_separator";
16
13
  import Tooltip from "../../pb_tooltip/_tooltip";
14
+ import PbReactPopover from "../../pb_popover/_popover";
17
15
 
18
16
  import {
19
17
  showActionBar,
@@ -56,11 +54,24 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
56
54
  const col = table.getColumn(id);
57
55
  const show = col.getIsVisible();
58
56
 
57
+ const handleVisibilityChange = () => {
58
+ col.toggleVisibility();
59
+ if (columnVisibilityControl?.onColumnVisibilityChange) {
60
+ const updatedVisibilityState = {
61
+ ...table.getAllColumns().reduce((acc: { [x: string]: any; }, col: { id: string | number; getIsVisible: () => any; }) => {
62
+ acc[col.id] = col.getIsVisible();
63
+ return acc;
64
+ }, {}),
65
+ };
66
+ columnVisibilityControl?.onColumnVisibilityChange(updatedVisibilityState);
67
+ }
68
+ };
69
+
59
70
  return (
60
71
  <Checkbox
61
72
  checked={show}
62
73
  key={id}
63
- onChange={() => col.toggleVisibility()}
74
+ onChange={handleVisibilityChange}
64
75
  paddingBottom="xs"
65
76
  text={label}
66
77
  />
@@ -80,16 +91,24 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
80
91
  const allOn = visibleArray.every(Boolean);
81
92
  const someOn = visibleArray.some(Boolean);
82
93
 
94
+ const handleGroupVisibilityChange = () => {
95
+ leaves.forEach((id) => table.getColumn(id).toggleVisibility(!allOn));
96
+ if (columnVisibilityControl?.onColumnVisibilityChange) {
97
+ const updatedVisibilityState = {
98
+ ...table.getAllColumns().reduce((acc: { [x: string]: any; }, col: { id: string | number; getIsVisible: () => any; }) => {
99
+ acc[col.id] = col.getIsVisible();
100
+ return acc;
101
+ }, {}),
102
+ };
103
+ columnVisibilityControl?.onColumnVisibilityChange(updatedVisibilityState);
104
+ }
105
+ };
83
106
  return (
84
107
  <>
85
108
  <Checkbox
86
109
  checked={allOn}
87
110
  indeterminate={!allOn && someOn}
88
- onChange={() =>
89
- leaves.forEach((id) =>
90
- table.getColumn(id).toggleVisibility(!allOn),
91
- )
92
- }
111
+ onChange={handleGroupVisibilityChange}
93
112
  paddingBottom="xs"
94
113
  text={node.label}
95
114
  />
@@ -113,7 +132,28 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
113
132
  hideActionBar(cardRef.current);
114
133
  }
115
134
  }
116
- }, [isVisible]);
135
+ }, [isVisible, type]);
136
+
137
+ const [showPopover, setShowPopover] = useState(false)
138
+
139
+ const togglePopover = () => setShowPopover((prev) => !prev)
140
+ const handleShouldClose = (shouldClose: boolean) =>
141
+ setShowPopover(!shouldClose)
142
+
143
+ const popoverReference = (
144
+ <Tooltip
145
+ placement="top"
146
+ text="Column Configuration"
147
+ >
148
+ <div onClick={togglePopover}>
149
+ <Icon
150
+ color="primary"
151
+ cursor="pointer"
152
+ icon="sliders-h"
153
+ />
154
+ </div>
155
+ </Tooltip>
156
+ )
117
157
 
118
158
  return (
119
159
  <Card
@@ -139,30 +179,17 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
139
179
  <FlexItem>{actions}</FlexItem>
140
180
  </>
141
181
  ) : (
142
- <Dropdown
143
- className="column-visibility-dropdown-wrapper"
144
- options={columnDefinitions}
182
+ <PbReactPopover
183
+ closeOnClick="outside"
184
+ placement="bottom-end"
185
+ reference={popoverReference}
186
+ shouldClosePopover={handleShouldClose}
187
+ show={showPopover}
188
+ zIndex={3}
145
189
  >
146
- <DropdownTrigger>
147
- <Tooltip
148
- placement='top'
149
- text="Column Configuration"
150
- zIndex={10}
151
- >
152
- <Icon
153
- color="primary"
154
- cursor="pointer"
155
- icon="sliders-h"
156
- />
157
- </Tooltip>
158
- </DropdownTrigger>
159
- <DropdownContainer
160
- className="column-visibility-dropdown"
161
- paddingTop="sm"
162
- >
163
- <>
190
+ <>
164
191
  <Caption
165
- paddingBottom="sm"
192
+ paddingY="sm"
166
193
  text="Columns Config"
167
194
  textAlign="center"
168
195
  />
@@ -177,8 +204,7 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
177
204
  </Flex>
178
205
  ))}
179
206
  </>
180
- </DropdownContainer>
181
- </Dropdown>
207
+ </PbReactPopover>
182
208
  )}
183
209
  </Flex>
184
210
  </Card>
@@ -1,4 +1,4 @@
1
- import React, { useContext } from "react"
1
+ import React, { useContext, useState } from "react"
2
2
  import classnames from "classnames"
3
3
  import { flexRender, Header, Table, RowModel } from "@tanstack/react-table"
4
4
 
@@ -8,10 +8,8 @@ import { GlobalProps } from "../../utilities/globalProps"
8
8
 
9
9
  import Flex from "../../pb_flex/_flex"
10
10
  import Checkbox from "../../pb_checkbox/_checkbox"
11
- import Dropdown from "../../pb_dropdown/_dropdown"
12
- import DropdownTrigger from "../../pb_dropdown/subcomponents/DropdownTrigger"
13
- import DropdownOption from "../../pb_dropdown/subcomponents/DropdownOption"
14
- import DropdownContainer from "../../pb_dropdown/subcomponents/DropdownContainer"
11
+ import SectionSeparator from "../../pb_section_separator/_section_separator"
12
+ import PbReactPopover from "../../pb_popover/_popover";
15
13
  import Icon from "../../pb_icon/_icon"
16
14
 
17
15
  import { SortIconButton } from "./SortIconButton"
@@ -136,6 +134,20 @@ const isToggleExpansionEnabled =
136
134
  justifyHeader = isLeafColumn ? "end" : "center";
137
135
  }
138
136
 
137
+ const [showPopover, setShowPopover] = useState(false)
138
+
139
+ const togglePopover = () => setShowPopover((prev) => !prev)
140
+ const handleShouldClose = (shouldClose: boolean) =>
141
+ setShowPopover(!shouldClose)
142
+
143
+ const popoverReference = (
144
+ <div className="gray-icon toggle-all-icon"
145
+ onClick={togglePopover}
146
+ >
147
+ <Icon icon={displayIcon(toggleExpansionIcon)[0]} />
148
+ </div>
149
+ )
150
+
139
151
  const handleExpandDepth = (depth: number) => {
140
152
  if (onExpandByDepthClick) {
141
153
  const flatRows = table?.getRowModel().flatRows
@@ -191,31 +203,33 @@ const isToggleExpansionEnabled =
191
203
  <ToggleIconButton onClick={handleExpandOrCollapse} />
192
204
  )}
193
205
  {isToggleExpansionEnabled && hasAnySubRows && expandByDepth && (
194
- <Dropdown className="expand-by-depth-dropdown-wrapper"
195
- options={expandByDepth}
196
- >
197
- <DropdownTrigger className="gray-icon toggle-all-icon">
198
- <Icon icon={displayIcon(toggleExpansionIcon)[0]} />
199
- </DropdownTrigger>
200
- <DropdownContainer className="expand-by-depth-dropdown">
201
- {expandByDepth.map((option:{ [key: string]: any }, index: number) => (
202
- <DropdownOption
203
- key={index}
204
- option={option}
205
- padding="none"
206
+
207
+ <PbReactPopover
208
+ closeOnClick="any"
209
+ placement="bottom-start"
210
+ reference={popoverReference}
211
+ shouldClosePopover={handleShouldClose}
212
+ show={showPopover}
213
+ zIndex={3}
206
214
  >
215
+ {expandByDepth.map((option:{ [key: string]: any }, index: number) => (
216
+ <>
207
217
  <Flex
208
218
  alignItems="center"
219
+ className="pb-advanced-table-popover-option"
220
+ cursor="pointer"
209
221
  htmlOptions={{onClick: () => {handleExpandDepth(option.depth)} }}
210
222
  paddingX="sm"
211
223
  paddingY="xs"
212
224
  >
213
225
  {option.label}
214
- </Flex>
215
- </DropdownOption>
216
- ))}
217
- </DropdownContainer>
218
- </Dropdown>
226
+ </Flex>
227
+ {index !== expandByDepth.length - 1 && <SectionSeparator/>}
228
+ </>
229
+ ))}
230
+ </PbReactPopover>
231
+
232
+
219
233
  )}
220
234
 
221
235
  {isToggleExpansionEnabledLoading &&(
@@ -53,15 +53,6 @@
53
53
  width: 100%;
54
54
  }
55
55
 
56
- .column-visibility-dropdown-wrapper {
57
- position: unset !important;
58
- }
59
- .column-visibility-dropdown {
60
- width: unset !important;
61
- right: $space_xxs;
62
- text-align: left;
63
- }
64
-
65
56
  // Virtualized table styles
66
57
  .virtualized-table-row {
67
58
  display: table !important;
@@ -159,13 +150,6 @@
159
150
  box-sizing: border-box !important;
160
151
  }
161
152
  }
162
- .expand-by-depth-dropdown-wrapper {
163
- position: unset !important;
164
- }
165
- .expand-by-depth-dropdown {
166
- width: unset !important;
167
- text-align: left;
168
- }
169
153
  }
170
154
 
171
155
  .pb_advanced_table_body {
@@ -554,14 +538,12 @@
554
538
  background-color: $white;
555
539
  box-shadow: $shadow_deep;
556
540
  }
541
+
557
542
  @include advanced-table-sticky-mixin(
558
543
  $border_light,
559
544
  $white,
560
545
  lighten($silver, $opacity_7)
561
546
  );
562
-
563
- // Apply border colors for sticky columns
564
- @include apply-sticky-colors("light");
565
547
  }
566
548
 
567
549
  // Responsive Styles
@@ -827,3 +809,8 @@
827
809
  }
828
810
  }
829
811
  }
812
+
813
+ // Outside of the pb_advanced_table class for popover
814
+ .pb-advanced-table-popover-option:hover {
815
+ background-color: $bg_light;
816
+ }
@@ -1,10 +1,18 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark, classname: object.loading ? "content-loading" : "" }.merge(object.table_props)) do %>
3
- <% if content.present? %>
4
- <% content.presence %>
5
- <% else %>
6
- <%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows }) %>
7
- <%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion }) %>
8
- <% end %>
9
- <% end %>
2
+ <% if object.id && object.selectable_rows && object.show_actions_bar %>
3
+ <%= pb_rails("advanced_table/table_action_bar", props: {
4
+ actions: object.actions,
5
+ is_visible: false,
6
+ selected_count: 0
7
+ }) %>
8
+ <% end %>
9
+
10
+ <%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark, classname: object.loading ? "content-loading" : "" }.merge(object.table_props)) do %>
11
+ <% if content.present? %>
12
+ <% content.presence %>
13
+ <% else %>
14
+ <%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
15
+ <%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion }) %>
16
+ <% end %>
17
+ <% end %>
10
18
  <% end %>
@@ -25,6 +25,10 @@ module Playbook
25
25
  default: "auto"
26
26
  prop :selectable_rows, type: Playbook::Props::Boolean,
27
27
  default: false
28
+ prop :show_actions_bar, type: Playbook::Props::Boolean,
29
+ default: true
30
+ prop :actions, type: Playbook::Props::Array,
31
+ default: []
28
32
 
29
33
  def classname
30
34
  additional_classes = [responsive_classname, max_height_classname]
@@ -47,6 +51,11 @@ module Playbook
47
51
  def selected_rows_length
48
52
  selected_rows.length
49
53
  end
54
+
55
+ def is_action_bar_visible
56
+ # Action bar visibility is controlled by JS based on selection
57
+ false
58
+ end
50
59
  end
51
60
  end
52
61
  end
@@ -1,4 +1,8 @@
1
- The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
1
+ The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has three required props__:
2
+
3
+ ### id
4
+
5
+ A unique `id` is required to allow the table functionality to work properly. Without it, certain functions like the action bar will not be able to properly reference the correct table.
2
6
 
3
7
  ### table_data
4
8
 
@@ -13,6 +17,6 @@ Column definitions are the single most important part of building a table as the
13
17
  - `accessor`: this is the key from your data for the value you want rendered in that column
14
18
  - `label`: this is what will be rendered as the column header label
15
19
 
16
- There is also one optional item that is only required if the table has nested data:
20
+ There is also one optional item that is only required if the table has nested data:
17
21
 
18
22
  - `cellAccessors`: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
@@ -49,6 +49,7 @@ const AdvancedTableColumnVisibilityWithState = (props) => {
49
49
  const columnVisibilityControl = {
50
50
  value: columnVisibility,
51
51
  onChange: setColumnVisibility,
52
+ onColumnVisibilityChange: (currentState) => console.log(currentState),
52
53
  }
53
54
  return (
54
55
  <div>
@@ -1 +1,3 @@
1
- The `columnVisibilityControl` prop also allows for greater control over the columnVisibility state. Devs can manage state themselves by passing in `value` and `onChange` as shown.
1
+ The `columnVisibilityControl` prop also allows for greater control over the columnVisibility state. Devs can manage state themselves by passing in `value` and `onChange` as shown.
2
+
3
+ The additional `onColumnVisibilityChange` provides a callback with the current state as the argument if needed.
@@ -3,7 +3,7 @@
3
3
  <br />
4
4
  <br />
5
5
 
6
- The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
6
+ The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
7
7
 
8
8
  ### tableData
9
9
 
@@ -0,0 +1,137 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ },
7
+ {
8
+ accessor: "newEnrollments",
9
+ label: "New Enrollments",
10
+ },
11
+ {
12
+ accessor: "scheduledMeetings",
13
+ label: "Scheduled Meetings",
14
+ },
15
+ {
16
+ accessor: "attendanceRate",
17
+ label: "Attendance Rate",
18
+ },
19
+ {
20
+ accessor: "completedClasses",
21
+ label: "Completed Classes",
22
+ },
23
+ {
24
+ accessor: "classCompletionRate",
25
+ label: "Class Completion Rate",
26
+ },
27
+ {
28
+ accessor: "graduatedStudents",
29
+ label: "Graduated Students",
30
+ }
31
+ ]
32
+
33
+ actions = [
34
+ pb_rails("circle_icon_button", props: {
35
+ icon: "file-csv",
36
+ variant: "link",
37
+ id: "export-selected-rows-btn",
38
+ data: {
39
+ action_type: "export"
40
+ }
41
+ }),
42
+ pb_rails("circle_icon_button", props: {
43
+ icon: "trash-alt",
44
+ variant: "link",
45
+ id: "delete-selected-rows-btn",
46
+ data: {
47
+ action_type: "delete"
48
+ }
49
+ })
50
+ ]
51
+ %>
52
+
53
+ <%= pb_rails("advanced_table", props: {
54
+ id: "selectable_rows_with_actions",
55
+ table_data: @table_data_no_subrows,
56
+ column_definitions: column_definitions,
57
+ selectable_rows: true,
58
+ enable_toggle_expansion: "none",
59
+ actions: actions
60
+ }) %>
61
+
62
+ <script>
63
+ // Handle action clicks using the data-selected-rows attribute
64
+ window.handleActionClick = function(actionType) {
65
+ const tableContainer = document.getElementById('selectable_rows_with_actions');
66
+ if (!tableContainer) return;
67
+
68
+ // Get selected rows from the data attribute
69
+ const selectedRowsJSON = tableContainer.getAttribute('data-selected-rows');
70
+ let selectedRowIds = [];
71
+
72
+ try {
73
+ // Parse the JSON string from the data attribute
74
+ if (selectedRowsJSON) {
75
+ selectedRowIds = JSON.parse(selectedRowsJSON);
76
+ }
77
+ } catch (e) {
78
+ // Fallback if JSON parsing fails
79
+ const checkboxes = tableContainer.querySelectorAll('input[type="checkbox"]:checked');
80
+ const selectedCheckboxes = Array.from(checkboxes).filter(checkbox =>
81
+ checkbox.id !== 'select-all-rows' &&
82
+ !checkbox.closest('#select-all-rows')
83
+ );
84
+ selectedRowIds = selectedCheckboxes.map(checkbox => checkbox.id);
85
+ }
86
+
87
+ // Show appropriate message
88
+ if (!selectedRowIds || selectedRowIds.length === 0) {
89
+ alert('No Selection Made');
90
+ } else {
91
+ if (actionType === 'export') {
92
+ alert(`Row ids ${selectedRowIds.join(', ')} will be exported!`);
93
+ } else if (actionType === 'delete') {
94
+ alert(`Row ids ${selectedRowIds.join(', ')} will be deleted!`);
95
+ }
96
+ }
97
+ };
98
+
99
+ // Add event listeners when the DOM is ready
100
+ document.addEventListener('DOMContentLoaded', function() {
101
+ // Get the buttons
102
+ const exportBtn = document.getElementById('export-selected-rows-btn');
103
+ const deleteBtn = document.getElementById('delete-selected-rows-btn');
104
+
105
+ // Add click event listeners
106
+ if (exportBtn) {
107
+ exportBtn.addEventListener('click', function(e) {
108
+ e.preventDefault();
109
+ window.handleActionClick('export');
110
+ });
111
+ }
112
+
113
+ if (deleteBtn) {
114
+ deleteBtn.addEventListener('click', function(e) {
115
+ e.preventDefault();
116
+ window.handleActionClick('delete');
117
+ });
118
+ }
119
+
120
+ // Optional: Event delegation through the action bar
121
+ const actionBar = document.querySelector('.row-selection-actions-card');
122
+ if (actionBar) {
123
+ actionBar.addEventListener('click', function(e) {
124
+ const exportButton = e.target.closest('#export-selected-rows-btn');
125
+ const deleteButton = e.target.closest('#delete-selected-rows-btn');
126
+
127
+ if (exportButton) {
128
+ e.preventDefault();
129
+ window.handleActionClick('export');
130
+ } else if (deleteButton) {
131
+ e.preventDefault();
132
+ window.handleActionClick('delete');
133
+ }
134
+ });
135
+ }
136
+ });
137
+ </script>
@@ -0,0 +1,3 @@
1
+ Custom actions content can be rendered within the Actions Bar as shown in this doc example. The component passed to `actions` will be rendered on the right of the actionsBar.
2
+
3
+ You can utilize script tags with your actions to provide your buttons with any clickable events needed.
@@ -0,0 +1,40 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ },
7
+ {
8
+ accessor: "newEnrollments",
9
+ label: "New Enrollments",
10
+ },
11
+ {
12
+ accessor: "scheduledMeetings",
13
+ label: "Scheduled Meetings",
14
+ },
15
+ {
16
+ accessor: "attendanceRate",
17
+ label: "Attendance Rate",
18
+ },
19
+ {
20
+ accessor: "completedClasses",
21
+ label: "Completed Classes",
22
+ },
23
+ {
24
+ accessor: "classCompletionRate",
25
+ label: "Class Completion Rate",
26
+ },
27
+ {
28
+ accessor: "graduatedStudents",
29
+ label: "Graduated Students",
30
+ }
31
+ ] %>
32
+
33
+ <%= pb_rails("advanced_table", props: {
34
+ id: "selectable_rows_with_actions",
35
+ table_data: @table_data_no_subrows,
36
+ column_definitions: column_definitions,
37
+ selectable_rows: true,
38
+ enable_toggle_expansion: "none",
39
+ show_actions_bar: false
40
+ }) %>
@@ -0,0 +1 @@
1
+ `show_actions_bar` is an optional prop that renders the header at the top showing the row count. This is set to `true` by default but can be toggled off by setting it to `false`
@@ -15,6 +15,8 @@ examples:
15
15
  - advanced_table_column_border_color_rails: Column Group Border Color
16
16
  - advanced_table_selectable_rows_rails: Selectable Rows
17
17
  - advanced_table_selectable_rows_no_subrows_rails: Selectable Rows (No Subrows)
18
+ - advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
19
+ - advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
18
20
 
19
21
  react:
20
22
  - advanced_table_default: Default (Required Props)