playbook_ui_docs 14.20.0.pre.alpha.PLAY2170checkboxrailsindeterminatelogicinkitPOC7980 → 14.20.0.pre.alpha.PLAY2178advancedtablerowpinning7983

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: fc5131eae9b5f300e6bfaaac89406f5976ed655a7a21738c7413963e4ac71c46
4
- data.tar.gz: 37a37195fe377d1225a85232aba158e1e5aa1378a2d8837b1fcfc902b0447414
3
+ metadata.gz: a181bbcea2dd2c2b1edd9f1102ff43c239d96b3939dd3b2c10423a9d929986e9
4
+ data.tar.gz: fc78caafbfa14e6cc8dd04cb16db7b97ed06c3f94616957b89a08af07b807217
5
5
  SHA512:
6
- metadata.gz: 2b07cad00d9c044ff8ec65d90f7b72dc6f757c724f61bb5ebd994c24babbc5d944224ea34ad7514d4ccdd81b2616e00b23713e09e4512a3795ff9863228f88a6
7
- data.tar.gz: 21f597eae15847f19c80de19bf9787f6a5ac7f5245207c0263301f26c277628e7d77678394fd2ff8882c9721a20c7a887c015a98ec780e91ff5a0f328b9323e2
6
+ metadata.gz: dd2c623ed58af7369d3c38ebcade47f3550c8fc0dbd541bfb5090167908b736359312fc46167d025b988eaf4b0b059681350cded6a8dfddc3fa353619bf6a30b
7
+ data.tar.gz: '0180aa22ea3eacdf10427f1512975d83b0d003be34681095e14a2efb965a9c889a4039e82b019d9b0a1ddb44430a3348a63b44aa8cc76fc5b26a8bb1f6019821'
@@ -0,0 +1,57 @@
1
+ import React, { useState } from "react"
2
+ import AdvancedTable from '../_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data_with_id.json"
4
+
5
+ const AdvancedTableRowPinning = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ const [pinnedRows, setPinnedRows] = useState({top: ["8", "9", "10", "11", "12", "13", "14"]})
39
+
40
+ return (
41
+ <div>
42
+ <AdvancedTable
43
+ columnDefinitions={columnDefinitions}
44
+ maxHeight="xs"
45
+ pinnedRows={{value: pinnedRows, onChange: setPinnedRows}}
46
+ tableData={MOCK_DATA}
47
+ tableProps={{sticky: true}}
48
+ {...props}
49
+ >
50
+ <AdvancedTable.Header enableSorting />
51
+ <AdvancedTable.Body />
52
+ </AdvancedTable>
53
+ </div>
54
+ )
55
+ }
56
+
57
+ export default AdvancedTableRowPinning
@@ -0,0 +1,5 @@
1
+ Use the `pinnedRows` prop to pin specific rows to the top of an Advanced Table. Pinned rows will remain at the top when scrolling through table data and reorganizing via sorting.
2
+
3
+ **NOTE:** This prop is in Beta. Current Requirements for V1:
4
+ - Sticky header required: Pinned rows must be used with `sticky: true` via `tableProps` (works with both responsive and non-responsive tables)
5
+ - Row ids required: Pass an array of row ids to the `top` property. For expandable rows, both parent and all its child row ids must be included individually
@@ -52,4 +52,5 @@ examples:
52
52
  - advanced_table_column_visibility: Column Visibility Control
53
53
  - advanced_table_column_visibility_with_state: Column Visibility Control With State
54
54
  - advanced_table_column_visibility_custom: Column Visibility Control with Custom Dropdown
55
- - advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
55
+ - advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
56
+ - advanced_table_pinned_rows: Pinned Rows
@@ -31,4 +31,5 @@ export { default as AdvancedTableColumnBorderColor} from './_advanced_table_colu
31
31
  export { default as AdvancedTableColumnVisibility } from './_advanced_table_column_visibility.jsx'
32
32
  export { default as AdvancedTableColumnVisibilityCustom } from './_advanced_table_column_visibility_custom.jsx'
33
33
  export { default as AdvancedTableColumnVisibilityMulti } from './_advanced_table_column_visibility_multi.jsx'
34
- export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
34
+ export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
35
+ export { default as AdvancedTablePinnedRows } from './_advanced_table_pinned_rows.jsx'
@@ -9,10 +9,11 @@
9
9
  <tr>
10
10
  <th>
11
11
  <%= pb_rails("checkbox", props: {
12
+ checked: true,
12
13
  text: "Uncheck All",
13
14
  value: "checkbox-value",
14
15
  name: "main-checkbox",
15
- indeterminate_main: true,
16
+ indeterminate: true,
16
17
  id: "indeterminate-checkbox"
17
18
  }) %>
18
19
  </th>
@@ -29,10 +30,55 @@
29
30
  value: checkbox[:id],
30
31
  name: "#{checkbox[:id]}-indeterminate-checkbox",
31
32
  id: "#{checkbox[:id]}-indeterminate-checkbox",
32
- indeterminate_parent: "indeterminate-checkbox",
33
33
  }) %>
34
34
  </td>
35
35
  </tr>
36
36
  <% end %>
37
37
  </tbody>
38
38
  <% end %>
39
+
40
+ <script>
41
+ document.addEventListener('DOMContentLoaded', function() {
42
+ const mainCheckboxWrapper = document.getElementById('indeterminate-checkbox');
43
+ const mainCheckbox = document.getElementsByName("main-checkbox")[0];
44
+ const childCheckboxes = document.querySelectorAll('input[type="checkbox"][id$="indeterminate-checkbox"]');
45
+
46
+ const updateMainCheckbox = () => {
47
+ // Count the number of checked child checkboxes
48
+ const checkedCount = Array.from(childCheckboxes).filter(cb => cb.checked).length;
49
+ // Determine if the main checkbox should be in an indeterminate state
50
+ const indeterminate = checkedCount > 0 && checkedCount < childCheckboxes.length;
51
+
52
+ // Set the main checkbox states
53
+ mainCheckbox.indeterminate = indeterminate;
54
+ mainCheckbox.checked = checkedCount > 0;
55
+
56
+ // Determine the main checkbox label based on the number of checked checkboxes
57
+ const text = checkedCount === 0 ? 'Check All' : 'Uncheck All';
58
+
59
+ // Determine the icon class to add and remove based on the number of checked checkboxes
60
+ const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
61
+ const iconClassToRemove = checkedCount === 0 ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
62
+
63
+ // Update main checkbox label
64
+ mainCheckboxWrapper.getElementsByClassName('pb_body_kit')[0].textContent = text;
65
+
66
+ // Add and remove the icon class to the main checkbox wrapper
67
+ mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.add(iconClassToAdd);
68
+ mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.remove(iconClassToRemove);
69
+
70
+ // Toggle the visibility of the checkbox icon based on the indeterminate state
71
+ mainCheckboxWrapper.getElementsByClassName("indeterminate_icon")[0].classList.toggle('hidden', !indeterminate);
72
+ mainCheckboxWrapper.getElementsByClassName("check_icon")[0].classList.toggle('hidden', indeterminate);
73
+ };
74
+
75
+ mainCheckbox.addEventListener('change', function() {
76
+ childCheckboxes.forEach(cb => cb.checked = this.checked);
77
+ updateMainCheckbox();
78
+ });
79
+
80
+ childCheckboxes.forEach(cb => {
81
+ cb.addEventListener('change', updateMainCheckbox);
82
+ });
83
+ });
84
+ </script>