Skip to content

Commit c490d2c

Browse files
Merge pull request #206 from matyasjay/add-international-phone-option
feat: add international option to Phone
2 parents def8ecf + 3eef9ca commit c490d2c

File tree

6 files changed

+363
-5
lines changed

6 files changed

+363
-5
lines changed

CHANGELOG.md

Lines changed: 345 additions & 1 deletion
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ https://user-images.githubusercontent.com/79102959/134945855-52577cab-9b16-4df5-
598598
| label | Text to show over the input | string | '' |
599599
| placeholder | Placeholder text to be displayed in the select | string | '' |
600600
| defaultCountry | Country to show by default | string | GB |
601+
| international | Force display country prefix in input | boolean | - |
601602
| **errorMessages** | | json | |
602603
| required | Error message to display on submit if the phone input is not filled and is required | string | ''
603604
| **registerConfig** | | json |
@@ -1040,4 +1041,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
10401041

10411042
<!-- ALL-CONTRIBUTORS-LIST:END -->
10421043

1043-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
1044+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onebeyond/react-form-builder",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"description": "React from builder using json schema",
55
"author": "One Beyond",
66
"license": "MIT",

src/Questions/Phone/__tests__/phone.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,15 @@ test('pattern error is displayed', () => {
107107

108108
expect(screen.getByText('This is not the right pattern'))
109109
})
110+
111+
test('country code is visible', () => {
112+
const result = render(
113+
<QuestionPhone
114+
question={{ ...question, defaultCountry: 'GB', international: true }}
115+
useForm={formMethods}
116+
/>
117+
)
118+
expect(
119+
result.container.querySelector('input[type="tel"]').getAttribute('value')
120+
).toBe('+44')
121+
})

src/Questions/Phone/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const QuestionPhone = ({ isMobile, isoCode, question, useForm, ...props }) => {
4444
placeholder={question.placeholder}
4545
registerConfig={question.registerConfig}
4646
name={question.name}
47+
international={question.international}
4748
{...props}
4849
/>
4950

0 commit comments

Comments
 (0)