Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add international option to Phone #206

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading