playbook_ui 14.21.2.pre.alpha.PLAY2020sidebarfilterPOC8265 → 14.21.2.pre.alpha.PLAY2179playbookiconsupdate8389
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/Components/CustomCell.tsx +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +20 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +25 -5
- data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +36 -16
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +18 -5
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +37 -17
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +91 -40
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ColumnStylingHelper.ts +15 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +49 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +36 -18
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +105 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +51 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +77 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +63 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +38 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.jsx +64 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/index.js +21 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +33 -0
- data/dist/chunks/_typeahead-BXD634Vm.js +22 -0
- data/dist/chunks/_weekday_stacked--dPf0i--.js +45 -0
- data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
- data/dist/chunks/lib-9VvC3Rp0.js +29 -0
- data/dist/chunks/{pb_form_validation-DSkdRDMf.js → pb_form_validation-CbyL4Bqa.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +3 -3
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +19 -7
- data/dist/chunks/_typeahead-CoOpeYom.js +0 -22
- data/dist/chunks/_weekday_stacked-BitxTXxk.js +0 -45
- data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
- data/dist/chunks/lib-D7Va7yqa.js +0 -29
@@ -0,0 +1,64 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import AdvancedTable from '../_advanced_table'
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data_with_id.json"
|
4
|
+
import { colors } from "playbook-ui"
|
5
|
+
|
6
|
+
const AdvancedTableRowStyling = (props) => {
|
7
|
+
const columnDefinitions = [
|
8
|
+
{
|
9
|
+
accessor: "year",
|
10
|
+
label: "Year",
|
11
|
+
cellAccessors: ["quarter", "month", "day"],
|
12
|
+
},
|
13
|
+
{
|
14
|
+
accessor: "newEnrollments",
|
15
|
+
label: "New Enrollments",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
accessor: "scheduledMeetings",
|
19
|
+
label: "Scheduled Meetings",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
accessor: "attendanceRate",
|
23
|
+
label: "Attendance Rate",
|
24
|
+
},
|
25
|
+
{
|
26
|
+
accessor: "completedClasses",
|
27
|
+
label: "Completed Classes",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
accessor: "classCompletionRate",
|
31
|
+
label: "Class Completion Rate",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
accessor: "graduatedStudents",
|
35
|
+
label: "Graduated Students",
|
36
|
+
},
|
37
|
+
]
|
38
|
+
|
39
|
+
const rowStyling = [
|
40
|
+
{
|
41
|
+
rowId: "1",
|
42
|
+
backgroundColor: colors.warning,
|
43
|
+
},
|
44
|
+
{
|
45
|
+
rowId: "8",
|
46
|
+
backgroundColor: colors.category_1,
|
47
|
+
fontColor: colors.white,
|
48
|
+
expandButtonColor: colors.white,
|
49
|
+
},
|
50
|
+
];
|
51
|
+
|
52
|
+
return (
|
53
|
+
<div>
|
54
|
+
<AdvancedTable
|
55
|
+
columnDefinitions={columnDefinitions}
|
56
|
+
rowStyling={rowStyling}
|
57
|
+
tableData={MOCK_DATA}
|
58
|
+
{...props}
|
59
|
+
/>
|
60
|
+
</div>
|
61
|
+
)
|
62
|
+
}
|
63
|
+
|
64
|
+
export default AdvancedTableRowStyling
|
@@ -0,0 +1,7 @@
|
|
1
|
+
The `rowStyling` prop can be used in conjunction with row ids to control certain styling options on individual rows. Currently, `rowStyling` gives you 3 optional controls:
|
2
|
+
|
3
|
+
- `backgroundColor` : use this to control the background color of the row
|
4
|
+
- `fontColor`: use this to control font color for each row if needed, for example if using a darker background color.
|
5
|
+
- `expandButtonColor`: use this to control the color of the expand icon if needed, for example if using a darker background color.
|
6
|
+
|
7
|
+
**NOTE:** Each object within the `tableData` Array must contain a unique id in order to attach an id to all Rows for this to function.
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions.jsx
CHANGED
@@ -47,14 +47,14 @@ const CustomActions = () => {
|
|
47
47
|
<CircleIconButton
|
48
48
|
icon="file-csv"
|
49
49
|
onClick={() =>
|
50
|
-
alert(rowIds.length === 0 ? "No Selection Made" :
|
50
|
+
alert(rowIds.length === 0 ? "No Selection Made" : 'Row ids ' + rowIds.join(", ") + 'will be exported!')
|
51
51
|
}
|
52
52
|
variant="link"
|
53
53
|
/>
|
54
54
|
<CircleIconButton
|
55
55
|
icon="trash-alt"
|
56
56
|
onClick={() =>
|
57
|
-
alert(rowIds.length === 0 ? "No Selection Made" :
|
57
|
+
alert(rowIds.length === 0 ? "No Selection Made" : 'Row ids ' + rowIds.join(", ") + 'will be deleted!')
|
58
58
|
}
|
59
59
|
variant="link"
|
60
60
|
/>
|
@@ -88,10 +88,11 @@ actions = [
|
|
88
88
|
if (!selectedRowIds || selectedRowIds.length === 0) {
|
89
89
|
alert('No Selection Made');
|
90
90
|
} else {
|
91
|
+
const selectedRowsString = selectedRowIds.join(', ');
|
91
92
|
if (actionType === 'export') {
|
92
|
-
alert(
|
93
|
+
alert('Row ids ' + selectedRowsString + ' will be exported!');
|
93
94
|
} else if (actionType === 'delete') {
|
94
|
-
alert(
|
95
|
+
alert('Row ids ' + selectedRowsString + ' will be deleted!');
|
95
96
|
}
|
96
97
|
}
|
97
98
|
};
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb
CHANGED
@@ -30,4 +30,4 @@
|
|
30
30
|
}
|
31
31
|
] %>
|
32
32
|
|
33
|
-
<%= pb_rails("advanced_table", props: { id: "
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_sticky_table", table_data: @table_data, column_definitions: column_definitions, max_height: "xs", table_props: { sticky: true }}) %>
|
@@ -19,6 +19,8 @@ examples:
|
|
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
24
|
|
23
25
|
react:
|
24
26
|
- advanced_table_default: Default (Required Props)
|
@@ -57,3 +59,7 @@ examples:
|
|
57
59
|
- advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
|
58
60
|
- advanced_table_pinned_rows: Pinned Rows
|
59
61
|
- advanced_table_scrollbar_none: Advanced Table Scrollbar None
|
62
|
+
- advanced_table_row_styling: Row Styling
|
63
|
+
- advanced_table_column_styling: Column Styling
|
64
|
+
- advanced_table_column_styling_column_headers: Column Styling with Multiple Headers
|
65
|
+
- advanced_table_infinite_scroll: Infinite Scroll
|
@@ -34,3 +34,7 @@ export { default as AdvancedTableColumnVisibilityMulti } from './_advanced_table
|
|
34
34
|
export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
|
35
35
|
export { default as AdvancedTablePinnedRows } from './_advanced_table_pinned_rows.jsx'
|
36
36
|
export { default as AdvancedTableScrollbarNone} from './_advanced_table_scrollbar_none.jsx'
|
37
|
+
export { default as AdvancedTableRowStyling } from './_advanced_table_row_styling.jsx'
|
38
|
+
export { default as AdvancedTableColumnStyling } from './_advanced_table_column_styling.jsx'
|
39
|
+
export { default as AdvancedTableColumnStylingColumnHeaders } from './_advanced_table_column_styling_column_headers.jsx'
|
40
|
+
export { default as AdvancedTableInfiniteScroll} from './_advanced_table_infinite_scroll.jsx'
|
@@ -266,6 +266,25 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
266
266
|
this.updateTableSelectedRowsAttribute();
|
267
267
|
});
|
268
268
|
}
|
269
|
+
this.addBorderRadiusOnLastVisibleRow()
|
270
|
+
}
|
271
|
+
|
272
|
+
addBorderRadiusOnLastVisibleRow() {
|
273
|
+
const parentElement = this.element.closest('.pb_advanced_table');
|
274
|
+
|
275
|
+
const table = document.getElementById(parentElement.id);
|
276
|
+
|
277
|
+
if (table) {
|
278
|
+
const visibleRows = table.querySelectorAll('tr.is-visible, tr:not(.toggle-content)');
|
279
|
+
|
280
|
+
visibleRows.forEach(row => row.classList.remove('last-visible-row'));
|
281
|
+
|
282
|
+
const lastVisibleRow = visibleRows[visibleRows.length - 1];
|
283
|
+
|
284
|
+
if (lastVisibleRow) {
|
285
|
+
lastVisibleRow.classList.add('last-visible-row');
|
286
|
+
}
|
287
|
+
}
|
269
288
|
}
|
270
289
|
|
271
290
|
|
@@ -367,6 +386,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
367
386
|
row.classList.toggle("bg-silver", !isVisible);
|
368
387
|
row.classList.toggle("bg-white", isVisible);
|
369
388
|
}
|
389
|
+
|
390
|
+
this.addBorderRadiusOnLastVisibleRow();
|
370
391
|
}
|
371
392
|
|
372
393
|
displayDownArrow() {
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<% header_row.each_with_index do |cell, cell_index| %>
|
8
8
|
<% header_id = cell[:accessor].present? ? cell[:accessor] : "header_#{row_index}_#{cell_index}" %>
|
9
9
|
<%= pb_rails("table/table_header", props: { id: header_id, colspan: cell[:colspan], classname: [object.th_classname(is_first_column: cell_index.zero?), ('last-header-cell' if cell[:is_last_in_group] && cell_index != 0)].compact.join(' '), sort_menu: cell[:accessor] ? cell[:sort_menu] : nil }) do %>
|
10
|
-
<%= pb_rails("flex", props: { align: "center", justify: cell_index.zero? ? "start" : row_index === header_rows.size - 1 ? "end" : "center", text_align: "end" }) do %>
|
10
|
+
<%= pb_rails("flex", props: { align: "center", justify: cell_index.zero? ? "start" : row_index === header_rows.size - 1 ? "end" : "center", text_align: (cell[:header_alignment] || "end") }) do %>
|
11
11
|
<% if cell_index.zero? && row_index === header_rows.size - 1 %>
|
12
12
|
<% if object.selectable_rows && object.enable_toggle_expansion != "none" %>
|
13
13
|
<%= pb_rails("flex/flex_item", props: { padding_right: "xs" }) do %>
|
@@ -98,6 +98,9 @@ module Playbook
|
|
98
98
|
|
99
99
|
process_columns(col[:columns], rows, current_depth + 1, max_depth)
|
100
100
|
else
|
101
|
+
raw_styling = col[:column_styling] || {}
|
102
|
+
header_alignment = raw_styling[:header_alignment]
|
103
|
+
|
101
104
|
colspan = 1
|
102
105
|
rows[current_depth] << {
|
103
106
|
label: col[:label],
|
@@ -105,6 +108,7 @@ module Playbook
|
|
105
108
|
accessor: col[:accessor],
|
106
109
|
sort_menu: col[:sort_menu],
|
107
110
|
is_last_in_group: is_last && current_depth.positive?,
|
111
|
+
header_alignment: header_alignment,
|
108
112
|
}
|
109
113
|
end
|
110
114
|
end
|
@@ -137,6 +141,7 @@ module Playbook
|
|
137
141
|
accessor: col[:accessor],
|
138
142
|
label: col[:label] || "",
|
139
143
|
sort_menu: col[:sort_menu] || nil,
|
144
|
+
column_styling: col[:column_styling] || {},
|
140
145
|
}
|
141
146
|
(max_depth - 1).times do
|
142
147
|
wrapped = { label: "", columns: [wrapped] }
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<% object.column_definitions.each_with_index do |column, index| %>
|
7
7
|
<% next unless column[:accessor].present? %>
|
8
8
|
<%= pb_rails("table/table_cell", props: { classname:object.td_classname(column, index)}) do %>
|
9
|
-
<%= pb_rails("flex", props:{ align: "center", justify:
|
9
|
+
<%= pb_rails("flex", props:{ align: "center", justify: object.justify_for(column, index), classname: object.loading ? "loading-cell" : "" }) do %>
|
10
10
|
<% if collapsible_trail && index.zero? %>
|
11
11
|
<% (1..depth).each do |i| %>
|
12
12
|
<% additional_offset = i > 1 ? (i - 1) * 0.25 : 0 %>
|
@@ -34,7 +34,7 @@
|
|
34
34
|
</button>
|
35
35
|
<% end %>
|
36
36
|
<% end %>
|
37
|
-
<%= pb_rails("flex/flex_item"
|
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? %>
|
@@ -80,6 +80,20 @@ module Playbook
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
def justify_for(column, index)
|
84
|
+
if index.zero?
|
85
|
+
"start"
|
86
|
+
else
|
87
|
+
case cell_alignment_for(column)
|
88
|
+
when "left" then "start"
|
89
|
+
when "center" then "center"
|
90
|
+
when "right" then "end"
|
91
|
+
else
|
92
|
+
"end"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
83
97
|
private
|
84
98
|
|
85
99
|
def custom_renderer_value(column, index)
|
@@ -103,6 +117,25 @@ module Playbook
|
|
103
117
|
def subrow_depth_classname
|
104
118
|
depth.positive? ? "depth-sub-row-#{depth}" : ""
|
105
119
|
end
|
120
|
+
|
121
|
+
def find_column_def_by_accessor(defs, target_accessor)
|
122
|
+
defs.each do |col|
|
123
|
+
return col if col[:accessor] == target_accessor
|
124
|
+
|
125
|
+
if col[:columns].is_a?(Array)
|
126
|
+
found = find_column_def_by_accessor(col[:columns], target_accessor)
|
127
|
+
return found if found
|
128
|
+
end
|
129
|
+
end
|
130
|
+
nil
|
131
|
+
end
|
132
|
+
|
133
|
+
def cell_alignment_for(column)
|
134
|
+
return nil unless column[:accessor]
|
135
|
+
|
136
|
+
orig_def = find_column_def_by_accessor(column_definitions, column[:accessor])
|
137
|
+
orig_def[:column_styling][:cell_alignment] if orig_def && orig_def[:column_styling].is_a?(Hash)
|
138
|
+
end
|
106
139
|
end
|
107
140
|
end
|
108
141
|
end
|