playbook_ui_docs 14.20.0 → 14.21.0.pre.rc.0
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 +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +6 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +137 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +40 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.html.erb +12 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.jsx +31 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/dist/playbook-doc.js +2 -2
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dce2e69208f1f0ba3457fd7ebf594e71cf22c2a95c20df36b66063c21117829
|
4
|
+
data.tar.gz: 9d53ddfa9bc5554aaeffbc7921c4cfae4f2955edaa1d22db523974e5ed421731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5deb4d9f7734a92b25ee57ebab8318b45704f6699287cf3969fafa99d4268da5a02e7bc818b1d9c33bab8d01a21dbbaf227503091e26a939e2c1c63130424308
|
7
|
+
data.tar.gz: 882ba26a22a8c031accdfe58cc7304145b433e9dbdb5e9ec53b95d4d2a064508eb46367f7fd79cc165624bcee63baf17f41ac3d2694987eb22ed5089102ed413
|
@@ -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
|
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>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.md
ADDED
@@ -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
|
+
}) %>
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.md
ADDED
@@ -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'
|