playbook_ui 14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 → 14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274
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/_playbook.scss +0 -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_beta_subrow_headers.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +8 -53
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +18 -23
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +0 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +4 -6
- data/app/pb_kits/playbook/pb_button/button.html.erb +3 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +12 -7
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +14 -9
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +11 -6
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +14 -8
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +15 -24
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_accept.jsx +1 -3
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_custom_description.jsx +1 -4
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_max_size.jsx +1 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +1 -8
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx +0 -18
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +1 -22
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +0 -80
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +5 -6
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +5 -5
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.html.erb +5 -4
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx +4 -4
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.md +1 -1
- data/app/pb_kits/playbook/pb_timeline/timeline.rb +6 -6
- data/app/pb_kits/playbook/utilities/globalPropNames.mjs +0 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +9 -18
- data/dist/chunks/_typeahead-gJLWiR0r.js +22 -0
- data/dist/chunks/_weekday_stacked-BT8jIMPK.js +45 -0
- data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- 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/classnames.rb +0 -1
- data/lib/playbook/spacing.rb +0 -21
- data/lib/playbook/version.rb +1 -1
- metadata +5 -6
- data/app/pb_kits/playbook/utilities/_gap.scss +0 -29
- data/dist/chunks/_typeahead-C2iCBqxQ.js +0 -36
- data/dist/chunks/_weekday_stacked-CWnbnW7m.js +0 -45
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80b37662bebc6f6f7e4e45d7ded73d10ea7fc90ba038eb1ff0282977b56aaf45
|
4
|
+
data.tar.gz: 9966bfe67740a8c489bca09defda4e00643f63a4d2fce90fee1bd97908f6f676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebae5c57518c2e101d13eb25a2f1ce3e5b34ec0960136c48698e489a7e07e33a1dc65e22249e26082df31b399a3c267385e5e7c7abc4f625a41f01c52add4732
|
7
|
+
data.tar.gz: e99ffce613a963251b91e62b05e77037391574b3866f14a63ddc5f92dd0cae5f4a7b9b56bdea482572629ae859cc82f6293962391b3e35341cae77345a3f070e
|
data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb
CHANGED
@@ -36,5 +36,5 @@
|
|
36
36
|
|
37
37
|
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
|
38
38
|
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
39
|
-
<%= pb_rails("advanced_table/table_body", props: { id: "
|
39
|
+
<%= pb_rails("advanced_table/table_body", props: { id: "subrow_headers", table_data: @table_data, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
|
40
40
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
`subrow_headers` is an optional prop that if present will add header rows at each level of the nested data. The prop takes an array of strings, each string being the text for each header row. The array of strings must be in the order in which they need to be rendered in the UI according to depth.
|
2
2
|
|
3
|
-
`enable_toggle_expansion` is an additional optional prop that can be used in conjunction with the subRowHeaders prop. `enable_toggle_expansion` is a string that can be "all", "header" or "none". If set to "all", the toggle
|
3
|
+
`enable_toggle_expansion` is an additional optional prop that can be used in conjunction with the subRowHeaders prop. `enable_toggle_expansion` is a string that can be "all", "header" or "none". If set to "all", the toggle exapansion button will appear in the table header as well as in the subRow headers. If set to "header" button will only appear in header and NOT in subRow headers. This is set to "header" by default.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
3
|
- advanced_table_beta: Default (Required Props)
|
4
|
-
- advanced_table_beta_subrow_headers: SubRow Headers
|
4
|
+
# - advanced_table_beta_subrow_headers: SubRow Headers
|
5
5
|
- advanced_table_collapsible_trail_rails: Collapsible Trail
|
6
6
|
- advanced_table_beta_sort: Enable Sorting
|
7
7
|
- advanced_table_custom_cell_rails: Custom Components for Cells
|
@@ -65,7 +65,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
65
65
|
if (!dataContent) {
|
66
66
|
return;
|
67
67
|
}
|
68
|
-
|
68
|
+
|
69
|
+
// Split the dataContent to get all ancestor IDs, check against simpleExpandedRows
|
69
70
|
const ancestorIds = dataContent.split("-").slice(0, -1);
|
70
71
|
|
71
72
|
const prefixedAncestorIds = ancestorIds.map(
|
@@ -75,22 +76,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
75
76
|
PbAdvancedTable.expandedRows.has(id)
|
76
77
|
);
|
77
78
|
|
78
|
-
|
79
|
-
if (dataContent.endsWith("sr")) {
|
80
|
-
const parentRowId = childRow.dataset.rowParent;
|
81
|
-
const isParentVisible =
|
82
|
-
childRow.previousElementSibling.classList.contains("is-visible");
|
83
|
-
if (parentRowId) {
|
84
|
-
const isInSet = PbAdvancedTable.expandedRows.has(parentRowId);
|
85
|
-
if (isInSet && isParentVisible) {
|
86
|
-
return true;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
90
|
-
return false;
|
91
|
-
};
|
92
|
-
|
93
|
-
if (allAncestorsExpanded || checkIfParentIsExpanded()) {
|
79
|
+
if (allAncestorsExpanded) {
|
94
80
|
childRow.style.display = "table-row";
|
95
81
|
childRow.classList.add("is-visible");
|
96
82
|
} else {
|
@@ -157,7 +143,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
157
143
|
static handleToggleAllHeaders(element) {
|
158
144
|
const table = element.closest(".pb_table");
|
159
145
|
const firstLevelButtons = table.querySelectorAll(
|
160
|
-
".pb_advanced_table_body > .pb_table_tr
|
146
|
+
".pb_advanced_table_body > .pb_table_tr [data-advanced-table]"
|
161
147
|
);
|
162
148
|
|
163
149
|
const allExpanded = Array.from(firstLevelButtons).every(
|
@@ -189,43 +175,12 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
189
175
|
}
|
190
176
|
}
|
191
177
|
|
192
|
-
static handleToggleAllSubRows(element, rowDepth) {
|
193
|
-
const table = element.closest(".pb_table");
|
194
|
-
const parentRow = element.closest("tr");
|
195
|
-
if (!parentRow) {
|
196
|
-
return;
|
197
|
-
}
|
198
|
-
const rowParentId = parentRow.dataset.rowParent;
|
199
|
-
// Select all buttons that for subrows at that depth and with same rowParent
|
200
|
-
const subRowButtons = table.querySelectorAll(
|
201
|
-
`.pb_advanced_table_body > .pb_table_tr[data-row-depth='${rowDepth}'].pb_table_tr[data-row-parent='${rowParentId}'] [data-advanced-table]`
|
202
|
-
);
|
203
|
-
|
204
|
-
const allExpanded = Array.from(subRowButtons).every(
|
205
|
-
(button) =>
|
206
|
-
button.querySelector(UP_ARROW_SELECTOR).style.display === "inline-block"
|
207
|
-
);
|
208
|
-
|
209
|
-
if (allExpanded) {
|
210
|
-
subRowButtons.forEach((button) => {
|
211
|
-
button.click();
|
212
|
-
PbAdvancedTable.expandedRows.delete(button.id);
|
213
|
-
});
|
214
|
-
} else {
|
215
|
-
subRowButtons.forEach((button) => {
|
216
|
-
if (!PbAdvancedTable.expandedRows.has(button.id)) {
|
217
|
-
button.click();
|
218
|
-
PbAdvancedTable.expandedRows.add(button.id);
|
219
|
-
}
|
220
|
-
});
|
221
|
-
}
|
222
|
-
}
|
178
|
+
// static handleToggleAllSubRows(element, rowDepth) {}
|
223
179
|
}
|
224
180
|
|
225
181
|
window.expandAllRows = (element) => {
|
226
182
|
PbAdvancedTable.handleToggleAllHeaders(element);
|
227
183
|
};
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
};
|
184
|
+
// window.expandAllSubRows = (element, rowDepth) => {
|
185
|
+
// PbAdvancedTable.handleToggleAllSubRows(element, rowDepth);
|
186
|
+
// };
|
@@ -31,7 +31,7 @@ module Playbook
|
|
31
31
|
end.compact
|
32
32
|
end
|
33
33
|
|
34
|
-
def render_row_and_children(row, column_definitions, current_depth, first_parent_child, ancestor_ids = [], top_parent_id = nil
|
34
|
+
def render_row_and_children(row, column_definitions, current_depth, first_parent_child, ancestor_ids = [], top_parent_id = nil)
|
35
35
|
top_parent_id ||= row.object_id
|
36
36
|
new_ancestor_ids = ancestor_ids + [row.object_id]
|
37
37
|
leaf_columns = flatten_columns(column_definitions)
|
@@ -39,35 +39,30 @@ module Playbook
|
|
39
39
|
output = ActiveSupport::SafeBuffer.new
|
40
40
|
is_first_child_of_subrow = current_depth.positive? && first_parent_child && subrow_headers[current_depth - 1].present?
|
41
41
|
|
42
|
-
|
43
|
-
subrow_data_attributes = {
|
44
|
-
advanced_table_content: subrow_ancestor_ids.join("-"),
|
45
|
-
row_depth: current_depth,
|
46
|
-
row_parent: "#{id}_#{ancestor_ids.last}",
|
47
|
-
}
|
48
|
-
# Subrow header if applicable
|
49
|
-
output << pb_rails("advanced_table/table_subrow_header", props: { row: row, column_definitions: leaf_columns, depth: current_depth, subrow_header: subrow_headers[current_depth - 1], collapsible_trail: collapsible_trail, classname: "toggle-content", subrow_data_attributes: subrow_data_attributes }) if is_first_child_of_subrow && enable_toggle_expansion == "all"
|
42
|
+
output << pb_rails("advanced_table/table_subrow_header", props: { row: row, column_definitions: column_definitions, depth: current_depth, subrow_header: subrow_headers[current_depth - 1], collapsible_trail: collapsible_trail }) if is_first_child_of_subrow && enable_toggle_expansion == "all"
|
50
43
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
44
|
+
# Pass only leaf_columns to table_row to account for multiple nested columns
|
45
|
+
output << pb_rails("advanced_table/table_row", props: {
|
46
|
+
id: id,
|
47
|
+
row: row,
|
48
|
+
column_definitions: leaf_columns,
|
49
|
+
depth: current_depth,
|
50
|
+
collapsible_trail: collapsible_trail,
|
51
|
+
})
|
55
52
|
|
56
53
|
if row[:children].present?
|
57
|
-
row[:children].
|
54
|
+
output << row[:children].map do |child_row|
|
58
55
|
is_first_child = row[:children].first == child_row
|
56
|
+
|
57
|
+
child_output = render_row_and_children(child_row, column_definitions, current_depth + 1, is_first_child, new_ancestor_ids, top_parent_id)
|
58
|
+
|
59
59
|
immediate_parent_id = row.object_id
|
60
|
+
top_parent = top_parent_id
|
61
|
+
# Combine ancestor_ids to build the content id
|
60
62
|
data_content = new_ancestor_ids.join("-") + "-#{child_row.object_id}"
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
row_depth: current_depth + 1,
|
65
|
-
row_parent: "#{id}_#{immediate_parent_id}",
|
66
|
-
advanced_table_content: data_content,
|
67
|
-
}
|
68
|
-
|
69
|
-
output << render_row_and_children(child_row, column_definitions, current_depth + 1, is_first_child, new_ancestor_ids, top_parent_id, additional_classes: "toggle-content", table_data_attributes: child_data_attributes)
|
70
|
-
end
|
64
|
+
child_output.to_str.sub("<tr", %(<tr class="toggle-content" data-top-parent="#{id}_#{top_parent}" data-row-depth="#{current_depth}" data-row-parent="#{id}_#{immediate_parent_id}" data-advanced-table-content="#{data_content}"))
|
65
|
+
end.join.html_safe
|
71
66
|
end
|
72
67
|
|
73
68
|
output
|
@@ -11,12 +11,6 @@ module Playbook
|
|
11
11
|
prop :depth
|
12
12
|
prop :collapsible_trail, type: Playbook::Props::Boolean,
|
13
13
|
default: true
|
14
|
-
prop :table_data_attributes, type: Playbook::Props::HashProp,
|
15
|
-
default: {}
|
16
|
-
|
17
|
-
def data
|
18
|
-
Hash(prop(:data)).merge(table_data_attributes)
|
19
|
-
end
|
20
14
|
|
21
15
|
def classname
|
22
16
|
generate_classname("pb_table_tr", "bg-white", subrow_depth_classname, separator: " ")
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= pb_content_tag(:
|
1
|
+
<%= pb_content_tag(:div) do %>
|
2
2
|
<% object.column_definitions.each_with_index do |column, index| %>
|
3
|
-
<%= pb_rails("table/table_cell", props: { classname:
|
3
|
+
<%= pb_rails("table/table_cell", props: { classname: object.td_classname}) do %>
|
4
4
|
<%= pb_rails("flex", props:{ align: "center", justify: "start" }) do %>
|
5
5
|
<% if collapsible_trail && index.zero? %>
|
6
6
|
<% (1..depth).each do |i| %>
|
@@ -14,15 +14,13 @@ module Playbook
|
|
14
14
|
default: ""
|
15
15
|
prop :collapsible_trail, type: Playbook::Props::Boolean,
|
16
16
|
default: true
|
17
|
-
prop :subrow_data_attributes, type: Playbook::Props::HashProp,
|
18
|
-
default: {}
|
19
17
|
|
20
|
-
def
|
21
|
-
|
18
|
+
def classname
|
19
|
+
generate_classname("pb_table_tr", "bg-white", subrow_depth_classname, separator: " ")
|
22
20
|
end
|
23
21
|
|
24
|
-
def
|
25
|
-
generate_classname("
|
22
|
+
def td_classname
|
23
|
+
generate_classname("id-cell", "chrome-styles", separator: " ")
|
26
24
|
end
|
27
25
|
|
28
26
|
private
|
@@ -1,5 +1,6 @@
|
|
1
|
-
<%=
|
2
|
-
object.tag == "button" ? object.options : object.link_options
|
1
|
+
<%= content_tag(object.tag,
|
2
|
+
object.tag == "button" ? object.options : object.link_options,
|
3
|
+
**combined_html_options) do %>
|
3
4
|
<% if object.variant === "reaction" %>
|
4
5
|
<% if icon && object.valid_emoji(object.icon) %>
|
5
6
|
<%= pb_rails("flex", props:{ align: "center" }) do %>
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:label, aria: object.aria,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname,
|
5
|
+
**combined_html_options
|
6
|
+
) do %>
|
2
7
|
<%= content.presence || object.input %>
|
3
8
|
<% if object.indeterminate %>
|
4
9
|
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_indeterminate">
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname + object.error_class,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<div class="input_wrapper">
|
3
8
|
<% if content.present? %>
|
4
9
|
<%= content %>
|
@@ -1,14 +1,19 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<% if object.label.present? %>
|
3
8
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
4
9
|
<% end %>
|
5
10
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
6
|
-
<input
|
7
|
-
data-default-value="<%= input_default_value %>"
|
8
|
-
id="dropdown-selected-option"
|
9
|
-
name="<%= object.name %>"
|
10
|
-
style="display: none"
|
11
|
-
<%= object.required ? "required" : ""%>
|
11
|
+
<input
|
12
|
+
data-default-value="<%= input_default_value %>"
|
13
|
+
id="dropdown-selected-option"
|
14
|
+
name="<%= object.name %>"
|
15
|
+
style="display: none"
|
16
|
+
<%= object.required ? "required" : ""%>
|
12
17
|
/>
|
13
18
|
<% if content.present? %>
|
14
19
|
<%= content.presence %>
|
@@ -1,15 +1,20 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
|
3
|
-
<% if content.present? %>
|
8
|
+
<% if content.present? %>
|
4
9
|
<%= content.presence %>
|
5
|
-
<% else %>
|
10
|
+
<% else %>
|
6
11
|
<%= pb_rails("list/item", props: {
|
7
|
-
display: "flex",
|
8
|
-
justify_content: "center",
|
9
|
-
padding:"xs",
|
10
|
-
}) do %>
|
12
|
+
display: "flex",
|
13
|
+
justify_content: "center",
|
14
|
+
padding:"xs",
|
15
|
+
}) do %>
|
11
16
|
<%= pb_rails("body", props: {text: "No option"}) %>
|
12
17
|
<% end %>
|
13
18
|
<% end %>
|
14
|
-
<% end %>
|
15
|
-
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -1,10 +1,15 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.option[:id],
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("list/item", props: {
|
3
|
-
display: "flex",
|
4
|
-
justify_content: "center",
|
5
|
-
padding:"none",
|
8
|
+
display: "flex",
|
9
|
+
justify_content: "center",
|
10
|
+
padding:"none",
|
6
11
|
cursor: "pointer"
|
7
|
-
}) do %>
|
12
|
+
}) do %>
|
8
13
|
<div class="dropdown_option_wrapper">
|
9
14
|
<% if content.present? %>
|
10
15
|
<%= content.presence %>
|
@@ -13,4 +18,4 @@
|
|
13
18
|
<% end %>
|
14
19
|
</div>
|
15
20
|
<% end %>
|
16
|
-
<% end %>
|
21
|
+
<% end %>
|
@@ -1,16 +1,21 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<% if content.present? %>
|
3
8
|
<div style="display: inline-block" tabindex="0" data-dropdown-custom-trigger>
|
4
9
|
<%= content.presence %>
|
5
10
|
</div>
|
6
11
|
<% else %>
|
7
12
|
<%= pb_rails("flex", props: {
|
8
|
-
align: "center",
|
9
|
-
border_radius:"lg",
|
10
|
-
classname: object.trigger_wrapper_classes,
|
11
|
-
cursor: "pointer",
|
12
|
-
justify: "between",
|
13
|
-
padding_x:"sm",
|
13
|
+
align: "center",
|
14
|
+
border_radius:"lg",
|
15
|
+
classname: object.trigger_wrapper_classes,
|
16
|
+
cursor: "pointer",
|
17
|
+
justify: "between",
|
18
|
+
padding_x:"sm",
|
14
19
|
padding_y:"xs",
|
15
20
|
html_options: {tabindex:"0"}
|
16
21
|
}) do %>
|
@@ -18,7 +23,7 @@
|
|
18
23
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
19
24
|
<% if object.custom_display.present? %>
|
20
25
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
21
|
-
<div id="dropdown_trigger_custom_display" style="display: none;">
|
26
|
+
<div id="dropdown_trigger_custom_display" style="display: none;">
|
22
27
|
<%= object.custom_display %>
|
23
28
|
</div>
|
24
29
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
@@ -35,3 +40,4 @@
|
|
35
40
|
<% end %>
|
36
41
|
<% end %>
|
37
42
|
<% end %>
|
43
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useEffect, useCallback, useRef } from 'react'
|
2
|
-
import { useDropzone, DropzoneInputProps, DropzoneRootProps
|
2
|
+
import { useDropzone, DropzoneInputProps, DropzoneRootProps } from 'react-dropzone'
|
3
3
|
import classnames from 'classnames'
|
4
4
|
|
5
5
|
import { buildCss, buildDataProps, noop, buildHtmlProps } from '../utilities/props'
|
@@ -9,10 +9,8 @@ import type { Callback } from '../types'
|
|
9
9
|
import Body from '../pb_body/_body'
|
10
10
|
import Card from '../pb_card/_card'
|
11
11
|
|
12
|
-
import { isEmpty } from '../utilities/object'
|
13
|
-
|
14
12
|
type FileUploadProps = {
|
15
|
-
accept?:
|
13
|
+
accept?: string[],
|
16
14
|
className?: string,
|
17
15
|
customMessage?: string,
|
18
16
|
dark?: boolean,
|
@@ -21,7 +19,7 @@ type FileUploadProps = {
|
|
21
19
|
acceptedFilesDescription?: string,
|
22
20
|
maxSize?: number,
|
23
21
|
onFilesAccepted: Callback<File, File>,
|
24
|
-
onFilesRejected: (error: string, files:
|
22
|
+
onFilesRejected: (error: string, files: File[]) => void,
|
25
23
|
}
|
26
24
|
|
27
25
|
const getFormattedFileSize = (fileSize: number): string => {
|
@@ -30,7 +28,7 @@ const getFormattedFileSize = (fileSize: number): string => {
|
|
30
28
|
|
31
29
|
const FileUpload = (props: FileUploadProps): React.ReactElement => {
|
32
30
|
const {
|
33
|
-
accept =
|
31
|
+
accept = null,
|
34
32
|
acceptedFilesDescription = '',
|
35
33
|
className,
|
36
34
|
customMessage,
|
@@ -50,37 +48,30 @@ const FileUpload = (props: FileUploadProps): React.ReactElement => {
|
|
50
48
|
getRootProps: () => DropzoneRootProps & any;
|
51
49
|
getInputProps: () => DropzoneInputProps & any;
|
52
50
|
isDragActive: boolean;
|
53
|
-
|
51
|
+
rejectedFiles: File[];
|
54
52
|
}
|
55
53
|
|
56
|
-
const { getRootProps, getInputProps, isDragActive,
|
54
|
+
const { getRootProps, getInputProps, isDragActive, rejectedFiles }: DropZoneProps = useDropzone({
|
57
55
|
accept,
|
58
56
|
maxSize,
|
59
57
|
onDrop,
|
60
58
|
})
|
61
59
|
|
62
|
-
const prevRejected = useRef<
|
60
|
+
const prevRejected = useRef<File[] | null>(null);
|
63
61
|
|
64
|
-
|
65
|
-
if (maxSize !== undefined) {
|
66
|
-
maxFileSizeText = `Max file size is ${getFormattedFileSize(maxSize)}.`
|
67
|
-
}
|
62
|
+
const maxFileSizeText = `Max file size is ${getFormattedFileSize(maxSize)}.`
|
68
63
|
|
69
64
|
useEffect(() => {
|
70
|
-
if (
|
71
|
-
const isFileTooLarge = maxSize &&
|
65
|
+
if (rejectedFiles === prevRejected.current) return
|
66
|
+
const isFileTooLarge = maxSize && rejectedFiles.length > 0 && rejectedFiles[0].size > maxSize;
|
72
67
|
if (isFileTooLarge) {
|
73
|
-
onFilesRejected(`File size is too large! ${maxFileSizeText}`,
|
68
|
+
onFilesRejected(`File size is too large! ${maxFileSizeText}`, rejectedFiles)
|
74
69
|
}
|
75
|
-
prevRejected.current =
|
76
|
-
}, [maxFileSizeText, maxSize, onFilesRejected,
|
70
|
+
prevRejected.current = rejectedFiles
|
71
|
+
}, [maxFileSizeText, maxSize, onFilesRejected, rejectedFiles])
|
77
72
|
|
78
73
|
const acceptedFileTypes = () => {
|
79
|
-
|
80
|
-
return []
|
81
|
-
}
|
82
|
-
|
83
|
-
return Object.keys(accept).map((fileType) => {
|
74
|
+
return accept.map((fileType) => {
|
84
75
|
if (fileType.startsWith('image/')) {
|
85
76
|
return fileType.replace('image/', ' ')
|
86
77
|
} else {
|
@@ -95,7 +86,7 @@ const FileUpload = (props: FileUploadProps): React.ReactElement => {
|
|
95
86
|
const getDescription = () => {
|
96
87
|
return customMessage
|
97
88
|
? customMessage
|
98
|
-
: `Choose a file or drag it here.${
|
89
|
+
: `Choose a file or drag it here.${accept === null ? '' : ` The accepted file types are: ${acceptedFilesDescription || acceptedFileTypes()}.`}${maxSize ? ` ${maxFileSizeText}` : ''}`;
|
99
90
|
}
|
100
91
|
|
101
92
|
return (
|
@@ -25,10 +25,7 @@ const FileUploadCustomDescription = (props) => {
|
|
25
25
|
{...props}
|
26
26
|
/>
|
27
27
|
<FileUpload
|
28
|
-
accept={
|
29
|
-
"application/pdf": [".pdf"],
|
30
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
31
|
-
}}
|
28
|
+
accept={['application/pdf','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']}
|
32
29
|
acceptedFilesDescription="Adobe (.pdf) and Microsoft (.xslx)"
|
33
30
|
onFilesAccepted={handleOnFilesAccepted}
|
34
31
|
{...props}
|
@@ -18,7 +18,7 @@ const AcceptedFilesList = ({ files }) => (
|
|
18
18
|
const RejectedFilesList = ({ files }) => (
|
19
19
|
<List>
|
20
20
|
{files.map((file) => (
|
21
|
-
<ListItem key={file.
|
21
|
+
<ListItem key={file.name}><Body color="error">{`${file.name} (file too large)`}</Body></ListItem>
|
22
22
|
))}
|
23
23
|
</List>
|
24
24
|
)
|
@@ -69,7 +69,6 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
69
69
|
const outerPaddingCss = outerPadding ? `outer_padding_${spaceCssName}${outerPadding}` : ''
|
70
70
|
const isTableTag = tag === 'table'
|
71
71
|
const dynamicInlineProps = globalInlineProps(props)
|
72
|
-
const stickyRightColumnReversed = stickyRightColumn.reverse()
|
73
72
|
|
74
73
|
const classNames = classnames(
|
75
74
|
'pb_table',
|
@@ -149,7 +148,7 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
149
148
|
if (!stickyRightColumn.length) return;
|
150
149
|
let accumulatedWidth = 0;
|
151
150
|
|
152
|
-
|
151
|
+
stickyRightColumn.reverse().forEach((colId, index) => {
|
153
152
|
const isLastColumn = index === stickyRightColumn.length - 1;
|
154
153
|
const header = document.querySelector(`th[id="${colId}"]`);
|
155
154
|
const cells = document.querySelectorAll(`td[id="${colId}"]`);
|
@@ -187,12 +186,6 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
187
186
|
setTimeout(() => {
|
188
187
|
handleStickyRightColumns();
|
189
188
|
}, 10);
|
190
|
-
|
191
|
-
window.addEventListener('resize', handleStickyRightColumns);
|
192
|
-
|
193
|
-
return () => {
|
194
|
-
window.removeEventListener('resize', handleStickyRightColumns);
|
195
|
-
};
|
196
189
|
}, [stickyRightColumn]);
|
197
190
|
|
198
191
|
useEffect(() => {
|
@@ -35,8 +35,6 @@ examples:
|
|
35
35
|
- table_lg: Large
|
36
36
|
- table_sticky: Sticky Header
|
37
37
|
- table_sticky_left_columns: Sticky Left Column
|
38
|
-
- table_sticky_right_columns: Sticky Right Column
|
39
|
-
- table_sticky_columns: Sticky Left and Right Columns
|
40
38
|
- table_alignment_row: Row Alignment
|
41
39
|
- table_alignment_column: Cell Alignment
|
42
40
|
- table_alignment_shift_row: Row Shift
|
@@ -26,8 +26,6 @@ export { default as TableWithSubcomponents } from './_table_with_subcomponents.j
|
|
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
28
|
export { default as TableStickyLeftColumns } from './_table_sticky_left_columns.jsx'
|
29
|
-
export { default as TableStickyRightColumns } from './_table_sticky_right_columns.jsx'
|
30
|
-
export { default as TableStickyColumns } from './_table_sticky_columns.jsx'
|
31
29
|
export { default as TableWithCollapsible } from './_table_with_collapsible.jsx'
|
32
30
|
export { default as TableWithCollapsibleWithCustomContent } from './_table_with_collapsible_with_custom_content.jsx'
|
33
31
|
export { default as TableWithCollapsibleWithNestedTable } from './_table_with_collapsible_with_nested_table.jsx'
|
@@ -16,8 +16,6 @@ const TextInputMask = (props) => {
|
|
16
16
|
zipCode: '',
|
17
17
|
postalCode: '',
|
18
18
|
ssn: '',
|
19
|
-
creditCard: '',
|
20
|
-
cvv: ''
|
21
19
|
})
|
22
20
|
|
23
21
|
const handleOnChangeFormField = ({ target }) => {
|
@@ -59,22 +57,6 @@ const TextInputMask = (props) => {
|
|
59
57
|
value={formFields.ssn}
|
60
58
|
{...props}
|
61
59
|
/>
|
62
|
-
<TextInput
|
63
|
-
label="Credit Card"
|
64
|
-
mask="creditCard"
|
65
|
-
name="creditCard"
|
66
|
-
onChange={handleOnChangeFormField}
|
67
|
-
value={formFields.creditCard}
|
68
|
-
{...props}
|
69
|
-
/>
|
70
|
-
<TextInput
|
71
|
-
label="CVV"
|
72
|
-
mask="cvv"
|
73
|
-
name="cvv"
|
74
|
-
onChange={handleOnChangeFormField}
|
75
|
-
value={formFields.cvv}
|
76
|
-
{...props}
|
77
|
-
/>
|
78
60
|
|
79
61
|
<br />
|
80
62
|
<br />
|