playbook_ui 13.21.0.pre.alpha.PBNTR224letuserresetrowexpansion2441 → 13.21.0.pre.alpha.PBNTR225advancedtablefeedback2438

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +21 -22
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +6 -3
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +12 -8
  5. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +14 -9
  6. data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +9 -5
  7. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +15 -11
  8. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +12 -8
  9. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +3 -2
  10. data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +0 -2
  11. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +2 -9
  12. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +83 -80
  13. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +54 -54
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +7 -7
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +7 -7
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +7 -7
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +7 -7
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +1 -1
  19. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +7 -7
  20. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +7 -7
  21. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +7 -7
  22. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +7 -7
  23. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +7 -7
  24. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +7 -7
  25. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +1 -1
  26. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading.js +1 -1
  27. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_chrome_styles.scss +13 -0
  28. data/lib/playbook/version.rb +1 -1
  29. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c791ef532b5ab0046b1f23ecb0ee10c42d252a03e82ff41aa6a9d975ba74a4c6
4
- data.tar.gz: c160c5caed43fb098b0ff002f03f5864fc0fb5b0fadd9cc4beeba5b84a55ce43
3
+ metadata.gz: f7cfb7021f51c07eb77a7166393965f50d634939c88a3d7b2a72890fc8f76aea
4
+ data.tar.gz: 4e0fd0437700056b9fcd95076dd5f700e89b616cf83f97ef9f96ae50c205352f
5
5
  SHA512:
6
- metadata.gz: ed5e0daf589b941e3fdf81c9afb1b82f92d499694b4d887f29c3562c1d3161b4ad96a1dcb37b16467b27bc94e66a2601862ce0aa88e4f58b02d99848e2e2a6e3
7
- data.tar.gz: 7a6cad2d2ff14437be085b01b78b1292dd14a464de5b27a2da662db19699050da4dbe7de3fbe7a6feac61d6032093db39a01ea38e862fe574ef8e6d85cbc5ab5
6
+ metadata.gz: '09e5b5458d55ae87b2f8ccd44d3f8dc9a95391b8e8ae5493fa5f05408acfe0bd5f2db7c84343fa450bbc05299a597fc8bf6ca48d9976eeac0b1720d353b0cba7'
7
+ data.tar.gz: e360ce6a4f2074667af1b2e8a9067fd28e8e7a6f30136d04a69c7f7e3f1dcda3835d4cf4663be4e816dd89909698b4c9b0ac8991ff779b3666e845239dd5afa8
@@ -1,19 +1,21 @@
1
- import React, { useContext } from "react";
1
+ import React, { useContext } from "react"
2
+ import { Getter, Row } from "@tanstack/react-table"
2
3
 
3
- import Flex from "../../pb_flex/_flex";
4
- import FlexItem from "../../pb_flex/_flex_item";
5
- import Icon from "../../pb_icon/_icon";
6
- import { GlobalProps } from "../../utilities/globalProps";
4
+ import { GenericObject } from "../../types"
7
5
 
8
- import { Getter, Row } from "@tanstack/react-table";
9
- import { DataType } from "../Utilities/types";
10
- import AdvancedTableContext from "../Context/AdvancedTableContext";
6
+ import { GlobalProps } from "../../utilities/globalProps"
7
+
8
+ import Flex from "../../pb_flex/_flex"
9
+ import FlexItem from "../../pb_flex/_flex_item"
10
+ import Icon from "../../pb_icon/_icon"
11
+
12
+ import AdvancedTableContext from "../Context/AdvancedTableContext"
11
13
 
12
14
  interface CustomCellProps {
13
- getValue?: Getter<string>;
14
- onRowToggleClick?: (arg: Row<DataType>) => void;
15
- row: Row<DataType>;
16
- value?: string;
15
+ getValue?: Getter<string>
16
+ onRowToggleClick?: (arg: Row<GenericObject>) => void
17
+ row: Row<GenericObject>
18
+ value?: string
17
19
  }
18
20
 
19
21
  export const CustomCell = ({
@@ -22,15 +24,12 @@ export const CustomCell = ({
22
24
  row,
23
25
  value,
24
26
  }: CustomCellProps & GlobalProps) => {
25
- const { setExpanded, expanded, expandedControl, inlineRowLoading } = useContext(AdvancedTableContext);
27
+ const { setExpanded, expanded, inlineRowLoading } = useContext(AdvancedTableContext)
26
28
 
27
- const handleOnExpand = (row: Row<DataType>) => {
28
- onRowToggleClick && onRowToggleClick(row);
29
-
30
- if (!expandedControl) {
31
- setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
32
- }
33
- };
29
+ const handleOnExpand = (row: Row<GenericObject>) => {
30
+ onRowToggleClick && onRowToggleClick(row)
31
+ setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() })
32
+ }
34
33
  const RowHasChildren = row.original.children ? true : false
35
34
  const renderButton = inlineRowLoading ? RowHasChildren : row.getCanExpand()
36
35
 
@@ -62,5 +61,5 @@ export const CustomCell = ({
62
61
  </FlexItem>
63
62
  </Flex>
64
63
  </div>
65
- );
66
- };
64
+ )
65
+ }
@@ -1,11 +1,14 @@
1
1
  import React from "react"
2
- import Icon from "../../pb_icon/_icon"
3
2
  import { Header } from "@tanstack/react-table"
4
- import { DataType } from "../Utilities/types"
3
+
4
+ import { GenericObject } from "../../types"
5
+
6
+ import Icon from "../../pb_icon/_icon"
7
+
5
8
  import { displayIcon } from "../Utilities/IconHelpers"
6
9
 
7
10
  type SortIconButtonProps = {
8
- header: Header<DataType, unknown>
11
+ header: Header<GenericObject, unknown>
9
12
  sortIcon?: string | string[]
10
13
  }
11
14
  export const SortIconButton = ({ header, sortIcon }: SortIconButtonProps) => {
@@ -1,23 +1,27 @@
1
1
  import React, { useContext } from "react"
2
+ import { Row, Table } from "@tanstack/react-table"
3
+
4
+ import { GenericObject } from "../../types"
5
+
6
+ import { GlobalProps } from "../../utilities/globalProps"
7
+
2
8
  import Flex from "../../pb_flex/_flex"
3
9
  import Caption from "../../pb_caption/_caption"
4
- import { Row, Table } from "@tanstack/react-table"
5
10
 
6
- import AdvancedTableContext from "../Context/AdvancedTableContext";
7
11
  import { ToggleIconButton } from "./ToggleIconButton"
8
12
  import { renderCollapsibleTrail } from "./CollapsibleTrail"
9
13
 
10
14
  import { isChrome } from "../Utilities/BrowserCheck"
11
- import { DataType } from "../Utilities/types"
12
- import { GlobalProps } from "../../utilities/globalProps"
15
+
16
+ import AdvancedTableContext from "../Context/AdvancedTableContext"
13
17
 
14
18
  interface SubRowHeaderRowProps {
15
19
  collapsibleTrail?: boolean
16
20
  enableToggleExpansion?: "all" | "header" | "none"
17
- onClick: (row: Row<DataType>) => void
18
- row: Row<DataType>
21
+ onClick: (row: Row<GenericObject>) => void
22
+ row: Row<GenericObject>
19
23
  subRowHeaders?: string[]
20
- table: Table<DataType>
24
+ table: Table<GenericObject>
21
25
  }
22
26
 
23
27
  export const SubRowHeaderRow = ({
@@ -28,7 +32,7 @@ export const SubRowHeaderRow = ({
28
32
  subRowHeaders,
29
33
  table,
30
34
  }: SubRowHeaderRowProps & GlobalProps) => {
31
- const { inlineRowLoading } = useContext(AdvancedTableContext);
35
+ const { inlineRowLoading } = useContext(AdvancedTableContext)
32
36
 
33
37
  const numberOfColumns = table.getAllFlatColumns().length
34
38
  const rowHasChildren = row.original.children ? true : false
@@ -1,20 +1,25 @@
1
1
  import React, { useContext } from "react"
2
- import classnames from "classnames";
3
- import Flex from "../../pb_flex/_flex"
2
+ import classnames from "classnames"
4
3
  import { flexRender, Header } from "@tanstack/react-table"
5
4
 
5
+ import { GenericObject } from "../../types"
6
+
7
+ import { GlobalProps } from "../../utilities/globalProps"
8
+
9
+ import Flex from "../../pb_flex/_flex"
10
+
6
11
  import { SortIconButton } from "./SortIconButton"
7
12
  import { ToggleIconButton } from "./ToggleIconButton"
13
+
8
14
  import { isChrome } from "../Utilities/BrowserCheck"
9
- import { DataType } from "../Utilities/types"
15
+
10
16
  import AdvancedTableContext from "../Context/AdvancedTableContext"
11
- import { GlobalProps } from "../../utilities/globalProps"
12
17
 
13
18
  type TableHeaderCellProps = {
14
19
  enableSorting?: boolean
15
20
  enableToggleExpansion?: "all" | "header" | "none"
16
21
  handleExpandOrCollapse?: () => void
17
- header?: Header<DataType, unknown>
22
+ header?: Header<GenericObject, unknown>
18
23
  headerChildren?: React.ReactNode | React.ReactNode[]
19
24
  loading?: boolean
20
25
  sortIcon?: string | string[]
@@ -45,24 +50,24 @@ export const TableHeaderCell = ({
45
50
  const cellClassName = classnames("table-header-cells",
46
51
  `${isChrome() ? "chrome-styles" : ""}`,
47
52
  `${enableSorting ? "table-header-cells-active" : ""}`
48
- );
53
+ )
49
54
 
50
55
  const cellId = `${loading ?
51
56
  `loading-${header.id}`
52
57
  : `${header.id}`
53
- }`;
58
+ }`
54
59
 
55
60
  const isToggleExpansionEnabledLoading =
56
61
  header.index === 0 &&
57
62
  loading &&
58
63
  (enableToggleExpansion === "all" || "header") &&
59
- enableToggleExpansion !== "none";
64
+ enableToggleExpansion !== "none"
60
65
 
61
66
  const isToggleExpansionEnabled =
62
67
  header.index === 0 &&
63
68
  !loading &&
64
69
  (enableToggleExpansion === "all" || "header") &&
65
- enableToggleExpansion !== "none";
70
+ enableToggleExpansion !== "none"
66
71
 
67
72
  return (
68
73
  <th
@@ -1,13 +1,17 @@
1
1
  import React, { useContext } from "react"
2
- import Icon from "../../pb_icon/_icon"
3
2
  import { Row } from "@tanstack/react-table"
4
- import AdvancedTableContext from "../Context/AdvancedTableContext"
5
- import { DataType } from "../Utilities/types"
3
+
4
+ import { GenericObject } from "../../types"
5
+
6
+ import Icon from "../../pb_icon/_icon"
7
+
6
8
  import { displayIcon } from "../Utilities/IconHelpers"
7
9
 
10
+ import AdvancedTableContext from "../Context/AdvancedTableContext"
11
+
8
12
  interface ToggleIconButtonProps {
9
- onClick: (row: Row<DataType>) => void
10
- row?: Row<DataType>
13
+ onClick: (row: Row<GenericObject>) => void
14
+ row?: Row<GenericObject>
11
15
  }
12
16
 
13
17
  export const ToggleIconButton = ({ row, onClick }: ToggleIconButtonProps) => {
@@ -1,22 +1,26 @@
1
1
  import React, { useContext } from "react"
2
- import classnames from "classnames";
3
- import { buildCss } from "../../utilities/props";
4
- import { globalProps } from "../../utilities/globalProps";
5
- import LoadingInline from "../../pb_loading_inline/_loading_inline"
2
+ import classnames from "classnames"
6
3
  import { flexRender, Row } from "@tanstack/react-table"
7
4
 
5
+ import { GenericObject } from "../../types"
6
+
7
+ import { buildCss } from "../../utilities/props"
8
+ import { globalProps } from "../../utilities/globalProps"
9
+ import { isChrome } from "../Utilities/BrowserCheck"
10
+
11
+ import LoadingInline from "../../pb_loading_inline/_loading_inline"
12
+
8
13
  import { SubRowHeaderRow } from "../Components/SubRowHeaderRow"
9
14
  import { LoadingCell } from "../Components/LoadingCell"
10
15
  import { renderCollapsibleTrail } from "../Components/CollapsibleTrail"
16
+
11
17
  import AdvancedTableContext from "../Context/AdvancedTableContext"
12
- import { isChrome } from "../Utilities/BrowserCheck"
13
- import { DataType } from "../Utilities/types"
14
18
 
15
19
  type TableBodyProps = {
16
- className?: string;
20
+ className?: string
17
21
  collapsibleTrail?: boolean
18
- dark?: boolean,
19
- id?: string;
22
+ dark?: boolean
23
+ id?: string
20
24
  subRowHeaders?: string[]
21
25
  }
22
26
 
@@ -42,14 +46,14 @@ export const TableBody = ({
42
46
  buildCss("pb_advanced_table_body"),
43
47
  globalProps(props),
44
48
  className
45
- );
49
+ )
46
50
 
47
51
  return (
48
52
  <>
49
53
  <tbody className={classes}
50
54
  id={id}
51
55
  >
52
- {table.getRowModel().rows.map((row: Row<DataType>) => {
56
+ {table.getRowModel().rows.map((row: Row<GenericObject>) => {
53
57
  const isExpandable = row.getIsExpanded()
54
58
  const isFirstChildofSubrow = row.depth > 0 && row.index === 0
55
59
  const rowHasNoChildren = row.original.children && !row.original.children.length ? true : false
@@ -1,18 +1,22 @@
1
1
  import React, { useContext } from "react"
2
- import classnames from "classnames";
3
- import { buildCss } from "../../utilities/props";
4
- import { globalProps } from "../../utilities/globalProps";
2
+ import classnames from "classnames"
5
3
  import { HeaderGroup } from "@tanstack/react-table"
6
- import AdvancedTableContext from "../Context/AdvancedTableContext"
4
+
5
+ import { GenericObject } from "../../types"
6
+
7
+ import { buildCss } from "../../utilities/props"
8
+ import { globalProps } from "../../utilities/globalProps"
9
+
7
10
  import { TableHeaderCell } from "../Components/TableHeaderCell"
8
- import { DataType } from "../Utilities/types"
11
+
12
+ import AdvancedTableContext from "../Context/AdvancedTableContext"
9
13
 
10
14
  type TableHeaderProps = {
11
15
  children?: React.ReactNode | React.ReactNode[]
12
16
  className?: string
13
17
  dark?: boolean,
14
18
  enableSorting?: boolean
15
- id?: string;
19
+ id?: string
16
20
  sortIcon?: string | string[]
17
21
  }
18
22
 
@@ -36,7 +40,7 @@ export const TableHeader = ({
36
40
  buildCss("pb_advanced_table_header"),
37
41
  globalProps(props),
38
42
  className
39
- );
43
+ )
40
44
 
41
45
 
42
46
  return (
@@ -45,7 +49,7 @@ export const TableHeader = ({
45
49
  id={id}
46
50
  >
47
51
  {/* Get the header groups (only one in this example) */}
48
- {table.getHeaderGroups().map((headerGroup: HeaderGroup<DataType>) => (
52
+ {table.getHeaderGroups().map((headerGroup: HeaderGroup<GenericObject>) => (
49
53
  <tr key={`${headerGroup.id}-headerGroup`}>
50
54
  {headerGroup.headers.map(header => (
51
55
  <TableHeaderCell
@@ -1,5 +1,6 @@
1
1
  import { RowModel } from "@tanstack/react-table"
2
- import { DataType, ExpandedStateObject } from "./types"
2
+ import { ExpandedStateObject } from "./types"
3
+ import { GenericObject } from "../../types"
3
4
 
4
5
  const filterExpandableRows = (expandedState: Record<string, boolean>) => {
5
6
  for (const expandedRow in expandedState) {
@@ -11,7 +12,7 @@ const filterExpandableRows = (expandedState: Record<string, boolean>) => {
11
12
  }
12
13
 
13
14
  export const updateExpandAndCollapseState = (
14
- tableRows: RowModel<DataType>,
15
+ tableRows: RowModel<GenericObject>,
15
16
  expanded: Record<string, boolean>,
16
17
  targetParent: string
17
18
  ) => {
@@ -4,5 +4,3 @@ export type ExpandedStateObject = Extract<
4
4
  ExpandedState,
5
5
  Record<string, boolean>
6
6
  >
7
-
8
- export type DataType = { [key: string]: any }
@@ -4,6 +4,7 @@
4
4
  @import "../tokens/spacing";
5
5
  @import "./scss_partials/loading";
6
6
  @import "./scss_partials/pseudo_states";
7
+ @import "./scss_partials/chrome_styles";
7
8
 
8
9
  .pb_advanced_table {
9
10
  $border-color: 1px solid $border_light !important;
@@ -86,15 +87,7 @@
86
87
  box-shadow: 1px 0px 0px 0px #e4e8f0 !important;
87
88
  }
88
89
 
89
- .chrome-styles:first-child {
90
- border-right: $border-color;
91
- }
92
-
93
- .table-card {
94
- .chrome-styles:first-child {
95
- border-right: $transparent !important;
96
- }
97
- }
90
+ @include chrome_styles($border-color);
98
91
 
99
92
  &.dark {
100
93
  .bg-white {
@@ -1,8 +1,8 @@
1
- import React, { useState, useEffect, useCallback } from "react";
2
- import classnames from "classnames";
3
- import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
4
- import { globalProps, GlobalProps } from "../utilities/globalProps";
5
- import Table from "../pb_table/_table";
1
+ import React, { useState, useEffect, useCallback } from "react"
2
+ import classnames from "classnames"
3
+
4
+ import { GenericObject } from "../types"
5
+
6
6
  import {
7
7
  createColumnHelper,
8
8
  getCoreRowModel,
@@ -11,39 +11,43 @@ import {
11
11
  Row,
12
12
  useReactTable,
13
13
  Getter,
14
- } from "@tanstack/react-table";
14
+ } from "@tanstack/react-table"
15
+
16
+ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props"
17
+ import { globalProps, GlobalProps } from "../utilities/globalProps"
15
18
 
16
- import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers";
19
+ import Table from "../pb_table/_table"
17
20
 
18
- import { CustomCell } from "./Components/CustomCell";
19
- import AdvancedTableContext from "./Context/AdvancedTableContext";
20
- import { TableHeader } from "./SubKits/TableHeader";
21
- import { TableBody } from "./SubKits/TableBody";
21
+ import AdvancedTableContext from "./Context/AdvancedTableContext"
22
22
 
23
- import { DataType } from "./Utilities/types";
23
+ import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers"
24
+
25
+ import { CustomCell } from "./Components/CustomCell"
26
+ import { TableHeader } from "./SubKits/TableHeader"
27
+ import { TableBody } from "./SubKits/TableBody"
24
28
 
25
29
  type AdvancedTableProps = {
26
- aria?: { [key: string]: string };
27
- children?: React.ReactNode | React.ReactNode[];
28
- className?: string;
29
- columnDefinitions: DataType[];
30
- dark?: boolean,
31
- data?: { [key: string]: string };
32
- enableToggleExpansion?: "all" | "header" | "none";
33
- expandedControl?: DataType;
30
+ aria?: { [key: string]: string }
31
+ children?: React.ReactNode | React.ReactNode[]
32
+ className?: string
33
+ columnDefinitions: GenericObject[]
34
+ dark?: boolean
35
+ data?: { [key: string]: string }
36
+ enableToggleExpansion?: "all" | "header" | "none"
37
+ expandedControl?: GenericObject
34
38
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
35
- id?: string;
36
- initialLoadingRowsCount?: number;
37
- inlineRowLoading?: boolean;
38
- loading?: boolean | string;
39
- onRowToggleClick?: (arg: Row<DataType>) => void;
40
- onToggleExpansionClick?: (arg: Row<DataType>) => void;
41
- sortControl?: DataType;
42
- tableData: DataType[];
43
- tableOptions?: DataType;
44
- tableProps?: DataType;
45
- toggleExpansionIcon?: string | string[];
46
- } & GlobalProps;
39
+ id?: string
40
+ initialLoadingRowsCount?: number
41
+ inlineRowLoading?: boolean
42
+ loading?: boolean | string
43
+ onRowToggleClick?: (arg: Row<GenericObject>) => void
44
+ onToggleExpansionClick?: (arg: Row<GenericObject>) => void
45
+ sortControl?: GenericObject
46
+ tableData: GenericObject[]
47
+ tableOptions?: GenericObject
48
+ tableProps?: GenericObject
49
+ toggleExpansionIcon?: string | string[]
50
+ } & GlobalProps
47
51
 
48
52
  const AdvancedTable = (props: AdvancedTableProps) => {
49
53
  const {
@@ -67,22 +71,22 @@ const AdvancedTable = (props: AdvancedTableProps) => {
67
71
  tableOptions,
68
72
  tableProps,
69
73
  toggleExpansionIcon = "arrows-from-line",
70
- } = props;
74
+ } = props
71
75
 
72
76
  const [loadingStateRowCount, setLoadingStateRowCount] = useState(
73
77
  initialLoadingRowsCount
74
- );
78
+ )
75
79
 
76
80
  // Create a local state for expanded and setExpanded if expandedControl not used
77
- const [localExpanded, setLocalExpanded] = useState({});
81
+ const [localExpanded, setLocalExpanded] = useState({})
78
82
 
79
83
  // Determine whether to use the prop or the local state
80
- const expanded = expandedControl ? expandedControl.value : localExpanded;
84
+ const expanded = expandedControl ? expandedControl.value : localExpanded
81
85
  const setExpanded = expandedControl
82
86
  ? expandedControl.onChange
83
- : setLocalExpanded;
87
+ : setLocalExpanded
84
88
 
85
- const columnHelper = createColumnHelper();
89
+ const columnHelper = createColumnHelper()
86
90
 
87
91
  //Create cells for first columns
88
92
  const createCellFunction = (cellAccessors: string[]) => {
@@ -90,10 +94,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
90
94
  row,
91
95
  getValue,
92
96
  }: {
93
- row: Row<DataType>;
94
- getValue: Getter<string>;
97
+ row: Row<GenericObject>
98
+ getValue: Getter<string>
95
99
  }) => {
96
- const rowData = row.original;
100
+ const rowData = row.original
97
101
 
98
102
  switch (row.depth) {
99
103
  case 0: {
@@ -103,12 +107,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
103
107
  onRowToggleClick={onRowToggleClick}
104
108
  row={row}
105
109
  />
106
- );
110
+ )
107
111
  }
108
112
  default: {
109
113
  // Handle other depths based on cellAccessors
110
- const depthAccessor = cellAccessors[row.depth - 1]; // Adjust index for depth
111
- const accessorValue = rowData[depthAccessor];
114
+ const depthAccessor = cellAccessors[row.depth - 1] // Adjust index for depth
115
+ const accessorValue = rowData[depthAccessor]
112
116
  return accessorValue ? (
113
117
  <CustomCell
114
118
  onRowToggleClick={onRowToggleClick}
@@ -117,13 +121,13 @@ const AdvancedTable = (props: AdvancedTableProps) => {
117
121
  />
118
122
  ) : (
119
123
  "N/A"
120
- );
124
+ )
121
125
  }
122
126
  }
123
- };
127
+ }
124
128
 
125
- return columnCells;
126
- };
129
+ return columnCells
130
+ }
127
131
 
128
132
  //Create column array in format needed by Tanstack
129
133
  const columns =
@@ -134,12 +138,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
134
138
  ...columnHelper.accessor(column.accessor, {
135
139
  header: column.label,
136
140
  }),
137
- };
141
+ }
138
142
  if (column.cellAccessors) {
139
- columnStructure.cell = createCellFunction(column.cellAccessors);
143
+ columnStructure.cell = createCellFunction(column.cellAccessors)
140
144
  }
141
- return columnStructure;
142
- });
145
+ return columnStructure
146
+ })
143
147
 
144
148
  //Syntax for sorting Array if we want to manage state ourselves
145
149
  const sorting = [
@@ -150,22 +154,22 @@ const AdvancedTable = (props: AdvancedTableProps) => {
150
154
  ? !sortControl.value.desc
151
155
  : false,
152
156
  },
153
- ];
157
+ ]
154
158
 
155
159
  const expandAndSortState = () => {
156
160
  if (sortControl) {
157
- return { state: { expanded, sorting } };
161
+ return { state: { expanded, sorting } }
158
162
  } else {
159
- return { state: { expanded } };
163
+ return { state: { expanded } }
160
164
  }
161
- };
165
+ }
162
166
 
163
167
  //initialize table
164
168
  const table = useReactTable({
165
169
  data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
166
170
  columns,
167
171
  onExpandedChange: setExpanded,
168
- getSubRows: (row: DataType) => row.children,
172
+ getSubRows: (row: GenericObject) => row.children,
169
173
  getCoreRowModel: getCoreRowModel(),
170
174
  getExpandedRowModel: getExpandedRowModel(),
171
175
  getSortedRowModel: getSortedRowModel(),
@@ -173,42 +177,42 @@ const AdvancedTable = (props: AdvancedTableProps) => {
173
177
  sortDescFirst: true,
174
178
  ...expandAndSortState(),
175
179
  ...tableOptions,
176
- });
180
+ })
177
181
 
178
- const tableRows = table.getRowModel();
182
+ const tableRows = table.getRowModel()
179
183
 
180
184
  // Set table row count for loading state
181
185
  const updateLoadingStateRowCount = useCallback(() => {
182
- const rowsCount = table.getRowModel().rows.length;
186
+ const rowsCount = table.getRowModel().rows.length
183
187
  if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
184
- setLoadingStateRowCount(rowsCount);
188
+ setLoadingStateRowCount(rowsCount)
185
189
  }
186
- }, [tableData, loadingStateRowCount]);
190
+ }, [tableData, loadingStateRowCount])
187
191
 
188
192
  useEffect(() => {
189
193
  if (!loading) {
190
- updateLoadingStateRowCount();
194
+ updateLoadingStateRowCount()
191
195
  }
192
- }, [loading, updateLoadingStateRowCount]);
196
+ }, [loading, updateLoadingStateRowCount])
193
197
 
194
- const handleExpandOrCollapse = (row: Row<DataType>) => {
195
- onToggleExpansionClick && onToggleExpansionClick(row);
198
+ const handleExpandOrCollapse = (row: Row<GenericObject>) => {
199
+ onToggleExpansionClick && onToggleExpansionClick(row)
196
200
 
197
- const expandedState = expanded;
198
- const targetParent = row?.parentId;
201
+ const expandedState = expanded
202
+ const targetParent = row?.parentId
199
203
  return setExpanded(
200
204
  updateExpandAndCollapseState(tableRows, expandedState, targetParent)
201
- );
202
- };
205
+ )
206
+ }
203
207
 
204
- const ariaProps = buildAriaProps(aria);
205
- const dataProps = buildDataProps(data);
206
- const htmlProps = buildHtmlProps(htmlOptions);
208
+ const ariaProps = buildAriaProps(aria)
209
+ const dataProps = buildDataProps(data)
210
+ const htmlProps = buildHtmlProps(htmlOptions)
207
211
  const classes = classnames(
208
212
  buildCss("pb_advanced_table"),
209
213
  globalProps(props),
210
214
  className
211
- );
215
+ )
212
216
 
213
217
  return (
214
218
  <div {...ariaProps}
@@ -222,7 +226,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
222
226
  columnDefinitions,
223
227
  enableToggleExpansion,
224
228
  expanded,
225
- expandedControl,
226
229
  handleExpandOrCollapse,
227
230
  inlineRowLoading,
228
231
  loading,
@@ -251,10 +254,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
251
254
  </Table>
252
255
  </AdvancedTableContext.Provider>
253
256
  </div>
254
- );
255
- };
257
+ )
258
+ }
256
259
 
257
- AdvancedTable.Header = TableHeader;
258
- AdvancedTable.Body = TableBody;
260
+ AdvancedTable.Header = TableHeader
261
+ AdvancedTable.Body = TableBody
259
262
 
260
- export default AdvancedTable;
263
+ export default AdvancedTable