playbook_ui_docs 14.20.0.pre.alpha.revert4453PBNTR933reactdraggablebugdragbtwnexamples7854 → 14.20.0.pre.alpha.revert4453PBNTR933reactdraggablebugdragbtwnexamples7973

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: 362372958ccc7f058b2ea26993671410d4022c1e36f432aecc9d4d9069acdddd
4
- data.tar.gz: a5653acda5e67571212067467a6d9c08e332267c9ba6acdd49f1a33f2cde835a
3
+ metadata.gz: bc17776d189017a4ad2de34e3daa6bee8618ba3eb287c79b79cadc420eaf845c
4
+ data.tar.gz: bd2e67c286c47a33e9a453cb15e69091d8f04d3427ea0015e43f9d9ae0ca6246
5
5
  SHA512:
6
- metadata.gz: ebb22edd40dfaa14eedd91f339ee1d6f422cd34bcc998d509484f6f77525d8be224ab015026ad998591cb18e4908e847f73c6bfc1ae2db21039437c6479ce377
7
- data.tar.gz: 03eb92091dd232460185a6c64168a963319f4996977838a11efc83a37a84722b95830f885fec804124e47d1bbd7e9a614dde361b7f9f35b228372a4c146fd304
6
+ metadata.gz: f2b37109051f522f28f5671e41f50ac02c8ed66b9049c4cc676f4667827039a2a78caaf976d66aa192ac3735f9d010bd93a724f146fd82cb3043a2ea55e8a509
7
+ data.tar.gz: 7953a04ca25b96e0e7caeea935f3c87d0a2a16ecca1de913028636a541c1b28b8878f99bb44cf08bc2d3cd4ab8bb1c00ce2efe06fc489c77fd9936b70297ccb4
@@ -1,4 +1,8 @@
1
- The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
1
+ The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has three required props__:
2
+
3
+ ### id
4
+
5
+ A unique `id` is required to allow the table functionality to work properly. Without it, certain functions like the action bar will not be able to properly reference the correct table.
2
6
 
3
7
  ### table_data
4
8
 
@@ -13,6 +17,6 @@ Column definitions are the single most important part of building a table as the
13
17
  - `accessor`: this is the key from your data for the value you want rendered in that column
14
18
  - `label`: this is what will be rendered as the column header label
15
19
 
16
- There is also one optional item that is only required if the table has nested data:
20
+ There is also one optional item that is only required if the table has nested data:
17
21
 
18
22
  - `cellAccessors`: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
@@ -3,7 +3,7 @@
3
3
  <br />
4
4
  <br />
5
5
 
6
- The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
6
+ The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
7
7
 
8
8
  ### tableData
9
9
 
@@ -0,0 +1,137 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ },
7
+ {
8
+ accessor: "newEnrollments",
9
+ label: "New Enrollments",
10
+ },
11
+ {
12
+ accessor: "scheduledMeetings",
13
+ label: "Scheduled Meetings",
14
+ },
15
+ {
16
+ accessor: "attendanceRate",
17
+ label: "Attendance Rate",
18
+ },
19
+ {
20
+ accessor: "completedClasses",
21
+ label: "Completed Classes",
22
+ },
23
+ {
24
+ accessor: "classCompletionRate",
25
+ label: "Class Completion Rate",
26
+ },
27
+ {
28
+ accessor: "graduatedStudents",
29
+ label: "Graduated Students",
30
+ }
31
+ ]
32
+
33
+ actions = [
34
+ pb_rails("circle_icon_button", props: {
35
+ icon: "file-csv",
36
+ variant: "link",
37
+ id: "export-selected-rows-btn",
38
+ data: {
39
+ action_type: "export"
40
+ }
41
+ }),
42
+ pb_rails("circle_icon_button", props: {
43
+ icon: "trash-alt",
44
+ variant: "link",
45
+ id: "delete-selected-rows-btn",
46
+ data: {
47
+ action_type: "delete"
48
+ }
49
+ })
50
+ ]
51
+ %>
52
+
53
+ <%= pb_rails("advanced_table", props: {
54
+ id: "selectable_rows_with_actions",
55
+ table_data: @table_data_no_subrows,
56
+ column_definitions: column_definitions,
57
+ selectable_rows: true,
58
+ enable_toggle_expansion: "none",
59
+ actions: actions
60
+ }) %>
61
+
62
+ <script>
63
+ // Handle action clicks using the data-selected-rows attribute
64
+ window.handleActionClick = function(actionType) {
65
+ const tableContainer = document.getElementById('selectable_rows_with_actions');
66
+ if (!tableContainer) return;
67
+
68
+ // Get selected rows from the data attribute
69
+ const selectedRowsJSON = tableContainer.getAttribute('data-selected-rows');
70
+ let selectedRowIds = [];
71
+
72
+ try {
73
+ // Parse the JSON string from the data attribute
74
+ if (selectedRowsJSON) {
75
+ selectedRowIds = JSON.parse(selectedRowsJSON);
76
+ }
77
+ } catch (e) {
78
+ // Fallback if JSON parsing fails
79
+ const checkboxes = tableContainer.querySelectorAll('input[type="checkbox"]:checked');
80
+ const selectedCheckboxes = Array.from(checkboxes).filter(checkbox =>
81
+ checkbox.id !== 'select-all-rows' &&
82
+ !checkbox.closest('#select-all-rows')
83
+ );
84
+ selectedRowIds = selectedCheckboxes.map(checkbox => checkbox.id);
85
+ }
86
+
87
+ // Show appropriate message
88
+ if (!selectedRowIds || selectedRowIds.length === 0) {
89
+ alert('No Selection Made');
90
+ } else {
91
+ if (actionType === 'export') {
92
+ alert(`Row ids ${selectedRowIds.join(', ')} will be exported!`);
93
+ } else if (actionType === 'delete') {
94
+ alert(`Row ids ${selectedRowIds.join(', ')} will be deleted!`);
95
+ }
96
+ }
97
+ };
98
+
99
+ // Add event listeners when the DOM is ready
100
+ document.addEventListener('DOMContentLoaded', function() {
101
+ // Get the buttons
102
+ const exportBtn = document.getElementById('export-selected-rows-btn');
103
+ const deleteBtn = document.getElementById('delete-selected-rows-btn');
104
+
105
+ // Add click event listeners
106
+ if (exportBtn) {
107
+ exportBtn.addEventListener('click', function(e) {
108
+ e.preventDefault();
109
+ window.handleActionClick('export');
110
+ });
111
+ }
112
+
113
+ if (deleteBtn) {
114
+ deleteBtn.addEventListener('click', function(e) {
115
+ e.preventDefault();
116
+ window.handleActionClick('delete');
117
+ });
118
+ }
119
+
120
+ // Optional: Event delegation through the action bar
121
+ const actionBar = document.querySelector('.row-selection-actions-card');
122
+ if (actionBar) {
123
+ actionBar.addEventListener('click', function(e) {
124
+ const exportButton = e.target.closest('#export-selected-rows-btn');
125
+ const deleteButton = e.target.closest('#delete-selected-rows-btn');
126
+
127
+ if (exportButton) {
128
+ e.preventDefault();
129
+ window.handleActionClick('export');
130
+ } else if (deleteButton) {
131
+ e.preventDefault();
132
+ window.handleActionClick('delete');
133
+ }
134
+ });
135
+ }
136
+ });
137
+ </script>
@@ -0,0 +1,3 @@
1
+ Custom actions content can be rendered within the Actions Bar as shown in this doc example. The component passed to `actions` will be rendered on the right of the actionsBar.
2
+
3
+ You can utilize script tags with your actions to provide your buttons with any clickable events needed.
@@ -0,0 +1,40 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ },
7
+ {
8
+ accessor: "newEnrollments",
9
+ label: "New Enrollments",
10
+ },
11
+ {
12
+ accessor: "scheduledMeetings",
13
+ label: "Scheduled Meetings",
14
+ },
15
+ {
16
+ accessor: "attendanceRate",
17
+ label: "Attendance Rate",
18
+ },
19
+ {
20
+ accessor: "completedClasses",
21
+ label: "Completed Classes",
22
+ },
23
+ {
24
+ accessor: "classCompletionRate",
25
+ label: "Class Completion Rate",
26
+ },
27
+ {
28
+ accessor: "graduatedStudents",
29
+ label: "Graduated Students",
30
+ }
31
+ ] %>
32
+
33
+ <%= pb_rails("advanced_table", props: {
34
+ id: "selectable_rows_with_actions",
35
+ table_data: @table_data_no_subrows,
36
+ column_definitions: column_definitions,
37
+ selectable_rows: true,
38
+ enable_toggle_expansion: "none",
39
+ show_actions_bar: false
40
+ }) %>
@@ -0,0 +1 @@
1
+ `show_actions_bar` is an optional prop that renders the header at the top showing the row count. This is set to `true` by default but can be toggled off by setting it to `false`
@@ -15,6 +15,8 @@ examples:
15
15
  - advanced_table_column_border_color_rails: Column Group Border Color
16
16
  - advanced_table_selectable_rows_rails: Selectable Rows
17
17
  - advanced_table_selectable_rows_no_subrows_rails: Selectable Rows (No Subrows)
18
+ - advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
19
+ - advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
18
20
 
19
21
  react:
20
22
  - advanced_table_default: Default (Required Props)
@@ -0,0 +1,12 @@
1
+ <%= pb_rails("select", props: { label: "Favorite Animal" }) do %>
2
+ <select name="animal" id="animal">
3
+ <optgroup label="Mammal">
4
+ <option value="1">Cat</option>
5
+ <option value="2">Dog</option>
6
+ </optgroup>
7
+ <optgroup label="Amphibian">
8
+ <option value="3">Frog</option>
9
+ <option value="4">Salamander</option>
10
+ </optgroup>
11
+ </select>
12
+ <% end %>
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+
3
+ import Select from '../_select'
4
+
5
+ const SelectCustomSelectSubheaders = (props) => {
6
+ return (
7
+ <div>
8
+ <Select
9
+ label="Favorite Animal"
10
+ {...props}
11
+ >
12
+ <select
13
+ id="animal"
14
+ name="animal"
15
+ {...props}
16
+ >
17
+ <optgroup label="Mammal">
18
+ <option value="1">{'Cat'}</option>
19
+ <option value="2">{'Dog'}</option>
20
+ </optgroup>
21
+ <optgroup label="Amphibian">
22
+ <option value="3">{'Frog'}</option>
23
+ <option value="4">{'Salamander'}</option>
24
+ </optgroup>
25
+ </select>
26
+ </Select>
27
+ </div>
28
+ )
29
+ }
30
+
31
+ export default SelectCustomSelectSubheaders
@@ -0,0 +1 @@
1
+ To create a select with non-selectable subheaders, use a Custom Select component to render a native `<select>` containing `<optgroup>` elements. The [optgroup HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/optgroup) groups related options under a non-selectable label in the dropdown.
@@ -8,6 +8,7 @@ examples:
8
8
  - select_required: Required Select Field
9
9
  - select_value_text_same: Equal option value and value text
10
10
  - select_custom_select: Custom Select
11
+ - select_custom_select_subheaders: Custom Select Subheaders
11
12
  - select_error: Select w/ Error
12
13
  - select_inline: Select Inline
13
14
  - select_inline_show_arrow: Select Inline (Always Show Arrow)
@@ -25,6 +26,7 @@ examples:
25
26
  - select_required: Required Select Field
26
27
  - select_value_text_same: Equal option value and value text
27
28
  - select_custom_select: Custom Select
29
+ - select_custom_select_subheaders: Custom Select Subheaders
28
30
  - select_error: Select w/ Error
29
31
  - select_inline: Select Inline
30
32
  - select_inline_show_arrow: Select Inline (Always Show Arrow)
@@ -11,3 +11,4 @@ export { default as SelectInlineShowArrow } from './_select_inline_show_arrow.js
11
11
  export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
12
12
  export { default as SelectMultiple } from './_select_multiple.jsx'
13
13
  export { default as SelectReactHook } from './_select_react_hook.jsx'
14
+ export { default as SelectCustomSelectSubheaders } from './_select_custom_select_subheaders.jsx'