Skip to content

Commit

Permalink
Add readonly prop for native input #164
Browse files Browse the repository at this point in the history
  • Loading branch information
iamstevendao committed Mar 22, 2020
1 parent cbc2217 commit cd69dee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/vue-tel-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div :class="['vue-tel-input', wrapperClasses, { disabled: disabled }]">
<div
v-click-outside="clickedOutside"
:tabindex="dropdownOptions && dropdownOptions.tabindex ? dropdownOptions.tabindex : 0"
:class="['vti__dropdown', { open: open }]"
:tabindex="dropdownOptions && dropdownOptions.tabindex ? dropdownOptions.tabindex : 0"
@keydown="keyboardNav"
@click="toggleDropdown"
@keydown.esc="reset"
Expand All @@ -20,8 +20,8 @@
<ul ref="list" class="vti__dropdown-list" v-show="open" :class="dropdownOpenDirection">
<li
v-for="(pb, index) in sortedCountries"
:key="pb.iso2 + (pb.preferred ? '-preferred' : '')"
:class="['vti__dropdown-item', getItemClass(index, pb.iso2)]"
:key="pb.iso2 + (pb.preferred ? '-preferred' : '')"
@click="choose(pb, true)"
@mousemove="selectedIndex = index"
>
Expand All @@ -37,15 +37,16 @@
ref="input"
type="tel"
v-model="phone"
:placeholder="parsedPlaceholder"
:disabled="disabled"
:required="required"
:autocomplete="autocomplete"
:autofocus="autofocus"
:name="name"
:class="['vti__input', inputClasses]"
:disabled="disabled"
:id="inputId"
:maxlength="maxLen"
:name="name"
:placeholder="parsedPlaceholder"
:readonly="readonly"
:required="required"
:tabindex="inputOptions && inputOptions.tabindex ? inputOptions.tabindex : 0"
@blur="onBlur"
@focus="onFocus"
Expand Down Expand Up @@ -212,6 +213,10 @@ export default {
type: Array,
default: () => getDefault('preferredCountries'),
},
readonly: {
type: Boolean,
default: () => getDefault('readonly'),
},
required: {
type: Boolean,
default: () => getDefault('required'),
Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const defaultOptions = {
onlyCountries: [],
placeholder: 'Enter a phone number',
preferredCountries: [],
readonly: false,
required: false,
validCharactersOnly: false,
wrapperClasses: '',
Expand Down

0 comments on commit cd69dee

Please sign in to comment.