playbook_ui 14.24.0.pre.rc.0 → 14.24.0.pre.rc.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e6c42711223f44800761968ff6b12e3e01d675dbf792208ac3af880849420ba
4
- data.tar.gz: 7ac59da841cc4a9040005e6de70ff3e1e87645917aa19714338d8031397d97e9
3
+ metadata.gz: 1d7c921bbafc031c8734dd2fbda179f02f97762f1bb3b4a2964386933139bd51
4
+ data.tar.gz: 87432d1e7a1256d628fbe3d00341b0887cc7f8b2607865d4a5f6ecc16333f772
5
5
  SHA512:
6
- metadata.gz: f0e3d0844fe67b12098f03a4eb1c4c31fd1307d6f4fec41c3c324fbe4645336a89af6abfb7f80a49ba292f6824677c88cd98c9624df441e61a5764605a62bb15
7
- data.tar.gz: 51924ba09262e9be87069173a5b994f843f42e45c4da68def19965c66161842eeef85be41d968c68244b4ffff73337e0dd0afe9d5e141b481ba86460bc0732c5
6
+ metadata.gz: 5bdab5a8aafafab76f68147d22a30729c8a23f8bd50bdc6e8528b3ece3cbb0bfe56fedc4de839bfbeefdb01ee641b4d91ca8e105323d7c8f3202957e9ce49fa5
7
+ data.tar.gz: d17e97778b03d734ab6001803d941dcc7bc04a6369c0758c69ada662639de8e88e3c80191d6d43a7338f80b766882bd36685791c8b74fd390b04238cae42faf5
@@ -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,11 +71,12 @@ export const CustomCell = ({
71
71
  >
72
72
  {row.getIsExpanded() ? (
73
73
  <Icon cursor="pointer"
74
- icon="circle-play-down"
74
+ icon="circle-play"
75
+ rotation={90}
75
76
  />
76
77
  ) : (
77
78
  <Icon cursor="pointer"
78
- icon="circle-play"
79
+ icon="circle-play"
79
80
  />
80
81
  )}
81
82
  </button>
@@ -101,7 +101,6 @@ export const TableHeaderCell = ({
101
101
  if (!header) return false;
102
102
 
103
103
  if (header.colSpan > 1 && header.column.parent !== undefined) return true;
104
-
105
104
  const parent = header.column.parent;
106
105
 
107
106
  if (!parent) {
@@ -83,11 +83,11 @@ export function useTableState({
83
83
  const buildColumns = useCallback((columnDefinitions: GenericObject[], isRoot = true): any[] => {
84
84
  return columnDefinitions?.map((column, index) => {
85
85
  const isFirstColumn = isRoot && index === 0;
86
-
87
86
  // Handle grouped columns
88
87
  if (column.columns && column.columns.length > 0) {
89
88
  return {
90
- header: column.header || column.label || "",
89
+ header: column.header ?? column.label ?? "",
90
+ id: column.id ?? column.label ?? `group-${index}`,
91
91
  columns: buildColumns(column.columns, false),
92
92
  };
93
93
  }
@@ -0,0 +1,107 @@
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 AdvancedTableWithCustomHeaderMultiHeader = (props) => {
10
+
11
+ const columnDefinitions = [
12
+ {
13
+ accessor: "year",
14
+ label: "Year",
15
+ id: "year",
16
+ cellAccessors: ["quarter", "month", "day"],
17
+ },
18
+ {
19
+ label: "Enrollment Data",
20
+ id: "enrollmentData",
21
+ header: () => (
22
+ <Flex alignItems="center"
23
+ justifyContent="center"
24
+ >
25
+ <Caption marginRight="xs">Enrollments Data</Caption>
26
+ <Tooltip placement="top"
27
+ text="Whoa. I'm a Tooltip"
28
+ zIndex={10}
29
+ >
30
+ <Icon cursor="pointer"
31
+ icon="info"
32
+ size="xs"
33
+ />
34
+ </Tooltip>
35
+ </Flex>
36
+ ),
37
+ columns: [
38
+ {
39
+ label: "Enrollment Stats",
40
+ id: "enrollmentStats",
41
+ columns: [
42
+ {
43
+ accessor: "newEnrollments",
44
+ id: "newEnrollments",
45
+ label: "New Enrollments",
46
+ },
47
+ {
48
+ accessor: "scheduledMeetings",
49
+ id: "scheduledMeetings",
50
+ label: "Scheduled Meetings",
51
+ },
52
+ ],
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ label: "Performance Data",
58
+ id: "performanceData",
59
+ columns: [
60
+ {
61
+ label: "Completion Metrics",
62
+ id: "completionMetrics",
63
+ columns: [
64
+ {
65
+ accessor: "completedClasses",
66
+ label: "Completed Classes",
67
+ id: "completedClasses",
68
+ },
69
+ {
70
+ accessor: "classCompletionRate",
71
+ label: "Class Completion Rate",
72
+ id: "classCompletionRate",
73
+ },
74
+ ],
75
+ },
76
+ {
77
+ label: "Attendance",
78
+ id: "attendance",
79
+ columns: [
80
+ {
81
+ accessor: "attendanceRate",
82
+ label: "Attendance Rate",
83
+ id: "attendanceRate",
84
+ },
85
+ {
86
+ accessor: "scheduledMeetings",
87
+ label: "Scheduled Meetings",
88
+ id: "scheduledMeetings",
89
+ },
90
+ ],
91
+ },
92
+ ],
93
+ },
94
+ ];
95
+
96
+ return (
97
+ <div>
98
+ <AdvancedTable
99
+ columnDefinitions={columnDefinitions}
100
+ tableData={MOCK_DATA}
101
+ {...props}
102
+ />
103
+ </div>
104
+ )
105
+ }
106
+
107
+ export default AdvancedTableWithCustomHeaderMultiHeader;
@@ -0,0 +1 @@
1
+ The optional `header` key/value pair within `columnDefinitions` can also be used with multi headers as seen here.
@@ -43,6 +43,7 @@ examples:
43
43
  - advanced_table_responsive: Responsive Tables
44
44
  - advanced_table_custom_cell: Custom Components for Cells
45
45
  - advanced_table_with_custom_header: Custom Header Cell
46
+ - advanced_table_with_custom_header_multi_header: Custom Header with Multiple Headers
46
47
  - advanced_table_pagination: Pagination
47
48
  - advanced_table_pagination_with_props: Pagination Props
48
49
  - advanced_table_loading: Loading State
@@ -40,3 +40,4 @@ export { default as AdvancedTableColumnStylingColumnHeaders } from './_advanced_
40
40
  export { default as AdvancedTableInfiniteScroll} from './_advanced_table_infinite_scroll.jsx'
41
41
  export {default as AdvancedTableWithCustomHeader} from './_advanced_table_with_custom_header.jsx'
42
42
  export { default as AdvancedTableCustomSort } from './_advanced_table_custom_sort.jsx'
43
+ export { default as AdvancedTableWithCustomHeaderMultiHeader } from './_advanced_table_with_custom_header_multi_header.jsx'
@@ -39,11 +39,11 @@
39
39
  style="color: <%= button_color %>"
40
40
  >
41
41
  <%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
42
- <%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play-down", cursor: "pointer" }) %>
42
+ <%= pb_rails("icon", props: { id: "advanced-table_close_icon", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
43
43
  </button>
44
44
  <% end %>
45
45
  <% end %>
46
- <%= pb_rails("flex/flex_item") do %>
46
+ <%= pb_rails("flex/flex_item") do %>
47
47
  <% if column[:custom_renderer].present? %>
48
48
  <%= raw(column[:custom_renderer].call(object.row, custom_renderer_value(column, index))) %>
49
49
  <% elsif index.zero? %>
@@ -6,6 +6,8 @@ module Playbook
6
6
  prop :error, type: Playbook::Props::Boolean, default: false
7
7
  prop :checked, type: Playbook::Props::Boolean, default: false
8
8
  prop :indeterminate_main, type: Playbook::Props::Boolean, default: false
9
+ prop :indeterminate_main_labels, type: Playbook::Props::Array,
10
+ default: []
9
11
  prop :indeterminate_parent
10
12
  prop :text
11
13
  prop :value
@@ -49,10 +51,19 @@ module Playbook
49
51
  end
50
52
 
51
53
  def data
52
- Hash(prop(:data)).merge(
54
+ base_data = Hash(prop(:data)).merge(
53
55
  pb_checkbox_indeterminate_main: indeterminate_main,
54
56
  pb_checkbox_indeterminate_parent: indeterminate_parent
55
57
  )
58
+
59
+ if indeterminate_main && indeterminate_main_labels.size == 2
60
+ base_data.merge!(
61
+ pb_checkbox_indeterminate_main_label_check: indeterminate_main_labels[0],
62
+ pb_checkbox_indeterminate_main_label_uncheck: indeterminate_main_labels[1]
63
+ )
64
+ end
65
+
66
+ base_data
56
67
  end
57
68
 
58
69
  private
@@ -9,10 +9,10 @@
9
9
  <tr>
10
10
  <th>
11
11
  <%= pb_rails("checkbox", props: {
12
- text: "Uncheck All",
13
12
  value: "checkbox-value",
14
13
  name: "main-checkbox",
15
14
  indeterminate_main: true,
15
+ indeterminate_main_labels: ["Check All Ice Cream", "Uncheck All Ice Cream"],
16
16
  id: "indeterminate-checkbox"
17
17
  }) %>
18
18
  </th>
@@ -1 +1,2 @@
1
- If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
1
+ If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
2
+ If you want to customize the main checkbox labels, set an array `indeterminate_main_labels` with "Check All" and "Uncheck All" labels.
@@ -23,7 +23,9 @@ export default class PbCheckbox extends PbEnhancedElement {
23
23
  mainCheckbox.checked = checkedCount > 0;
24
24
 
25
25
  // Determine the main checkbox label based on the number of checked checkboxes
26
- const text = checkedCount === 0 ? 'Check All' : 'Uncheck All';
26
+ const checkAllLabel = mainCheckboxWrapper.dataset.pbCheckboxIndeterminateMainLabelCheck ?? 'Check All'
27
+ const uncheckAllLabel = mainCheckboxWrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck ?? 'Uncheck All'
28
+ const text = checkedCount === 0 ? checkAllLabel : uncheckAllLabel;
27
29
 
28
30
  // Determine the icon class to add and remove based on the number of checked checkboxes
29
31
  const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
@@ -19,6 +19,7 @@
19
19
  value: "checkbox-value",
20
20
  name: "main-checkbox-selectable",
21
21
  indeterminate_main: true,
22
+ indeterminate_main_labels: ["", ""],
22
23
  id: "checkbox-selectable"
23
24
  }) %>
24
25
  <% end %>