vue-tel-input 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils.js DELETED
@@ -1,291 +0,0 @@
1
- import allCountries from './assets/all-countries';
2
-
3
- export function getCountry() {
4
- return fetch('https://ip2c.org/s')
5
- .then((response) => response.text())
6
- .then((response) => {
7
- const result = (response || '').toString();
8
-
9
- if (!result || result[0] !== '1') {
10
- throw new Error('unable to fetch the country');
11
- }
12
-
13
- return result.substr(2, 2);
14
- });
15
- }
16
-
17
- // Credits: http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/
18
- export function setCaretPosition(ctrl, pos) {
19
- // Modern browsers
20
- if (ctrl.setSelectionRange) {
21
- ctrl.focus();
22
- ctrl.setSelectionRange(pos, pos);
23
-
24
- // IE8 and below
25
- } else if (ctrl.createTextRange) {
26
- const range = ctrl.createTextRange();
27
- range.collapse(true);
28
- range.moveEnd('character', pos);
29
- range.moveStart('character', pos);
30
- range.select();
31
- }
32
- }
33
-
34
- export const allProps = [
35
- {
36
- name: 'allCountries',
37
- type: Array,
38
- default: allCountries,
39
- description: 'All countries that are used in <code>libphonenumber-js</code>, can be overridden by this prop',
40
- inDemo: false,
41
- },
42
- {
43
- name: 'autoFormat',
44
- type: Boolean,
45
- default: true,
46
- description: 'Auto update the input to the formatted phone number when it\'s valid',
47
- inDemo: true,
48
- },
49
- {
50
- name: 'customValidate',
51
- type: [Boolean, RegExp],
52
- default: false,
53
- description: 'Custom validation RegExp for input',
54
- inDemo: false,
55
- },
56
- {
57
- name: 'defaultCountry',
58
- default: '',
59
- type: [String, Number],
60
- description: 'Default country (by iso2 or dialCode), will override the country fetched from IP address of user',
61
- inDemo: false,
62
- },
63
- {
64
- name: 'disabled',
65
- default: false,
66
- type: Boolean,
67
- description: 'Disable <code>vue-tel-input</code>, including the input & flag dropdown',
68
- inDemo: false,
69
- },
70
- {
71
- name: 'autoDefaultCountry',
72
- default: true,
73
- type: Boolean,
74
- description: 'To fetch default country based on IP address of user',
75
- inDemo: false,
76
- },
77
- {
78
- name: 'dropdownOptions',
79
- type: Object,
80
- description: 'Options for dropdown, see below',
81
- inDemo: false,
82
- },
83
- {
84
- name: 'dropdownOptions.disabled',
85
- default: false,
86
- type: Boolean,
87
- description: 'Disable dropdown',
88
- inDemo: false,
89
- },
90
- {
91
- name: 'dropdownOptions.showDialCodeInList',
92
- default: true,
93
- type: Boolean,
94
- description: 'Show dial code in the dropdown list',
95
- inDemo: true,
96
- },
97
- {
98
- name: 'dropdownOptions.showDialCodeInSelection',
99
- default: false,
100
- type: Boolean,
101
- description: 'Show dial code in the dropdown selection',
102
- inDemo: true,
103
- },
104
- {
105
- name: 'dropdownOptions.showFlags',
106
- default: true,
107
- type: Boolean,
108
- description: 'Show flags in the dropdown selection and list',
109
- inDemo: true,
110
- },
111
- {
112
- name: 'dropdownOptions.tabindex',
113
- default: 0,
114
- type: Number,
115
- description: 'Native dropdown <code>tabindex</code> attribute',
116
- inDemo: false,
117
- },
118
- {
119
- name: 'ignoredCountries',
120
- default: [],
121
- type: Array,
122
- description: 'List of countries will NOT be shown on the dropdown',
123
- inDemo: false,
124
- },
125
- {
126
- name: 'inputOptions',
127
- type: Object,
128
- description: 'Options for input, see below',
129
- inDemo: false,
130
- },
131
- {
132
- name: 'inputOptions.autocomplete',
133
- type: String,
134
- default: 'on',
135
- description: 'Native input <code>autocomplete</code> attribute',
136
- inDemo: false,
137
- },
138
- {
139
- name: 'inputOptions.autofocus',
140
- type: Boolean,
141
- default: false,
142
- description: 'Native input <code>autofocus</code> attribute',
143
- inDemo: false,
144
- },
145
- // {
146
- // name: 'inputOptions.dynamicPlaceholder',
147
- // default: false,
148
- // type: Boolean,
149
- // description: 'Placeholder as a sample phone number in the current country',
150
- // inDemo: false,
151
- // },
152
- {
153
- name: 'inputOptions.aria-describedby',
154
- default: '',
155
- type: String,
156
- description: 'Native input <code>aria-describedby</code> attribute',
157
- inDemo: false,
158
- },
159
- {
160
- name: 'inputOptions.id',
161
- default: '',
162
- type: String,
163
- description: 'Native input <code>id</code> attribute',
164
- inDemo: false,
165
- },
166
- {
167
- name: 'inputOptions.maxlength',
168
- default: 25,
169
- type: Number,
170
- description: 'Native input <code>maxlength</code> attribute',
171
- inDemo: false,
172
- },
173
- {
174
- name: 'inputOptions.name',
175
- default: 'telephone',
176
- type: String,
177
- description: 'Native input <code>name</code> attribute',
178
- inDemo: false,
179
- },
180
- {
181
- name: 'inputOptions.showDialCode',
182
- default: false,
183
- type: Boolean,
184
- description: 'Show dial code in input',
185
- inDemo: false,
186
- },
187
- {
188
- name: 'inputOptions.placeholder',
189
- default: 'Enter a phone number',
190
- type: String,
191
- description: 'Placeholder for the input',
192
- inDemo: false,
193
- },
194
- {
195
- name: 'inputOptions.readonly',
196
- default: false,
197
- type: Boolean,
198
- description: 'Native input <code>readonly</code> attribute',
199
- inDemo: false,
200
- },
201
- {
202
- name: 'inputOptions.required',
203
- default: false,
204
- type: Boolean,
205
- description: 'Native input <code>required</code> attribute',
206
- inDemo: false,
207
- },
208
- {
209
- name: 'inputOptions.tabindex',
210
- default: 0,
211
- type: Number,
212
- description: 'Native input <code>tabindex</code> attribute',
213
- inDemo: false,
214
- },
215
- {
216
- name: 'inputOptions.type',
217
- default: 'tel',
218
- type: String,
219
- description: 'Native input <code>type</code> attribute',
220
- inDemo: false,
221
- },
222
- {
223
- name: 'inputOptions.styleClasses',
224
- default: '',
225
- type: [String, Array, Object],
226
- description: 'Custom classes for the <code>input</code>',
227
- inDemo: false,
228
- },
229
- {
230
- name: 'invalidMsg',
231
- default: '',
232
- type: String,
233
- description: '',
234
- inDemo: false,
235
- },
236
- {
237
- name: 'mode',
238
- default: 'auto',
239
- type: String,
240
- description: 'Allowed values: <code>\'auto\'</code> (Default set by phone), <code>\'international\'</code> (Format number with the dial code i.e. + 61), <code>\'national\'</code> (Format number without dial code i.e. 0321232)',
241
- inDemo: true,
242
- options: ['auto', 'national', 'international'],
243
- },
244
- {
245
- name: 'onlyCountries',
246
- default: [],
247
- type: Array,
248
- description: 'List of countries will be shown on the dropdown',
249
- inDemo: false,
250
- },
251
- {
252
- name: 'preferredCountries',
253
- default: [],
254
- type: Array,
255
- description: 'Preferred countries list, will be on top of the dropdown',
256
- inDemo: false,
257
- },
258
- {
259
- name: 'styleClasses',
260
- default: '',
261
- type: [String, Array, Object],
262
- description: 'Custom classes for the wrapper',
263
- inDemo: false,
264
- },
265
- {
266
- name: 'validCharactersOnly',
267
- default: false,
268
- type: Boolean,
269
- description: 'Only allow valid characters in a phone number (will also verify in <code>mounted</code>, so phone number with invalid characters will be shown as an empty string)',
270
- inDemo: false,
271
- },
272
- ];
273
-
274
- export const defaultOptions = [...allProps]
275
- .reduce((prv, crr) => {
276
- if (crr.name.includes('.')) {
277
- const [key, nestedKey] = crr.name.split('.');
278
- if (prv[key]) {
279
- Object.assign(prv[key], { [nestedKey]: crr.default });
280
- } else {
281
- Object.assign(prv, { [key]: { [nestedKey]: crr.default } });
282
- }
283
- } else {
284
- Object.assign(prv, { [crr.name]: crr.default });
285
- }
286
- return prv;
287
- }, {});
288
-
289
- export default {
290
- options: { ...defaultOptions },
291
- };
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.node.json",
3
- "include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
4
- "compilerOptions": {
5
- "composite": true,
6
- "types": ["node"]
7
- }
8
- }
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.web.json",
3
- "include": [
4
- "env.d.ts",
5
- "src/**/*",
6
- "src/**/*.vue",
7
- "examples/module/main.ts"
8
- ],
9
- "compilerOptions": {
10
- "baseUrl": ".",
11
- "paths": {
12
- "@/*": [
13
- "./src/*"
14
- ]
15
- }
16
- },
17
- "allowJs": true,
18
- "references": [
19
- {
20
- "path": "./tsconfig.config.json"
21
- }
22
- ]
23
- }
package/vite.config.ts DELETED
@@ -1,67 +0,0 @@
1
- import { fileURLToPath, URL } from 'url';
2
- import { defineConfig } from 'vite';
3
- import vue from '@vitejs/plugin-vue';
4
- import path from 'path';
5
- import { viteStaticCopy } from 'vite-plugin-static-copy'
6
-
7
- // https://vitejs.dev/config/
8
- export default defineConfig(({ command }) => {
9
- if (command === 'serve') {
10
- return {
11
- plugins: [
12
- vue(),
13
- ],
14
- resolve: {
15
- alias: {
16
- '@': fileURLToPath(new URL('./src', import.meta.url))
17
- }
18
- },
19
- build: {
20
- rollupOptions: {
21
- input: { app: './examples/module/index.html' },
22
- }
23
- },
24
- server: {
25
- open: '/examples/module/',
26
- }
27
- }
28
- }
29
-
30
- return {
31
- plugins: [
32
- vue(),
33
- viteStaticCopy({
34
- targets: [
35
- { src: 'src/assets/component.css', dest: 'css' },
36
- { src: 'src/assets/sprite.css', dest: 'css' },
37
- ]
38
- }),
39
- ],
40
- resolve: {
41
- alias: {
42
- '@': fileURLToPath(new URL('./src', import.meta.url))
43
- }
44
- },
45
- build: {
46
- lib: {
47
- formats: ['es', 'cjs', 'iife'],
48
- entry: path.resolve(__dirname, 'src/index.js'),
49
- name: 'VueTelInput',
50
- fileName: (format) => `vue-tel-input.${format}.js`
51
- },
52
- rollupOptions: {
53
- external: ['vue'],
54
- output: {
55
- exports: 'named',
56
- globals: {
57
- vue: 'Vue'
58
- },
59
- assetFileNames: (assetInfo) => {
60
- if (assetInfo.name === 'style.css') return 'vue-tel-input.css';
61
- return assetInfo.name;
62
- },
63
- },
64
- }
65
- },
66
- };
67
- })