Skip to content

Commit

Permalink
Merge pull request #206 from matyasjay/add-international-phone-option
Browse files Browse the repository at this point in the history
feat: add international option to Phone
  • Loading branch information
inigomarquinez committed Mar 1, 2024
2 parents def8ecf + 3eef9ca commit c490d2c
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 5 deletions.
346 changes: 345 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

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

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

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onebeyond/react-form-builder",
"version": "1.3.0",
"version": "1.4.0",
"description": "React from builder using json schema",
"author": "One Beyond",
"license": "MIT",
Expand Down
12 changes: 12 additions & 0 deletions src/Questions/Phone/__tests__/phone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,15 @@ test('pattern error is displayed', () => {

expect(screen.getByText('This is not the right pattern'))
})

test('country code is visible', () => {
const result = render(
<QuestionPhone
question={{ ...question, defaultCountry: 'GB', international: true }}
useForm={formMethods}
/>
)
expect(
result.container.querySelector('input[type="tel"]').getAttribute('value')
).toBe('+44')
})
1 change: 1 addition & 0 deletions src/Questions/Phone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const QuestionPhone = ({ isMobile, isoCode, question, useForm, ...props }) => {
placeholder={question.placeholder}
registerConfig={question.registerConfig}
name={question.name}
international={question.international}
{...props}
/>

Expand Down

0 comments on commit c490d2c

Please sign in to comment.