playbook_ui_docs 14.12.0.pre.rc.8 → 14.12.0.pre.rc.10
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_phone_number_input/docs/_phone_number_input_format.html.erb +15 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.jsx +24 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.md +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
- data/dist/playbook-doc.js +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec71dd0274574e54f478a3124935999c8d9d6553ca03cae1d0cea5bc23f3f1b
|
4
|
+
data.tar.gz: 8c93cf3991b8a0d8c281828277c9d6b44e6e5f752d89d5927ea5aeca0e660b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69d7c402fcb4d4d601ffc36431954c7c601b2bb014df282b6e2d1296c7b26d00b8f874a606e380f2a6a05da27a75ee31a1b8211f47b10cc097e646220355a969
|
7
|
+
data.tar.gz: 64cf6394a9e84cc821dba6971bc9011fdebd005b68017d66aaa1e41a8fd37b0047c4d50fc8667f8b2e19ef282ee20203fab7481c4756094746cc31c29cdb33f6
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= pb_rails("phone_number_input", props: {
|
2
|
+
id: "phone_number_input",
|
3
|
+
format_as_you_type: true
|
4
|
+
}) %>
|
5
|
+
|
6
|
+
<%= pb_rails("button", props: {id: "clickable", text: "Save Phone Number"}) %>
|
7
|
+
|
8
|
+
<%= javascript_tag do %>
|
9
|
+
document.querySelector('#clickable').addEventListener('click', () => {
|
10
|
+
const formattedPhoneNumber = document.querySelector('#phone_number_input').value
|
11
|
+
const unformattedPhoneNumber = formattedPhoneNumber.replace(/\D/g, "")
|
12
|
+
|
13
|
+
alert(`Formatted: ${formattedPhoneNumber}. Unformatted: ${unformattedPhoneNumber}`)
|
14
|
+
})
|
15
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { PhoneNumberInput, Body } from "playbook-ui";
|
3
|
+
|
4
|
+
const PhoneNumberInputFormat = (props) => {
|
5
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
6
|
+
|
7
|
+
const handleOnChange = ({ number }) => {
|
8
|
+
setPhoneNumber(number);
|
9
|
+
};
|
10
|
+
|
11
|
+
return (
|
12
|
+
<>
|
13
|
+
<PhoneNumberInput
|
14
|
+
formatAsYouType
|
15
|
+
id="format"
|
16
|
+
onChange={handleOnChange}
|
17
|
+
{...props}
|
18
|
+
/>
|
19
|
+
{phoneNumber && <Body>Unformatted number: {phoneNumber}</Body>}
|
20
|
+
</>
|
21
|
+
);
|
22
|
+
};
|
23
|
+
|
24
|
+
export default PhoneNumberInputFormat;
|
@@ -0,0 +1 @@
|
|
1
|
+
NOTE: the `number` in the React `onChange` event will not include formatting (no spaces, dashes, and parentheses). For Rails, the `value` will include formatting and its value must be sanitized manually.
|
@@ -8,10 +8,12 @@ examples:
|
|
8
8
|
- phone_number_input_validation: Form Validation
|
9
9
|
- phone_number_input_clear_field: Clearing the Input Field
|
10
10
|
- phone_number_input_access_input_element: Accessing the Input Element
|
11
|
+
- phone_number_input_format: Format as You Type
|
11
12
|
|
12
13
|
rails:
|
13
14
|
- phone_number_input_default: Default
|
14
15
|
- phone_number_input_preferred_countries: Preferred Countries
|
15
16
|
- phone_number_input_initial_country: Initial Country
|
16
17
|
- phone_number_input_only_countries: Limited Countries
|
17
|
-
- phone_number_input_validation: Form Validation
|
18
|
+
- phone_number_input_validation: Form Validation
|
19
|
+
- phone_number_input_format: Format as You Type
|
@@ -5,3 +5,4 @@ export { default as PhoneNumberInputOnlyCountries } from './_phone_number_input_
|
|
5
5
|
export { default as PhoneNumberInputValidation } from './_phone_number_input_validation'
|
6
6
|
export { default as PhoneNumberInputClearField } from './_phone_number_input_clear_field'
|
7
7
|
export { default as PhoneNumberInputAccessInputElement } from './_phone_number_input_access_input_element'
|
8
|
+
export { default as PhoneNumberInputFormat } from './_phone_number_input_format'
|