playbook_ui 14.13.0.pre.rc.10 → 14.13.0
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/_advanced_table.scss +63 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.html.erb +99 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_rails.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.html.erb +61 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_table.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +2 -5
- data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +5 -0
- data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +4 -0
- data/app/pb_kits/playbook/pb_draggable/index.js +151 -15
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +11 -7
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.html.erb +11 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting.jsx +22 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_rails.md +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_formatting_react.md +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_home_address_street/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +13 -2
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +2 -6
- data/app/pb_kits/playbook/pb_layout/body.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/header.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/item.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +1 -5
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +1 -5
- data/app/pb_kits/playbook/pb_legend/legend.html.erb +1 -6
- data/app/pb_kits/playbook/pb_message/message.html.erb +1 -6
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +1 -6
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.html.erb +1 -1
- data/app/pb_kits/playbook/pb_text_input/index.js +52 -83
- data/dist/chunks/{_typeahead-CkemExmL.js → _typeahead-btjo1UN5.js} +2 -2
- data/dist/chunks/_weekday_stacked-DeYS_l8v.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/version.rb +1 -1
- metadata +15 -5
- data/dist/chunks/_weekday_stacked-CtSzPEH0.js +0 -45
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
@@ -1,102 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const inputElements = document.querySelectorAll('[data-pb-input-mask="true"]');
|
4
|
-
|
5
|
-
inputElements.forEach((inputElement) => {
|
6
|
-
inputElement.addEventListener("input", (event) => {
|
7
|
-
const maskType = inputElement.getAttribute("mask");
|
8
|
-
const cursorPosition = inputElement.selectionStart;
|
9
|
-
|
10
|
-
let rawValue = event.target.value;
|
11
|
-
let formattedValue = rawValue;
|
12
|
-
|
13
|
-
// Apply formatting based on the mask type
|
14
|
-
switch (maskType) {
|
15
|
-
case "currency":
|
16
|
-
formattedValue = formatCurrency(rawValue);
|
17
|
-
break;
|
18
|
-
case "ssn":
|
19
|
-
formattedValue = formatSSN(rawValue);
|
20
|
-
break;
|
21
|
-
case "postal_code":
|
22
|
-
formattedValue = formatPostalCode(rawValue);
|
23
|
-
break;
|
24
|
-
case "zip_code":
|
25
|
-
formattedValue = formatZipCode(rawValue);
|
26
|
-
break;
|
27
|
-
}
|
28
|
-
|
29
|
-
// Update the sanitized input field in the same wrapper
|
30
|
-
const sanitizedInput = inputElement
|
31
|
-
.closest(".text_input_wrapper")
|
32
|
-
?.querySelector('[data="sanitized-pb-input"]');
|
33
|
-
|
34
|
-
if (sanitizedInput) {
|
35
|
-
switch (maskType) {
|
36
|
-
case "ssn":
|
37
|
-
sanitizedInput.value = sanitizeSSN(formattedValue);
|
38
|
-
break;
|
39
|
-
case "currency":
|
40
|
-
sanitizedInput.value = sanitizeCurrency(formattedValue);
|
41
|
-
break;
|
42
|
-
default:
|
43
|
-
sanitizedInput.value = formattedValue;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
inputElement.value = formattedValue;
|
48
|
-
setCursorPosition(inputElement, cursorPosition, rawValue, formattedValue);
|
49
|
-
});
|
50
|
-
});
|
1
|
+
import PbEnhancedElement from "../pb_enhanced_element"
|
2
|
+
import { INPUTMASKS } from "./inputMask"
|
51
3
|
|
4
|
+
export default class PbTextInput extends PbEnhancedElement {
|
5
|
+
static get selector() {
|
6
|
+
return '[data-pb-input-mask="true"]';
|
52
7
|
}
|
53
|
-
}
|
54
|
-
|
55
|
-
function formatCurrency(value) {
|
56
|
-
const numericValue = value.replace(/[^0-9]/g, "").slice(0, 15);
|
57
|
-
|
58
|
-
if (!numericValue) return "";
|
59
|
-
|
60
|
-
const dollars = parseFloat((parseInt(numericValue) / 100).toFixed(2));
|
61
|
-
if (dollars === 0) return "";
|
62
8
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
function formatSSN(value) {
|
71
|
-
const cleaned = value.replace(/\D/g, "").slice(0, 9);
|
72
|
-
return cleaned
|
73
|
-
.replace(/(\d{5})(?=\d)/, "$1-")
|
74
|
-
.replace(/(\d{3})(?=\d)/, "$1-");
|
75
|
-
}
|
9
|
+
connect() {
|
10
|
+
this.handleInput = this.handleInput.bind(this);
|
11
|
+
this.element.addEventListener("input", this.handleInput);
|
12
|
+
this.handleInput();
|
13
|
+
}
|
76
14
|
|
77
|
-
|
78
|
-
|
79
|
-
}
|
15
|
+
disconnect() {
|
16
|
+
this.element.removeEventListener("input", this.handleInput);
|
17
|
+
}
|
80
18
|
|
81
|
-
|
82
|
-
|
83
|
-
|
19
|
+
handleInput() {
|
20
|
+
const maskType = this.element.getAttribute("mask");
|
21
|
+
const cursorPosition = this.element.selectionStart;
|
22
|
+
const rawValue = this.element.value;
|
23
|
+
let formattedValue = rawValue;
|
24
|
+
|
25
|
+
const maskKey = {
|
26
|
+
currency: 'currency',
|
27
|
+
ssn: 'ssn',
|
28
|
+
postal_code: 'postalCode',
|
29
|
+
zip_code: 'zipCode',
|
30
|
+
}[maskType];
|
31
|
+
|
32
|
+
if (maskKey && INPUTMASKS[maskKey]) {
|
33
|
+
formattedValue = INPUTMASKS[maskKey].format(rawValue);
|
34
|
+
}
|
35
|
+
|
36
|
+
const sanitizedInput = this.element
|
37
|
+
.closest(".text_input_wrapper")
|
38
|
+
?.querySelector('[data="sanitized-pb-input"]');
|
39
|
+
|
40
|
+
if (sanitizedInput) {
|
41
|
+
switch (maskType) {
|
42
|
+
case "ssn":
|
43
|
+
sanitizedInput.value = sanitizeSSN(formattedValue);
|
44
|
+
break;
|
45
|
+
case "currency":
|
46
|
+
sanitizedInput.value = sanitizeCurrency(formattedValue);
|
47
|
+
break;
|
48
|
+
default:
|
49
|
+
sanitizedInput.value = formattedValue;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
this.element.value = formattedValue;
|
54
|
+
setCursorPosition(this.element, cursorPosition, rawValue, formattedValue);
|
55
|
+
}
|
84
56
|
}
|
85
57
|
|
86
58
|
function sanitizeSSN(input) {
|
87
|
-
return input.replace(/\D/g, "");
|
59
|
+
return input.replace(/\D/g, "");
|
88
60
|
}
|
89
61
|
|
90
62
|
function sanitizeCurrency(input) {
|
91
|
-
return input.replace(/[$,]/g, "");
|
63
|
+
return input.replace(/[$,]/g, "");
|
92
64
|
}
|
93
65
|
|
94
|
-
// function to set cursor position
|
95
66
|
function setCursorPosition(inputElement, cursorPosition, rawValue, formattedValue) {
|
96
67
|
const difference = formattedValue.length - rawValue.length;
|
97
|
-
|
98
68
|
const newPosition = Math.max(0, cursorPosition + difference);
|
99
|
-
|
100
69
|
requestAnimationFrame(() => {
|
101
70
|
inputElement.setSelectionRange(newPosition, newPosition);
|
102
71
|
});
|