playbook_ui 14.19.0 → 14.20.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +11 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +148 -15
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +20 -3
  5. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +23 -13
  6. data/app/pb_kits/playbook/pb_advanced_table/Utilities/VisibilityTree.ts +47 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +9 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +7 -2
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.jsx +57 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.md +4 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.jsx +62 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.md +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.jsx +82 -0
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.md +1 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +65 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +1 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +5 -1
  19. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +1 -0
  20. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +2 -2
  21. data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +13 -0
  22. data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +11 -1
  23. data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.html.erb +1 -0
  24. data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.jsx +41 -0
  25. data/app/pb_kits/playbook/pb_file_upload/docs/example.yml +2 -0
  26. data/app/pb_kits/playbook/pb_file_upload/docs/index.js +1 -0
  27. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -0
  28. data/app/pb_kits/playbook/pb_file_upload/file_upload.rb +7 -1
  29. data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +18 -0
  30. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +9 -9
  31. data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +2 -2
  32. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +4 -2
  33. data/dist/chunks/{_typeahead-D62OcwsT.js → _typeahead-BPSIWtFT.js} +3 -3
  34. data/dist/chunks/_weekday_stacked-PfWrqC3z.js +45 -0
  35. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  36. data/dist/chunks/lib-B20MXZcW.js +29 -0
  37. data/dist/chunks/{pb_form_validation-BioH7DWv.js → pb_form_validation-WWvUXPKD.js} +1 -1
  38. data/dist/chunks/vendor.js +1 -1
  39. data/dist/playbook-doc.js +1 -1
  40. data/dist/playbook-rails-react-bindings.js +1 -1
  41. data/dist/playbook-rails.js +1 -1
  42. data/dist/playbook.css +1 -1
  43. data/lib/playbook/version.rb +2 -2
  44. metadata +18 -7
  45. data/dist/chunks/_weekday_stacked-Ceh9N0ow.js +0 -45
  46. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
  47. data/dist/chunks/lib-CeKZrPmu.js +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 242dea3f908e8ab1063890e221e4a5a52ab48694d7cba5ce7d20223b05ebece5
4
- data.tar.gz: 2b8a758c373ac4796e6f7bfaf5b1df93f0a0289272df3dd3dbd5c758c84380f9
3
+ metadata.gz: 8fa79ee278fc38b79bf8ba0d013868027d1b9b26029ccb1cf2f173b2a7797c83
4
+ data.tar.gz: 9e914077f1ad480c8f7ffa9bb65a6828a7b9a887d7b8b3e536bacfa5ab7c5a6e
5
5
  SHA512:
6
- metadata.gz: f2aff5a100ae75592c9f06769d1773a5c053b9aaabf107b6861e36c7892d7a8239a7da9fbc82dfbaf1cc37dd58b1dd1ba580390d1e0dd21dcb6f496040ae3f33
7
- data.tar.gz: f144555056550a5abc69c7a9efd94ab207530c7d3263e18da5263cb26382b34f07b55b30a68834617f8e7bf57e5c8e724457e7f77225dbc31aa5a8b625515bcb
6
+ metadata.gz: 4ef970a5758c8caf8a18b1d242eaf93c406318aaa676c2515200ed8e35fb8391de2acb7c2bc22f9350d6dd8555e26707fcdae48d0b779ee50372d35606364f86
7
+ data.tar.gz: 1b0da522bd01978c4087c086cc6ec8d0066296696a7c8ff82d26e74d6d126694c83f2b3fa7d39b2cafb97678a9f66a4a175864a8c534d273590a763c03b18171
@@ -93,7 +93,17 @@ export const RegularTableView = ({
93
93
 
94
94
  {row.getVisibleCells().map((cell: Cell<GenericObject, unknown>, i: number) => {
95
95
  const isPinnedLeft = columnPinning.left.includes(cell.column.id);
96
- const isLastCell = cell.column.parent?.columns?.at(-1)?.id === cell.column.id;
96
+ const isLastCell = (() => {
97
+ const parent = cell.column.parent;
98
+ if (!parent) {
99
+ const last = row.getVisibleCells().at(-1);
100
+ return last?.column.id === cell.column.id;
101
+ }
102
+
103
+ const visibleSiblings = parent.columns.filter(col => col.getIsVisible());
104
+ return visibleSiblings.at(-1)?.id === cell.column.id;
105
+ })();
106
+
97
107
  const { column } = cell;
98
108
  return (
99
109
  <td
@@ -1,25 +1,112 @@
1
- import React, { useEffect, useRef } from "react";
1
+ import React, { useEffect, useRef, useContext } from "react";
2
+
3
+ import AdvancedTableContext from "../Context/AdvancedTableContext";
4
+ import { buildVisibilityTree } from "../Utilities/VisibilityTree";
5
+
2
6
  import Card from "../../pb_card/_card";
3
7
  import Caption from "../../pb_caption/_caption";
4
8
  import Flex from "../../pb_flex/_flex";
5
9
  import FlexItem from "../../pb_flex/_flex_item";
6
- import { showActionBar, hideActionBar } from "../Utilities/ActionBarAnimationHelper";
10
+ import Dropdown from "../../pb_dropdown/_dropdown";
11
+ import DropdownContainer from "../../pb_dropdown/subcomponents/DropdownContainer";
12
+ import DropdownTrigger from "../../pb_dropdown/subcomponents/DropdownTrigger";
13
+ import Icon from "../../pb_icon/_icon";
14
+ import Checkbox from "../../pb_checkbox/_checkbox";
15
+ import SectionSeparator from "../../pb_section_separator/_section_separator";
16
+ import Tooltip from "../../pb_tooltip/_tooltip";
17
+
18
+ import {
19
+ showActionBar,
20
+ hideActionBar,
21
+ } from "../Utilities/ActionBarAnimationHelper";
22
+ import { GenericObject } from "../../types";
7
23
 
8
24
  interface TableActionBarProps {
9
- isVisible: boolean;
25
+ isVisible: boolean | GenericObject | undefined;
10
26
  selectedCount: number;
11
27
  actions?: React.ReactNode[] | React.ReactNode;
28
+ type?: string;
29
+ }
30
+
31
+ interface VisibilityNode {
32
+ id?: string | undefined;
33
+ label?: string | undefined;
34
+ children?: VisibilityNode[];
12
35
  }
13
36
 
14
37
  const TableActionBar: React.FC<TableActionBarProps> = ({
15
38
  isVisible,
16
39
  selectedCount,
17
- actions
40
+ actions,
41
+ type = "row-selection",
18
42
  }) => {
19
43
  const cardRef = useRef(null);
44
+ const { table, columnVisibilityControl, columnDefinitions } =
45
+ useContext(AdvancedTableContext);
46
+
47
+ // ----------- Column visibility logic -----------
48
+ const includeIds = columnVisibilityControl?.includeIds;
49
+ const firstLeafId = table.getAllLeafColumns()[0]?.id;
50
+ // Get the first leaf column ID to exclude it from the visibility tree
51
+ // This is to avoid showing the first column in the dropdown
52
+ // as toggling it's visibility breaks the expanded row functionality
53
+ const tree = buildVisibilityTree(columnDefinitions, includeIds).filter(node => node.id !== firstLeafId);
54
+
55
+ const renderLeaf = (id: string, label: string) => {
56
+ const col = table.getColumn(id);
57
+ const show = col.getIsVisible();
58
+
59
+ return (
60
+ <Checkbox
61
+ checked={show}
62
+ key={id}
63
+ onChange={() => col.toggleVisibility()}
64
+ paddingBottom="xs"
65
+ text={label}
66
+ />
67
+ );
68
+ };
69
+
70
+ const gatherLeafIds = (node: VisibilityNode): string[] =>
71
+ node.children && node.children.length
72
+ ? node.children.flatMap(gatherLeafIds)
73
+ : node.id
74
+ ? [node.id]
75
+ : [];
76
+
77
+ const renderGroup = (node: VisibilityNode ) => {
78
+ const leaves = gatherLeafIds(node);
79
+ const visibleArray = leaves.map((id) => table.getColumn(id).getIsVisible());
80
+ const allOn = visibleArray.every(Boolean);
81
+ const someOn = visibleArray.some(Boolean);
82
+
83
+ return (
84
+ <>
85
+ <Checkbox
86
+ checked={allOn}
87
+ indeterminate={!allOn && someOn}
88
+ onChange={() =>
89
+ leaves.forEach((id) =>
90
+ table.getColumn(id).toggleVisibility(!allOn),
91
+ )
92
+ }
93
+ paddingBottom="xs"
94
+ text={node.label}
95
+ />
96
+ <Flex flexDirection="column"
97
+ paddingLeft="lg"
98
+ >
99
+ {node?.children?.map((child) =>
100
+ child.children ? renderGroup(child) : renderLeaf(child.id, child.label),
101
+ )}
102
+ </Flex>
103
+ </>
104
+ );
105
+ };
106
+ // ------------ End of column visibility logic --------
20
107
 
21
108
  useEffect(() => {
22
- if (cardRef.current) {
109
+ if (cardRef.current && type === "row-selection") {
23
110
  if (isVisible) {
24
111
  showActionBar(cardRef.current);
25
112
  } else {
@@ -31,22 +118,68 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
31
118
  return (
32
119
  <Card
33
120
  borderNone={!isVisible}
34
- className={`${isVisible && "show-action-card row-selection-actions-card"}`}
121
+ className={`${
122
+ isVisible && "show-action-card row-selection-actions-card"
123
+ }`}
35
124
  htmlOptions={{ ref: cardRef as any }}
36
125
  padding={`${isVisible ? "xs" : "none"}`}
37
126
  >
38
127
  <Flex
39
128
  alignItems="center"
40
- justify="between"
129
+ justify={type === "row-selection" ? "between" : "end"}
41
130
  >
42
- <Caption
43
- color="light"
44
- paddingLeft="xs"
45
- size="xs"
46
- >
47
- {selectedCount} Selected
48
- </Caption>
49
- <FlexItem>{actions}</FlexItem>
131
+ {type === "row-selection" ? (
132
+ <>
133
+ <Caption color="light"
134
+ paddingLeft="xs"
135
+ size="xs"
136
+ >
137
+ {selectedCount} Selected
138
+ </Caption>
139
+ <FlexItem>{actions}</FlexItem>
140
+ </>
141
+ ) : (
142
+ <Dropdown
143
+ className="column-visibility-dropdown-wrapper"
144
+ options={columnDefinitions}
145
+ >
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
+ <>
164
+ <Caption
165
+ paddingBottom="sm"
166
+ text="Columns Config"
167
+ textAlign="center"
168
+ />
169
+ <SectionSeparator paddingBottom="xs" />
170
+ {tree.map((node: VisibilityNode) => (
171
+ <Flex cursor="pointer"
172
+ flexDirection="column"
173
+ key={node.id}
174
+ paddingX="xs"
175
+ >
176
+ {node.children ? renderGroup(node) : renderLeaf(node.id, node.label)}
177
+ </Flex>
178
+ ))}
179
+ </>
180
+ </DropdownContainer>
181
+ </Dropdown>
182
+ )}
50
183
  </Flex>
51
184
  </Card>
52
185
  );
@@ -79,9 +79,26 @@ export const TableHeaderCell = ({
79
79
  header?.column.getLeafColumns().length === 1 &&
80
80
  header?.column.getLeafColumns()[0].id === header.column.id
81
81
 
82
- const isLastHeaderCell =
83
- header?.column.parent?.columns.at(-1) === header?.column ||
84
- (header?.colSpan > 1 && header?.column.parent !== undefined);
82
+ const columnHasVisibleLeaf = (col: any): boolean =>
83
+ col.getIsVisible?.() ||
84
+ (Array.isArray(col.columns) &&
85
+ col.columns.some((child: any) => columnHasVisibleLeaf(child)));
86
+
87
+ // Check on column position in stack + visibility to add the vertical border
88
+ const isLastHeaderCell = (() => {
89
+ if (!header) return false;
90
+
91
+ if (header.colSpan > 1 && header.column.parent !== undefined) return true;
92
+
93
+ const parent = header.column.parent;
94
+
95
+ if (!parent) {
96
+ const topHeaders = table?.getHeaderGroups()[0].headers.filter((h: any) => columnHasVisibleLeaf(h.column));
97
+ return topHeaders?.at(-1)?.id === header.id;
98
+ }
99
+ const visibleSiblings = parent.columns.filter(columnHasVisibleLeaf);
100
+ return visibleSiblings.at(-1) === header.column;
101
+ })();
85
102
 
86
103
  const cellClassName = classnames(
87
104
  "table-header-cells",
@@ -26,6 +26,8 @@ interface UseTableStateProps {
26
26
  virtualizedRows?: boolean;
27
27
  tableOptions?: GenericObject;
28
28
  onRowSelectionChange?: (arg: RowSelectionState) => void;
29
+ columnVisibilityControl?: GenericObject;
30
+
29
31
  }
30
32
 
31
33
  export function useTableState({
@@ -40,16 +42,19 @@ export function useTableState({
40
42
  pagination = false,
41
43
  paginationProps,
42
44
  virtualizedRows = false,
43
- tableOptions
45
+ tableOptions,
46
+ columnVisibilityControl
44
47
  }: UseTableStateProps) {
45
48
  // Create a local state for expanded and setExpanded if expandedControl not used
46
49
  const [localExpanded, setLocalExpanded] = useState({});
47
50
  const [loadingStateRowCount, setLoadingStateRowCount] = useState(initialLoadingRowsCount);
48
51
  const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
49
-
52
+ const [localColumnVisibility, setLocalColumnVisibility] = useState({});
50
53
  // Determine whether to use the prop or the local state
51
54
  const expanded = expandedControl ? expandedControl.value : localExpanded;
52
55
  const setExpanded = expandedControl ? expandedControl.onChange : setLocalExpanded;
56
+ const columnVisibility = (columnVisibilityControl && columnVisibilityControl.value) ? columnVisibilityControl.value : localColumnVisibility;
57
+ const setColumnVisibility = (columnVisibilityControl && columnVisibilityControl.onChange) ? columnVisibilityControl.onChange : setLocalColumnVisibility;
53
58
 
54
59
  // Virtualized data handling (chunked loading)
55
60
  const fetchSize = 20; // Number of rows per "page"
@@ -104,17 +109,21 @@ export function useTableState({
104
109
  }]), [columnDefinitions, sortControl]);
105
110
 
106
111
  // Custom state based on features enabled
107
- const customState = useCallback(() => {
108
- if (sortControl && selectableRows) {
109
- return { state: { expanded, sorting, rowSelection } };
110
- } else if (sortControl) {
111
- return { state: { expanded, sorting } };
112
- } else if (selectableRows) {
113
- return { state: { expanded, rowSelection } };
114
- } else {
115
- return { state: { expanded } };
116
- }
117
- }, [expanded, rowSelection, sortControl, selectableRows, sorting]);
112
+ const customState = useCallback(() => ({
113
+ state: {
114
+ expanded,
115
+ ...(sortControl && { sorting }),
116
+ ...(selectableRows && { rowSelection }),
117
+ ...(columnVisibility && { columnVisibility }),
118
+ },
119
+ }), [
120
+ expanded,
121
+ sortControl,
122
+ sorting,
123
+ selectableRows,
124
+ rowSelection,
125
+ columnVisibility,
126
+ ]);
118
127
 
119
128
  // Pagination configuration
120
129
  const paginationInitializer = useMemo(() => {
@@ -145,6 +154,7 @@ export function useTableState({
145
154
  sortDescFirst: true,
146
155
  onRowSelectionChange: setRowSelection,
147
156
  getRowId: selectableRows ? row => row.id : undefined,
157
+ onColumnVisibilityChange: setColumnVisibility,
148
158
  meta: {
149
159
  columnDefinitions
150
160
  },
@@ -0,0 +1,47 @@
1
+ export interface VisibilityNode {
2
+ id: string;
3
+ label: string;
4
+ children?: VisibilityNode[];
5
+ }
6
+ export const buildVisibilityTree = (
7
+ defs: any[],
8
+ allowed?: string[] | null
9
+ ): VisibilityNode[] =>
10
+ defs
11
+ .map((def) => {
12
+ const isGroup = Array.isArray(def.columns) && def.columns.length > 0;
13
+
14
+ // No filter at all → keep it
15
+ if (!allowed?.length) {
16
+ return isGroup
17
+ ? {
18
+ id: def.id,
19
+ label: def.label,
20
+ children: buildVisibilityTree(def.columns, allowed),
21
+ }
22
+ : { id: def.id, label: def.label };
23
+ }
24
+
25
+ // 1️⃣ If *this* ID is explicitly allowed → keep it & all its children
26
+ if (allowed.includes(def.id)) {
27
+ return isGroup
28
+ ? {
29
+ id: def.id,
30
+ label: def.label,
31
+ children: buildVisibilityTree(def.columns, null),
32
+ }
33
+ : { id: def.id, label: def.label };
34
+ }
35
+
36
+ // Otherwise, if it’s a group, recurse & keep only if kids survive
37
+ if (isGroup) {
38
+ const kids = buildVisibilityTree(def.columns, allowed).filter(Boolean);
39
+ return kids.length
40
+ ? { id: def.id, label: def.label, children: kids }
41
+ : null;
42
+ }
43
+
44
+ // Leaf not allowed → drop it
45
+ return null;
46
+ })
47
+ .filter(Boolean);
@@ -53,6 +53,15 @@
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
+
56
65
  // Virtualized table styles
57
66
  .virtualized-table-row {
58
67
  display: table !important;
@@ -35,6 +35,7 @@ type AdvancedTableProps = {
35
35
  className?: string
36
36
  columnDefinitions: GenericObject[]
37
37
  columnGroupBorderColor?: "text_lt_default" | "text_lt_light" | "text_lt_lighter" | "text_dk_default" | "text_dk_light" | "text_dk_lighter"
38
+ columnVisibilityControl?: GenericObject
38
39
  dark?: boolean
39
40
  data?: { [key: string]: string }
40
41
  enableToggleExpansion?: "all" | "header" | "none"
@@ -73,6 +74,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
73
74
  className,
74
75
  columnDefinitions,
75
76
  columnGroupBorderColor,
77
+ columnVisibilityControl,
76
78
  dark = false,
77
79
  data = {},
78
80
  enableToggleExpansion = "header",
@@ -132,7 +134,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
132
134
  paginationProps,
133
135
  virtualizedRows,
134
136
  tableOptions,
135
- onRowSelectionChange
137
+ onRowSelectionChange,
138
+ columnVisibilityControl,
136
139
  });
137
140
 
138
141
  // Initialize table actions
@@ -252,7 +255,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
252
255
  : {};
253
256
 
254
257
  // Visibility flag for action bar
255
- const isActionBarVisible = selectableRows && showActionsBar && selectedRowsLength > 0;
258
+ const isActionBarVisible = (selectableRows && showActionsBar && selectedRowsLength > 0) || columnVisibilityControl;
256
259
 
257
260
  return (
258
261
  <>
@@ -286,6 +289,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
286
289
  <AdvancedTableProvider
287
290
  columnDefinitions={columnDefinitions}
288
291
  columnGroupBorderColor={columnGroupBorderColor}
292
+ columnVisibilityControl={columnVisibilityControl}
289
293
  enableToggleExpansion={enableToggleExpansion}
290
294
  enableVirtualization={virtualizedRows}
291
295
  expandByDepth={expandByDepth}
@@ -316,6 +320,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
316
320
  actions={actions}
317
321
  isVisible={isActionBarVisible}
318
322
  selectedCount={selectedRowsLength}
323
+ type={columnVisibilityControl ? "column-visibility" : "row-selection"}
319
324
  />
320
325
 
321
326
  {/* Main Table */}
@@ -0,0 +1,57 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableColumnVisibility = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ id: "year"
12
+ },
13
+ {
14
+ accessor: "newEnrollments",
15
+ label: "New Enrollments",
16
+ id: "newEnrollments"
17
+ },
18
+ {
19
+ accessor: "scheduledMeetings",
20
+ label: "Scheduled Meetings",
21
+ id: "scheduledMeetings"
22
+ },
23
+ {
24
+ accessor: "attendanceRate",
25
+ label: "Attendance Rate",
26
+ id: "attendanceRate"
27
+ },
28
+ {
29
+ accessor: "completedClasses",
30
+ label: "Completed Classes",
31
+ id: "completedClasses"
32
+ },
33
+ {
34
+ accessor: "classCompletionRate",
35
+ label: "Class Completion Rate",
36
+ id: "classCompletionRate"
37
+ },
38
+ {
39
+ accessor: "graduatedStudents",
40
+ label: "Graduated Students",
41
+ id: "graduatedStudents"
42
+ },
43
+ ]
44
+
45
+ return (
46
+ <div>
47
+ <AdvancedTable
48
+ columnDefinitions={columnDefinitions}
49
+ columnVisibilityControl={{default: true}}
50
+ tableData={MOCK_DATA}
51
+ {...props}
52
+ />
53
+ </div>
54
+ )
55
+ }
56
+
57
+ export default AdvancedTableColumnVisibility
@@ -0,0 +1,4 @@
1
+ The `columnVisibilityControl` prop allows users to toggle the visibility of table columns dynamically.
2
+
3
+ The default can be enabled simply by passing `{ default:true }` to the prop as shown. This will render the header with the icon enabled dropdown. The dropdown contains all columns present in the Table and any can be toggled on or off via the checkboxes.
4
+ **NOTE**: The first column will not be shown in the dropdown as an option since all the expansion logic/functionality lives there and it should always be visible.
@@ -0,0 +1,62 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableColumnVisibilityCustom = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ id: "year"
12
+ },
13
+ {
14
+ accessor: "newEnrollments",
15
+ label: "New Enrollments",
16
+ id: "newEnrollments"
17
+ },
18
+ {
19
+ accessor: "scheduledMeetings",
20
+ label: "Scheduled Meetings",
21
+ id: "scheduledMeetings"
22
+ },
23
+ {
24
+ accessor: "attendanceRate",
25
+ label: "Attendance Rate",
26
+ id: "attendanceRate"
27
+ },
28
+ {
29
+ accessor: "completedClasses",
30
+ label: "Completed Classes",
31
+ id: "completedClasses"
32
+ },
33
+ {
34
+ accessor: "classCompletionRate",
35
+ label: "Class Completion Rate",
36
+ id: "classCompletionRate"
37
+ },
38
+ {
39
+ accessor: "graduatedStudents",
40
+ label: "Graduated Students",
41
+ id: "graduatedStudents"
42
+ },
43
+ ]
44
+
45
+ const columnVisibilityControl = {
46
+ // This is the list of column ids that will be included in the column visibility control
47
+ includeIds:["newEnrollments", "scheduledMeetings", "attendanceRate", "completedClasses"],
48
+ }
49
+
50
+ return (
51
+ <div>
52
+ <AdvancedTable
53
+ columnDefinitions={columnDefinitions}
54
+ columnVisibilityControl={columnVisibilityControl}
55
+ tableData={MOCK_DATA}
56
+ {...props}
57
+ />
58
+ </div>
59
+ )
60
+ }
61
+
62
+ export default AdvancedTableColumnVisibilityCustom
@@ -0,0 +1 @@
1
+ By using the `includeIds` key/value pair as shown within the `columnVisibilityControl` prop, you can control which columns show up as options in the columnVisibility dropdown.
@@ -0,0 +1,82 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableColumnVisibilityMulti = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ id: "year",
11
+ cellAccessors: ["quarter", "month", "day"],
12
+ },
13
+ {
14
+ label: "Enrollment Data",
15
+ id: "enrollmentData",
16
+ columns: [
17
+ {
18
+ label: "Enrollment Stats",
19
+ id: "enrollmentStats",
20
+ columns: [
21
+ {
22
+ accessor: "newEnrollments",
23
+ label: "New Enrollments",
24
+ id: "newEnrollments",
25
+ },
26
+ {
27
+ accessor: "scheduledMeetings",
28
+ label: "Scheduled Meetings",
29
+ id: "scheduledMeetings",
30
+ },
31
+ ],
32
+ },
33
+ ],
34
+ },
35
+ {
36
+ label: "Performance Data",
37
+ id: "performanceData",
38
+ columns: [
39
+ {
40
+ label: "Completion Metrics",
41
+ id: "completionMetrics",
42
+ columns: [
43
+ {
44
+ accessor: "completedClasses",
45
+ label: "Completed Classes",
46
+ id: "completedClasses",
47
+ },
48
+ {
49
+ accessor: "classCompletionRate",
50
+ label: "Class Completion Rate",
51
+ id: "classCompletionRate",
52
+ },
53
+ ],
54
+ },
55
+ {
56
+ label: "Attendance",
57
+ id: "attendance",
58
+ columns: [
59
+ {
60
+ accessor: "attendanceRate",
61
+ label: "Attendance Rate",
62
+ id: "attendanceRate",
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ },
68
+ ];
69
+
70
+ return (
71
+ <div>
72
+ <AdvancedTable
73
+ columnDefinitions={columnDefinitions}
74
+ columnVisibilityControl={{default: true}}
75
+ tableData={MOCK_DATA}
76
+ {...props}
77
+ />
78
+ </div>
79
+ )
80
+ }
81
+
82
+ export default AdvancedTableColumnVisibilityMulti
@@ -0,0 +1 @@
1
+ The `columnVisibilityControl` prop can also be used with multi-header columns as shown.