0.0.18 • Published 2 years ago

vue3-headless-tel-input v0.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vue 3 headless tel input docs

Installation

With npm

npm install vue3-headless-tel-input

With yarn

yarn add vue3-headless-tel-input

Official documentation

Usage

Import composable and give returned ref to the input

import { useTelInput } from "vue3-headless-tel-input"

const {
  inputRef, 
  countries, selectedCountry, selectedCountryObject, 
  value, unmaskedValue 
} = useTelInput(input)

Template part

<template>
  <div>
    <select v-model="selectedCountry">
      <option v-for="country in countries" :key="country.code" :value="country.code">
        {{ country.callingCode }}
      </option>
    </select>
    <input ref="inputRef" />
  </div>
</template>

Vue component example with v-model

<script setup>
import { toRef, watch } from "vue"
import { useTelInput } from "vue3-headless-tel-input"

const props = defineProps({
  modelValue: String,
  default: undefined
});
const emit = defineEmit(["update:model-value"])

const value = toRef(props, "modelValue");

const { inputRef, selectedCountry, selectedCountryObject, unmaskedValue } = useTelInput(value);

watch(unmaskedValue, () => {
  emit("update:model-value", unmaskedValue.value);
});
</script>
<template>
  <div>
    <select v-for="country in countries" :key="country.code" v-model="selectedCountry">
      <option :value="country.code">
        {{ country.name.common }} {{ country.callingCode }}
      </option>
    </select>
    <input ref="inputRef" />
  </div>
</template>
0.0.17

2 years ago

0.0.18

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago