playbook_ui 14.22.0.pre.alpha.PLAY2256stickydataidreact8523 → 14.22.0.pre.alpha.PLAY2281atcustomheaderrails8968

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +6 -7
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +32 -11
  4. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +2 -2
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +5 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +6 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_sort.jsx +65 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_sort.md +5 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header.jsx +69 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header.md +1 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +51 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.md +1 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +12 -8
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
  15. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +5 -1
  16. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +36 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -2
  18. data/app/pb_kits/playbook/pb_badge/_badge.scss +5 -6
  19. data/app/pb_kits/playbook/pb_bar_graph/barGraphTheme.ts +106 -0
  20. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_colors.jsx +33 -15
  21. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.jsx +33 -15
  22. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_height.jsx +52 -22
  23. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_height.md +3 -0
  24. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.jsx +12 -16
  25. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend.jsx +31 -15
  26. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_non_clickable.jsx +39 -16
  27. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +86 -38
  28. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.jsx +32 -15
  29. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.jsx +72 -22
  30. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.md +1 -1
  31. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_spline.jsx +31 -15
  32. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.jsx +37 -16
  33. data/app/pb_kits/playbook/pb_bar_graph/docs/_description.md +1 -3
  34. data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -3
  35. data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +0 -2
  36. data/app/pb_kits/playbook/pb_body/docs/_body_truncate.jsx +3 -3
  37. data/app/pb_kits/playbook/pb_body/docs/_body_truncate_react.md +4 -0
  38. data/app/pb_kits/playbook/pb_circle_chart/circleChartTheme.ts +36 -1
  39. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +71 -26
  40. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +29 -16
  41. data/app/pb_kits/playbook/pb_circle_chart/docs/{_circle_chart_colors.md → _circle_chart_colors_rails.md} +1 -1
  42. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors_react.md +2 -0
  43. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.jsx +28 -16
  44. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.md +4 -2
  45. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +23 -15
  46. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.jsx +81 -51
  47. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +103 -75
  48. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +3 -6
  49. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +19 -13
  50. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +30 -17
  51. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_labels.jsx +34 -20
  52. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_legend_kit.jsx +29 -20
  53. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_title.jsx +28 -20
  54. data/app/pb_kits/playbook/pb_circle_chart/docs/_description.md +1 -0
  55. data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +0 -1
  56. data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +0 -1
  57. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +12 -4
  58. data/app/pb_kits/playbook/pb_draggable/context/types.ts +5 -2
  59. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +27 -17
  60. data/app/pb_kits/playbook/pb_title/docs/_title_truncate.jsx +3 -3
  61. data/app/pb_kits/playbook/pb_title/docs/_title_truncate_react.md +4 -0
  62. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open.html.erb +14 -0
  63. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open_rails.md +1 -0
  64. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
  65. data/app/pb_kits/playbook/pb_tooltip/index.js +59 -36
  66. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +9 -2
  67. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input.html.erb +18 -0
  68. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_preserve_input_rails.md +1 -0
  69. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
  70. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +3 -0
  71. data/dist/chunks/_circle_chart-BZmlhBs2.js +1 -0
  72. data/dist/chunks/{_typeahead-B7FRYVtS.js → _typeahead-B1tu_vWi.js} +3 -3
  73. data/dist/chunks/_weekday_stacked-CKk0dR5s.js +45 -0
  74. data/dist/chunks/{lib-Carqm8Ip.js → lib-DYpq0k8j.js} +1 -1
  75. data/dist/chunks/{pb_form_validation-DqRmTS8m.js → pb_form_validation-BUOKwfvW.js} +1 -1
  76. data/dist/chunks/vendor.js +1 -1
  77. data/dist/menu.yml +68 -8
  78. data/dist/playbook-doc.js +2 -2
  79. data/dist/playbook-rails-react-bindings.js +1 -1
  80. data/dist/playbook-rails.js +1 -1
  81. data/dist/playbook.css +1 -1
  82. data/lib/playbook/version.rb +1 -1
  83. metadata +28 -17
  84. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.jsx +0 -72
  85. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +0 -6
  86. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +0 -64
  87. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +0 -1
  88. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.jsx +0 -38
  89. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.md +0 -1
  90. data/dist/chunks/_weekday_stacked-BOIXPXFw.js +0 -45
  91. /data/app/pb_kits/playbook/pb_body/docs/{_body_truncate.md → _body_truncate_rails.md} +0 -0
  92. /data/app/pb_kits/playbook/pb_title/docs/{_title_truncate.md → _title_truncate_rails.md} +0 -0
  93. /data/app/pb_kits/playbook/pb_tooltip/docs/{_tooltip_click_open.md → _tooltip_click_open_react.md} +0 -0
  94. /data/app/pb_kits/playbook/pb_typeahead/docs/{_typeahead_preserve_input.md → _typeahead_preserve_input_react.md} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d78eb539bff4c09f8f56e54833e4930e9bc85402c1a3a50e2739a3defc103623
4
- data.tar.gz: f2e756e717c11b93d51dc929ec90a8ba6b889e2835eff61a0918fc62a92b36b7
3
+ metadata.gz: ddcfecfbe5c6d6dc4bbf934394560b00a8a2a12d3a4c8c6265f8631cf67f91b9
4
+ data.tar.gz: a1ae8ef97c98ce81a2ee2f79c3cb7778b680a6fd26a943081db510cb2537eb83
5
5
  SHA512:
6
- metadata.gz: 92c48871d8d522eff9429550e9326503fd89e417b60cfc8c8273c5e44eb87c81500dc9bd8333939ff2dad29ed9ad80dca16255d4b105f24ea5c17da7a07e52d1
7
- data.tar.gz: 883f732d8b305027e5ae8a3d952b26bcee861285895d2a974ff724e1be57e9db4c4927b94ffcf6577cd1f1475c4bb11332c3e67b9dcccb3eb1f9669f3db10669
6
+ metadata.gz: 3e144374508f511c0b8dd6d4f131290491e37db99754b0567ac9780ed747195714975406ae7980439ff42ce818de7a5fd4ead198c34a1440cc475dbc8f03afde
7
+ data.tar.gz: bc83e8baca7f39fd42afd83c3aa27a6cee79bda3ddc2e2098df15ca4330c18acebd116264dccd2234d3aa977f66278b61cf042530eeb11bcf617ab82d865a21d
@@ -20,7 +20,7 @@ interface CustomCellProps {
20
20
  customRenderer?: (row: Row<GenericObject>, value: string | undefined) => React.ReactNode
21
21
  selectableRows?: boolean
22
22
  customStyle?: GenericObject
23
- }
23
+ }
24
24
 
25
25
  export const CustomCell = ({
26
26
  getValue,
@@ -35,7 +35,7 @@ export const CustomCell = ({
35
35
 
36
36
  const handleOnExpand = (row: Row<GenericObject>) => {
37
37
  onRowToggleClick && onRowToggleClick(row);
38
-
38
+
39
39
  if (!expandedControl) {
40
40
  setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
41
41
  }
@@ -46,8 +46,8 @@ export const CustomCell = ({
46
46
 
47
47
  return (
48
48
  <div style={{ paddingLeft: `${row.depth * 1.25}em`}}>
49
- <Flex
50
- alignItems="center"
49
+ <Flex
50
+ alignItems="center"
51
51
  columnGap="xs"
52
52
  justify="start"
53
53
  orientation="row"
@@ -71,12 +71,11 @@ export const CustomCell = ({
71
71
  >
72
72
  {row.getIsExpanded() ? (
73
73
  <Icon cursor="pointer"
74
- icon="circle-play"
75
- rotation={90}
74
+ icon="circle-play-down"
76
75
  />
77
76
  ) : (
78
77
  <Icon cursor="pointer"
79
- icon="circle-play"
78
+ icon="circle-play"
80
79
  />
81
80
  )}
82
81
  </button>
@@ -7,6 +7,7 @@ import { GlobalProps } from "../../utilities/globalProps"
7
7
 
8
8
  import Flex from "../../pb_flex/_flex"
9
9
  import Caption from "../../pb_caption/_caption"
10
+ import Icon from "../../pb_icon/_icon"
10
11
 
11
12
  import { ToggleIconButton } from "./ToggleIconButton"
12
13
  import { renderCollapsibleTrail } from "./CollapsibleTrail"
@@ -32,17 +33,19 @@ export const SubRowHeaderRow = ({
32
33
  subRowHeaders,
33
34
  table,
34
35
  }: SubRowHeaderRowProps & GlobalProps) => {
35
- const { inlineRowLoading } = useContext(AdvancedTableContext)
36
+ const { inlineRowLoading, customSort, onCustomSortClick } = useContext(AdvancedTableContext)
36
37
 
37
38
  const numberOfColumns = table.getAllFlatColumns().length
38
39
  const rowHasChildren = row.original.children ? true : false
39
40
  const canExpand = inlineRowLoading ? rowHasChildren : row.getCanExpand()
41
+ const hasSubrowsToSort = row.getParentRow()?.subRows
42
+
40
43
 
41
44
  return (
42
45
  <tr className="custom-row bg-silver">
43
46
  <td
44
47
  className={`custom-row-first-column ${
45
- isChrome() ? "chrome-styles" : ""
48
+ isChrome() ? "chrome-styles" : ""
46
49
  }`}
47
50
  colSpan={1}
48
51
  >
@@ -50,21 +53,39 @@ export const SubRowHeaderRow = ({
50
53
  <div style={{ paddingLeft: `${row.depth * 1.25}em` }}>
51
54
  <Flex align="center"
52
55
  columnGap="xs"
56
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
+ //@ts-ignore
58
+ justifyContent={customSort && hasSubrowsToSort && hasSubrowsToSort.length > 1 ? "between" : undefined}
53
59
  >
54
- {enableToggleExpansion === "all" && canExpand ? (
55
- <ToggleIconButton onClick={onClick}
56
- row={row}
60
+ <Flex columnGap="xs">
61
+ {enableToggleExpansion === "all" && canExpand ? (
62
+ <ToggleIconButton onClick={onClick}
63
+ row={row}
64
+ />
65
+ ) : null}
66
+ <Caption
67
+ marginLeft={canExpand ? "none" : "xs"}
68
+ text={subRowHeaders[row.depth - 1]}
57
69
  />
58
- ) : null}
59
- <Caption
60
- marginLeft={canExpand ? "none" : "xs"}
61
- text={subRowHeaders[row.depth - 1]}
62
- />
70
+ </Flex>
71
+ {customSort && hasSubrowsToSort && hasSubrowsToSort.length > 1 && (
72
+ <button
73
+ aria-label="Sort this group"
74
+ className="sort-button-icon gray-icon"
75
+ onClick={() => { onCustomSortClick && onCustomSortClick(row.getParentRow()?.subRows)}}
76
+ >
77
+ <Icon
78
+ cursor="pointer"
79
+ fixedWidth
80
+ icon="sort"
81
+ />
82
+ </button>
83
+ )}
63
84
  </Flex>
64
85
  </div>
65
86
  </td>
66
87
 
67
88
  <td colSpan={numberOfColumns - 1} />
68
89
  </tr>
69
- )
90
+ );
70
91
  }
@@ -87,7 +87,7 @@ export function useTableState({
87
87
  // Handle grouped columns
88
88
  if (column.columns && column.columns.length > 0) {
89
89
  return {
90
- header: column.label || "",
90
+ header: column.header || column.label || "",
91
91
  columns: buildColumns(column.columns, false),
92
92
  };
93
93
  }
@@ -95,7 +95,7 @@ export function useTableState({
95
95
  // Define the base column structure
96
96
  const columnStructure = {
97
97
  ...columnHelper.accessor(column.accessor, {
98
- header: column.label || "",
98
+ header: column.header ?? column.label ?? "",
99
99
  }),
100
100
  };
101
101
 
@@ -189,6 +189,11 @@
189
189
  box-sizing: border-box !important;
190
190
  }
191
191
  }
192
+ // Fixes for tooltip picking up th styling from Table kit
193
+ .pb_tooltip_kit {
194
+ font-weight: unset;
195
+ text-transform: unset;
196
+ }
192
197
  }
193
198
 
194
199
  .pb_advanced_table_body {
@@ -36,6 +36,7 @@ type AdvancedTableProps = {
36
36
  columnDefinitions: GenericObject[]
37
37
  columnGroupBorderColor?: "text_lt_default" | "text_lt_light" | "text_lt_lighter" | "text_dk_default" | "text_dk_light" | "text_dk_lighter"
38
38
  columnVisibilityControl?: GenericObject
39
+ customSort?:boolean;
39
40
  dark?: boolean
40
41
  data?: { [key: string]: string }
41
42
  enableToggleExpansion?: "all" | "header" | "none"
@@ -67,6 +68,7 @@ type AdvancedTableProps = {
67
68
  tableProps?: GenericObject
68
69
  toggleExpansionIcon?: string | string[]
69
70
  onRowSelectionChange?: (arg: RowSelectionState) => void
71
+ onCustomSortClick?: (arg: GenericObject[]) => void
70
72
  virtualizedRows?: boolean
71
73
  allowFullScreen?: boolean
72
74
  fullScreenControl?: (controls: FullscreenControls) => void
@@ -81,6 +83,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
81
83
  columnDefinitions,
82
84
  columnGroupBorderColor,
83
85
  columnVisibilityControl,
86
+ customSort,
84
87
  dark = false,
85
88
  data = {},
86
89
  enableToggleExpansion = "header",
@@ -95,6 +98,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
95
98
  maxHeight,
96
99
  onRowToggleClick,
97
100
  onToggleExpansionClick,
101
+ onCustomSortClick,
98
102
  pagination = false,
99
103
  paginationProps,
100
104
  pinnedRows,
@@ -325,6 +329,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
325
329
  columnDefinitions={columnDefinitions}
326
330
  columnGroupBorderColor={columnGroupBorderColor}
327
331
  columnVisibilityControl={columnVisibilityControl}
332
+ customSort={customSort}
328
333
  enableToggleExpansion={enableToggleExpansion}
329
334
  enableVirtualization={virtualizedRows}
330
335
  expandByDepth={expandByDepth}
@@ -336,6 +341,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
336
341
  isActionBarVisible={isActionBarVisible}
337
342
  isFullscreen={isFullscreen}
338
343
  loading={loading}
344
+ onCustomSortClick={onCustomSortClick}
339
345
  onExpandByDepthClick={onExpandByDepthClick}
340
346
  pinnedRows={pinnedRows}
341
347
  responsive={responsive}
@@ -0,0 +1,65 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data.json"
4
+
5
+ const AdvancedTableCustomSort = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ id: "year",
11
+ cellAccessors: ["quarter", "month", "day"],
12
+ },
13
+ {
14
+ accessor: "newEnrollments",
15
+ id: "newEnrollments",
16
+ label: "New Enrollments",
17
+ },
18
+ {
19
+ accessor: "scheduledMeetings",
20
+ id: "scheduledMeetings",
21
+ label: "Scheduled Meetings",
22
+ },
23
+ {
24
+ accessor: "attendanceRate",
25
+ id: "attendanceRate",
26
+ label: "Attendance Rate",
27
+ },
28
+ {
29
+ accessor: "completedClasses",
30
+ id: "completedClasses",
31
+ label: "Completed Classes",
32
+ },
33
+ {
34
+ accessor: "classCompletionRate",
35
+ id: "classCompletionRate",
36
+ label: "Class Completion Rate",
37
+ },
38
+ {
39
+ accessor: "graduatedStudents",
40
+ id: "graduatedStudents",
41
+ label: "Graduated Students",
42
+ },
43
+ ]
44
+
45
+ //Render the subRow header rows
46
+ const subRowHeaders = ["Quarter", "Month", "Day"]
47
+
48
+ return (
49
+ <div>
50
+ <AdvancedTable
51
+ columnDefinitions={columnDefinitions}
52
+ customSort
53
+ enableToggleExpansion="all"
54
+ onCustomSortClick={(subrows)=>{console.log("Custom sort clicked", subrows)}}
55
+ tableData={MOCK_DATA}
56
+ {...props}
57
+ >
58
+ <AdvancedTable.Header enableSorting />
59
+ <AdvancedTable.Body subRowHeaders={subRowHeaders} />
60
+ </AdvancedTable>
61
+ </div>
62
+ )
63
+ }
64
+
65
+ export default AdvancedTableCustomSort
@@ -0,0 +1,5 @@
1
+ The optional `customSort` prop can be used to add a sort button within a subrow header. The button will only appear if that subrowheader has more than one subrow nested within it. This button comes with a callback function called `onCustomSortClick`.
2
+
3
+ The `onCustomSortClick` provides as an argument an array of all the subrows nested within that level of the table.
4
+
5
+ __NOTE__: `customSort` must be used in conjunction with the `subRowHeaders` prop. The `customSort` DOES NOT handle the sort logic, this must be handled on the frontend using the callback provided.
@@ -0,0 +1,69 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import Icon from "../../pb_icon/_icon"
4
+ import Flex from "../../pb_flex/_flex"
5
+ import Caption from "../../pb_caption/_caption"
6
+ import Tooltip from "../../pb_tooltip/_tooltip"
7
+ import MOCK_DATA from "./advanced_table_mock_data.json"
8
+
9
+ const AdvancedTableWithCustomHeader = (props) => {
10
+ const columnDefinitions = [
11
+ {
12
+ accessor: "year",
13
+ label: "Year",
14
+ cellAccessors: ["quarter", "month", "day"],
15
+ },
16
+ {
17
+ accessor: "newEnrollments",
18
+ label: "New Enrollments",
19
+ header: () => (
20
+ <Flex alignItems="center"
21
+ justifyContent="center"
22
+ >
23
+ <Caption marginRight="xs">New Enrollments</Caption>
24
+ <Tooltip placement="top"
25
+ text="Whoa. I'm a Tooltip"
26
+ zIndex={10}
27
+ >
28
+ <Icon cursor="pointer"
29
+ icon="info"
30
+ size="xs"
31
+ />
32
+ </Tooltip>
33
+ </Flex>
34
+ ),
35
+ },
36
+ {
37
+ accessor: "scheduledMeetings",
38
+ label: "Scheduled Meetings",
39
+ },
40
+ {
41
+ accessor: "attendanceRate",
42
+ label: "Attendance Rate",
43
+ },
44
+ {
45
+ accessor: "completedClasses",
46
+ label: "Completed Classes",
47
+ },
48
+ {
49
+ accessor: "classCompletionRate",
50
+ label: "Class Completion Rate",
51
+ },
52
+ {
53
+ accessor: "graduatedStudents",
54
+ label: "Graduated Students",
55
+ },
56
+ ];
57
+
58
+ return (
59
+ <div>
60
+ <AdvancedTable
61
+ columnDefinitions={columnDefinitions}
62
+ tableData={MOCK_DATA}
63
+ {...props}
64
+ />
65
+ </div>
66
+ )
67
+ }
68
+
69
+ export default AdvancedTableWithCustomHeader
@@ -0,0 +1 @@
1
+ The optional `header` key/value pair can be used within `columnDefinitions` to render a custom header. This example shows an Icon and Tooltip being used but other kits can be used as well.
@@ -0,0 +1,51 @@
1
+ <%
2
+ column_definitions = [
3
+ {
4
+ accessor: "year",
5
+ label: "Year",
6
+ cellAccessors: ["quarter", "month", "day"],
7
+ },
8
+ {
9
+ accessor: "newEnrollments",
10
+ label: "New Enrollments",
11
+ custom_header_renderer: ->(cell, label) {
12
+ capture do
13
+ pb_rails("flex", props: { align_items: "center", justify_content: "center" }) do
14
+ pb_rails("caption", props: { margin_right: "xs", text: "New Enrollments" }) +
15
+ pb_rails("icon", props: { id: "tooltip-interact", icon: "info", size: "xs" }) +
16
+ pb_rails("tooltip", props: {
17
+ trigger_element_id: "tooltip-interact",
18
+ tooltip_id: "example-custom-tooltip",
19
+ position: "top",
20
+ z_index: "10"
21
+ }) do
22
+ "Whoa. I'm a Tooltip"
23
+ end
24
+ end
25
+ end
26
+ }
27
+ },
28
+ {
29
+ accessor: "scheduledMeetings",
30
+ label: "Scheduled Meetings",
31
+ },
32
+ {
33
+ accessor: "attendanceRate",
34
+ label: "Attendance Rate",
35
+ },
36
+ {
37
+ accessor: "completedClasses",
38
+ label: "Completed Classes",
39
+ },
40
+ {
41
+ accessor: "classCompletionRate",
42
+ label: "Class Completion Rate",
43
+ },
44
+ {
45
+ accessor: "graduatedStudents",
46
+ label: "Graduated Students",
47
+ }
48
+ ]
49
+ %>
50
+
51
+ <%= pb_rails("advanced_table", props: { id: "custom_header_table", table_data: @table_data, column_definitions: column_definitions }) %>
@@ -0,0 +1 @@
1
+ The optional `custom_header_renderer` item can be used within `column_definitions` to render a custom header. This example shows an Icon and Tooltip being used but other kits can be used as well.
@@ -10,23 +10,25 @@ examples:
10
10
  - advanced_table_beta_sort: Enable Sorting
11
11
  - advanced_table_responsive: Responsive Tables
12
12
  - advanced_table_custom_cell_rails: Custom Components for Cells
13
+ - advanced_table_with_custom_header_rails: Custom Header Cell
13
14
  - advanced_table_column_headers: Multi-Header Columns
14
15
  - advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
15
- - advanced_table_column_border_color_rails: Column Group Border Color
16
16
  - advanced_table_no_subrows: Table with No Subrows or Expansion
17
17
  - advanced_table_selectable_rows_rails: Selectable Rows
18
18
  - advanced_table_selectable_rows_no_subrows_rails: Selectable Rows (No Subrows)
19
19
  - advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
20
20
  - advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
21
21
  - advanced_table_scrollbar_none: Advanced Table Scrollbar None
22
- # - advanced_table_column_styling_rails: Column Styling
23
- # - advanced_table_column_styling_column_headers_rails: Column Styling with Multiple Headers
22
+ - advanced_table_column_styling_rails: Column Styling
23
+ - advanced_table_column_styling_column_headers_rails: Column Styling with Multiple Headers
24
+ - advanced_table_column_border_color_rails: Column Group Border Color
25
+
24
26
 
25
27
  react:
26
28
  - advanced_table_default: Default (Required Props)
27
- - advanced_table_loading: Loading State
28
29
  - advanced_table_sort: Enable Sorting
29
30
  - advanced_table_sort_control: Sort Control
31
+ - advanced_table_custom_sort: Custom Sort
30
32
  - advanced_table_expanded_control: Expanded Control
31
33
  - advanced_table_expand_by_depth: Expand by Depth
32
34
  - advanced_table_subrow_headers: SubRow Headers
@@ -37,29 +39,31 @@ examples:
37
39
  - advanced_table_table_props_sticky_header: Sticky Header for Responsive Table
38
40
  - advanced_table_sticky_columns: Sticky Columns
39
41
  - advanced_table_sticky_columns_and_header: Sticky Columns with Sticky Header
40
- - advanced_table_inline_row_loading: Inline Row Loading
41
42
  - advanced_table_responsive: Responsive Tables
42
43
  - advanced_table_custom_cell: Custom Components for Cells
44
+ - advanced_table_with_custom_header: Custom Header Cell
43
45
  - advanced_table_pagination: Pagination
44
46
  - advanced_table_pagination_with_props: Pagination Props
47
+ - advanced_table_loading: Loading State
48
+ - advanced_table_inline_row_loading: Inline Row Loading
45
49
  - advanced_table_column_headers: Multi-Header Columns
46
50
  - advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
47
51
  - advanced_table_column_headers_custom_cell: Multi-Header Columns with Custom Cells
48
- - advanced_table_column_border_color: Column Group Border Color
49
52
  - advanced_table_no_subrows: Table with No Subrows or Expansion
53
+ - advanced_table_pinned_rows: Pinned Rows
50
54
  - advanced_table_selectable_rows: Selectable Rows
51
55
  - advanced_table_selectable_rows_no_subrows_react: Selectable Rows (No Subrows)
52
56
  - advanced_table_selectable_rows_actions: Selectable Rows (With Actions)
53
57
  - advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
54
58
  - advanced_table_inline_editing: Inline Cell Editing
55
- - advanced_table_fullscreen: Fullscreen
56
59
  - advanced_table_column_visibility: Column Visibility Control
57
60
  - advanced_table_column_visibility_with_state: Column Visibility Control With State
58
61
  - advanced_table_column_visibility_custom: Column Visibility Control with Custom Dropdown
59
62
  - advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
60
- - advanced_table_pinned_rows: Pinned Rows
61
63
  - advanced_table_scrollbar_none: Advanced Table Scrollbar None
62
64
  - advanced_table_row_styling: Row Styling
63
65
  - advanced_table_column_styling: Column Styling
64
66
  - advanced_table_column_styling_column_headers: Column Styling with Multiple Headers
67
+ - advanced_table_column_border_color: Column Group Border Color
68
+ - advanced_table_fullscreen: Fullscreen
65
69
  - advanced_table_infinite_scroll: Infinite Scroll
@@ -38,3 +38,5 @@ export { default as AdvancedTableRowStyling } from './_advanced_table_row_stylin
38
38
  export { default as AdvancedTableColumnStyling } from './_advanced_table_column_styling.jsx'
39
39
  export { default as AdvancedTableColumnStylingColumnHeaders } from './_advanced_table_column_styling_column_headers.jsx'
40
40
  export { default as AdvancedTableInfiniteScroll} from './_advanced_table_infinite_scroll.jsx'
41
+ export {default as AdvancedTableWithCustomHeader} from './_advanced_table_with_custom_header.jsx'
42
+ export { default as AdvancedTableCustomSort } from './_advanced_table_custom_sort.jsx'
@@ -26,7 +26,11 @@
26
26
  <% end %>
27
27
  <% end %>
28
28
  <% end %>
29
- <%= cell[:label] %>
29
+ <% if object.has_custom_header_renderer?(cell) %>
30
+ <%= raw(object.render_custom_header(cell)) %>
31
+ <% else %>
32
+ <%= cell[:label] %>
33
+ <% end %>
30
34
  <% end %>
31
35
  <% end %>
32
36
  <% end %>
@@ -76,6 +76,30 @@ module Playbook
76
76
  end
77
77
  end
78
78
 
79
+ # Get original column definition for custom rendering
80
+ def find_original_column_def(accessor)
81
+ find_column_def_by_accessor(column_definitions, accessor)
82
+ end
83
+
84
+ # Check if a header cell has a custom renderer
85
+ def has_custom_header_renderer?(cell)
86
+ return false unless cell[:accessor].present?
87
+
88
+ original_def = find_original_column_def(cell[:accessor])
89
+ original_def && original_def[:custom_header_renderer].present?
90
+ end
91
+
92
+ # Render custom header content
93
+ def render_custom_header(cell)
94
+ return cell[:label] unless has_custom_header_renderer?(cell)
95
+
96
+ original_def = find_original_column_def(cell[:accessor])
97
+ custom_renderer = original_def[:custom_header_renderer]
98
+
99
+ # Call the custom renderer with the cell data and label
100
+ custom_renderer.call(cell, cell[:label])
101
+ end
102
+
79
103
  private
80
104
 
81
105
  def compute_max_depth(columns)
@@ -148,6 +172,18 @@ module Playbook
148
172
  end
149
173
  wrapped
150
174
  end
175
+
176
+ def find_column_def_by_accessor(defs, target_accessor)
177
+ defs.each do |col|
178
+ return col if col[:accessor] == target_accessor
179
+
180
+ if col[:columns].is_a?(Array)
181
+ found = find_column_def_by_accessor(col[:columns], target_accessor)
182
+ return found if found
183
+ end
184
+ end
185
+ nil
186
+ end
151
187
  end
152
188
  end
153
189
  end
@@ -30,11 +30,11 @@
30
30
  class="gray-icon expand-toggle-icon"
31
31
  data-advanced-table="true">
32
32
  <%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
33
- <%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
33
+ <%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play-down", cursor: "pointer" }) %>
34
34
  </button>
35
35
  <% end %>
36
36
  <% end %>
37
- <%= pb_rails("flex/flex_item") do %>
37
+ <%= pb_rails("flex/flex_item") do %>
38
38
  <% if column[:custom_renderer].present? %>
39
39
  <%= raw(column[:custom_renderer].call(object.row, custom_renderer_value(column, index))) %>
40
40
  <% elsif index.zero? %>
@@ -5,7 +5,7 @@
5
5
  @import "../tokens/typography";
6
6
 
7
7
  [class^=pb_badge_kit] {
8
- $pb_badge_height: 18px;
8
+ $pb_badge_height_rounded: 16px;
9
9
 
10
10
  display: inline-flex;
11
11
  align-items: center;
@@ -13,7 +13,6 @@
13
13
  border-radius: $border_rad_light;
14
14
  padding: 0 $space_xs/2;
15
15
  border-width: 1px;
16
- border-style: solid;
17
16
  border-color: $card_light;
18
17
  white-space: nowrap;
19
18
 
@@ -31,10 +30,10 @@
31
30
  }
32
31
 
33
32
  &[class*=_rounded] {
34
- height: $pb_badge_height;
35
- min-height: $pb_badge_height;
36
- min-width: $pb_badge_height;
37
- border-radius: $pb_badge_height / 2;
33
+ height: $pb_badge_height_rounded;
34
+ min-height: $pb_badge_height_rounded;
35
+ min-width: $pb_badge_height_rounded;
36
+ border-radius: $pb_badge_height_rounded / 2;
38
37
  }
39
38
 
40
39
  &[class*=_notification] {