vue-tel-input 9.6.0 → 9.7.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.
@@ -0,0 +1,290 @@
1
+ import { DefineComponent } from "vue";
2
+ import type { CountryCode, PhoneNumber } from "libphonenumber-js";
3
+
4
+ export interface DropdownOptions {
5
+ /**
6
+ * Native input aria-label attribute
7
+ * @default ''
8
+ */
9
+ ariaLabel?: string;
10
+ /**
11
+ * Disable dropdown
12
+ * @default false
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * Show dial code in the dropdown list
17
+ * @default true
18
+ */
19
+ showDialCodeInList?: boolean;
20
+ /**
21
+ * Show dial code in the dropdown selection
22
+ * @default false
23
+ */
24
+ showDialCodeInSelection?: boolean;
25
+ /**
26
+ * Show flags in the dropdown selection and list
27
+ * @default true
28
+ */
29
+ showFlags?: boolean;
30
+ /**
31
+ * Show country search box
32
+ * @default false
33
+ */
34
+ showSearchBox?: boolean;
35
+ /**
36
+ * Placeholder for the search box
37
+ * @default ''
38
+ */
39
+ searchBoxPlaceholder?: string;
40
+ /**
41
+ * Native dropdown tabindex attribute
42
+ * @default 0
43
+ */
44
+ tabindex?: number;
45
+ }
46
+
47
+ export interface InputOptions {
48
+ /**
49
+ * Native input autocomplete attribute
50
+ * @default 'on'
51
+ */
52
+ autocomplete?: string;
53
+ /**
54
+ * Native input autofocus attribute
55
+ * @default false
56
+ */
57
+ autofocus?: boolean;
58
+ /**
59
+ * Native input aria-describedby attribute
60
+ * @default ''
61
+ */
62
+ "aria-describedby"?: string;
63
+ /**
64
+ * Native input id attribute
65
+ * @default ''
66
+ */
67
+ id?: string;
68
+ /**
69
+ * Native input maxlength attribute
70
+ * @default 25
71
+ */
72
+ maxlength?: number;
73
+ /**
74
+ * Native input name attribute
75
+ * @default 'telephone'
76
+ */
77
+ name?: string;
78
+ /**
79
+ * Show dial code in input
80
+ * @default false
81
+ */
82
+ showDialCode?: boolean;
83
+ /**
84
+ * Placeholder for the input
85
+ * @default 'Enter a phone number'
86
+ */
87
+ placeholder?: string;
88
+ /**
89
+ * Native input readonly attribute
90
+ * @default false
91
+ */
92
+ readonly?: boolean;
93
+ /**
94
+ * Native input required attribute
95
+ * @default false
96
+ */
97
+ required?: boolean;
98
+ /**
99
+ * Native input tabindex attribute
100
+ * @default 0
101
+ */
102
+ tabindex?: number;
103
+ /**
104
+ * Native input type attribute
105
+ * @default 'tel'
106
+ */
107
+ type?: string;
108
+ /**
109
+ * Custom classes for the input
110
+ * @default ''
111
+ */
112
+ styleClasses?: string | string[] | Record<string, boolean>;
113
+ }
114
+
115
+ export type Country = [
116
+ CountryName: string,
117
+ Iso2: Lowercase<CountryCode>,
118
+ DialCode: string,
119
+ Priority?: number,
120
+ AreaCodes?: string[]
121
+ ];
122
+
123
+ export interface CountryObject {
124
+ name: string;
125
+ iso2: CountryCode;
126
+ dialCode: string;
127
+ priority?: number;
128
+ areaCode?: string[] | null;
129
+ }
130
+
131
+ export type PhoneMeta = {
132
+ country: PhoneNumber['country'],
133
+ countryCode: PhoneNumber['country'],
134
+ valid: boolean,
135
+ possible: boolean,
136
+ formatted: string,
137
+ nationalNumber: string
138
+ };
139
+
140
+ export interface PhoneObject {
141
+ number: string;
142
+ isValid: boolean;
143
+ country?: CountryObject;
144
+ countryCode?: string;
145
+ nationalNumber?: string;
146
+ formatted?: string;
147
+ [key: string]: any;
148
+ }
149
+
150
+ export interface VueTelInputProps {
151
+ /**
152
+ * All countries that are used in libphonenumber-js, can be overridden by this prop
153
+ * @default An array of all countries
154
+ */
155
+ allCountries?: CountryObject[];
156
+ /**
157
+ * Auto update the input to the formatted phone number when it's valid
158
+ * @default true
159
+ */
160
+ autoFormat?: boolean;
161
+ /**
162
+ * Custom validation RegExp for input
163
+ * @default false
164
+ */
165
+ customValidate?: boolean | RegExp;
166
+ /**
167
+ * Default country (by iso2 or dialCode), will override the country fetched from IP address of user
168
+ * @default ''
169
+ */
170
+ defaultCountry?: string | number;
171
+ /**
172
+ * Disable vue-tel-input, including the input & flag dropdown
173
+ * @default false
174
+ */
175
+ disabled?: boolean;
176
+ /**
177
+ * To fetch default country based on IP address of user
178
+ * @default true
179
+ */
180
+ autoDefaultCountry?: boolean;
181
+ /**
182
+ * Options for dropdown
183
+ */
184
+ dropdownOptions?: DropdownOptions;
185
+ /**
186
+ * List of countries will NOT be shown on the dropdown
187
+ * @default []
188
+ */
189
+ ignoredCountries?: string[];
190
+ /**
191
+ * Options for input
192
+ */
193
+ inputOptions?: InputOptions;
194
+ /**
195
+ * Invalid message
196
+ * @default ''
197
+ */
198
+ invalidMsg?: string;
199
+ /**
200
+ * Format mode for the phone number
201
+ * - 'auto': Default set by phone
202
+ * - 'international': Format number with the dial code (e.g., +61)
203
+ * - 'national': Format number without dial code (e.g., 0321232)
204
+ * @default 'auto'
205
+ */
206
+ mode?: "auto" | "international" | "national";
207
+ /**
208
+ * List of countries will be shown on the dropdown
209
+ * @default []
210
+ */
211
+ onlyCountries?: string[];
212
+ /**
213
+ * Preferred countries list, will be on top of the dropdown
214
+ * @default []
215
+ */
216
+ preferredCountries?: string[];
217
+ /**
218
+ * Custom classes for the wrapper
219
+ * @default ''
220
+ */
221
+ styleClasses?: string | string[] | Record<string, boolean>;
222
+ /**
223
+ * Only allow valid characters in a phone number (will also verify in mounted,
224
+ * so phone number with invalid characters will be shown as an empty string)
225
+ * @default false
226
+ */
227
+ validCharactersOnly?: boolean;
228
+ /**
229
+ * The phone number value for v-model binding
230
+ */
231
+ modelValue?: string;
232
+ }
233
+
234
+ export interface VueTelInputEmits {
235
+ /**
236
+ * Fires when the input changes
237
+ * In vue-tel-input@next (Vue 3), this replaces the @input event
238
+ */
239
+ "on-input": (number: string, phoneObject: PhoneObject) => void;
240
+ /**
241
+ * Fires when the correctness of the phone number changes (from true to false or vice-versa)
242
+ * and when the component is mounted
243
+ */
244
+ "validate": (phoneObject: PhoneObject) => void;
245
+ /**
246
+ * Fires when country changed (even for the first time)
247
+ */
248
+ "country-changed": (country: CountryObject) => void;
249
+ /**
250
+ * Fires on blur event
251
+ */
252
+ "blur": () => void;
253
+ /**
254
+ * Fires on focus event
255
+ */
256
+ "focus": () => void;
257
+ /**
258
+ * Fires on keyup.space event
259
+ */
260
+ "space": () => void;
261
+ /**
262
+ * Fires on keyup.enter event
263
+ */
264
+ "enter": () => void;
265
+ /**
266
+ * Fires when the flags dropdown opens
267
+ */
268
+ "open": () => void;
269
+ /**
270
+ * Fires when the flags dropdown closes
271
+ */
272
+ "close": () => void;
273
+ /**
274
+ * Emitted for v-model support
275
+ */
276
+ "update:modelValue": (value: string) => void;
277
+ [key: string]: (...args: any[]) => void;
278
+ }
279
+
280
+ declare const VueTelInput: DefineComponent<VueTelInputProps, {}, {}, {}, {}, {}, {}, VueTelInputEmits> & {
281
+ install: (app: any, options?: any) => void;
282
+ };
283
+
284
+ export default VueTelInput;
285
+
286
+ declare module "@vue/runtime-core" {
287
+ interface GlobalComponents {
288
+ VueTelInput: typeof VueTelInput;
289
+ }
290
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tel-input",
3
- "version": "9.6.0",
3
+ "version": "9.7.1",
4
4
  "description": "International Telephone Input with Vue",
5
5
  "author": "Steven Dao <iamstevendao@gmail.com>",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "exports": {
14
14
  ".": {
15
+ "types": "./dist/vue-tel-input.d.ts",
15
16
  "import": "./dist/vue-tel-input.js",
16
17
  "require": "./dist/vue-tel-input.umd.cjs"
17
18
  },
@@ -19,10 +20,12 @@
19
20
  },
20
21
  "main": "./dist/vue-tel-input.umd.cjs",
21
22
  "module": "./dist/vue-tel-input.js",
23
+ "types": "./dist/vue-tel-input.d.ts",
22
24
  "scripts": {
23
25
  "dev": "vitepress dev docs",
24
26
  "test": "vitest --ui",
25
27
  "build": "vue-tsc && vite build",
28
+ "postbuild": "cp src/types/index.d.ts dist/vue-tel-input.d.ts",
26
29
  "preview": "vite preview",
27
30
  "docs:dev": "vitepress dev docs",
28
31
  "docs:build": "vitepress build docs",