playbook_ui 13.21.0.pre.alpha.PBNTR225advancedtablefeedback2438 → 13.21.0.pre.alpha.PBNTR238DatePickerYearBug2436

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