playbook_ui_docs 14.12.0.pre.rc.9 → 14.12.0.pre.rc.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4ec7464e00bb2e08de6a546ae0cdbbd3a97cb462867feb3d48c4f5bff4b3144
4
- data.tar.gz: 8cbc935bc616c16c66179531a0b50db1ae84aa030d71be4833cba7069d5f95b2
3
+ metadata.gz: 427bfc3d5e71d87bb8f069471caf1088e6719e1728f52a5a886e2038d6ab5341
4
+ data.tar.gz: 7d1599f0ba6ce11891f0d016c44a2bd40b33384e5ce23fa0a10469f04a36e97e
5
5
  SHA512:
6
- metadata.gz: c295681b0de306de4e0b0f832cdb1f90f1e49122fdbd5d41a2107e5d890786e585814613fe725ce808d99d45f31f4a537ea5a33620cccb5fb558d83c9eafc224
7
- data.tar.gz: a421883fa1eecaf7896a70598109bfd393bd5e8fbe0fbca58edb9a81075d3651938e58691405280ff5ba7647d42837a1a1218c09ccf30ddfbf70199363150bd1
6
+ metadata.gz: 8189c453fcbfe4f344f88eb81c0947da90b34edd40306916a1873ec4afe15f600e65885522e5384e84201ce834a3183cf367453836e83508f6276276590e16f7
7
+ data.tar.gz: 4084e79c437a1bf6e5010342721de251c84b9ad8135b401c22d359bbe9d77744bf2056425a6a2c9f8f9d6ce666db903f4da8fd0adeb5779442ace09394a13999
@@ -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'