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

Feature: Add separateDialCode option #123

Merged
Merged
Changes from 1 commit
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
15 changes: 13 additions & 2 deletions addon/components/phone-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const PHONE_NUMBER_FORMAT = 'E164' // https://en.wikipedia.org/wiki/E.164
number='123'
onlyCountries=europeanCountries
preferredCountries=englishSpeakingCountries
separateDialCode=true
update=(action 'handleUpdate')}}
```

Expand Down Expand Up @@ -90,6 +91,14 @@ export default Component.extend({
*/
this.preferredCountries = this.preferredCountries || ['us', 'gb']

/**
Display the country dial code next to the selected flag so it's not part of the typed number

@argument separateDialCode
@type {boolean}
*/
this.separateDialCode = this.separateDialCode || false

/**
You have to implement this function to update the `number`.

Expand Down Expand Up @@ -129,7 +138,8 @@ export default Component.extend({
autoPlaceholder,
initialCountry,
onlyCountries,
preferredCountries
preferredCountries,
separateDialCode
} = this

var input = document.getElementById(this.elementId)
Expand All @@ -139,7 +149,8 @@ export default Component.extend({
autoPlaceholder,
initialCountry,
onlyCountries,
preferredCountries
preferredCountries,
separateDialCode
})

const number = this.number
Expand Down