Skip to content

Commit f505a3b

Browse files
committed
[v3] New build files
1 parent a9bbed3 commit f505a3b

18 files changed

+10284
-772
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.{js,jsx,ts,tsx,vue}]
2+
indent_style = space
3+
indent_size = 2
4+
end_of_line = lf
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true
7+
max_line_length = 100

README-v2.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# vue-tel-input v2.x.x
2+
International Telephone Input with Vue.
3+
4+
[![](https://img.shields.io/npm/dt/vue-tel-input.svg)](https://www.npmjs.com/package/vue-tel-input) [![](https://img.shields.io/github/stars/educationlink/vue-tel-input.svg)](https://github.com/EducationLink/vue-tel-input)
5+
6+
Checkout [Demo](https://educationlink.github.io/vue-tel-input/) or [Playground](https://codesandbox.io/s/0yyyk45q7w?fontsize=14&module=%2Fsrc%2FApp.vue&moduleview=1).
7+
8+
<p align="center">
9+
<img width="600px" alt="In-action GIF" src="https://thumbs.gfycat.com/EducatedPoliteBluefintuna-size_restricted.gif"/>
10+
</p>
11+
12+
## Installation
13+
- **yarn**:
14+
```bash
15+
yarn add vue-tel-input
16+
```
17+
- **npm**:
18+
```bash
19+
npm i --save vue-tel-input
20+
```
21+
22+
## Usage
23+
- Import default `CSS` to your project:
24+
```js
25+
import 'vue-tel-input/dist/vue-tel-input.css';
26+
```
27+
28+
- In your component:
29+
```html
30+
<template>
31+
...
32+
<vue-tel-input v-model="phone"></vue-tel-input>
33+
...
34+
<template>
35+
<script>
36+
import VueTelInput from 'vue-tel-input';
37+
38+
export default {
39+
components: {
40+
VueTelInput,
41+
},
42+
data() {
43+
return {
44+
phone: '',
45+
};
46+
},
47+
}
48+
</script>
49+
```
50+
51+
### Use as a custom field of [vue-form-generator](https://github.com/vue-generators/vue-form-generator)
52+
- Add a component using `vue-form-generator`'s `abstractField` mixin
53+
```js
54+
// tel-input.vue
55+
<template>
56+
<vue-tel-input v-model="value"></vue-tel-input>
57+
</template>
58+
59+
<script>
60+
import VueTelInput from 'vue-tel-input'
61+
import { abstractField } from 'vue-form-generator';
62+
63+
export default {
64+
name: 'TelephoneInput',
65+
mixins: [abstractField],
66+
components: {
67+
VueTelInput,
68+
},
69+
};
70+
</script>
71+
```
72+
73+
- Register the new field as a global component
74+
```js
75+
import Vue from 'vue';
76+
import TelInput from '<path>/tel-input.vue';
77+
78+
import 'vue-tel-input/dist/vue-tel-input.css';
79+
80+
Vue.component('field-tel-input', TelInput);
81+
```
82+
83+
- Now it can be used as `tel-input` in schema of `vue-form-generator`
84+
```js
85+
var schema: {
86+
fields: [{
87+
type: "tel-input",
88+
label: "Awesome (tel input)",
89+
model: "telephone"
90+
}]
91+
};
92+
```
93+
Read more on `vue-form-generator`'s [instruction page](https://icebob.gitbooks.io/vueformgenerator/content/fields/custom_fields.html)
94+
95+
### Props
96+
97+
Test all props on [CodeSandbox](https://codesandbox.io/s/0yyyk45q7w?fontsize=14&module=%2Fsrc%2FApp.vue&moduleview=1).
98+
99+
| Property | Type | Default value | Description |
100+
| -------- | ---- | ------------- | ----------- |
101+
| `defaultCountry` | `String` | `''` | Default country, will override the country fetched from IP address of user |
102+
| `disabledFetchingCountry` | `Boolean` | `false` | Disable fetching current country based on IP address of user |
103+
| `disabled` | `Boolean` | `false` | Disable input field |
104+
| `disabledFormatting` | `Boolean` | `false` | Disable formatting the phone number in the input, the formatted result still be accessible by `formattedNumber` returned from `onInput` event |
105+
| `placeholder` | `String` | Enter a phone number | Placeholder for the input |
106+
| `required` | `Boolean` | `false` | Required property for HTML5 required attribute |
107+
| `enabledCountryCode` | `Boolean` | `false` | Enable country code in the input |
108+
| `enabledFlags` | `Boolean` | `true` | Enable flags in the input |
109+
| `preferredCountries` | `Array` | `[]` | Preferred countries list, will be on top of the dropdown. ie `['AU', 'BR']` |
110+
| `onlyCountries` | `Array` | `[]` | List of countries will be shown on the dropdown. ie `['AU', 'BR']` |
111+
| `ignoredCountries` | `Array` | `[]` | List of countries will NOT be shown on the dropdown. ie `['AU', 'BR']` |
112+
| `autocomplete` | `String` | `'on'` | Native input 'autocomplete' attribute |
113+
| `name` | `String` | `'telephone'` | Native input 'name' attribute |
114+
| `maxLen` | `Number` | `25` | Native input 'maxlength' attribute |
115+
| `wrapperClasses` | `String` &#124; `Array` &#124; `Object` | `''` | Custom classes for the wrapper |
116+
| `inputClasses` | `String` &#124; `Array` &#124; `Object` | `''` | Custom classes for the `input` |
117+
| `inputId` | `String` | `''` | Custom 'id' for the `input` |
118+
| `dropdownOptions` | `Object` | `{ disabledDialCode: false, tabindex: 0 }` | Options for dropdown, supporting `disabledDialCode` and `tabindex`|
119+
| `inputOptions` | `Object` | `{ showDialCode: false, tabindex: 0 }` | Options for input, supporting `showDialCode` (always show dial code in the input) and `tabindex`|
120+
| `validCharactersOnly` | `Boolean` | `false` | Only allow valid characters in a phone number (will also verify in `mounted`, so phone number with invalid characters will be shown as an empty string) |
121+
122+
### Events
123+
124+
| Event | Arguments | Description | Notes |
125+
| ----- | --------- | ----------- | ----- |
126+
| `input` | `String`, `Object` | Fires when the input changes with the argument is the object includes `{ number, isValid, country }` | `onInput` deprecated |
127+
| `validate` | `Object` | Fires when the correctness of the phone number changes (from `true` to `false` or vice-versa) and when the component is mounted `{ number, isValid, country }` | `onValidate` deprecated |
128+
| `blur` | | Fires on blur event | `onBlur` deprecated |
129+
| `space` | | Fires on keyup.space event | `onSpace` deprecated |
130+
| `enter` | | Fires on keyup.enter event | `onEnter` deprecated |
131+
| `open` | | Fires when the flags dropdown opens | |
132+
| `close` | | Fires when the flags dropdown closes | |
133+
| `country-changed` | `Object` | Fires when country changed (even for the first time) | Available from `v2.4.2` |
134+
135+
### Slots
136+
| Slot | Description | Notes |
137+
| ---- | ----------- | ----- |
138+
| `arrow-icon` | Replace the arrow next to the flag with a component of your choice | Available from [v2.4.3](https://github.com/EducationLink/vue-tel-input/releases/tag/v2.4.3) |
139+
140+
## Highlights & Credits
141+
- Telephone Number parsing, validation by [libphonenumber-js](https://catamphetamine.github.io/libphonenumber-js/).
142+
- Country Codes data from [intl-tel-input](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/data.js).
143+
- User's country by [ip2c.org](https://ip2c.org/s), request using [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
144+
145+
## Demo Usage
146+
147+
```bash
148+
149+
# install dependencies
150+
$ yarn/npm install
151+
152+
# compile demo for development
153+
$ yarn/npm dev
154+
155+
# open Browser and start serving in demo
156+
$ yarn/npm demo:open
157+
158+
# compile dist demo
159+
$ yarn/npm dist:demo
160+
161+
# compile dist
162+
$ yarn/npm dist
163+
164+
```
165+
166+
## Typescript Support
167+
168+
If you working with typescript will need declaration requirements.
169+
170+
```bash
171+
npm install --save-dev @types/vue-tel-input
172+
```
173+
174+
## Contributors
175+
- [mikob](https://github.com/mikob) for super awesome work to [remove the bootstrap dependency](https://github.com/EducationLink/vue-tel-input/pull/13).
176+
- [kalcifield](https://github.com/kalcifield) for helping make the input [preload with a phone number](https://github.com/EducationLink/vue-tel-input/pull/8).
177+
- [serbemas](https://github.com/serbemas) for [adding web components support](https://github.com/EducationLink/vue-tel-input/pull/92).
178+
179+
...[more](https://github.com/EducationLink/vue-tel-input/graphs/contributors)
180+
181+
made with &#x2764; by [Steven](https://github.com/iamstevendao).

build/rollup.config.base.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import babel from 'rollup-plugin-babel';
2+
import resolve from 'rollup-plugin-node-resolve';
3+
import vue from 'rollup-plugin-vue';
4+
import cjs from 'rollup-plugin-commonjs';
5+
import replace from 'rollup-plugin-replace';
6+
import postcss from 'rollup-plugin-postcss';
7+
import analyze from 'rollup-plugin-analyzer';
8+
9+
const config = require('../package.json');
10+
11+
export default {
12+
input: 'src/index.js',
13+
plugins: [
14+
resolve({
15+
mainFields: ['module', 'jsnext:main', 'main', 'browser'],
16+
}),
17+
vue({
18+
css: true,
19+
}),
20+
babel({
21+
exclude: 'node_modules/**',
22+
runtimeHelpers: true,
23+
extensions: ['.js', '.jsx', '.es6', '.es', '.mjs', '.vue'],
24+
}),
25+
cjs(),
26+
replace({
27+
VERSION: JSON.stringify(config.version),
28+
}),
29+
postcss(),
30+
analyze(),
31+
],
32+
watch: {
33+
include: 'src/**',
34+
},
35+
};

build/rollup.config.browser.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { terser } from 'rollup-plugin-terser';
2+
import base from './rollup.config.base';
3+
4+
const config = Object.assign({}, base, {
5+
output: {
6+
exports: 'named',
7+
name: 'VueTelInput',
8+
file: 'dist/vue-tel-input.min.js',
9+
format: 'iife',
10+
},
11+
});
12+
13+
config.plugins.push(terser());
14+
15+
export default config;

build/rollup.config.es.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import base from './rollup.config.base';
2+
3+
const config = Object.assign({}, base, {
4+
output: {
5+
name: 'vue-tel-input',
6+
file: 'dist/vue-tel-input.esm.js',
7+
format: 'es',
8+
},
9+
external: [
10+
'libphonenumber-js',
11+
],
12+
});
13+
14+
export default config;

build/rollup.config.umd.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import base from './rollup.config.base';
2+
3+
const config = Object.assign({}, base, {
4+
output: {
5+
exports: 'named',
6+
name: 'vue-tel-input',
7+
file: 'dist/vue-tel-input.umd.js',
8+
format: 'umd',
9+
},
10+
});
11+
12+
export default config;

demo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set -e
55

66
# build
7-
NODE_ENV=demo npm run build
7+
npm run demo
88

99
# Copy circle CI configuration to prevent running from gh-pages
1010
cp circle.yml docs

demo/App.vue

Lines changed: 0 additions & 79 deletions
This file was deleted.

demo/index.html

Lines changed: 0 additions & 26 deletions
This file was deleted.

demo/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)