playbook_ui 14.9.0.pre.alpha.PLAY1731inputmasking4868 → 14.9.0.pre.alpha.PLAY1731inputmasking4890
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_table/docs/_table_sticky_left_columns.html.erb +95 -0
- data/app/pb_kits/playbook/pb_table/index.ts +100 -26
- data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/table.rb +17 -2
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +17 -9
- data/dist/chunks/{_typeahead-Cx7J1O_I.js → _typeahead-DpEzGwBY.js} +2 -2
- data/dist/chunks/{_weekday_stacked-Z6CSak-K.js → _weekday_stacked-DLTISjm1.js} +1 -1
- data/dist/chunks/{lib-SyD3buPZ.js → lib-CVPInSs5.js} +1 -1
- data/dist/chunks/{pb_form_validation-Dt8UJgrJ.js → pb_form_validation-CDLJ5eAG.js} +1 -1
- 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 +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ace04229d2b84d22c632f080832024432c4454ab7fcd274fdc941babe4b4c3e5
|
4
|
+
data.tar.gz: c950b28b5c9a9345f27eb1f7b3e4b732ff2db706cc7f55f868a67be87042dc42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a29e24c59e3f6d6b819d65ecd3702134a15f7accedb68fc78c18c7e949249bd1eb203d562ab6bff6ec4cbae4b462a0086a128acee68c3d805831533d1695c14
|
7
|
+
data.tar.gz: d438301928055198fae77f828152f61dffa9e6f08cfdc47e7c612b14a1afee13d26575d6ed2ba65b49fe0b9f60f6ae5c52fb121da526a1e9dd5cb5ecb49aa16a
|
@@ -0,0 +1,95 @@
|
|
1
|
+
<%= pb_rails("table", props: { size: "md", responsive: "scroll", sticky_left_column: ["1", "2", "3"] }) do %>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th id="1">Column 1</th>
|
5
|
+
<th id="2">Column 2</th>
|
6
|
+
<th id="3">Column 3</th>
|
7
|
+
<th>Column 4</th>
|
8
|
+
<th>Column 5</th>
|
9
|
+
<th>Column 6</th>
|
10
|
+
<th>Column 7</th>
|
11
|
+
<th>Column 8</th>
|
12
|
+
<th>Column 9</th>
|
13
|
+
<th>Column 10</th>
|
14
|
+
<th>Column 11</th>
|
15
|
+
<th>Column 12</th>
|
16
|
+
<th>Column 13</th>
|
17
|
+
<th>Column 14</th>
|
18
|
+
<th>Column 15</th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
<tbody>
|
22
|
+
<tr>
|
23
|
+
<td id="1">Value 1</td>
|
24
|
+
<td id="2">Value 2</td>
|
25
|
+
<td id="3">Value 3</td>
|
26
|
+
<td>Value 4</td>
|
27
|
+
<td>Value 5</td>
|
28
|
+
<td>Column 6</td>
|
29
|
+
<td>Column 7</td>
|
30
|
+
<td>Column 8</td>
|
31
|
+
<td>Column 9</td>
|
32
|
+
<td>Column 10</td>
|
33
|
+
<td>Column 11</td>
|
34
|
+
<td>Column 12</td>
|
35
|
+
<td>Column 13</td>
|
36
|
+
<td>Column 14</td>
|
37
|
+
<td>Column 15</td>
|
38
|
+
|
39
|
+
</tr>
|
40
|
+
<tr>
|
41
|
+
<td id="1">Value 1</td>
|
42
|
+
<td id="2">Value 2</td>
|
43
|
+
<td id="3">Value 3</td>
|
44
|
+
<td>Value 4</td>
|
45
|
+
<td>Value 5</td>
|
46
|
+
<td>Column 6</td>
|
47
|
+
<td>Column 7</td>
|
48
|
+
<td>Column 8</td>
|
49
|
+
<td>Column 9</td>
|
50
|
+
<td>Column 10</td>
|
51
|
+
<td>Column 11</td>
|
52
|
+
<td>Column 12</td>
|
53
|
+
<td>Column 13</td>
|
54
|
+
<td>Column 14</td>
|
55
|
+
<td>Column 15</td>
|
56
|
+
|
57
|
+
</tr>
|
58
|
+
<tr>
|
59
|
+
<td id="1">Value 1</td>
|
60
|
+
<td id="2">Value 2</td>
|
61
|
+
<td id="3">Value 3</td>
|
62
|
+
<td>Value 4</td>
|
63
|
+
<td>Value 5</td>
|
64
|
+
<td>Column 6</td>
|
65
|
+
<td>Column 7</td>
|
66
|
+
<td>Column 8</td>
|
67
|
+
<td>Column 9</td>
|
68
|
+
<td>Column 10</td>
|
69
|
+
<td>Column 11</td>
|
70
|
+
<td>Column 12</td>
|
71
|
+
<td>Column 13</td>
|
72
|
+
<td>Column 14</td>
|
73
|
+
<td>Column 15</td>
|
74
|
+
|
75
|
+
</tr>
|
76
|
+
<tr>
|
77
|
+
<td id="1">Value 1</td>
|
78
|
+
<td id="2">Value 2</td>
|
79
|
+
<td id="3">Value 3</td>
|
80
|
+
<td>Value 4</td>
|
81
|
+
<td>Value 5</td>
|
82
|
+
<td>Column 6</td>
|
83
|
+
<td>Column 7</td>
|
84
|
+
<td>Column 8</td>
|
85
|
+
<td>Column 9</td>
|
86
|
+
<td>Column 10</td>
|
87
|
+
<td>Column 11</td>
|
88
|
+
<td>Column 12</td>
|
89
|
+
<td>Column 13</td>
|
90
|
+
<td>Column 14</td>
|
91
|
+
<td>Column 15</td>
|
92
|
+
|
93
|
+
</tr>
|
94
|
+
</tbody>
|
95
|
+
<% end %>
|
@@ -1,32 +1,106 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
2
|
|
3
3
|
export default class PbTable extends PbEnhancedElement {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
//
|
14
|
-
|
15
|
-
|
16
|
-
const
|
17
|
-
|
18
|
-
|
4
|
+
private stickyLeftColumns: string[] = [];
|
5
|
+
private handleStickyColumnsRef: () => void;
|
6
|
+
|
7
|
+
static get selector(): string {
|
8
|
+
return '.table-responsive-collapse'
|
9
|
+
}
|
10
|
+
|
11
|
+
connect(): void {
|
12
|
+
const tables = document.querySelectorAll('.table-responsive-collapse');
|
13
|
+
// Each Table
|
14
|
+
[].forEach.call(tables, (table: HTMLTableElement) => {
|
15
|
+
// Header Titles
|
16
|
+
const headers: string[] = [];
|
17
|
+
[].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
|
18
|
+
const colSpan = header.colSpan
|
19
|
+
for (let i = 0; i < colSpan; i++) {
|
20
|
+
headers.push(header.textContent.replace(/\r?\n|\r/, ''));
|
21
|
+
}
|
22
|
+
});
|
23
|
+
// for each row in tbody
|
24
|
+
[].forEach.call(table.querySelectorAll('tbody tr'), (row: HTMLTableRowElement) => {
|
25
|
+
// for each cell
|
26
|
+
[].forEach.call(row.cells, (cell: HTMLTableCellElement, headerIndex: number) => {
|
27
|
+
// apply the attribute
|
28
|
+
cell.setAttribute('data-title', headers[headerIndex])
|
29
|
+
})
|
30
|
+
})
|
31
|
+
});
|
32
|
+
|
33
|
+
// New sticky columns logic
|
34
|
+
this.initStickyColumns();
|
35
|
+
}
|
36
|
+
|
37
|
+
private initStickyColumns(): void {
|
38
|
+
// Find tables with sticky-left-column class
|
39
|
+
const tables = document.querySelectorAll('.sticky-left-column');
|
40
|
+
|
41
|
+
tables.forEach((table) => {
|
42
|
+
// Extract sticky left column IDs by looking at the component's class
|
43
|
+
const classList = Array.from(table.classList);
|
44
|
+
|
45
|
+
// Look for classes in the format sticky-left-column-{ids}
|
46
|
+
const stickyColumnClass = classList.find(cls => cls.startsWith('sticky-columns-'));
|
47
|
+
if (stickyColumnClass) {
|
48
|
+
// Extract the IDs from the class name
|
49
|
+
this.stickyLeftColumns = stickyColumnClass
|
50
|
+
.replace('sticky-columns-', '')
|
51
|
+
.split('-');
|
52
|
+
|
53
|
+
if (this.stickyLeftColumns.length > 0) {
|
54
|
+
this.handleStickyColumnsRef = this.handleStickyColumns.bind(this);
|
55
|
+
this.handleStickyColumns();
|
56
|
+
window.addEventListener('resize', this.handleStickyColumnsRef);
|
57
|
+
}
|
19
58
|
}
|
20
59
|
});
|
60
|
+
}
|
21
61
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
})
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
}
|
62
|
+
private handleStickyColumns(): void {
|
63
|
+
let accumulatedWidth = 0;
|
64
|
+
|
65
|
+
this.stickyLeftColumns.forEach((colId, index) => {
|
66
|
+
const isLastColumn = index === this.stickyLeftColumns.length - 1;
|
67
|
+
const header = document.querySelector(`th[id="${colId}"]`);
|
68
|
+
const cells = document.querySelectorAll(`td[id="${colId}"]`);
|
69
|
+
|
70
|
+
if (header) {
|
71
|
+
header.classList.add('sticky');
|
72
|
+
(header as HTMLElement).style.left = `${accumulatedWidth}px`;
|
73
|
+
|
74
|
+
if (!isLastColumn) {
|
75
|
+
header.classList.add('with-border');
|
76
|
+
header.classList.remove('sticky-shadow');
|
77
|
+
} else {
|
78
|
+
header.classList.remove('with-border');
|
79
|
+
header.classList.add('sticky-shadow');
|
80
|
+
}
|
81
|
+
|
82
|
+
accumulatedWidth += (header as HTMLElement).offsetWidth;
|
83
|
+
}
|
84
|
+
|
85
|
+
cells.forEach((cell) => {
|
86
|
+
cell.classList.add('sticky');
|
87
|
+
(cell as HTMLElement).style.left = `${accumulatedWidth - (header as HTMLElement).offsetWidth}px`;
|
88
|
+
|
89
|
+
if (!isLastColumn) {
|
90
|
+
cell.classList.add('with-border');
|
91
|
+
cell.classList.remove('sticky-shadow');
|
92
|
+
} else {
|
93
|
+
cell.classList.remove('with-border');
|
94
|
+
cell.classList.add('sticky-shadow');
|
95
|
+
}
|
96
|
+
});
|
97
|
+
});
|
98
|
+
}
|
99
|
+
|
100
|
+
// Cleanup method to remove event listener
|
101
|
+
disconnect(): void {
|
102
|
+
if (this.handleStickyColumnsRef) {
|
103
|
+
window.removeEventListener('resize', this.handleStickyColumnsRef);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
@@ -23,6 +23,8 @@ module Playbook
|
|
23
23
|
prop :text
|
24
24
|
prop :sticky, type: Playbook::Props::Boolean,
|
25
25
|
default: false
|
26
|
+
prop :sticky_left_column, type: Playbook::Props::Array,
|
27
|
+
default: []
|
26
28
|
prop :vertical_border, type: Playbook::Props::Boolean,
|
27
29
|
default: false
|
28
30
|
prop :striped, type: Playbook::Props::Boolean,
|
@@ -37,8 +39,8 @@ module Playbook
|
|
37
39
|
def classname
|
38
40
|
generate_classname(
|
39
41
|
"pb_table", "table-#{size}", single_line_class, dark_class,
|
40
|
-
disable_hover_class, container_class, data_table_class, sticky_class,
|
41
|
-
vertical_border_class, striped_class, outer_padding_class,
|
42
|
+
disable_hover_class, container_class, data_table_class, sticky_class, sticky_left_column_class,
|
43
|
+
collapse_class, vertical_border_class, striped_class, outer_padding_class,
|
42
44
|
"table-responsive-#{responsive}", separator: " "
|
43
45
|
)
|
44
46
|
end
|
@@ -73,6 +75,19 @@ module Playbook
|
|
73
75
|
sticky ? "sticky-header" : nil
|
74
76
|
end
|
75
77
|
|
78
|
+
def sticky_left_column_class
|
79
|
+
if sticky_left_column.empty?
|
80
|
+
nil
|
81
|
+
else
|
82
|
+
sticky_col_classname = "sticky-left-column sticky-columns"
|
83
|
+
sticky_left_column.each do |id|
|
84
|
+
sticky_col_classname += "-#{id}"
|
85
|
+
end
|
86
|
+
|
87
|
+
sticky_col_classname
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
76
91
|
def striped_class
|
77
92
|
striped ? "striped" : nil
|
78
93
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
type InputMask = {
|
2
|
-
format: (value: string) => string
|
2
|
+
format: (value: string | number) => string
|
3
3
|
pattern: string
|
4
4
|
placeholder: string
|
5
5
|
}
|
@@ -8,8 +8,10 @@ type InputMaskDictionary = {
|
|
8
8
|
[key in 'currency' | 'zipCode' | 'postalCode' | 'ssn']: InputMask
|
9
9
|
}
|
10
10
|
|
11
|
-
const formatCurrency = (value: string): string => {
|
12
|
-
const
|
11
|
+
const formatCurrency = (value: string | number): string => {
|
12
|
+
const valueString = typeof value === 'number' ? value.toString() : value;
|
13
|
+
|
14
|
+
const numericValue = valueString.replace(/[^0-9]/g, '').slice(0, 15)
|
13
15
|
|
14
16
|
if (!numericValue) return ''
|
15
17
|
|
@@ -23,17 +25,23 @@ const formatCurrency = (value: string): string => {
|
|
23
25
|
}).format(dollars)
|
24
26
|
}
|
25
27
|
|
26
|
-
const formatBasicPostal = (value: string): string => {
|
27
|
-
|
28
|
+
const formatBasicPostal = (value: string | number): string => {
|
29
|
+
const valueString = typeof value === 'number' ? value.toString() : value;
|
30
|
+
|
31
|
+
return valueString.replace(/\D/g, '').slice(0, 5)
|
28
32
|
}
|
29
33
|
|
30
|
-
const formatExtendedPostal = (value: string): string => {
|
31
|
-
const
|
34
|
+
const formatExtendedPostal = (value: string | number): string => {
|
35
|
+
const valueString = typeof value === 'number' ? value.toString() : value;
|
36
|
+
|
37
|
+
const cleaned = valueString.replace(/\D/g, '').slice(0, 9)
|
32
38
|
return cleaned.replace(/(\d{5})(?=\d)/, '$1-')
|
33
39
|
}
|
34
40
|
|
35
|
-
const formatSSN = (value: string): string => {
|
36
|
-
const
|
41
|
+
const formatSSN = (value: string | number): string => {
|
42
|
+
const valueString = typeof value === 'number' ? value.toString() : value;
|
43
|
+
|
44
|
+
const cleaned = valueString.replace(/\D/g, '').slice(0, 9)
|
37
45
|
return cleaned
|
38
46
|
.replace(/(\d{5})(?=\d)/, '$1-')
|
39
47
|
.replace(/(\d{3})(?=\d)/, '$1-')
|