playbook_ui 14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 → 14.10.0.pre.alpha.play1465attempt25272
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_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 +30 -30
- 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/pb_typeahead/_typeahead.tsx +3 -2
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +12 -4
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +5 -1
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +8 -3
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +6 -1
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +21 -6
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +13 -6
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +7 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +4 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +5 -5
- data/app/pb_kits/playbook/utilities/globalPropNames.mjs +0 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +9 -18
- data/dist/chunks/_typeahead-BhT5aXCY.js +22 -0
- data/dist/chunks/_weekday_stacked-DJOTNDSY.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/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 +4 -5
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c93b9ff47768d50c0d18d31f265545696ab20026a354c4ce1902bf708a97e276
|
4
|
+
data.tar.gz: ec50794f12461ba77cca8a805a20512ee641c0dc5c74168240ad79f071b87958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676259bf2c4b7eadd6ca71fad89f4182a2a4a297e3531d0390681353605ca5a07367114596288292d42c48ad0d45bc051c68fc3ade51fe22e8924c24b226ca48
|
7
|
+
data.tar.gz: 0c40167b772c7e4125ef170e13bce0426751a658c8e987bce7fa1a89d0ddd7045f7848565560fe95f9c09c0347a5af19ab5f79d28a99e95078feee1fd1106e32
|
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,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 />
|
@@ -6,7 +6,7 @@ type InputMask = {
|
|
6
6
|
}
|
7
7
|
|
8
8
|
type InputMaskDictionary = {
|
9
|
-
[key in 'currency' | 'zipCode' | 'postalCode' | 'ssn'
|
9
|
+
[key in 'currency' | 'zipCode' | 'postalCode' | 'ssn']: InputMask
|
10
10
|
}
|
11
11
|
|
12
12
|
const formatCurrencyDefaultValue = (value: string): string => {
|
@@ -58,15 +58,6 @@ const formatSSN = (value: string): string => {
|
|
58
58
|
.replace(/(\d{3})(?=\d)/, '$1-')
|
59
59
|
}
|
60
60
|
|
61
|
-
const formatCreditCard = (value: string): string => {
|
62
|
-
const cleaned = value.replace(/\D/g, '').slice(0, 16)
|
63
|
-
return cleaned.replace(/(\d{4})(?=\d)/g, '$1 ')
|
64
|
-
}
|
65
|
-
|
66
|
-
const formatCVV = (value: string): string => {
|
67
|
-
return value.replace(/\D/g, '').slice(0, 4)
|
68
|
-
}
|
69
|
-
|
70
61
|
export const INPUTMASKS: InputMaskDictionary = {
|
71
62
|
currency: {
|
72
63
|
format: formatCurrency,
|
@@ -93,16 +84,4 @@ export const INPUTMASKS: InputMaskDictionary = {
|
|
93
84
|
pattern: '\\d{3}-\\d{2}-\\d{4}',
|
94
85
|
placeholder: '123-45-6789',
|
95
86
|
},
|
96
|
-
creditCard: {
|
97
|
-
format: formatCreditCard,
|
98
|
-
formatDefaultValue: formatCreditCard,
|
99
|
-
pattern: '\\d{4} \\d{4} \\d{4} \\d{4}',
|
100
|
-
placeholder: '1234 5678 9012 3456',
|
101
|
-
},
|
102
|
-
cvv: {
|
103
|
-
format: formatCVV,
|
104
|
-
formatDefaultValue: formatCVV,
|
105
|
-
pattern: '\\d{3,4}',
|
106
|
-
placeholder: '123',
|
107
|
-
},
|
108
87
|
}
|
@@ -226,83 +226,3 @@ test('returns masked ssn value', () => {
|
|
226
226
|
|
227
227
|
expect(input.value).toBe('123-45-6789')
|
228
228
|
})
|
229
|
-
|
230
|
-
const TextInputCreditCardMask = (props) => {
|
231
|
-
const [creditCard, setValue] = useState('')
|
232
|
-
const handleOnChange = ({ target }) => {
|
233
|
-
setValue(target.value)
|
234
|
-
}
|
235
|
-
|
236
|
-
return (
|
237
|
-
<TextInput
|
238
|
-
mask="creditCard"
|
239
|
-
onChange={handleOnChange}
|
240
|
-
value={creditCard}
|
241
|
-
{...props}
|
242
|
-
/>
|
243
|
-
)
|
244
|
-
}
|
245
|
-
|
246
|
-
test('returns masked credit card value', () => {
|
247
|
-
render(
|
248
|
-
<TextInputCreditCardMask
|
249
|
-
data={{ testid: testId }}
|
250
|
-
/>
|
251
|
-
)
|
252
|
-
|
253
|
-
const kit = screen.getByTestId(testId)
|
254
|
-
|
255
|
-
const input = within(kit).getByRole('textbox')
|
256
|
-
|
257
|
-
fireEvent.change(input, { target: { value: '1234567890123456' } })
|
258
|
-
|
259
|
-
expect(input.value).toBe('1234 5678 9012 3456')
|
260
|
-
|
261
|
-
fireEvent.change(input, { target: { value: '1234' } })
|
262
|
-
|
263
|
-
expect(input.value).toBe('1234')
|
264
|
-
|
265
|
-
fireEvent.change(input, { target: { value: '' } })
|
266
|
-
|
267
|
-
expect(input.value).toBe('')
|
268
|
-
})
|
269
|
-
|
270
|
-
const TextInputCVVMask = (props) => {
|
271
|
-
const [cvv, setValue] = useState('')
|
272
|
-
const handleOnChange = ({ target }) => {
|
273
|
-
setValue(target.value)
|
274
|
-
}
|
275
|
-
|
276
|
-
return (
|
277
|
-
<TextInput
|
278
|
-
mask="cvv"
|
279
|
-
onChange={handleOnChange}
|
280
|
-
value={cvv}
|
281
|
-
{...props}
|
282
|
-
/>
|
283
|
-
)
|
284
|
-
}
|
285
|
-
|
286
|
-
test('returns masked CVV value', () => {
|
287
|
-
render(
|
288
|
-
<TextInputCVVMask
|
289
|
-
data={{ testid: testId }}
|
290
|
-
/>
|
291
|
-
)
|
292
|
-
|
293
|
-
const kit = screen.getByTestId(testId)
|
294
|
-
|
295
|
-
const input = within(kit).getByRole('textbox')
|
296
|
-
|
297
|
-
fireEvent.change(input, { target: { value: '1234' } })
|
298
|
-
|
299
|
-
expect(input.value).toBe('1234')
|
300
|
-
|
301
|
-
fireEvent.change(input, { target: { value: '123' } })
|
302
|
-
|
303
|
-
expect(input.value).toBe('123')
|
304
|
-
|
305
|
-
fireEvent.change(input, { target: { value: '' } })
|
306
|
-
|
307
|
-
expect(input.value).toBe('')
|
308
|
-
})
|