playbook_ui 14.10.0.pre.alpha.play16825244 → 14.10.0.pre.alpha.play16825301
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_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 +53 -8
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +23 -18
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +6 -0
- 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 +6 -4
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +11 -9
- data/app/pb_kits/playbook/pb_badge/_badge.scss +4 -2
- data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.scss +3 -1
- data/app/pb_kits/playbook/pb_button/_button.scss +3 -1
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +4 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +3 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss +5 -3
- data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.scss +6 -4
- data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.scss +4 -2
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +10 -8
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +24 -15
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_accept.jsx +3 -1
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_custom_description.jsx +4 -1
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_max_size.jsx +1 -1
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +6 -4
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +3 -1
- data/app/pb_kits/playbook/pb_label_value/_label_value.scss +4 -2
- data/app/pb_kits/playbook/pb_message/_message_mixins.scss +3 -1
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.scss +3 -1
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.scss +5 -3
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +10 -8
- data/app/pb_kits/playbook/pb_pill/_pill.scss +4 -2
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +4 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +4 -2
- data/app/pb_kits/playbook/pb_select/_select.scss +5 -3
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +5 -3
- data/app/pb_kits/playbook/pb_table/_table.tsx +8 -1
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +3 -1
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx +18 -0
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +22 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +80 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.scss +3 -1
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.scss +5 -4
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +4 -2
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +3 -3
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.html.erb +4 -5
- 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_toggle/_toggle.scss +5 -3
- data/dist/chunks/_typeahead-C2iCBqxQ.js +36 -0
- data/dist/chunks/_weekday_stacked-CWnbnW7m.js +45 -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/lib/playbook/version.rb +1 -1
- metadata +4 -4
- data/dist/chunks/_typeahead-CbKUtXZa.js +0 -22
- data/dist/chunks/_weekday_stacked-CNIlTH0K.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: bcddb88a9dfb415486e86df29a22c55884190ed39205451c9034a621311c75f8
|
4
|
+
data.tar.gz: 344f303ea394159d8314f69334c59620cc6f1ab1c5781768cb700e7b17ac09e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d48f3e79dffff5949ede088d54fbf2042a1b7f9443a84f9222d9aaa640cd4428fe4f8c19342558360c760e011a9457cff979e9d27a980446014b3bdb2db999
|
7
|
+
data.tar.gz: ac66fc8ced8a8332815151154d12cd7628813ddae7ea3b22b84997923228edc5efcf40c4fb2f0d08acbf565b0f4c1c6e84c7d439f3d0e226ebd96eba2b451ea7
|
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: "test_table", 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 expansion button will appear in the table header as well as in the subRow headers. If set to "header", the button will only appear in header and NOT in subRow headers. This prop 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
|
-
|
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,8 +65,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
65
65
|
if (!dataContent) {
|
66
66
|
return;
|
67
67
|
}
|
68
|
-
|
69
|
-
// Split the dataContent to get all ancestor IDs, check against simpleExpandedRows
|
68
|
+
// Split the dataContent to get all ancestor IDs, check against ExpandedRows
|
70
69
|
const ancestorIds = dataContent.split("-").slice(0, -1);
|
71
70
|
|
72
71
|
const prefixedAncestorIds = ancestorIds.map(
|
@@ -76,7 +75,22 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
76
75
|
PbAdvancedTable.expandedRows.has(id)
|
77
76
|
);
|
78
77
|
|
79
|
-
|
78
|
+
const checkIfParentIsExpanded = () => {
|
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()) {
|
80
94
|
childRow.style.display = "table-row";
|
81
95
|
childRow.classList.add("is-visible");
|
82
96
|
} else {
|
@@ -143,7 +157,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
143
157
|
static handleToggleAllHeaders(element) {
|
144
158
|
const table = element.closest(".pb_table");
|
145
159
|
const firstLevelButtons = table.querySelectorAll(
|
146
|
-
".pb_advanced_table_body > .pb_table_tr [data-advanced-table]"
|
160
|
+
".pb_advanced_table_body > .pb_table_tr[data-row-depth='0'] [data-advanced-table]"
|
147
161
|
);
|
148
162
|
|
149
163
|
const allExpanded = Array.from(firstLevelButtons).every(
|
@@ -175,12 +189,43 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
175
189
|
}
|
176
190
|
}
|
177
191
|
|
178
|
-
|
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
|
+
}
|
179
223
|
}
|
180
224
|
|
181
225
|
window.expandAllRows = (element) => {
|
182
226
|
PbAdvancedTable.handleToggleAllHeaders(element);
|
183
227
|
};
|
184
|
-
|
185
|
-
|
186
|
-
|
228
|
+
|
229
|
+
window.expandAllSubRows = (element, rowDepth) => {
|
230
|
+
PbAdvancedTable.handleToggleAllSubRows(element, rowDepth);
|
231
|
+
};
|
@@ -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, additional_classes: "", table_data_attributes: {})
|
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,30 +39,35 @@ 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
|
-
|
42
|
+
subrow_ancestor_ids = ancestor_ids + ["#{row.object_id}sr"]
|
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"
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
column_definitions: leaf_columns,
|
49
|
-
depth: current_depth,
|
50
|
-
collapsible_trail: collapsible_trail,
|
51
|
-
})
|
51
|
+
current_data_attributes = current_depth.zero? ? { row_depth: 0 } : table_data_attributes
|
52
|
+
|
53
|
+
# Additional class and data attributes needed for toggle logic
|
54
|
+
output << pb_rails("advanced_table/table_row", props: { id: id, row: row, column_definitions: leaf_columns, depth: current_depth, collapsible_trail: collapsible_trail, classname: additional_classes, table_data_attributes: current_data_attributes })
|
52
55
|
|
53
56
|
if row[:children].present?
|
54
|
-
|
57
|
+
row[:children].each do |child_row|
|
55
58
|
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
|
62
60
|
data_content = new_ancestor_ids.join("-") + "-#{child_row.object_id}"
|
63
61
|
|
64
|
-
|
65
|
-
|
62
|
+
child_data_attributes = {
|
63
|
+
top_parent: "#{id}_#{top_parent_id}",
|
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
|
66
71
|
end
|
67
72
|
|
68
73
|
output
|
@@ -11,6 +11,12 @@ 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
|
14
20
|
|
15
21
|
def classname
|
16
22
|
generate_classname("pb_table_tr", "bg-white", subrow_depth_classname, separator: " ")
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= pb_content_tag(:
|
1
|
+
<%= pb_content_tag(:tr) 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: "id-cell chrome-styles"}) 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,13 +14,15 @@ 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: {}
|
17
19
|
|
18
|
-
def
|
19
|
-
|
20
|
+
def data
|
21
|
+
Hash(prop(:data)).merge(subrow_data_attributes)
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
generate_classname("
|
24
|
+
def classname
|
25
|
+
generate_classname("pb_table_tr", "bg-silver", "pb_subrow_header", subrow_depth_classname, separator: " ")
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
[class^=pb_avatar_action_button_kit] {
|
2
4
|
|
3
5
|
$icon_size: 0px;
|
@@ -13,7 +15,7 @@
|
|
13
15
|
color: $value;
|
14
16
|
}
|
15
17
|
}
|
16
|
-
|
18
|
+
|
17
19
|
@mixin icon-base {
|
18
20
|
&.dark{
|
19
21
|
background-color: $bg_dark
|
@@ -31,22 +33,22 @@
|
|
31
33
|
}
|
32
34
|
|
33
35
|
@each $name, $size in $avatar-sizes {
|
34
|
-
|
36
|
+
|
35
37
|
&[class*=_#{$name}] {
|
36
|
-
|
38
|
+
|
37
39
|
$avatar_size: map-get($avatar-sizes, $name);
|
38
|
-
$icon_size: $avatar_size
|
39
|
-
$border_size: $icon_size
|
40
|
+
$icon_size: math.div($avatar_size, 2);
|
41
|
+
$border_size: math.div($icon_size, 10);
|
40
42
|
|
41
43
|
position: relative;
|
42
44
|
width: $avatar_size * 1.25;
|
43
45
|
height: $avatar_size * 1.1;
|
44
46
|
display: flex;
|
45
|
-
|
47
|
+
|
46
48
|
[class^=pb_tooltip_kit] {
|
47
49
|
justify-self: center;
|
48
50
|
}
|
49
|
-
|
51
|
+
|
50
52
|
&[class*=_bottom] .icon {
|
51
53
|
@include icon-base;
|
52
54
|
top: $icon_size * 1.27;
|
@@ -59,8 +61,8 @@
|
|
59
61
|
left: $icon_size * 1.5;
|
60
62
|
}
|
61
63
|
&[class*=_left] [class^=pb_avatar_kit] {
|
62
|
-
padding-left: $icon_size
|
64
|
+
padding-left: math.div($icon_size , 2);
|
63
65
|
}
|
64
66
|
}
|
65
67
|
}
|
66
|
-
}
|
68
|
+
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@import "../tokens/border_radius";
|
2
4
|
@import "../tokens/colors";
|
3
5
|
@import "../tokens/opacity";
|
@@ -11,7 +13,7 @@
|
|
11
13
|
align-items: center;
|
12
14
|
justify-content: center;
|
13
15
|
border-radius: $border_rad_light;
|
14
|
-
padding: 0 $space_xs
|
16
|
+
padding: 0 math.div($space_xs, 2);
|
15
17
|
border-width: 1px;
|
16
18
|
border-style: solid;
|
17
19
|
border-color: $card_light;
|
@@ -34,7 +36,7 @@
|
|
34
36
|
height: $pb_badge_height;
|
35
37
|
min-height: $pb_badge_height;
|
36
38
|
min-width: $pb_badge_height;
|
37
|
-
border-radius: $pb_badge_height
|
39
|
+
border-radius: math.div($pb_badge_height, 2);
|
38
40
|
}
|
39
41
|
|
40
42
|
&[class*=_notification] {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@import "../tokens/colors";
|
2
4
|
@import "../tokens/opacity";
|
3
5
|
@import "../tokens/spacing";
|
@@ -9,7 +11,7 @@
|
|
9
11
|
display: inline-flex;
|
10
12
|
align-items: center;
|
11
13
|
justify-content: center;
|
12
|
-
padding: 0 $space_xs
|
14
|
+
padding: 0 math.div($space_xs, 2);
|
13
15
|
|
14
16
|
svg {
|
15
17
|
margin-right: 8px;
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@import "./button_mixins";
|
2
4
|
@import "../tokens/colors";
|
3
5
|
@import "../tokens/border_radius";
|
@@ -17,7 +19,7 @@ $pb_button_sizes: (
|
|
17
19
|
@each $name, $size in $pb_button_sizes {
|
18
20
|
&[class*=size_#{$name}] {
|
19
21
|
font-size: $size;
|
20
|
-
padding: $size
|
22
|
+
padding: math.div($size, 2) $size * 2.42;
|
21
23
|
@if $name == "sm" {
|
22
24
|
min-height: 0;
|
23
25
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@import "../pb_button/button";
|
2
4
|
@import "../pb_button/button_mixins";
|
3
5
|
|
@@ -16,7 +18,7 @@ $pb_button_styles: (
|
|
16
18
|
flex-grow: 0;
|
17
19
|
width: $pb_button_size;
|
18
20
|
height: $pb_button_size;
|
19
|
-
border-radius: $pb_button_size
|
21
|
+
border-radius: math.div($pb_button_size, 2);
|
20
22
|
line-height: $pb_button_size;
|
21
23
|
flex-basis: $pb_button_size;
|
22
24
|
min-width: $pb_button_size;
|
@@ -53,4 +55,4 @@ $pb_button_styles: (
|
|
53
55
|
}
|
54
56
|
}
|
55
57
|
}
|
56
|
-
}
|
58
|
+
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@import "../../pb_textarea/textarea_mixin";
|
2
4
|
|
3
5
|
[class^=pb_date_picker_kit] {
|
@@ -41,7 +43,7 @@
|
|
41
43
|
&.error {
|
42
44
|
.date_picker_input_wrapper {
|
43
45
|
[class*=pb_body_kit] {
|
44
|
-
margin-top: $space_xs
|
46
|
+
margin-top: math.div($space_xs, 2);
|
45
47
|
}
|
46
48
|
|
47
49
|
input,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@media (min-width: 500px) {
|
2
4
|
.flatpickr-calendar {
|
3
5
|
padding: $space_xs;
|
@@ -6,8 +8,8 @@
|
|
6
8
|
width: 315.88px
|
7
9
|
}
|
8
10
|
.flatpickr-months {
|
9
|
-
margin-left: $space_xs
|
10
|
-
margin-top: $space_xs
|
11
|
+
margin-left: math.div($space_xs, 4);
|
12
|
+
margin-top: math.div($space_xs, 3);
|
11
13
|
}
|
12
14
|
}
|
13
15
|
@media (max-width: 499px) {
|
@@ -19,7 +21,7 @@
|
|
19
21
|
}
|
20
22
|
}
|
21
23
|
// Firefox Header Adjustments
|
22
|
-
@supports (-moz-appearance:none) {
|
24
|
+
@supports (-moz-appearance:none) {
|
23
25
|
select.flatpickr-monthDropdown-months {
|
24
26
|
width: 97px !important;
|
25
27
|
margin-left: $space_xs + 3;
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
[class^=pb_date_range_inline_kit] {
|
2
4
|
&[class*=_center] {
|
3
5
|
& > [class^=pb_caption],
|
@@ -21,14 +23,14 @@
|
|
21
23
|
display: flex;
|
22
24
|
align-items: center;
|
23
25
|
[class*=pb_date_range_inline_arrow] {
|
24
|
-
margin-left: $space_xs
|
25
|
-
margin-right: $space_xs
|
26
|
+
margin-left: math.div($space_xs, 2);
|
27
|
+
margin-right: math.div($space_xs, 2);
|
26
28
|
}
|
27
29
|
[class*=pb_date_range_inline_timezone] {
|
28
|
-
margin-left: $space_xs
|
30
|
+
margin-left: math.div($space_xs, 2);
|
29
31
|
}
|
30
32
|
[class*=pb_date_range_inline_icon] {
|
31
|
-
margin-right: $space_xs
|
33
|
+
margin-right: math.div($space_xs, 2);
|
32
34
|
}
|
33
35
|
}
|
34
36
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
[class^=pb_date_time_stacked] {
|
2
4
|
|
3
5
|
[class^=padding_month] {
|
@@ -19,7 +21,7 @@
|
|
19
21
|
|
20
22
|
}
|
21
23
|
.date-time-padding {
|
22
|
-
padding-right: $space_xs
|
23
|
-
padding-left: $space_xs
|
24
|
+
padding-right: math.div($space_xs, 2);
|
25
|
+
padding-left: math.div($space_xs, 2);
|
24
26
|
}
|
25
27
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
@use "sass:math";
|
2
|
+
|
1
3
|
@import "../tokens/colors";
|
2
4
|
@import "../tokens/spacing";
|
3
5
|
@import "../tokens/typography";
|
@@ -122,7 +124,7 @@
|
|
122
124
|
|
123
125
|
&.error {
|
124
126
|
[class*=pb_body_kit] {
|
125
|
-
margin-top: $space_xs
|
127
|
+
margin-top: math.div($space_xs, 2);
|
126
128
|
}
|
127
129
|
|
128
130
|
[class*="dropdown_trigger_wrapper"] {
|
@@ -146,7 +148,7 @@
|
|
146
148
|
&[class*="subtle"] {
|
147
149
|
.dropdown_wrapper {
|
148
150
|
.pb_dropdown_container {
|
149
|
-
|
151
|
+
|
150
152
|
[class*="pb_dropdown_option"]:first-child {
|
151
153
|
margin-top: $space_xs;
|
152
154
|
}
|
@@ -161,7 +163,7 @@
|
|
161
163
|
border-radius: $border_radius_md;
|
162
164
|
border-bottom: none;
|
163
165
|
position: relative;
|
164
|
-
|
166
|
+
|
165
167
|
&::after {
|
166
168
|
content: "";
|
167
169
|
position: absolute;
|
@@ -172,20 +174,20 @@
|
|
172
174
|
background: $border_light;
|
173
175
|
}
|
174
176
|
}
|
175
|
-
|
177
|
+
|
176
178
|
[class*="pb_dropdown_option"]:last-child::after {
|
177
|
-
display: none;
|
179
|
+
display: none;
|
178
180
|
}
|
179
181
|
}
|
180
182
|
}
|
181
|
-
|
183
|
+
|
182
184
|
&[class*="separators_hidden"] {
|
183
185
|
.dropdown_wrapper {
|
184
186
|
.pb_dropdown_container {
|
185
187
|
[class*="pb_dropdown_option"]:first-child {
|
186
188
|
margin-top: $space_xs;
|
187
189
|
}
|
188
|
-
|
190
|
+
|
189
191
|
[class*="pb_dropdown_option"]:last-child {
|
190
192
|
margin-bottom: $space_xs;
|
191
193
|
}
|
@@ -193,7 +195,7 @@
|
|
193
195
|
[class*="pb_dropdown_option"] {
|
194
196
|
padding: $space_xxs $space_xs;
|
195
197
|
margin: $space_xxs $space_xs;
|
196
|
-
|
198
|
+
|
197
199
|
&::after {
|
198
200
|
height: 0px;
|
199
201
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useEffect, useCallback, useRef } from 'react'
|
2
|
-
import { useDropzone, DropzoneInputProps, DropzoneRootProps } from 'react-dropzone'
|
2
|
+
import { useDropzone, DropzoneInputProps, DropzoneRootProps, FileRejection } from 'react-dropzone'
|
3
3
|
import classnames from 'classnames'
|
4
4
|
|
5
5
|
import { buildCss, buildDataProps, noop, buildHtmlProps } from '../utilities/props'
|
@@ -9,8 +9,10 @@ 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
|
+
|
12
14
|
type FileUploadProps = {
|
13
|
-
accept?: string[]
|
15
|
+
accept?: Record<string, string[]>,
|
14
16
|
className?: string,
|
15
17
|
customMessage?: string,
|
16
18
|
dark?: boolean,
|
@@ -19,7 +21,7 @@ type FileUploadProps = {
|
|
19
21
|
acceptedFilesDescription?: string,
|
20
22
|
maxSize?: number,
|
21
23
|
onFilesAccepted: Callback<File, File>,
|
22
|
-
onFilesRejected: (error: string, files:
|
24
|
+
onFilesRejected: (error: string, files: readonly FileRejection[]) => void,
|
23
25
|
}
|
24
26
|
|
25
27
|
const getFormattedFileSize = (fileSize: number): string => {
|
@@ -28,7 +30,7 @@ const getFormattedFileSize = (fileSize: number): string => {
|
|
28
30
|
|
29
31
|
const FileUpload = (props: FileUploadProps): React.ReactElement => {
|
30
32
|
const {
|
31
|
-
accept =
|
33
|
+
accept = {},
|
32
34
|
acceptedFilesDescription = '',
|
33
35
|
className,
|
34
36
|
customMessage,
|
@@ -48,30 +50,37 @@ const FileUpload = (props: FileUploadProps): React.ReactElement => {
|
|
48
50
|
getRootProps: () => DropzoneRootProps & any;
|
49
51
|
getInputProps: () => DropzoneInputProps & any;
|
50
52
|
isDragActive: boolean;
|
51
|
-
|
53
|
+
fileRejections: readonly FileRejection[];
|
52
54
|
}
|
53
55
|
|
54
|
-
const { getRootProps, getInputProps, isDragActive,
|
56
|
+
const { getRootProps, getInputProps, isDragActive, fileRejections }: DropZoneProps = useDropzone({
|
55
57
|
accept,
|
56
58
|
maxSize,
|
57
59
|
onDrop,
|
58
60
|
})
|
59
61
|
|
60
|
-
const prevRejected = useRef<
|
62
|
+
const prevRejected = useRef<readonly FileRejection[] | null>(null);
|
61
63
|
|
62
|
-
|
64
|
+
let maxFileSizeText = ''
|
65
|
+
if (maxSize !== undefined) {
|
66
|
+
maxFileSizeText = `Max file size is ${getFormattedFileSize(maxSize)}.`
|
67
|
+
}
|
63
68
|
|
64
69
|
useEffect(() => {
|
65
|
-
if (
|
66
|
-
const isFileTooLarge = maxSize &&
|
70
|
+
if (fileRejections === prevRejected.current) return
|
71
|
+
const isFileTooLarge = maxSize && fileRejections.length > 0 && fileRejections[0].file.size > maxSize;
|
67
72
|
if (isFileTooLarge) {
|
68
|
-
onFilesRejected(`File size is too large! ${maxFileSizeText}`,
|
73
|
+
onFilesRejected(`File size is too large! ${maxFileSizeText}`, fileRejections)
|
69
74
|
}
|
70
|
-
prevRejected.current =
|
71
|
-
}, [maxFileSizeText, maxSize, onFilesRejected,
|
75
|
+
prevRejected.current = fileRejections
|
76
|
+
}, [maxFileSizeText, maxSize, onFilesRejected, fileRejections])
|
72
77
|
|
73
78
|
const acceptedFileTypes = () => {
|
74
|
-
|
79
|
+
if (!accept) {
|
80
|
+
return []
|
81
|
+
}
|
82
|
+
|
83
|
+
return Object.keys(accept).map((fileType) => {
|
75
84
|
if (fileType.startsWith('image/')) {
|
76
85
|
return fileType.replace('image/', ' ')
|
77
86
|
} else {
|
@@ -86,7 +95,7 @@ const FileUpload = (props: FileUploadProps): React.ReactElement => {
|
|
86
95
|
const getDescription = () => {
|
87
96
|
return customMessage
|
88
97
|
? customMessage
|
89
|
-
: `Choose a file or drag it here.${accept
|
98
|
+
: `Choose a file or drag it here.${isEmpty(accept) ? '' : ` The accepted file types are: ${acceptedFilesDescription || acceptedFileTypes()}.`}${maxSize ? ` ${maxFileSizeText}` : ''}`;
|
90
99
|
}
|
91
100
|
|
92
101
|
return (
|
@@ -25,7 +25,10 @@ const FileUploadCustomDescription = (props) => {
|
|
25
25
|
{...props}
|
26
26
|
/>
|
27
27
|
<FileUpload
|
28
|
-
accept={
|
28
|
+
accept={{
|
29
|
+
"application/pdf": [".pdf"],
|
30
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
31
|
+
}}
|
29
32
|
acceptedFilesDescription="Adobe (.pdf) and Microsoft (.xslx)"
|
30
33
|
onFilesAccepted={handleOnFilesAccepted}
|
31
34
|
{...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.name}><Body color="error">{`${file.name} (file too large)`}</Body></ListItem>
|
21
|
+
<ListItem key={file.file.name}><Body color="error">{`${file.file.name} (file too large)`}</Body></ListItem>
|
22
22
|
))}
|
23
23
|
</List>
|
24
24
|
)
|