playbook_ui 14.9.0.pre.rc.8 → 14.9.0.pre.rc.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +1 -1
- 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_custom_cell_rails.html.erb +53 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +15 -0
- data/app/pb_kits/playbook/pb_table/_table.tsx +103 -24
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +87 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +2 -0
- data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +4 -0
- data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +18 -0
- data/dist/chunks/_weekday_stacked-BDFu4IMD.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +9 -3
- data/dist/chunks/_weekday_stacked-Cup4SPuD.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e75cb19f382af8d53b3c588b3ef84978512fab3c3369fcc7d0a971a64a962298
|
4
|
+
data.tar.gz: 8d8df7a92ad1ec2b01d4c67e898ce471cc67d5c865a426fc08aecec431451687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf02d8ed242ee067842ef2b20bf606a4891978203e73a4e411f175b9154e7f6c833d513aee0b84ce04a39003482690f73b7952bdeecbf9da4e7311828ac0c270
|
7
|
+
data.tar.gz: 51cc4cee3b67a283dd4476b5412a3520660b1fd5fdf54d633c7a6e7cca9b52f94fd82802c193fb3e2ceca1c1788bf35c23c9ae28f07a7c0e85778f2382550d0f
|
@@ -55,5 +55,5 @@
|
|
55
55
|
|
56
56
|
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
|
57
57
|
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
58
|
-
<%= pb_rails("advanced_table/table_body", props: { id: "
|
58
|
+
<%= pb_rails("advanced_table/table_body", props: { id: "beta_sort", table_data: @table_data, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
|
59
59
|
<% end %>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<%
|
2
|
+
column_definitions = [
|
3
|
+
{
|
4
|
+
accessor: "year",
|
5
|
+
label: "Year",
|
6
|
+
cellAccessors: ["quarter", "month", "day"],
|
7
|
+
custom_renderer: ->(row, value) {
|
8
|
+
capture do
|
9
|
+
pb_rails("flex") do
|
10
|
+
pb_rails("title", props: { text: value, size: 4 }) +
|
11
|
+
pb_rails("badge", props: { dark: true, margin_left: "xxs", text: row[:newEnrollments].to_i > 20 ? "High" : "Low", variant: "neutral" })
|
12
|
+
end
|
13
|
+
end
|
14
|
+
}
|
15
|
+
},
|
16
|
+
{
|
17
|
+
accessor: "newEnrollments",
|
18
|
+
label: "New Enrollments",
|
19
|
+
custom_renderer: ->(row, value) { pb_rails("pill", props: { text: value, variant: "success" }) }
|
20
|
+
},
|
21
|
+
{
|
22
|
+
accessor: "scheduledMeetings",
|
23
|
+
label: "Scheduled Meetings",
|
24
|
+
custom_renderer: ->(row, value) { content_tag(:a, value, href: "#") }
|
25
|
+
},
|
26
|
+
{
|
27
|
+
accessor: "attendanceRate",
|
28
|
+
label: "Attendance Rate",
|
29
|
+
custom_renderer: ->(row, value) {
|
30
|
+
capture do
|
31
|
+
pb_rails("flex", props: { align_items: "end", orientation: "column" }) do
|
32
|
+
pb_rails("detail", props: { bold: true, color: "default", text: value }) +
|
33
|
+
pb_rails("caption", props: { size: "xs", text: row[:graduatedStudents] })
|
34
|
+
end
|
35
|
+
end
|
36
|
+
}
|
37
|
+
},
|
38
|
+
{
|
39
|
+
accessor: "completedClasses",
|
40
|
+
label: "Completed Classes",
|
41
|
+
},
|
42
|
+
{
|
43
|
+
accessor: "classCompletionRate",
|
44
|
+
label: "Class Completion Rate",
|
45
|
+
},
|
46
|
+
{
|
47
|
+
accessor: "graduatedStudents",
|
48
|
+
label: "Graduated Students",
|
49
|
+
}
|
50
|
+
]
|
51
|
+
%>
|
52
|
+
|
53
|
+
<%= pb_rails("advanced_table", props: { id: "custom_cell", table_data: @table_data, column_definitions: column_definitions }) %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The Advanced Table also allows for rendering custom components within individual Cells. To achieve this, you can make use of the optional `custom_renderer` item within each column_definitions. This function gives you access to the current Cell's value if you just want to use that with a custom Kit, but it also gives you access to the entire `row` object. The row object provides all data for the current row.
|
2
|
+
|
3
|
+
See [here](https://playbook.powerapp.cloud/kits/advanced_table/rails#column_definitions) for more indepth information on column_definitions are how to use them.
|
4
|
+
|
5
|
+
See [here](https://github.com/powerhome/playbook/tree/master/playbook/app/pb_kits/playbook/pb_advanced_table#readme) for the structure of the table_data used.
|
@@ -3,6 +3,7 @@ examples:
|
|
3
3
|
- advanced_table_beta: Default (Required Props)
|
4
4
|
- advanced_table_beta_subrow_headers: SubRow Headers
|
5
5
|
- advanced_table_beta_sort: Enable Sorting
|
6
|
+
- advanced_table_custom_cell_rails: Custom Components for Cells
|
6
7
|
|
7
8
|
react:
|
8
9
|
- advanced_table_default: Default (Required Props)
|
@@ -11,7 +11,9 @@
|
|
11
11
|
</button>
|
12
12
|
<% end %>
|
13
13
|
<%= pb_rails("flex/flex_item", props:{padding_left: index.zero? && object.row[:children].present? ? "none" : "xs"}) do %>
|
14
|
-
<% if
|
14
|
+
<% if column[:custom_renderer].present? %>
|
15
|
+
<%= raw(column[:custom_renderer].call(object.row, custom_renderer_value(column, index))) %>
|
16
|
+
<% elsif index.zero? %>
|
15
17
|
<% if object.depth.zero? %>
|
16
18
|
<%= object.row[column[:accessor].to_sym] %>
|
17
19
|
<% else %>
|
@@ -26,6 +26,21 @@ module Playbook
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
+
def custom_renderer_value(column, index)
|
30
|
+
if index.zero?
|
31
|
+
if depth.zero?
|
32
|
+
row[column[:accessor].to_sym]
|
33
|
+
else
|
34
|
+
depth_accessors.each_with_index do |item, accessor_index|
|
35
|
+
key = item.to_sym
|
36
|
+
return row[key] if depth - 1 == accessor_index
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
row[column[:accessor].to_sym]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
29
44
|
def subrow_depth_classname
|
30
45
|
depth.positive? ? "depth-sub-row-#{depth}" : ""
|
31
46
|
end
|
@@ -4,11 +4,11 @@ import { buildAriaProps, buildDataProps, buildHtmlProps } from '../utilities/pro
|
|
4
4
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
5
5
|
import PbTable from '.'
|
6
6
|
import {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
TableHead,
|
8
|
+
TableHeader,
|
9
|
+
TableBody,
|
10
|
+
TableRow,
|
11
|
+
TableCell,
|
12
12
|
} from "./subcomponents";
|
13
13
|
|
14
14
|
type TableProps = {
|
@@ -28,6 +28,7 @@ type TableProps = {
|
|
28
28
|
singleLine?: boolean,
|
29
29
|
size?: "sm" | "md" | "lg",
|
30
30
|
sticky?: boolean,
|
31
|
+
stickyLeftcolumn?: string[],
|
31
32
|
striped?: boolean,
|
32
33
|
tag?: "table" | "div",
|
33
34
|
verticalBorder?: boolean,
|
@@ -51,6 +52,7 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
51
52
|
singleLine = false,
|
52
53
|
size = 'sm',
|
53
54
|
sticky = false,
|
55
|
+
stickyLeftcolumn = [],
|
54
56
|
striped = false,
|
55
57
|
tag = 'table',
|
56
58
|
verticalBorder = false,
|
@@ -76,6 +78,7 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
76
78
|
'single-line': singleLine,
|
77
79
|
'no-hover': disableHover,
|
78
80
|
'sticky-header': sticky,
|
81
|
+
'sticky-left-column': stickyLeftcolumn,
|
79
82
|
'striped': striped,
|
80
83
|
[outerPaddingCss]: outerPadding !== '',
|
81
84
|
},
|
@@ -85,6 +88,56 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
85
88
|
className
|
86
89
|
)
|
87
90
|
|
91
|
+
useEffect(() => {
|
92
|
+
const handleStickyColumns = () => {
|
93
|
+
let accumulatedWidth = 0;
|
94
|
+
|
95
|
+
stickyLeftcolumn.forEach((colId, index) => {
|
96
|
+
const isLastColumn = index === stickyLeftcolumn.length - 1;
|
97
|
+
const header = document.querySelector(`th[id="${colId}"]`);
|
98
|
+
const cells = document.querySelectorAll(`td[id="${colId}"]`);
|
99
|
+
|
100
|
+
if (header) {
|
101
|
+
header.classList.add('sticky');
|
102
|
+
(header as HTMLElement).style.left = `${accumulatedWidth}px`;
|
103
|
+
|
104
|
+
if (!isLastColumn) {
|
105
|
+
header.classList.add('with-border');
|
106
|
+
header.classList.remove('sticky-shadow');
|
107
|
+
} else {
|
108
|
+
header.classList.remove('with-border');
|
109
|
+
header.classList.add('sticky-shadow');
|
110
|
+
}
|
111
|
+
|
112
|
+
accumulatedWidth += (header as HTMLElement).offsetWidth;
|
113
|
+
}
|
114
|
+
|
115
|
+
cells.forEach((cell) => {
|
116
|
+
cell.classList.add('sticky');
|
117
|
+
(cell as HTMLElement).style.left = `${accumulatedWidth - (header as HTMLElement).offsetWidth}px`;
|
118
|
+
|
119
|
+
if (!isLastColumn) {
|
120
|
+
cell.classList.add('with-border');
|
121
|
+
cell.classList.remove('sticky-shadow');
|
122
|
+
} else {
|
123
|
+
cell.classList.remove('with-border');
|
124
|
+
cell.classList.add('sticky-shadow');
|
125
|
+
}
|
126
|
+
});
|
127
|
+
});
|
128
|
+
};
|
129
|
+
|
130
|
+
setTimeout(() => {
|
131
|
+
handleStickyColumns();
|
132
|
+
}, 10);
|
133
|
+
|
134
|
+
window.addEventListener('resize', handleStickyColumns);
|
135
|
+
|
136
|
+
return () => {
|
137
|
+
window.removeEventListener('resize', handleStickyColumns);
|
138
|
+
};
|
139
|
+
}, [stickyLeftcolumn]);
|
140
|
+
|
88
141
|
useEffect(() => {
|
89
142
|
const instance = new PbTable()
|
90
143
|
instance.connect()
|
@@ -92,26 +145,52 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
92
145
|
|
93
146
|
return (
|
94
147
|
<>
|
95
|
-
{
|
96
|
-
<table
|
97
|
-
{
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
148
|
+
{responsive === 'scroll' ? (
|
149
|
+
<div className='table-responsive-scroll'>
|
150
|
+
{isTableTag ? (
|
151
|
+
<table
|
152
|
+
{...ariaProps}
|
153
|
+
{...dataProps}
|
154
|
+
{...htmlProps}
|
155
|
+
className={classNames}
|
156
|
+
id={id}
|
157
|
+
>
|
158
|
+
{children}
|
159
|
+
</table>
|
160
|
+
) : (
|
161
|
+
<div
|
162
|
+
{...ariaProps}
|
163
|
+
{...dataProps}
|
164
|
+
{...htmlProps}
|
165
|
+
className={classNames}
|
166
|
+
id={id}
|
167
|
+
>
|
168
|
+
{children}
|
169
|
+
</div>
|
170
|
+
)}
|
114
171
|
</div>
|
172
|
+
) : (
|
173
|
+
isTableTag ? (
|
174
|
+
<table
|
175
|
+
{...ariaProps}
|
176
|
+
{...dataProps}
|
177
|
+
{...htmlProps}
|
178
|
+
className={classNames}
|
179
|
+
id={id}
|
180
|
+
>
|
181
|
+
{children}
|
182
|
+
</table>
|
183
|
+
) : (
|
184
|
+
<div
|
185
|
+
{...ariaProps}
|
186
|
+
{...dataProps}
|
187
|
+
{...htmlProps}
|
188
|
+
className={classNames}
|
189
|
+
id={id}
|
190
|
+
>
|
191
|
+
{children}
|
192
|
+
</div>
|
193
|
+
)
|
115
194
|
)}
|
116
195
|
</>
|
117
196
|
)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Table from '../_table'
|
3
|
+
|
4
|
+
const TableStickyLeftColumns = () => {
|
5
|
+
return (
|
6
|
+
<Table
|
7
|
+
responsive="scroll"
|
8
|
+
size="md"
|
9
|
+
stickyLeftcolumn={["1", "2", "3"]}
|
10
|
+
>
|
11
|
+
<thead>
|
12
|
+
<tr>
|
13
|
+
<th id="1">{'Column 1'}</th>
|
14
|
+
<th id="2">{'Column 2'}</th>
|
15
|
+
<th id="3">{'Column 3'}</th>
|
16
|
+
<th>{'Column 4'}</th>
|
17
|
+
<th>{'Column 5'}</th>
|
18
|
+
<th>{'Column 6'}</th>
|
19
|
+
<th>{'Column 7'}</th>
|
20
|
+
<th>{'Column 8'}</th>
|
21
|
+
<th>{'Column 9'}</th>
|
22
|
+
<th>{'Column 10'}</th>
|
23
|
+
<th>{'Column 11'}</th>
|
24
|
+
<th>{'Column 12'}</th>
|
25
|
+
<th>{'Column 13'}</th>
|
26
|
+
<th>{'Column 14'}</th>
|
27
|
+
<th>{'Column 15'}</th>
|
28
|
+
</tr>
|
29
|
+
</thead>
|
30
|
+
<tbody>
|
31
|
+
<tr>
|
32
|
+
<td id="1">{'Value 1'}</td>
|
33
|
+
<td id="2">{'Value 2'}</td>
|
34
|
+
<td id="3">{'Value 3'}</td>
|
35
|
+
<td>{'Value 4'}</td>
|
36
|
+
<td>{'Value 5'}</td>
|
37
|
+
<td>{'Value 6'}</td>
|
38
|
+
<td>{'Value 7'}</td>
|
39
|
+
<td>{'Value 8'}</td>
|
40
|
+
<td>{'Value 9'}</td>
|
41
|
+
<td>{'Value 10'}</td>
|
42
|
+
<td>{'Value 11'}</td>
|
43
|
+
<td>{'Value 12'}</td>
|
44
|
+
<td>{'Value 13'}</td>
|
45
|
+
<td>{'Value 14'}</td>
|
46
|
+
<td>{'Value 15'}</td>
|
47
|
+
</tr>
|
48
|
+
<tr>
|
49
|
+
<td id="1">{'Value 1'}</td>
|
50
|
+
<td id="2">{'Value 2'}</td>
|
51
|
+
<td id="3">{'Value 3'}</td>
|
52
|
+
<td>{'Value 4'}</td>
|
53
|
+
<td>{'Value 5'}</td>
|
54
|
+
<td>{'Value 6'}</td>
|
55
|
+
<td>{'Value 7'}</td>
|
56
|
+
<td>{'Value 8'}</td>
|
57
|
+
<td>{'Value 9'}</td>
|
58
|
+
<td>{'Value 10'}</td>
|
59
|
+
<td>{'Value 11'}</td>
|
60
|
+
<td>{'Value 12'}</td>
|
61
|
+
<td>{'Value 13'}</td>
|
62
|
+
<td>{'Value 14'}</td>
|
63
|
+
<td>{'Value 15'}</td>
|
64
|
+
</tr>
|
65
|
+
<tr>
|
66
|
+
<td id="1">{'Value 1'}</td>
|
67
|
+
<td id="2">{'Value 2'}</td>
|
68
|
+
<td id="3">{'Value 3'}</td>
|
69
|
+
<td>{'Value 4'}</td>
|
70
|
+
<td>{'Value 5'}</td>
|
71
|
+
<td>{'Value 6'}</td>
|
72
|
+
<td>{'Value 7'}</td>
|
73
|
+
<td>{'Value 8'}</td>
|
74
|
+
<td>{'Value 9'}</td>
|
75
|
+
<td>{'Value 10'}</td>
|
76
|
+
<td>{'Value 11'}</td>
|
77
|
+
<td>{'Value 12'}</td>
|
78
|
+
<td>{'Value 13'}</td>
|
79
|
+
<td>{'Value 14'}</td>
|
80
|
+
<td>{'Value 15'}</td>
|
81
|
+
</tr>
|
82
|
+
</tbody>
|
83
|
+
</Table>
|
84
|
+
)
|
85
|
+
}
|
86
|
+
|
87
|
+
export default TableStickyLeftColumns
|
@@ -25,3 +25,4 @@ export { default as TableDiv } from './_table_div.jsx'
|
|
25
25
|
export { default as TableWithSubcomponents } from './_table_with_subcomponents.jsx'
|
26
26
|
export { default as TableWithSubcomponentsAsDivs } from './_table_with_subcomponents_as_divs.jsx'
|
27
27
|
export { default as TableOuterPadding } from './_table_outer_padding.jsx'
|
28
|
+
export { default as TableStickyLeftColumns } from './_table_sticky_left_columns.jsx'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@import "../../tokens/colors";
|
2
|
+
|
3
|
+
[class^="pb_table"] {
|
4
|
+
.sticky {
|
5
|
+
position: sticky !important;
|
6
|
+
left: 0;
|
7
|
+
z-index: 1;
|
8
|
+
background-color: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
.with-border {
|
12
|
+
border-right: 1px solid $border_light !important;
|
13
|
+
}
|
14
|
+
|
15
|
+
.sticky-shadow {
|
16
|
+
box-shadow: 4px 0 10px rgba(60, 106, 172, 0.16) !important;
|
17
|
+
}
|
18
|
+
}
|