playbook_ui 13.20.0.pre.alpha.play1247htmloptions2404 → 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 (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +21 -19
  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 -79
  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/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -2
  29. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +1 -2
  30. data/app/pb_kits/playbook/pb_background/background.html.erb +1 -2
  31. data/app/pb_kits/playbook/pb_badge/badge.html.erb +1 -2
  32. data/app/pb_kits/playbook/pb_body/body.html.erb +1 -2
  33. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +1 -2
  34. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +1 -2
  35. data/app/pb_kits/playbook/pb_button/button.html.erb +1 -2
  36. data/app/pb_kits/playbook/pb_button/button.rb +3 -2
  37. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +1 -2
  38. data/app/pb_kits/playbook/pb_caption/caption.html.erb +1 -2
  39. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -2
  40. data/app/pb_kits/playbook/pb_card/card_body.html.erb +1 -2
  41. data/app/pb_kits/playbook/pb_card/card_header.html.erb +1 -2
  42. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +1 -3
  43. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -2
  44. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +1 -2
  45. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +1 -2
  46. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -2
  47. data/app/pb_kits/playbook/pb_contact/contact.html.erb +1 -2
  48. data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -2
  49. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +1 -2
  50. data/app/pb_kits/playbook/pb_date/date.html.erb +1 -2
  51. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -3
  52. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +1 -2
  53. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +1 -2
  54. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +1 -2
  55. data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +1 -2
  56. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +2 -3
  57. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +1 -2
  58. data/app/pb_kits/playbook/pb_detail/detail.html.erb +1 -2
  59. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -2
  60. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +2 -3
  61. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +1 -2
  62. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -3
  63. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -2
  64. data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -2
  65. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +1 -2
  66. data/app/pb_kits/playbook/pb_flex/flex.html.erb +1 -2
  67. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +1 -2
  68. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -2
  69. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +2 -2
  70. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -2
  71. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +1 -2
  72. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +1 -2
  73. data/app/pb_kits/playbook/pb_icon/icon.html.erb +1 -2
  74. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +1 -2
  75. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -2
  76. data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +1 -2
  77. data/app/pb_kits/playbook/pb_image/image.html.erb +1 -2
  78. data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +1 -2
  79. data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +2 -3
  80. data/app/pb_kits/playbook/pb_layout/body.html.erb +1 -2
  81. data/app/pb_kits/playbook/pb_layout/footer.html.erb +1 -2
  82. data/app/pb_kits/playbook/pb_layout/header.html.erb +1 -2
  83. data/app/pb_kits/playbook/pb_layout/item.html.erb +1 -2
  84. data/app/pb_kits/playbook/pb_layout/layout.html.erb +1 -2
  85. data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +1 -2
  86. data/app/pb_kits/playbook/pb_legend/legend.html.erb +1 -2
  87. data/app/pb_kits/playbook/pb_list/item.html.erb +1 -2
  88. data/app/pb_kits/playbook/pb_list/list.html.erb +1 -2
  89. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +1 -2
  90. data/app/pb_kits/playbook/pb_message/message.html.erb +1 -2
  91. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +2 -3
  92. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +1 -2
  93. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +1 -2
  94. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +1 -2
  95. data/app/pb_kits/playbook/pb_nav/item.html.erb +2 -4
  96. data/app/pb_kits/playbook/pb_nav/nav.html.erb +1 -2
  97. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -2
  98. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +1 -2
  99. data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
  100. data/app/pb_kits/playbook/pb_person/person.html.erb +1 -2
  101. data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +1 -2
  102. data/app/pb_kits/playbook/pb_pill/pill.html.erb +1 -2
  103. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -2
  104. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +1 -2
  105. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +1 -2
  106. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -2
  107. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +1 -2
  108. data/app/pb_kits/playbook/pb_radio/radio.html.erb +1 -2
  109. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +1 -2
  110. data/app/pb_kits/playbook/pb_select/select.html.erb +1 -2
  111. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -2
  112. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -2
  113. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -2
  114. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +1 -2
  115. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +1 -2
  116. data/app/pb_kits/playbook/pb_source/source.html.erb +1 -2
  117. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +1 -2
  118. data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +1 -2
  119. data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +1 -2
  120. data/app/pb_kits/playbook/pb_table/table.html.erb +2 -4
  121. data/app/pb_kits/playbook/pb_table/table_body.html.erb +3 -5
  122. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +3 -5
  123. data/app/pb_kits/playbook/pb_table/table_head.html.erb +3 -5
  124. data/app/pb_kits/playbook/pb_table/table_header.html.erb +3 -5
  125. data/app/pb_kits/playbook/pb_table/table_row.html.erb +3 -5
  126. data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +1 -2
  127. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +1 -2
  128. data/app/pb_kits/playbook/pb_time/time.html.erb +1 -2
  129. data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +2 -3
  130. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +1 -2
  131. data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -2
  132. data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +1 -2
  133. data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +1 -2
  134. data/app/pb_kits/playbook/pb_title/title.html.erb +2 -3
  135. data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +1 -2
  136. data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +1 -2
  137. data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +1 -2
  138. data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +1 -2
  139. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +1 -2
  140. data/app/pb_kits/playbook/pb_user/user.html.erb +1 -2
  141. data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +1 -2
  142. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +1 -2
  143. data/lib/playbook/kit_base.rb +0 -18
  144. data/lib/playbook/version.rb +2 -2
  145. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e02e5f3489c1023e0b6ad3090f1970ec8e1c36691376a085c6f76d75b8ce8fa6
4
- data.tar.gz: d94386b85c53885fd714d25b360fbe654eafae1e39af8f3be133b2516238a616
3
+ metadata.gz: f7cfb7021f51c07eb77a7166393965f50d634939c88a3d7b2a72890fc8f76aea
4
+ data.tar.gz: 4e0fd0437700056b9fcd95076dd5f700e89b616cf83f97ef9f96ae50c205352f
5
5
  SHA512:
6
- metadata.gz: b0bfc0c59486a1a564f48db1a05bae3979c9e3b2262b39ccbfc45043c618192af84658355555ac64a06ece1ffe9caed19227d619b7f15ff51bf5d279a021dc77
7
- data.tar.gz: 54a237fe6b13077b388c408009a1b34552d6d35e90bfaece2ea53481bd96f84e3e1fa66db6e170cab2c10a74f49db22ec47114c938b89df84fcbcfb08dc910d9
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,12 +24,12 @@ export const CustomCell = ({
22
24
  row,
23
25
  value,
24
26
  }: CustomCellProps & GlobalProps) => {
25
- const { setExpanded, expanded, inlineRowLoading } = useContext(AdvancedTableContext);
27
+ const { setExpanded, expanded, inlineRowLoading } = useContext(AdvancedTableContext)
26
28
 
27
- const handleOnExpand = (row: Row<DataType>) => {
28
- onRowToggleClick && onRowToggleClick(row);
29
- setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
30
- };
29
+ const handleOnExpand = (row: Row<GenericObject>) => {
30
+ onRowToggleClick && onRowToggleClick(row)
31
+ setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() })
32
+ }
31
33
  const RowHasChildren = row.original.children ? true : false
32
34
  const renderButton = inlineRowLoading ? RowHasChildren : row.getCanExpand()
33
35
 
@@ -59,5 +61,5 @@ export const CustomCell = ({
59
61
  </FlexItem>
60
62
  </Flex>
61
63
  </div>
62
- );
63
- };
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}
@@ -250,10 +254,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
250
254
  </Table>
251
255
  </AdvancedTableContext.Provider>
252
256
  </div>
253
- );
254
- };
257
+ )
258
+ }
255
259
 
256
- AdvancedTable.Header = TableHeader;
257
- AdvancedTable.Body = TableBody;
260
+ AdvancedTable.Header = TableHeader
261
+ AdvancedTable.Body = TableBody
258
262
 
259
- export default AdvancedTable;
263
+ export default AdvancedTable