playbook_ui 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2010 → 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2034

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx +2 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +10 -7
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +3 -3
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +8 -8
  6. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +22 -14
  7. data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +3 -3
  8. data/app/pb_kits/playbook/pb_advanced_table/README.md +133 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/{SubComponents → SubKits}/TableBody.tsx +4 -4
  10. data/app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx +5 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/Utilities/{helper_functions.tsx → ExpansionControlHelpers.tsx} +1 -15
  12. data/app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx +8 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +13 -12
  14. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +27 -19
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +2 -5
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +13 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +1 -0
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +39 -39
  19. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +11 -0
  20. data/dist/menu.yml +1 -1
  21. data/lib/playbook/version.rb +1 -1
  22. metadata +10 -5
  23. data/app/pb_kits/playbook/pb_advanced_table/{SubComponents → SubKits}/TableHeader.tsx +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f15a8ac0110aaa64e75c62164518fb815e028873c5909c72a57b6322c2b98661
4
- data.tar.gz: fbe1cc5a5f53f2c9387b9b2ff209abe5c9f808d16f248a285e20bb9ab980c33e
3
+ metadata.gz: e32f23fffa170bf6c5db5e7ac37c6834dec1c75fbecc8e55de9538729d17b830
4
+ data.tar.gz: b4f1deb56f2a97f265a98cc42bd5e2ab16bb7e64235127b91df17b560591f064
5
5
  SHA512:
6
- metadata.gz: ab28994eae8dd6bcceb5d9ca44a65ec378060cba26a86c519742e892fc721b13ff6fca4a1f526385c942f4db7b30e9f8f3a96d37b6e7c1571bf84e76bf6f9a40
7
- data.tar.gz: a23907ecbcf8a0afa5a3abca06e60b9c18e227a0f5bac019731d9be43f209ef689159e2d5b067d4a511ed8d1245739372689385d2e6830ff17dac8363d866d61
6
+ metadata.gz: 674b96a423b2f1c63dd816ee764735f7b59f13b2df3930bee4ff4afebca861e6dcba7dce4ab868d04c84ab5c8e720dcf21f807074f8bc76fce6a892b264309f5
7
+ data.tar.gz: 0ea00c622676362e9b3c3c6d3d7d29628fcd0e24420b1566c5bce7edfa4047f37c1cf3b2d0bf4a890335df628ce012921e74290b1aee7f37518ac68c6311494e
@@ -19,8 +19,8 @@ export const renderCollapsibleTrail = (currentDepth: number) => {
19
19
  const lines = []
20
20
  for (let i = 1; i <= currentDepth; i++) {
21
21
  // Calculate leftOffset with additional 0.4rem for each depth level above 1
22
- const additionalOffset = i > 1 ? (i - 1) * 0.4 : 0
23
- const leftOffset = i * 1.6 + additionalOffset
22
+ const additionalOffset = i > 1 ? (i - 1) * 0.25 : 0
23
+ const leftOffset = i * 1.0 + additionalOffset
24
24
  lines.push(<CollapsibleTrail key={i}
25
25
  leftOffset={leftOffset}
26
26
  />
@@ -10,17 +10,17 @@ import { DataType } from "../Utilities/types";
10
10
  import AdvancedTableContext from "../Context/AdvancedTableContext";
11
11
 
12
12
  interface CustomCellProps {
13
- row: Row<DataType>;
14
13
  getValue?: Getter<string>;
15
- value?: string;
16
14
  onRowToggleClick?: (arg: Row<DataType>) => void;
15
+ row: Row<DataType>;
16
+ value?: string;
17
17
  }
18
18
 
19
19
  export const CustomCell = ({
20
- row,
21
20
  getValue,
22
- value,
23
21
  onRowToggleClick,
22
+ row,
23
+ value,
24
24
  }: CustomCellProps & GlobalProps) => {
25
25
  const { setExpanded, expanded } = useContext(AdvancedTableContext);
26
26
  const RowWithoutChildren = row.originalSubRows === undefined;
@@ -31,7 +31,7 @@ export const CustomCell = ({
31
31
  };
32
32
 
33
33
  return (
34
- <div style={{ paddingLeft: `${row.depth * 2}rem` }}>
34
+ <div style={{ paddingLeft: `${row.depth * 1.25}rem` }}>
35
35
  <Flex alignItems="center"
36
36
  columnGap="xs"
37
37
  orientation="row"
@@ -42,11 +42,14 @@ export const CustomCell = ({
42
42
  onClick={() => handleOnExpand(row)}
43
43
  >
44
44
  {row.getIsExpanded() ? (
45
- <Icon icon="circle-play"
45
+ <Icon cursor="pointer"
46
+ icon="circle-play"
46
47
  rotation={90}
47
48
  />
48
49
  ) : (
49
- <Icon icon="circle-play" />
50
+ <Icon cursor="pointer"
51
+ icon="circle-play"
52
+ />
50
53
  )}
51
54
  </button>
52
55
  ) : null}
@@ -2,7 +2,7 @@ import React from "react"
2
2
  import Icon from "../../pb_icon/_icon"
3
3
  import { Header } from "@tanstack/react-table"
4
4
  import { DataType } from "../Utilities/types"
5
- import { displayIcon } from "../Utilities/helper_functions"
5
+ import { displayIcon } from "../Utilities/IconHelpers"
6
6
 
7
7
  type SortIconButtonProps = {
8
8
  header: Header<DataType, unknown>
@@ -13,13 +13,13 @@ export const SortIconButton = ({ header, sortIcon }: SortIconButtonProps) => {
13
13
  return (
14
14
  <>
15
15
  {header.column.getIsSorted() === "desc" ? (
16
- <div className="year-sort-icon"
16
+ <div className="sort-button-icon"
17
17
  key={displayIcon(sortIcon)[0]}
18
18
  >
19
19
  <Icon icon={displayIcon(sortIcon)[0]} />
20
20
  </div>
21
21
  ) : (
22
- <div className="year-sort-icon"
22
+ <div className="sort-button-icon"
23
23
  key={displayIcon(sortIcon)[1]}
24
24
  >
25
25
  <Icon icon={displayIcon(sortIcon)[1]} />
@@ -6,26 +6,26 @@ import { Row, Table } from "@tanstack/react-table"
6
6
  import { ToggleIconButton } from "./ToggleIconButton"
7
7
  import { renderCollapsibleTrail } from "./CollapsibleTrail"
8
8
 
9
- import { isChrome } from "../Utilities/helper_functions"
9
+ import { isChrome } from "../Utilities/BrowserCheck"
10
10
  import { DataType } from "../Utilities/types"
11
11
  import { GlobalProps } from "../../utilities/globalProps"
12
12
 
13
13
  interface SubRowHeaderRowProps {
14
+ collapsibleTrail?: boolean
15
+ enableToggleExpansion?: "all" | "header"
14
16
  onClick: (row: Row<DataType>) => void
15
17
  row: Row<DataType>
16
- table: Table<DataType>
17
- collapsibleTrail?: boolean
18
18
  subRowHeaders?: string[]
19
- enableToggleExpansion?: "all" | "header"
19
+ table: Table<DataType>
20
20
  }
21
21
 
22
22
  export const SubRowHeaderRow = ({
23
- row,
24
- table,
25
- onClick,
26
23
  collapsibleTrail,
27
- subRowHeaders,
28
24
  enableToggleExpansion,
25
+ onClick,
26
+ row,
27
+ subRowHeaders,
28
+ table,
29
29
  }: SubRowHeaderRowProps & GlobalProps) => {
30
30
  const numberOfColumns = table.getAllFlatColumns().length
31
31
 
@@ -1,34 +1,35 @@
1
1
  import React, { useContext } from "react"
2
+ import classnames from "classnames";
2
3
  import Flex from "../../pb_flex/_flex"
3
4
  import { flexRender, Header } from "@tanstack/react-table"
4
5
 
5
6
  import { SortIconButton } from "./SortIconButton"
6
7
  import { ToggleIconButton } from "./ToggleIconButton"
7
- import { isChrome } from "../Utilities/helper_functions"
8
+ import { isChrome } from "../Utilities/BrowserCheck"
8
9
  import { DataType } from "../Utilities/types"
9
10
  import AdvancedTableContext from "../Context/AdvancedTableContext"
10
11
  import { GlobalProps } from "../../utilities/globalProps"
11
12
 
12
13
  type TableHeaderCellProps = {
13
- headerChildren?: React.ReactNode | React.ReactNode[]
14
14
  enableSorting?: boolean
15
15
  enableToggleExpansion?: "all" | "header"
16
16
  handleExpandOrCollapse?: () => void
17
17
  header?: Header<DataType, unknown>
18
+ headerChildren?: React.ReactNode | React.ReactNode[]
18
19
  headerId?: string
19
20
  loading?: boolean
20
21
  sortIcon?: string | string[]
21
22
  } & GlobalProps
22
23
 
23
24
  export const TableHeaderCell = ({
24
- header,
25
- headerId,
26
25
  enableSorting,
27
- sortIcon,
28
- headerChildren,
29
- loading,
30
26
  enableToggleExpansion,
31
27
  handleExpandOrCollapse,
28
+ header,
29
+ headerChildren,
30
+ headerId,
31
+ loading,
32
+ sortIcon,
32
33
  }: TableHeaderCellProps) => {
33
34
  const { sortControl } = useContext(AdvancedTableContext)
34
35
 
@@ -43,15 +44,21 @@ export const TableHeaderCell = ({
43
44
  }
44
45
  }
45
46
 
47
+ const cellClassName = classnames("table-header-cells",
48
+ `${isChrome() ? "chrome-styles" : ""}`,
49
+ `${enableSorting ? "table-header-cells-active" : ""}`
50
+ );
51
+
52
+ const cellId = `${loading ?
53
+ `loading-${header.id}${headerId ? `-${headerId}` : ""}`
54
+ : `${header.id}${headerId ? `-${headerId}` : ""}`
55
+ }`;
56
+
46
57
  return (
47
58
  <th
48
59
  align="right"
49
- className={`table-header-cells ${isChrome() ? "chrome-styles" : ""}`}
50
- id={`${
51
- loading
52
- ? `loading-${header.id}-${headerId}`
53
- : `${header.id}-${headerId}`
54
- }`}
60
+ className={cellClassName}
61
+ id={cellId}
55
62
  key={`${header.id}-header`}
56
63
  >
57
64
  {header.isPlaceholder ? null : headerChildren && header.index === 0 ? (
@@ -64,7 +71,7 @@ export const TableHeaderCell = ({
64
71
  ) : (
65
72
  <Flex
66
73
  alignItems="center"
67
- justify={header.index === 0 ? "between" : "none"}
74
+ justify={header.index === 0 && enableSorting ? "between" : header.index === 0 && !enableSorting ? "start" : "end"}
68
75
  paddingLeft={loading ? "sm" : "none"}
69
76
  >
70
77
  {header.index === 0 &&
@@ -97,6 +104,7 @@ export const TableHeaderCell = ({
97
104
  },
98
105
  })}
99
106
  justify={header.index === 0 && enableSorting ? "between" : "none"}
107
+ paddingLeft={enableSorting ? "xxs" : "xs"}
100
108
  >
101
109
  <div>
102
110
  {flexRender(header.column.columnDef.header, header.getContext())}
@@ -3,18 +3,18 @@ import Icon from "../../pb_icon/_icon"
3
3
  import { Row } from "@tanstack/react-table"
4
4
  import AdvancedTableContext from "../Context/AdvancedTableContext"
5
5
  import { DataType } from "../Utilities/types"
6
- import { displayIcon } from "../Utilities/helper_functions"
6
+ import { displayIcon } from "../Utilities/IconHelpers"
7
7
 
8
8
  interface ToggleIconButtonProps {
9
- row?: Row<DataType>
10
9
  onClick: (row: Row<DataType>) => void
10
+ row?: Row<DataType>
11
11
  }
12
12
 
13
13
  export const ToggleIconButton = ({ row, onClick }: ToggleIconButtonProps) => {
14
14
  const { toggleExpansionIcon } = useContext(AdvancedTableContext)
15
15
  return (
16
16
  <button
17
- className="gray-icon time-period-toggle-icon"
17
+ className="gray-icon toggle-all-icon"
18
18
  key={displayIcon(toggleExpansionIcon)[0]}
19
19
  onClick={() => onClick(row)}
20
20
  >
@@ -0,0 +1,133 @@
1
+ # Advanced Table Kit Data Structure
2
+
3
+ The AdvancedTable Kit's `tableData` prop consumes the data that will render the table and as such has a specific structure. It must be an array of objects, where the key/value pairs will become the values rendered within each column. If children are present, they must also take the form of an array of objects. The kit will automatically render `children` as subRows.
4
+
5
+ Here is the data structure being used within the kits doc examples:
6
+
7
+ ```
8
+ MOCK_DATA = [
9
+ {
10
+ year: "2021",
11
+ quarter: null,
12
+ month: null,
13
+ day: null,
14
+ newEnrollments: "20",
15
+ scheduledMeetings: "10",
16
+ attendanceRate: "51%",
17
+ completedClasses: "3",
18
+ classCompletionRate: "33%",
19
+ graduatedStudents: "19",
20
+ children: [
21
+ {
22
+ year: "2021",
23
+ quarter: "Q1",
24
+ month: null,
25
+ day: null,
26
+ newEnrollments: "2",
27
+ scheduledMeetings: "35",
28
+ attendanceRate: "32%",
29
+ completedClasses: "15",
30
+ classCompletionRate: "52%",
31
+ graduatedStudents: "36",
32
+ children: [
33
+ {
34
+ year: "2021",
35
+ quarter: "Q1",
36
+ month: "January",
37
+ day: null,
38
+ newEnrollments: "16",
39
+ scheduledMeetings: "20",
40
+ attendanceRate: "11%",
41
+ completedClasses: "13",
42
+ classCompletionRate: "47%",
43
+ graduatedStudents: "28",
44
+ children: [
45
+ {
46
+ year: "2021",
47
+ quarter: "Q1",
48
+ month: "January",
49
+ day: "10",
50
+ newEnrollments: "34",
51
+ scheduledMeetings: "28",
52
+ attendanceRate: "97%",
53
+ completedClasses: "20",
54
+ classCompletionRate: "15%",
55
+ graduatedStudents: "17",
56
+ },
57
+ {
58
+ year: "2021",
59
+ quarter: "Q1",
60
+ month: "January",
61
+ day: "20",
62
+ newEnrollments: "43",
63
+ scheduledMeetings: "23",
64
+ attendanceRate: "66%",
65
+ completedClasses: "26",
66
+ classCompletionRate: "47%",
67
+ graduatedStudents: "9",
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ year: "2021",
73
+ quarter: "Q1",
74
+ month: "February",
75
+ day: null,
76
+ newEnrollments: "20",
77
+ scheduledMeetings: "41",
78
+ attendanceRate: "95%",
79
+ completedClasses: "26",
80
+ classCompletionRate: "83%",
81
+ graduatedStudents: "43",
82
+ children: [
83
+ {
84
+ year: "2011",
85
+ quarter: "Q1",
86
+ month: "February",
87
+ day: "15",
88
+ newEnrollments: "19",
89
+ scheduledMeetings: "35",
90
+ attendanceRate: "69%",
91
+ completedClasses: "8",
92
+ classCompletionRate: "75%",
93
+ graduatedStudents: "23",
94
+ },
95
+ ],
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ year: "2022",
103
+ quarter: null,
104
+ month: null,
105
+ day: null,
106
+ newEnrollments: "25",
107
+ scheduledMeetings: "17",
108
+ attendanceRate: "75%",
109
+ completedClasses: "5",
110
+ classCompletionRate: "45%",
111
+ graduatedStudents: "32",
112
+ children: [
113
+ //similar to chldren above
114
+ ]
115
+ },
116
+ {
117
+ year: "2023",
118
+ quarter: null,
119
+ month: null,
120
+ day: null,
121
+ newEnrollments: "10",
122
+ scheduledMeetings: "15",
123
+ attendanceRate: "65%",
124
+ completedClasses: "4",
125
+ classCompletionRate: "49%",
126
+ graduatedStudents: "29",
127
+ children: [
128
+ //similar to children above
129
+ ],
130
+ },
131
+ ];
132
+
133
+ ```
@@ -6,7 +6,7 @@ import { SubRowHeaderRow } from "../Components/SubRowHeaderRow"
6
6
  import { LoadingCell } from "../Components/LoadingCell"
7
7
  import { renderCollapsibleTrail } from "../Components/CollapsibleTrail"
8
8
  import AdvancedTableContext from "../Context/AdvancedTableContext"
9
- import { isChrome } from "../Utilities/helper_functions"
9
+ import { isChrome } from "../Utilities/BrowserCheck"
10
10
  import { DataType } from "../Utilities/types"
11
11
 
12
12
  type TableBodyProps = {
@@ -19,10 +19,10 @@ export const TableBody = ({
19
19
  subRowHeaders,
20
20
  }: TableBodyProps) => {
21
21
  const {
22
- table,
22
+ enableToggleExpansion,
23
23
  handleExpandOrCollapse,
24
24
  loading,
25
- enableToggleExpansion,
25
+ table,
26
26
  } = useContext(AdvancedTableContext)
27
27
  return (
28
28
  <>
@@ -78,7 +78,7 @@ export const TableBody = ({
78
78
  ))}
79
79
  </tr>
80
80
 
81
- {/* Display LoadingInline if getYearData is querying and there are no children already */}
81
+ {/* Display LoadingInline if Row Data is querying and there are no children already */}
82
82
  {isExpandable && rowHasNoChildren && row.depth === 0 ? (
83
83
  <tr key={`${row.id}-row`}>
84
84
  <td colSpan={numberOfColumns}>
@@ -0,0 +1,5 @@
1
+ //Checking browser. Using this to add classname and css for browser specific issues with table borders
2
+ export const isChrome = () => {
3
+ const userAgent = navigator.userAgent.toLowerCase()
4
+ return userAgent.includes("chrome") && !userAgent.includes("edg")
5
+ }
@@ -60,18 +60,4 @@ export const updateExpandAndCollapseState = (
60
60
  ...(expanded as ExpandedStateObject),
61
61
  ...updateExpandedRows,
62
62
  })
63
- }
64
-
65
- //Checking browser. Using this to add classname and css for browser specific issues with table borders
66
- export const isChrome = () => {
67
- const userAgent = navigator.userAgent.toLowerCase()
68
- return userAgent.includes("chrome") && !userAgent.includes("edg")
69
- }
70
-
71
- // Logic for handling icons related props to allow for string or array of strings
72
- export const displayIcon = (icon: string | string[]) => {
73
- if (typeof icon === "string") {
74
- return [icon, icon]
75
- }
76
- return icon
77
- }
63
+ }
@@ -0,0 +1,8 @@
1
+ // Logic for handling icons related props to allow for string OR array of strings
2
+ export const displayIcon = (icon: string | string[]) => {
3
+ if (typeof icon === "string") {
4
+ return [icon, icon]
5
+ }
6
+ return icon
7
+ }
8
+
@@ -8,15 +8,6 @@
8
8
  .pb_advanced_table {
9
9
  $border-color: 1px solid $border_light !important;
10
10
 
11
- //animation scss
12
- @keyframes wave {
13
- 0% {
14
- background-position: -468px 0;
15
- }
16
- 100% {
17
- background-position: 468px 0;
18
- }
19
- }
20
11
  [id$="-span"] {
21
12
  word-wrap: normal;
22
13
  }
@@ -34,9 +25,13 @@
34
25
  }
35
26
 
36
27
  .table-header-cells:first-child {
37
- color: $primary !important;
38
28
  min-width: 180px;
39
29
  }
30
+
31
+ .table-header-cells-active:first-child {
32
+ color: $primary !important;
33
+ }
34
+
40
35
  // Icons
41
36
  .button-icon {
42
37
  display: flex;
@@ -51,12 +46,12 @@
51
46
  @extend %primary-color-pseudo;
52
47
  }
53
48
 
54
- .year-sort-icon {
49
+ .sort-button-icon {
55
50
  @extend .button-icon;
56
51
  padding: 2px;
57
52
  }
58
53
 
59
- .time-period-toggle-icon {
54
+ .toggle-all-icon {
60
55
  @extend .button-icon;
61
56
  @extend %primary-color-pseudo;
62
57
  padding: 2px 0;
@@ -94,4 +89,10 @@
94
89
  .chrome-styles:first-child {
95
90
  border-right: $border-color;
96
91
  }
92
+
93
+ .table-card {
94
+ .chrome-styles:first-child {
95
+ border-right: $transparent !important;
96
+ }
97
+ }
97
98
  }
@@ -13,54 +13,54 @@ import {
13
13
  Getter,
14
14
  } from "@tanstack/react-table";
15
15
 
16
- import { updateExpandAndCollapseState } from "./Utilities/helper_functions";
16
+ import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers";
17
17
 
18
18
  import { CustomCell } from "./Components/CustomCell";
19
19
  import AdvancedTableContext from "./Context/AdvancedTableContext";
20
- import { TableHeader } from "./SubComponents/TableHeader";
21
- import { TableBody } from "./SubComponents/TableBody";
20
+ import { TableHeader } from "./SubKits/TableHeader";
21
+ import { TableBody } from "./SubKits/TableBody";
22
22
 
23
23
  import { DataType, ExpandedStateObject } from "./Utilities/types";
24
24
 
25
25
  type AdvancedTableProps = {
26
26
  aria?: { [key: string]: string };
27
+ children?: React.ReactNode | React.ReactNode[];
27
28
  className?: string;
29
+ columnDefinitions: DataType[];
28
30
  data?: { [key: string]: string };
31
+ enableToggleExpansion?: "all" | "header";
32
+ expandedControl?: DataType;
29
33
  id?: string;
30
- tableData: DataType[];
34
+ initialLoadingRowsCount?: number;
31
35
  loading?: boolean | string;
32
- columnDefinitions: DataType[];
33
- children?: React.ReactNode | React.ReactNode[];
34
36
  onRowToggleClick?: (arg: Row<DataType>) => void;
35
37
  onToggleExpansionClick?: (arg: Row<DataType>) => void;
38
+ sortControl?: DataType;
39
+ tableData: DataType[];
36
40
  tableOptions?: DataType;
37
41
  tableProps?: DataType;
38
- enableToggleExpansion?: "all" | "header";
39
42
  toggleExpansionIcon?: string | string[];
40
- initialLoadingRowsCount?: number;
41
- expandedControl?: DataType;
42
- sortControl?: DataType;
43
43
  } & GlobalProps;
44
44
 
45
45
  const AdvancedTable = (props: AdvancedTableProps) => {
46
46
  const {
47
47
  aria = {},
48
+ children,
48
49
  className,
50
+ columnDefinitions,
49
51
  data = {},
52
+ enableToggleExpansion = "header",
53
+ expandedControl,
50
54
  id,
51
- tableData,
55
+ initialLoadingRowsCount = 10,
52
56
  loading,
53
57
  onRowToggleClick,
54
58
  onToggleExpansionClick,
55
- columnDefinitions,
56
- children,
59
+ sortControl,
60
+ tableData,
57
61
  tableOptions,
58
62
  tableProps,
59
- enableToggleExpansion = "header",
60
63
  toggleExpansionIcon = "arrows-from-line",
61
- initialLoadingRowsCount = 10,
62
- expandedControl,
63
- sortControl,
64
64
  } = props;
65
65
 
66
66
  const [loadingStateRowCount, setLoadingStateRowCount] = useState(
@@ -152,6 +152,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
152
152
  }
153
153
  };
154
154
 
155
+ //initialize table
155
156
  const table = useReactTable({
156
157
  data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
157
158
  columns,
@@ -218,13 +219,20 @@ const AdvancedTable = (props: AdvancedTableProps) => {
218
219
  }}
219
220
  >
220
221
  <Table
221
- className={`${loading && "content-loading"}`}
222
+ className={`${loading ? "content-loading" : ""}`}
222
223
  dataTable
223
224
  numberSpacing="tabular"
224
225
  responsive="none"
225
226
  {...tableProps}
226
227
  >
227
- {children}
228
+ {children ? (
229
+ children
230
+ ) : (
231
+ <>
232
+ <TableHeader />
233
+ <TableBody />
234
+ </>
235
+ )}
228
236
  </Table>
229
237
  </AdvancedTableContext.Provider>
230
238
  </div>
@@ -27,7 +27,7 @@ const AdvancedTableDefault = (props) => {
27
27
  },
28
28
  {
29
29
  accessor: "classCompletionRate",
30
- label: "ClassCompletion Rate",
30
+ label: "Class Completion Rate",
31
31
  },
32
32
  {
33
33
  accessor: "graduatedStudents",
@@ -41,10 +41,7 @@ const AdvancedTableDefault = (props) => {
41
41
  columnDefinitions={columnDefinitions}
42
42
  tableData={MOCK_DATA}
43
43
  {...props}
44
- >
45
- <AdvancedTable.Header/>
46
- <AdvancedTable.Body/>
47
- </AdvancedTable>
44
+ />
48
45
  </div>
49
46
  );
50
47
  };
@@ -0,0 +1,13 @@
1
+ The AdvancedTable kit takes the table data and automatically renders expandable subrows for nested items to any depth needed. In it's simplest form, the kit has two required props:
2
+
3
+ `tableData` is the data that the kit needs to consume to render the table. This data will take the structure of an array of objects where each object will be rendered as a row with the key/value pairs being the column values. If an object within that data has children, the kit will automatically create subRows with icon buttons on the parent rows to toggle the subRows open or closed. The toggleExpansionAll button in the first column header can also be used to toggle expansion for the top level parent rows. For a visual of the data structure needed for `tableData`, see [here](https://github.com/powerhome/playbook/blob/1b2481c06137d2bc63031a1120c1bd4d01bfd9ec/playbook/app/pb_kits/playbook/pb_advanced_table/README.md).
4
+
5
+
6
+ `columnDefinitions` maps to the columns prop on the Tanstack table. Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `ColumnDefinitions` in the AdvancedTable kit is a array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
7
+
8
+ - `accessor`: this is the key from your data for the value you want rendered in that column
9
+ - `label`: this is what will be rendered as the column header label
10
+
11
+ There is also one optional item that is only required if the table has nested data:
12
+
13
+ - `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.
@@ -0,0 +1 @@
1
+ The AdvancedTable kit uses the [Tanstack Table v8](https://tanstack.com/table/v8/docs/introduction) under the hood to render advanced tables that allow for complex, nested data structures with expansion and sort options.
@@ -12,7 +12,7 @@ export const MOCK_DATA = [
12
12
  graduatedStudents: "19",
13
13
  children: [
14
14
  {
15
- year: "2011",
15
+ year: "2021",
16
16
  quarter: "Q1",
17
17
  month: null,
18
18
  day: null,
@@ -24,7 +24,7 @@ export const MOCK_DATA = [
24
24
  graduatedStudents: "36",
25
25
  children: [
26
26
  {
27
- year: "2011",
27
+ year: "2021",
28
28
  quarter: "Q1",
29
29
  month: "January",
30
30
  day: null,
@@ -36,7 +36,7 @@ export const MOCK_DATA = [
36
36
  graduatedStudents: "28",
37
37
  children: [
38
38
  {
39
- year: "2011",
39
+ year: "2021",
40
40
  quarter: "Q1",
41
41
  month: "January",
42
42
  day: "10",
@@ -48,7 +48,7 @@ export const MOCK_DATA = [
48
48
  graduatedStudents: "17",
49
49
  },
50
50
  {
51
- year: "2011",
51
+ year: "2021",
52
52
  quarter: "Q1",
53
53
  month: "January",
54
54
  day: "20",
@@ -62,7 +62,7 @@ export const MOCK_DATA = [
62
62
  ],
63
63
  },
64
64
  {
65
- year: "2011",
65
+ year: "2021",
66
66
  quarter: "Q1",
67
67
  month: "February",
68
68
  day: null,
@@ -96,15 +96,15 @@ export const MOCK_DATA = [
96
96
  quarter: null,
97
97
  month: null,
98
98
  day: null,
99
- newEnrollments: "20",
100
- scheduledMeetings: "10",
101
- attendanceRate: "51%",
102
- completedClasses: "3",
103
- classCompletionRate: "33%",
104
- graduatedStudents: "19",
99
+ newEnrollments: "25",
100
+ scheduledMeetings: "17",
101
+ attendanceRate: "75%",
102
+ completedClasses: "5",
103
+ classCompletionRate: "45%",
104
+ graduatedStudents: "32",
105
105
  children: [
106
106
  {
107
- year: "2011",
107
+ year: "2022",
108
108
  quarter: "Q1",
109
109
  month: null,
110
110
  day: null,
@@ -116,7 +116,7 @@ export const MOCK_DATA = [
116
116
  graduatedStudents: "36",
117
117
  children: [
118
118
  {
119
- year: "2011",
119
+ year: "2022",
120
120
  quarter: "Q1",
121
121
  month: "January",
122
122
  day: null,
@@ -128,10 +128,10 @@ export const MOCK_DATA = [
128
128
  graduatedStudents: "28",
129
129
  children: [
130
130
  {
131
- year: "2011",
131
+ year: "2022",
132
132
  quarter: "Q1",
133
133
  month: "January",
134
- day: "10",
134
+ day: "15",
135
135
  newEnrollments: "34",
136
136
  scheduledMeetings: "28",
137
137
  attendanceRate: "97%",
@@ -140,10 +140,10 @@ export const MOCK_DATA = [
140
140
  graduatedStudents: "17",
141
141
  },
142
142
  {
143
- year: "2011",
143
+ year: "2022",
144
144
  quarter: "Q1",
145
145
  month: "January",
146
- day: "20",
146
+ day: "25",
147
147
  newEnrollments: "43",
148
148
  scheduledMeetings: "23",
149
149
  attendanceRate: "66%",
@@ -154,9 +154,9 @@ export const MOCK_DATA = [
154
154
  ],
155
155
  },
156
156
  {
157
- year: "2011",
157
+ year: "2022",
158
158
  quarter: "Q1",
159
- month: "February",
159
+ month: "May",
160
160
  day: null,
161
161
  newEnrollments: "20",
162
162
  scheduledMeetings: "41",
@@ -168,8 +168,8 @@ export const MOCK_DATA = [
168
168
  {
169
169
  year: "2011",
170
170
  quarter: "Q1",
171
- month: "February",
172
- day: "15",
171
+ month: "May",
172
+ day: "2",
173
173
  newEnrollments: "19",
174
174
  scheduledMeetings: "35",
175
175
  attendanceRate: "69%",
@@ -188,15 +188,15 @@ export const MOCK_DATA = [
188
188
  quarter: null,
189
189
  month: null,
190
190
  day: null,
191
- newEnrollments: "20",
192
- scheduledMeetings: "10",
193
- attendanceRate: "51%",
194
- completedClasses: "3",
195
- classCompletionRate: "33%",
196
- graduatedStudents: "19",
191
+ newEnrollments: "10",
192
+ scheduledMeetings: "15",
193
+ attendanceRate: "65%",
194
+ completedClasses: "4",
195
+ classCompletionRate: "49%",
196
+ graduatedStudents: "29",
197
197
  children: [
198
198
  {
199
- year: "2011",
199
+ year: "2023",
200
200
  quarter: "Q1",
201
201
  month: null,
202
202
  day: null,
@@ -208,9 +208,9 @@ export const MOCK_DATA = [
208
208
  graduatedStudents: "36",
209
209
  children: [
210
210
  {
211
- year: "2011",
211
+ year: "2023",
212
212
  quarter: "Q1",
213
- month: "January",
213
+ month: "March",
214
214
  day: null,
215
215
  newEnrollments: "16",
216
216
  scheduledMeetings: "20",
@@ -220,9 +220,9 @@ export const MOCK_DATA = [
220
220
  graduatedStudents: "28",
221
221
  children: [
222
222
  {
223
- year: "2011",
223
+ year: "2023",
224
224
  quarter: "Q1",
225
- month: "January",
225
+ month: "March",
226
226
  day: "10",
227
227
  newEnrollments: "34",
228
228
  scheduledMeetings: "28",
@@ -232,10 +232,10 @@ export const MOCK_DATA = [
232
232
  graduatedStudents: "17",
233
233
  },
234
234
  {
235
- year: "2011",
235
+ year: "2023",
236
236
  quarter: "Q1",
237
- month: "January",
238
- day: "20",
237
+ month: "March",
238
+ day: "11",
239
239
  newEnrollments: "43",
240
240
  scheduledMeetings: "23",
241
241
  attendanceRate: "66%",
@@ -246,9 +246,9 @@ export const MOCK_DATA = [
246
246
  ],
247
247
  },
248
248
  {
249
- year: "2011",
249
+ year: "2023",
250
250
  quarter: "Q1",
251
- month: "February",
251
+ month: "April",
252
252
  day: null,
253
253
  newEnrollments: "20",
254
254
  scheduledMeetings: "41",
@@ -258,9 +258,9 @@ export const MOCK_DATA = [
258
258
  graduatedStudents: "43",
259
259
  children: [
260
260
  {
261
- year: "2011",
261
+ year: "2023",
262
262
  quarter: "Q1",
263
- month: "February",
263
+ month: "April",
264
264
  day: "15",
265
265
  newEnrollments: "19",
266
266
  scheduledMeetings: "35",
@@ -1,3 +1,14 @@
1
+
2
+ //animation scss
3
+ @keyframes wave {
4
+ 0% {
5
+ background-position: -468px 0;
6
+ }
7
+ 100% {
8
+ background-position: 468px 0;
9
+ }
10
+ }
11
+
1
12
  .content-loading {
2
13
  pointer-events: none;
3
14
  p,
data/dist/menu.yml CHANGED
@@ -45,7 +45,7 @@ kits:
45
45
  description: Tables display a collection of structured data and typically have the ability to sort, filter, and paginate data.
46
46
  - name: "advanced_table"
47
47
  platforms: *react_only
48
- description:
48
+ description: The Advanced Table can be used to display complex, nested data in a way that allows for expansion and/or sorting.
49
49
  - name: "list"
50
50
  platforms: *web
51
51
  description: Lists display a vertical set of related content.
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "13.16.0"
5
- VERSION = "13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2010"
5
+ VERSION = "13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2034"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2010
4
+ version: 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2034
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-26 00:00:00.000000000 Z
12
+ date: 2024-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -277,14 +277,19 @@ files:
277
277
  - app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx
278
278
  - app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx
279
279
  - app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx
280
- - app/pb_kits/playbook/pb_advanced_table/SubComponents/TableBody.tsx
281
- - app/pb_kits/playbook/pb_advanced_table/SubComponents/TableHeader.tsx
282
- - app/pb_kits/playbook/pb_advanced_table/Utilities/helper_functions.tsx
280
+ - app/pb_kits/playbook/pb_advanced_table/README.md
281
+ - app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx
282
+ - app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
283
+ - app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx
284
+ - app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx
285
+ - app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx
283
286
  - app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts
284
287
  - app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss
285
288
  - app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx
286
289
  - app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx
287
290
  - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx
291
+ - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md
292
+ - app/pb_kits/playbook/pb_advanced_table/docs/_description.md
288
293
  - app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js
289
294
  - app/pb_kits/playbook/pb_advanced_table/docs/example.yml
290
295
  - app/pb_kits/playbook/pb_advanced_table/docs/index.js
@@ -5,23 +5,23 @@ import { TableHeaderCell } from "../Components/TableHeaderCell"
5
5
  import { DataType } from "../Utilities/types"
6
6
 
7
7
  type TableHeaderProps = {
8
- headerId?: string
8
+ children?: React.ReactNode | React.ReactNode[]
9
9
  enableSorting?: boolean
10
+ headerId?: string
10
11
  sortIcon?: string | string[]
11
- children?: React.ReactNode | React.ReactNode[]
12
12
  }
13
13
 
14
14
  export const TableHeader = ({
15
- headerId,
16
- enableSorting = false,
17
15
  children,
16
+ enableSorting = false,
17
+ headerId,
18
18
  sortIcon = ["arrow-up-short-wide", "arrow-down-short-wide"],
19
19
  }: TableHeaderProps) => {
20
20
  const {
21
- table,
21
+ enableToggleExpansion,
22
22
  handleExpandOrCollapse,
23
23
  loading,
24
- enableToggleExpansion,
24
+ table,
25
25
  } = useContext(AdvancedTableContext)
26
26
 
27
27
  return (