vue-smart-phone-input 1.0.0

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/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @rstar327/vue-phone-input
2
+
3
+ A Vue 3 international phone number input component with country flags, auto-formatting, validation, and IP-based country detection.
4
+
5
+ ## Features
6
+
7
+ - Country selector with flag emojis and search
8
+ - Auto-format phone numbers based on country patterns
9
+ - Phone number validation
10
+ - Auto-detect country from IP address
11
+ - Full keyboard navigation in dropdown
12
+ - Copy/paste support (auto-detects country from pasted `+` numbers)
13
+ - v-model support (outputs E.164 format)
14
+ - TypeScript support
15
+ - Zero dependencies (only requires Vue 3)
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install @rstar327/vue-phone-input
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```vue
26
+ <template>
27
+ <PhoneInput
28
+ v-model="phone"
29
+ default-country="us"
30
+ @validate="onValidate"
31
+ @country-changed="onCountryChanged"
32
+ />
33
+ </template>
34
+
35
+ <script setup>
36
+ import { ref } from 'vue'
37
+ import { PhoneInput } from '@rstar327/vue-phone-input'
38
+
39
+ const phone = ref('')
40
+
41
+ function onValidate({ valid, e164, nationalNumber }) {
42
+ console.log('Valid:', valid, 'E.164:', e164)
43
+ }
44
+
45
+ function onCountryChanged(country) {
46
+ console.log('Country:', country.name, country.flag)
47
+ }
48
+ </script>
49
+ ```
50
+
51
+ ## Props
52
+
53
+ | Prop | Type | Default | Description |
54
+ |------|------|---------|-------------|
55
+ | `modelValue` | `string` | `""` | Phone number in E.164 format (v-model) |
56
+ | `defaultCountry` | `string` | `"us"` | Default country ISO2 code |
57
+ | `autoDetectCountry` | `boolean` | `true` | Auto-detect country from IP |
58
+ | `placeholder` | `string` | `"Phone number"` | Input placeholder |
59
+ | `disabled` | `boolean` | `false` | Disable the input |
60
+ | `readonly` | `boolean` | `false` | Make input readonly |
61
+ | `showValidation` | `boolean` | `true` | Show validation indicator |
62
+ | `preferredCountries` | `string[]` | `[]` | ISO2 codes to show first in dropdown |
63
+
64
+ ## Events
65
+
66
+ | Event | Payload | Description |
67
+ |-------|---------|-------------|
68
+ | `update:modelValue` | `string` | E.164 formatted number |
69
+ | `validate` | `{ valid, e164, nationalNumber }` | Validation result |
70
+ | `country-changed` | `Country` | When country selection changes |
71
+ | `focus` | — | Input focused |
72
+ | `blur` | — | Input blurred |
73
+
74
+ ## Utilities
75
+
76
+ ```js
77
+ import {
78
+ countries, // Full country list
79
+ findCountryByIso2, // Find country by ISO2 code
80
+ findCountryByDialCode, // Find country by dial code
81
+ validatePhone, // Validate a phone number
82
+ formatPhoneNumber, // Format digits with a pattern
83
+ detectCountryFromIP, // Detect country from IP (async)
84
+ searchCountries, // Search countries by name/code
85
+ } from '@rstar327/vue-phone-input'
86
+ ```
87
+
88
+ ## License
89
+
90
+ MIT
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`vue`);function t(e){return e.toUpperCase().split(``).map(e=>String.fromCodePoint(127397+e.charCodeAt(0))).join(``)}var n=[{name:`Afghanistan`,iso2:`af`,dialCode:`93`},{name:`Albania`,iso2:`al`,dialCode:`355`},{name:`Algeria`,iso2:`dz`,dialCode:`213`},{name:`Argentina`,iso2:`ar`,dialCode:`54`},{name:`Armenia`,iso2:`am`,dialCode:`374`},{name:`Australia`,iso2:`au`,dialCode:`61`,format:`.... ... ...`},{name:`Austria`,iso2:`at`,dialCode:`43`},{name:`Azerbaijan`,iso2:`az`,dialCode:`994`},{name:`Bahrain`,iso2:`bh`,dialCode:`973`},{name:`Bangladesh`,iso2:`bd`,dialCode:`880`},{name:`Belarus`,iso2:`by`,dialCode:`375`},{name:`Belgium`,iso2:`be`,dialCode:`32`},{name:`Bolivia`,iso2:`bo`,dialCode:`591`},{name:`Bosnia and Herzegovina`,iso2:`ba`,dialCode:`387`},{name:`Brazil`,iso2:`br`,dialCode:`55`,format:`(..) .....-.....`},{name:`Bulgaria`,iso2:`bg`,dialCode:`359`},{name:`Cambodia`,iso2:`kh`,dialCode:`855`},{name:`Cameroon`,iso2:`cm`,dialCode:`237`},{name:`Canada`,iso2:`ca`,dialCode:`1`,format:`(...) ...-.....`},{name:`Chile`,iso2:`cl`,dialCode:`56`},{name:`China`,iso2:`cn`,dialCode:`86`,format:`... .... ....`},{name:`Colombia`,iso2:`co`,dialCode:`57`},{name:`Costa Rica`,iso2:`cr`,dialCode:`506`},{name:`Croatia`,iso2:`hr`,dialCode:`385`},{name:`Cuba`,iso2:`cu`,dialCode:`53`},{name:`Cyprus`,iso2:`cy`,dialCode:`357`},{name:`Czech Republic`,iso2:`cz`,dialCode:`420`},{name:`Denmark`,iso2:`dk`,dialCode:`45`,format:`.. .. .. ..`},{name:`Dominican Republic`,iso2:`do`,dialCode:`1`},{name:`Ecuador`,iso2:`ec`,dialCode:`593`},{name:`Egypt`,iso2:`eg`,dialCode:`20`},{name:`El Salvador`,iso2:`sv`,dialCode:`503`},{name:`Estonia`,iso2:`ee`,dialCode:`372`},{name:`Ethiopia`,iso2:`et`,dialCode:`251`},{name:`Finland`,iso2:`fi`,dialCode:`358`},{name:`France`,iso2:`fr`,dialCode:`33`,format:`. .. .. .. ..`},{name:`Georgia`,iso2:`ge`,dialCode:`995`},{name:`Germany`,iso2:`de`,dialCode:`49`,format:`.... ........`},{name:`Ghana`,iso2:`gh`,dialCode:`233`},{name:`Greece`,iso2:`gr`,dialCode:`30`},{name:`Guatemala`,iso2:`gt`,dialCode:`502`},{name:`Honduras`,iso2:`hn`,dialCode:`504`},{name:`Hong Kong`,iso2:`hk`,dialCode:`852`,format:`.... ....`},{name:`Hungary`,iso2:`hu`,dialCode:`36`},{name:`Iceland`,iso2:`is`,dialCode:`354`},{name:`India`,iso2:`in`,dialCode:`91`,format:`..... .....`},{name:`Indonesia`,iso2:`id`,dialCode:`62`},{name:`Iran`,iso2:`ir`,dialCode:`98`},{name:`Iraq`,iso2:`iq`,dialCode:`964`},{name:`Ireland`,iso2:`ie`,dialCode:`353`},{name:`Israel`,iso2:`il`,dialCode:`972`},{name:`Italy`,iso2:`it`,dialCode:`39`,format:`... ... ....`},{name:`Jamaica`,iso2:`jm`,dialCode:`1`},{name:`Japan`,iso2:`jp`,dialCode:`81`,format:`.. .... ....`},{name:`Jordan`,iso2:`jo`,dialCode:`962`},{name:`Kazakhstan`,iso2:`kz`,dialCode:`7`},{name:`Kenya`,iso2:`ke`,dialCode:`254`},{name:`Kuwait`,iso2:`kw`,dialCode:`965`},{name:`Kyrgyzstan`,iso2:`kg`,dialCode:`996`},{name:`Laos`,iso2:`la`,dialCode:`856`},{name:`Latvia`,iso2:`lv`,dialCode:`371`},{name:`Lebanon`,iso2:`lb`,dialCode:`961`},{name:`Libya`,iso2:`ly`,dialCode:`218`},{name:`Lithuania`,iso2:`lt`,dialCode:`370`},{name:`Luxembourg`,iso2:`lu`,dialCode:`352`},{name:`Macau`,iso2:`mo`,dialCode:`853`},{name:`Malaysia`,iso2:`my`,dialCode:`60`},{name:`Maldives`,iso2:`mv`,dialCode:`960`},{name:`Malta`,iso2:`mt`,dialCode:`356`},{name:`Mexico`,iso2:`mx`,dialCode:`52`,format:`... ... ....`},{name:`Moldova`,iso2:`md`,dialCode:`373`},{name:`Mongolia`,iso2:`mn`,dialCode:`976`},{name:`Montenegro`,iso2:`me`,dialCode:`382`},{name:`Morocco`,iso2:`ma`,dialCode:`212`},{name:`Myanmar`,iso2:`mm`,dialCode:`95`},{name:`Nepal`,iso2:`np`,dialCode:`977`},{name:`Netherlands`,iso2:`nl`,dialCode:`31`,format:`.. ........`},{name:`New Zealand`,iso2:`nz`,dialCode:`64`},{name:`Nicaragua`,iso2:`ni`,dialCode:`505`},{name:`Nigeria`,iso2:`ng`,dialCode:`234`},{name:`North Korea`,iso2:`kp`,dialCode:`850`},{name:`North Macedonia`,iso2:`mk`,dialCode:`389`},{name:`Norway`,iso2:`no`,dialCode:`47`,format:`... .. ...`},{name:`Oman`,iso2:`om`,dialCode:`968`},{name:`Pakistan`,iso2:`pk`,dialCode:`92`},{name:`Palestine`,iso2:`ps`,dialCode:`970`},{name:`Panama`,iso2:`pa`,dialCode:`507`},{name:`Paraguay`,iso2:`py`,dialCode:`595`},{name:`Peru`,iso2:`pe`,dialCode:`51`},{name:`Philippines`,iso2:`ph`,dialCode:`63`},{name:`Poland`,iso2:`pl`,dialCode:`48`},{name:`Portugal`,iso2:`pt`,dialCode:`351`},{name:`Puerto Rico`,iso2:`pr`,dialCode:`1`},{name:`Qatar`,iso2:`qa`,dialCode:`974`},{name:`Romania`,iso2:`ro`,dialCode:`40`},{name:`Russia`,iso2:`ru`,dialCode:`7`,format:`(...) ...-..-..`},{name:`Saudi Arabia`,iso2:`sa`,dialCode:`966`},{name:`Senegal`,iso2:`sn`,dialCode:`221`},{name:`Serbia`,iso2:`rs`,dialCode:`381`},{name:`Singapore`,iso2:`sg`,dialCode:`65`,format:`.... ....`},{name:`Slovakia`,iso2:`sk`,dialCode:`421`},{name:`Slovenia`,iso2:`si`,dialCode:`386`},{name:`Somalia`,iso2:`so`,dialCode:`252`},{name:`South Africa`,iso2:`za`,dialCode:`27`},{name:`South Korea`,iso2:`kr`,dialCode:`82`,format:`.. .... ....`},{name:`Spain`,iso2:`es`,dialCode:`34`,format:`... ... ...`},{name:`Sri Lanka`,iso2:`lk`,dialCode:`94`},{name:`Sudan`,iso2:`sd`,dialCode:`249`},{name:`Sweden`,iso2:`se`,dialCode:`46`},{name:`Switzerland`,iso2:`ch`,dialCode:`41`},{name:`Syria`,iso2:`sy`,dialCode:`963`},{name:`Taiwan`,iso2:`tw`,dialCode:`886`},{name:`Tajikistan`,iso2:`tj`,dialCode:`992`},{name:`Tanzania`,iso2:`tz`,dialCode:`255`},{name:`Thailand`,iso2:`th`,dialCode:`66`},{name:`Tunisia`,iso2:`tn`,dialCode:`216`},{name:`Turkey`,iso2:`tr`,dialCode:`90`,format:`... ... .. ..`},{name:`Turkmenistan`,iso2:`tm`,dialCode:`993`},{name:`Uganda`,iso2:`ug`,dialCode:`256`},{name:`Ukraine`,iso2:`ua`,dialCode:`380`},{name:`United Arab Emirates`,iso2:`ae`,dialCode:`971`},{name:`United Kingdom`,iso2:`gb`,dialCode:`44`,format:`.... ......`},{name:`United States`,iso2:`us`,dialCode:`1`,format:`(...) ...-.....`},{name:`Uruguay`,iso2:`uy`,dialCode:`598`},{name:`Uzbekistan`,iso2:`uz`,dialCode:`998`},{name:`Venezuela`,iso2:`ve`,dialCode:`58`},{name:`Vietnam`,iso2:`vn`,dialCode:`84`},{name:`Yemen`,iso2:`ye`,dialCode:`967`},{name:`Zambia`,iso2:`zm`,dialCode:`260`},{name:`Zimbabwe`,iso2:`zw`,dialCode:`263`}].map(e=>({...e,flag:t(e.iso2)}));function r(e){return n.find(t=>t.iso2===e.toLowerCase())}function i(e){return n.find(t=>t.dialCode===e)}var a=`https://ipapi.co/json/`,o=`us`;async function s(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),5e3),n=await fetch(a,{signal:e.signal});if(clearTimeout(t),!n.ok)throw Error(`IP lookup failed`);return r(((await n.json()).country_code??``).toLowerCase())??r(o)}catch{return r(o)}}function c(e){if(!e)return n;let t=e.toLowerCase();return n.filter(e=>e.name.toLowerCase().includes(t)||e.dialCode.includes(t)||e.iso2.includes(t))}var l=4,u=15;function d(e,t){if(!t||!e)return e;let n=``,r=0;for(let i of t){if(r>=e.length)break;i===`.`?n+=e[r++]:n+=i}return r<e.length&&(n+=e.slice(r)),n}function f(e){return e.replace(/\D/g,``)}function p(e,t){let n=f(e),r=t?.dialCode??``,i=r&&n.startsWith(r)?n.slice(r.length):n,a=r?`+${r}${i}`:`+${n}`,o=t?.format?d(i,t.format):i,s=r.length+i.length;return{valid:i.length>=l&&s<=u&&/^\d+$/.test(i),formatted:o,e164:a,nationalNumber:i,country:t}}var m=[`tabindex`,`onKeydown`],h={class:`vpi-flag`},g={class:`vpi-dial-code`},_=[`value`,`placeholder`,`disabled`,`readonly`],v=[`onKeydown`],y=[`onClick`,`onMouseenter`],b={class:`vpi-flag`},x={class:`vpi-country-name`},S={class:`vpi-country-code`},C=(0,e.defineComponent)({__name:`PhoneInput`,props:{modelValue:{default:``},defaultCountry:{default:`us`},autoDetectCountry:{type:Boolean,default:!0},placeholder:{default:`Phone number`},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},showValidation:{type:Boolean,default:!0},preferredCountries:{default:()=>[]}},emits:[`update:modelValue`,`country-changed`,`validate`,`focus`,`blur`],setup(t,{emit:i}){let a=t,o=i,l=(0,e.ref)(r(a.defaultCountry)??null),u=(0,e.ref)(``),C=(0,e.ref)(!1),w=(0,e.ref)(!1),T=(0,e.ref)(!1),E=(0,e.ref)(``),D=(0,e.ref)(0),O=(0,e.ref)({}),k=(0,e.ref)(),A=(0,e.ref)(),j=(0,e.ref)(),M=(0,e.ref)(),N=(0,e.ref)(),P=(0,e.computed)(()=>{let e=c(E.value);if(a.preferredCountries.length>0){let t=a.preferredCountries.map(e=>r(e)).filter(Boolean),n=e.filter(e=>!a.preferredCountries.includes(e.iso2));e=[...t,...n]}return e}),F=(0,e.computed)(()=>u.value?l.value?.format?d(u.value,l.value.format):u.value:``),I=(0,e.computed)(()=>p(u.value,l.value)),L=(0,e.computed)(()=>I.value.valid);function R(e){let t=e.target;u.value=f(t.value),U()}function z(e){e.preventDefault();let t=e.clipboardData?.getData(`text`)??``,r=f(t);if(t.startsWith(`+`)){let e=r;for(let t of n)if(e.startsWith(t.dialCode)){l.value=t,u.value=e.slice(t.dialCode.length),o(`country-changed`,t),U();return}}u.value=r,U()}function B(e){[`Backspace`,`Delete`,`Tab`,`Escape`,`Enter`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)||(e.ctrlKey||e.metaKey)&&[`a`,`c`,`v`,`x`].includes(e.key.toLowerCase())||/^\d$/.test(e.key)||e.preventDefault()}function V(){C.value=!0,o(`focus`)}function H(){C.value=!1,w.value=!0,o(`blur`)}function U(){let e=I.value;o(`update:modelValue`,e.e164),o(`validate`,{valid:e.valid,e164:e.e164,nationalNumber:e.nationalNumber})}function W(){a.disabled||(T.value=!T.value,T.value&&(Z(),(0,e.nextTick)(()=>M.value?.focus())))}function G(){T.value=!1,E.value=``,D.value=0}function K(t){l.value=t,G(),o(`country-changed`,t),U(),(0,e.nextTick)(()=>k.value?.focus())}function q(){let e=P.value[D.value];e&&K(e)}function J(){D.value<P.value.length-1&&(D.value++,X())}function Y(){D.value>0&&(D.value--,X())}function X(){(0,e.nextTick)(()=>{(N.value?.children[D.value])?.scrollIntoView({block:`nearest`})})}function Z(){let e=A.value?.getBoundingClientRect();if(!e)return;let t=window.innerHeight-e.bottom<300;O.value={position:`fixed`,left:`${e.left}px`,width:`280px`,zIndex:`9999`,...t?{bottom:`${window.innerHeight-e.top+4}px`}:{top:`${e.bottom+4}px`}}}function Q(e){T.value&&j.value&&!j.value.contains(e.target)&&!A.value?.contains(e.target)&&G()}function $(e){if(!e)return;let t=f(e);if(e.startsWith(`+`)){for(let e of n)if(t.startsWith(e.dialCode)){l.value=e,u.value=t.slice(e.dialCode.length);return}}u.value=t}return(0,e.watch)(()=>a.modelValue,e=>{$(e)},{immediate:!0}),(0,e.watch)(()=>a.defaultCountry,e=>{let t=r(e);t&&(l.value=t)}),(0,e.onMounted)(async()=>{document.addEventListener(`click`,Q),a.autoDetectCountry&&!a.modelValue&&(l.value=await s())}),(0,e.onBeforeUnmount)(()=>{document.removeEventListener(`click`,Q)}),(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:(0,e.normalizeClass)([`vpi-wrapper`,{"vpi-focused":C.value,"vpi-invalid":!L.value&&w.value,"vpi-disabled":t.disabled}])},[(0,e.createElementVNode)(`div`,{class:`vpi-country`,onClick:W,ref_key:`countryBtnRef`,ref:A,tabindex:t.disabled?-1:0,onKeydown:[(0,e.withKeys)((0,e.withModifiers)(W,[`prevent`]),[`enter`]),(0,e.withKeys)((0,e.withModifiers)(W,[`prevent`]),[`space`])]},[(0,e.createElementVNode)(`span`,h,(0,e.toDisplayString)(l.value?.flag),1),(0,e.createElementVNode)(`span`,g,`+`+(0,e.toDisplayString)(l.value?.dialCode),1),r[1]||=(0,e.createElementVNode)(`span`,{class:`vpi-arrow`},`▾`,-1)],40,m),(0,e.createElementVNode)(`input`,{ref_key:`inputRef`,ref:k,type:`tel`,value:F.value,placeholder:t.placeholder,disabled:t.disabled,readonly:t.readonly,class:`vpi-input`,onInput:R,onFocus:V,onBlur:H,onPaste:z,onKeydown:B},null,40,_),w.value&&t.showValidation?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,class:(0,e.normalizeClass)([`vpi-validation`,L.value?`vpi-valid`:`vpi-error`])},(0,e.toDisplayString)(L.value?`✓`:`✗`),3)):(0,e.createCommentVNode)(``,!0),((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:`body`},[T.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`vpi-dropdown`,ref_key:`dropdownRef`,ref:j,style:(0,e.normalizeStyle)(O.value)},[(0,e.withDirectives)((0,e.createElementVNode)(`input`,{ref_key:`searchRef`,ref:M,type:`text`,class:`vpi-search`,"onUpdate:modelValue":r[0]||=e=>E.value=e,placeholder:`Search country...`,onKeydown:[(0,e.withKeys)(G,[`escape`]),(0,e.withKeys)((0,e.withModifiers)(J,[`prevent`]),[`down`]),(0,e.withKeys)((0,e.withModifiers)(Y,[`prevent`]),[`up`]),(0,e.withKeys)((0,e.withModifiers)(q,[`prevent`]),[`enter`])]},null,40,v),[[e.vModelText,E.value]]),(0,e.createElementVNode)(`ul`,{class:`vpi-country-list`,ref_key:`listRef`,ref:N},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(P.value,(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`li`,{key:t.iso2,class:(0,e.normalizeClass)([`vpi-country-item`,{"vpi-highlighted":n===D.value}]),onClick:e=>K(t),onMouseenter:e=>D.value=n},[(0,e.createElementVNode)(`span`,b,(0,e.toDisplayString)(t.flag),1),(0,e.createElementVNode)(`span`,x,(0,e.toDisplayString)(t.name),1),(0,e.createElementVNode)(`span`,S,`+`+(0,e.toDisplayString)(t.dialCode),1)],42,y))),128))],512)],4)):(0,e.createCommentVNode)(``,!0)]))],2))}});exports.PhoneInput=C,exports.countries=n,exports.detectCountryFromIP=s,exports.findCountryByDialCode=i,exports.findCountryByIso2=r,exports.formatPhoneNumber=d,exports.searchCountries=c,exports.stripNonDigits=f,exports.validatePhone=p;
@@ -0,0 +1,959 @@
1
+ import { Fragment as e, Teleport as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, nextTick as c, normalizeClass as l, normalizeStyle as ee, onBeforeUnmount as te, onMounted as u, openBlock as d, ref as f, renderList as p, toDisplayString as m, vModelText as ne, watch as h, withDirectives as re, withKeys as g, withModifiers as _ } from "vue";
2
+ //#region src/data/countries.ts
3
+ function v(e) {
4
+ return e.toUpperCase().split("").map((e) => String.fromCodePoint(127397 + e.charCodeAt(0))).join("");
5
+ }
6
+ var y = [
7
+ {
8
+ name: "Afghanistan",
9
+ iso2: "af",
10
+ dialCode: "93"
11
+ },
12
+ {
13
+ name: "Albania",
14
+ iso2: "al",
15
+ dialCode: "355"
16
+ },
17
+ {
18
+ name: "Algeria",
19
+ iso2: "dz",
20
+ dialCode: "213"
21
+ },
22
+ {
23
+ name: "Argentina",
24
+ iso2: "ar",
25
+ dialCode: "54"
26
+ },
27
+ {
28
+ name: "Armenia",
29
+ iso2: "am",
30
+ dialCode: "374"
31
+ },
32
+ {
33
+ name: "Australia",
34
+ iso2: "au",
35
+ dialCode: "61",
36
+ format: ".... ... ..."
37
+ },
38
+ {
39
+ name: "Austria",
40
+ iso2: "at",
41
+ dialCode: "43"
42
+ },
43
+ {
44
+ name: "Azerbaijan",
45
+ iso2: "az",
46
+ dialCode: "994"
47
+ },
48
+ {
49
+ name: "Bahrain",
50
+ iso2: "bh",
51
+ dialCode: "973"
52
+ },
53
+ {
54
+ name: "Bangladesh",
55
+ iso2: "bd",
56
+ dialCode: "880"
57
+ },
58
+ {
59
+ name: "Belarus",
60
+ iso2: "by",
61
+ dialCode: "375"
62
+ },
63
+ {
64
+ name: "Belgium",
65
+ iso2: "be",
66
+ dialCode: "32"
67
+ },
68
+ {
69
+ name: "Bolivia",
70
+ iso2: "bo",
71
+ dialCode: "591"
72
+ },
73
+ {
74
+ name: "Bosnia and Herzegovina",
75
+ iso2: "ba",
76
+ dialCode: "387"
77
+ },
78
+ {
79
+ name: "Brazil",
80
+ iso2: "br",
81
+ dialCode: "55",
82
+ format: "(..) .....-....."
83
+ },
84
+ {
85
+ name: "Bulgaria",
86
+ iso2: "bg",
87
+ dialCode: "359"
88
+ },
89
+ {
90
+ name: "Cambodia",
91
+ iso2: "kh",
92
+ dialCode: "855"
93
+ },
94
+ {
95
+ name: "Cameroon",
96
+ iso2: "cm",
97
+ dialCode: "237"
98
+ },
99
+ {
100
+ name: "Canada",
101
+ iso2: "ca",
102
+ dialCode: "1",
103
+ format: "(...) ...-....."
104
+ },
105
+ {
106
+ name: "Chile",
107
+ iso2: "cl",
108
+ dialCode: "56"
109
+ },
110
+ {
111
+ name: "China",
112
+ iso2: "cn",
113
+ dialCode: "86",
114
+ format: "... .... ...."
115
+ },
116
+ {
117
+ name: "Colombia",
118
+ iso2: "co",
119
+ dialCode: "57"
120
+ },
121
+ {
122
+ name: "Costa Rica",
123
+ iso2: "cr",
124
+ dialCode: "506"
125
+ },
126
+ {
127
+ name: "Croatia",
128
+ iso2: "hr",
129
+ dialCode: "385"
130
+ },
131
+ {
132
+ name: "Cuba",
133
+ iso2: "cu",
134
+ dialCode: "53"
135
+ },
136
+ {
137
+ name: "Cyprus",
138
+ iso2: "cy",
139
+ dialCode: "357"
140
+ },
141
+ {
142
+ name: "Czech Republic",
143
+ iso2: "cz",
144
+ dialCode: "420"
145
+ },
146
+ {
147
+ name: "Denmark",
148
+ iso2: "dk",
149
+ dialCode: "45",
150
+ format: ".. .. .. .."
151
+ },
152
+ {
153
+ name: "Dominican Republic",
154
+ iso2: "do",
155
+ dialCode: "1"
156
+ },
157
+ {
158
+ name: "Ecuador",
159
+ iso2: "ec",
160
+ dialCode: "593"
161
+ },
162
+ {
163
+ name: "Egypt",
164
+ iso2: "eg",
165
+ dialCode: "20"
166
+ },
167
+ {
168
+ name: "El Salvador",
169
+ iso2: "sv",
170
+ dialCode: "503"
171
+ },
172
+ {
173
+ name: "Estonia",
174
+ iso2: "ee",
175
+ dialCode: "372"
176
+ },
177
+ {
178
+ name: "Ethiopia",
179
+ iso2: "et",
180
+ dialCode: "251"
181
+ },
182
+ {
183
+ name: "Finland",
184
+ iso2: "fi",
185
+ dialCode: "358"
186
+ },
187
+ {
188
+ name: "France",
189
+ iso2: "fr",
190
+ dialCode: "33",
191
+ format: ". .. .. .. .."
192
+ },
193
+ {
194
+ name: "Georgia",
195
+ iso2: "ge",
196
+ dialCode: "995"
197
+ },
198
+ {
199
+ name: "Germany",
200
+ iso2: "de",
201
+ dialCode: "49",
202
+ format: ".... ........"
203
+ },
204
+ {
205
+ name: "Ghana",
206
+ iso2: "gh",
207
+ dialCode: "233"
208
+ },
209
+ {
210
+ name: "Greece",
211
+ iso2: "gr",
212
+ dialCode: "30"
213
+ },
214
+ {
215
+ name: "Guatemala",
216
+ iso2: "gt",
217
+ dialCode: "502"
218
+ },
219
+ {
220
+ name: "Honduras",
221
+ iso2: "hn",
222
+ dialCode: "504"
223
+ },
224
+ {
225
+ name: "Hong Kong",
226
+ iso2: "hk",
227
+ dialCode: "852",
228
+ format: ".... ...."
229
+ },
230
+ {
231
+ name: "Hungary",
232
+ iso2: "hu",
233
+ dialCode: "36"
234
+ },
235
+ {
236
+ name: "Iceland",
237
+ iso2: "is",
238
+ dialCode: "354"
239
+ },
240
+ {
241
+ name: "India",
242
+ iso2: "in",
243
+ dialCode: "91",
244
+ format: "..... ....."
245
+ },
246
+ {
247
+ name: "Indonesia",
248
+ iso2: "id",
249
+ dialCode: "62"
250
+ },
251
+ {
252
+ name: "Iran",
253
+ iso2: "ir",
254
+ dialCode: "98"
255
+ },
256
+ {
257
+ name: "Iraq",
258
+ iso2: "iq",
259
+ dialCode: "964"
260
+ },
261
+ {
262
+ name: "Ireland",
263
+ iso2: "ie",
264
+ dialCode: "353"
265
+ },
266
+ {
267
+ name: "Israel",
268
+ iso2: "il",
269
+ dialCode: "972"
270
+ },
271
+ {
272
+ name: "Italy",
273
+ iso2: "it",
274
+ dialCode: "39",
275
+ format: "... ... ...."
276
+ },
277
+ {
278
+ name: "Jamaica",
279
+ iso2: "jm",
280
+ dialCode: "1"
281
+ },
282
+ {
283
+ name: "Japan",
284
+ iso2: "jp",
285
+ dialCode: "81",
286
+ format: ".. .... ...."
287
+ },
288
+ {
289
+ name: "Jordan",
290
+ iso2: "jo",
291
+ dialCode: "962"
292
+ },
293
+ {
294
+ name: "Kazakhstan",
295
+ iso2: "kz",
296
+ dialCode: "7"
297
+ },
298
+ {
299
+ name: "Kenya",
300
+ iso2: "ke",
301
+ dialCode: "254"
302
+ },
303
+ {
304
+ name: "Kuwait",
305
+ iso2: "kw",
306
+ dialCode: "965"
307
+ },
308
+ {
309
+ name: "Kyrgyzstan",
310
+ iso2: "kg",
311
+ dialCode: "996"
312
+ },
313
+ {
314
+ name: "Laos",
315
+ iso2: "la",
316
+ dialCode: "856"
317
+ },
318
+ {
319
+ name: "Latvia",
320
+ iso2: "lv",
321
+ dialCode: "371"
322
+ },
323
+ {
324
+ name: "Lebanon",
325
+ iso2: "lb",
326
+ dialCode: "961"
327
+ },
328
+ {
329
+ name: "Libya",
330
+ iso2: "ly",
331
+ dialCode: "218"
332
+ },
333
+ {
334
+ name: "Lithuania",
335
+ iso2: "lt",
336
+ dialCode: "370"
337
+ },
338
+ {
339
+ name: "Luxembourg",
340
+ iso2: "lu",
341
+ dialCode: "352"
342
+ },
343
+ {
344
+ name: "Macau",
345
+ iso2: "mo",
346
+ dialCode: "853"
347
+ },
348
+ {
349
+ name: "Malaysia",
350
+ iso2: "my",
351
+ dialCode: "60"
352
+ },
353
+ {
354
+ name: "Maldives",
355
+ iso2: "mv",
356
+ dialCode: "960"
357
+ },
358
+ {
359
+ name: "Malta",
360
+ iso2: "mt",
361
+ dialCode: "356"
362
+ },
363
+ {
364
+ name: "Mexico",
365
+ iso2: "mx",
366
+ dialCode: "52",
367
+ format: "... ... ...."
368
+ },
369
+ {
370
+ name: "Moldova",
371
+ iso2: "md",
372
+ dialCode: "373"
373
+ },
374
+ {
375
+ name: "Mongolia",
376
+ iso2: "mn",
377
+ dialCode: "976"
378
+ },
379
+ {
380
+ name: "Montenegro",
381
+ iso2: "me",
382
+ dialCode: "382"
383
+ },
384
+ {
385
+ name: "Morocco",
386
+ iso2: "ma",
387
+ dialCode: "212"
388
+ },
389
+ {
390
+ name: "Myanmar",
391
+ iso2: "mm",
392
+ dialCode: "95"
393
+ },
394
+ {
395
+ name: "Nepal",
396
+ iso2: "np",
397
+ dialCode: "977"
398
+ },
399
+ {
400
+ name: "Netherlands",
401
+ iso2: "nl",
402
+ dialCode: "31",
403
+ format: ".. ........"
404
+ },
405
+ {
406
+ name: "New Zealand",
407
+ iso2: "nz",
408
+ dialCode: "64"
409
+ },
410
+ {
411
+ name: "Nicaragua",
412
+ iso2: "ni",
413
+ dialCode: "505"
414
+ },
415
+ {
416
+ name: "Nigeria",
417
+ iso2: "ng",
418
+ dialCode: "234"
419
+ },
420
+ {
421
+ name: "North Korea",
422
+ iso2: "kp",
423
+ dialCode: "850"
424
+ },
425
+ {
426
+ name: "North Macedonia",
427
+ iso2: "mk",
428
+ dialCode: "389"
429
+ },
430
+ {
431
+ name: "Norway",
432
+ iso2: "no",
433
+ dialCode: "47",
434
+ format: "... .. ..."
435
+ },
436
+ {
437
+ name: "Oman",
438
+ iso2: "om",
439
+ dialCode: "968"
440
+ },
441
+ {
442
+ name: "Pakistan",
443
+ iso2: "pk",
444
+ dialCode: "92"
445
+ },
446
+ {
447
+ name: "Palestine",
448
+ iso2: "ps",
449
+ dialCode: "970"
450
+ },
451
+ {
452
+ name: "Panama",
453
+ iso2: "pa",
454
+ dialCode: "507"
455
+ },
456
+ {
457
+ name: "Paraguay",
458
+ iso2: "py",
459
+ dialCode: "595"
460
+ },
461
+ {
462
+ name: "Peru",
463
+ iso2: "pe",
464
+ dialCode: "51"
465
+ },
466
+ {
467
+ name: "Philippines",
468
+ iso2: "ph",
469
+ dialCode: "63"
470
+ },
471
+ {
472
+ name: "Poland",
473
+ iso2: "pl",
474
+ dialCode: "48"
475
+ },
476
+ {
477
+ name: "Portugal",
478
+ iso2: "pt",
479
+ dialCode: "351"
480
+ },
481
+ {
482
+ name: "Puerto Rico",
483
+ iso2: "pr",
484
+ dialCode: "1"
485
+ },
486
+ {
487
+ name: "Qatar",
488
+ iso2: "qa",
489
+ dialCode: "974"
490
+ },
491
+ {
492
+ name: "Romania",
493
+ iso2: "ro",
494
+ dialCode: "40"
495
+ },
496
+ {
497
+ name: "Russia",
498
+ iso2: "ru",
499
+ dialCode: "7",
500
+ format: "(...) ...-..-.."
501
+ },
502
+ {
503
+ name: "Saudi Arabia",
504
+ iso2: "sa",
505
+ dialCode: "966"
506
+ },
507
+ {
508
+ name: "Senegal",
509
+ iso2: "sn",
510
+ dialCode: "221"
511
+ },
512
+ {
513
+ name: "Serbia",
514
+ iso2: "rs",
515
+ dialCode: "381"
516
+ },
517
+ {
518
+ name: "Singapore",
519
+ iso2: "sg",
520
+ dialCode: "65",
521
+ format: ".... ...."
522
+ },
523
+ {
524
+ name: "Slovakia",
525
+ iso2: "sk",
526
+ dialCode: "421"
527
+ },
528
+ {
529
+ name: "Slovenia",
530
+ iso2: "si",
531
+ dialCode: "386"
532
+ },
533
+ {
534
+ name: "Somalia",
535
+ iso2: "so",
536
+ dialCode: "252"
537
+ },
538
+ {
539
+ name: "South Africa",
540
+ iso2: "za",
541
+ dialCode: "27"
542
+ },
543
+ {
544
+ name: "South Korea",
545
+ iso2: "kr",
546
+ dialCode: "82",
547
+ format: ".. .... ...."
548
+ },
549
+ {
550
+ name: "Spain",
551
+ iso2: "es",
552
+ dialCode: "34",
553
+ format: "... ... ..."
554
+ },
555
+ {
556
+ name: "Sri Lanka",
557
+ iso2: "lk",
558
+ dialCode: "94"
559
+ },
560
+ {
561
+ name: "Sudan",
562
+ iso2: "sd",
563
+ dialCode: "249"
564
+ },
565
+ {
566
+ name: "Sweden",
567
+ iso2: "se",
568
+ dialCode: "46"
569
+ },
570
+ {
571
+ name: "Switzerland",
572
+ iso2: "ch",
573
+ dialCode: "41"
574
+ },
575
+ {
576
+ name: "Syria",
577
+ iso2: "sy",
578
+ dialCode: "963"
579
+ },
580
+ {
581
+ name: "Taiwan",
582
+ iso2: "tw",
583
+ dialCode: "886"
584
+ },
585
+ {
586
+ name: "Tajikistan",
587
+ iso2: "tj",
588
+ dialCode: "992"
589
+ },
590
+ {
591
+ name: "Tanzania",
592
+ iso2: "tz",
593
+ dialCode: "255"
594
+ },
595
+ {
596
+ name: "Thailand",
597
+ iso2: "th",
598
+ dialCode: "66"
599
+ },
600
+ {
601
+ name: "Tunisia",
602
+ iso2: "tn",
603
+ dialCode: "216"
604
+ },
605
+ {
606
+ name: "Turkey",
607
+ iso2: "tr",
608
+ dialCode: "90",
609
+ format: "... ... .. .."
610
+ },
611
+ {
612
+ name: "Turkmenistan",
613
+ iso2: "tm",
614
+ dialCode: "993"
615
+ },
616
+ {
617
+ name: "Uganda",
618
+ iso2: "ug",
619
+ dialCode: "256"
620
+ },
621
+ {
622
+ name: "Ukraine",
623
+ iso2: "ua",
624
+ dialCode: "380"
625
+ },
626
+ {
627
+ name: "United Arab Emirates",
628
+ iso2: "ae",
629
+ dialCode: "971"
630
+ },
631
+ {
632
+ name: "United Kingdom",
633
+ iso2: "gb",
634
+ dialCode: "44",
635
+ format: ".... ......"
636
+ },
637
+ {
638
+ name: "United States",
639
+ iso2: "us",
640
+ dialCode: "1",
641
+ format: "(...) ...-....."
642
+ },
643
+ {
644
+ name: "Uruguay",
645
+ iso2: "uy",
646
+ dialCode: "598"
647
+ },
648
+ {
649
+ name: "Uzbekistan",
650
+ iso2: "uz",
651
+ dialCode: "998"
652
+ },
653
+ {
654
+ name: "Venezuela",
655
+ iso2: "ve",
656
+ dialCode: "58"
657
+ },
658
+ {
659
+ name: "Vietnam",
660
+ iso2: "vn",
661
+ dialCode: "84"
662
+ },
663
+ {
664
+ name: "Yemen",
665
+ iso2: "ye",
666
+ dialCode: "967"
667
+ },
668
+ {
669
+ name: "Zambia",
670
+ iso2: "zm",
671
+ dialCode: "260"
672
+ },
673
+ {
674
+ name: "Zimbabwe",
675
+ iso2: "zw",
676
+ dialCode: "263"
677
+ }
678
+ ].map((e) => ({
679
+ ...e,
680
+ flag: v(e.iso2)
681
+ }));
682
+ function b(e) {
683
+ return y.find((t) => t.iso2 === e.toLowerCase());
684
+ }
685
+ function x(e) {
686
+ return y.find((t) => t.dialCode === e);
687
+ }
688
+ //#endregion
689
+ //#region src/composables/useCountryDetection.ts
690
+ var S = "https://ipapi.co/json/", C = "us";
691
+ async function w() {
692
+ try {
693
+ let e = new AbortController(), t = setTimeout(() => e.abort(), 5e3), n = await fetch(S, { signal: e.signal });
694
+ if (clearTimeout(t), !n.ok) throw Error("IP lookup failed");
695
+ return b(((await n.json()).country_code ?? "").toLowerCase()) ?? b(C);
696
+ } catch {
697
+ return b(C);
698
+ }
699
+ }
700
+ function T(e) {
701
+ if (!e) return y;
702
+ let t = e.toLowerCase();
703
+ return y.filter((e) => e.name.toLowerCase().includes(t) || e.dialCode.includes(t) || e.iso2.includes(t));
704
+ }
705
+ //#endregion
706
+ //#region src/composables/usePhoneValidation.ts
707
+ var E = 4, D = 15;
708
+ function O(e, t) {
709
+ if (!t || !e) return e;
710
+ let n = "", r = 0;
711
+ for (let i of t) {
712
+ if (r >= e.length) break;
713
+ i === "." ? n += e[r++] : n += i;
714
+ }
715
+ return r < e.length && (n += e.slice(r)), n;
716
+ }
717
+ function k(e) {
718
+ return e.replace(/\D/g, "");
719
+ }
720
+ function A(e, t) {
721
+ let n = k(e), r = t?.dialCode ?? "", i = r && n.startsWith(r) ? n.slice(r.length) : n, a = r ? `+${r}${i}` : `+${n}`, o = t?.format ? O(i, t.format) : i, s = r.length + i.length;
722
+ return {
723
+ valid: i.length >= E && s <= D && /^\d+$/.test(i),
724
+ formatted: o,
725
+ e164: a,
726
+ nationalNumber: i,
727
+ country: t
728
+ };
729
+ }
730
+ //#endregion
731
+ //#region src/PhoneInput.vue?vue&type=script&setup=true&lang.ts
732
+ var ie = ["tabindex", "onKeydown"], ae = { class: "vpi-flag" }, j = { class: "vpi-dial-code" }, oe = [
733
+ "value",
734
+ "placeholder",
735
+ "disabled",
736
+ "readonly"
737
+ ], se = ["onKeydown"], ce = ["onClick", "onMouseenter"], M = { class: "vpi-flag" }, N = { class: "vpi-country-name" }, P = { class: "vpi-country-code" }, F = /* @__PURE__ */ s({
738
+ __name: "PhoneInput",
739
+ props: {
740
+ modelValue: { default: "" },
741
+ defaultCountry: { default: "us" },
742
+ autoDetectCountry: {
743
+ type: Boolean,
744
+ default: !0
745
+ },
746
+ placeholder: { default: "Phone number" },
747
+ disabled: {
748
+ type: Boolean,
749
+ default: !1
750
+ },
751
+ readonly: {
752
+ type: Boolean,
753
+ default: !1
754
+ },
755
+ showValidation: {
756
+ type: Boolean,
757
+ default: !0
758
+ },
759
+ preferredCountries: { default: () => [] }
760
+ },
761
+ emits: [
762
+ "update:modelValue",
763
+ "country-changed",
764
+ "validate",
765
+ "focus",
766
+ "blur"
767
+ ],
768
+ setup(s, { emit: v }) {
769
+ let x = s, S = v, C = f(b(x.defaultCountry) ?? null), E = f(""), D = f(!1), F = f(!1), I = f(!1), L = f(""), R = f(0), z = f({}), B = f(), V = f(), H = f(), U = f(), W = f(), G = n(() => {
770
+ let e = T(L.value);
771
+ if (x.preferredCountries.length > 0) {
772
+ let t = x.preferredCountries.map((e) => b(e)).filter(Boolean), n = e.filter((e) => !x.preferredCountries.includes(e.iso2));
773
+ e = [...t, ...n];
774
+ }
775
+ return e;
776
+ }), le = n(() => E.value ? C.value?.format ? O(E.value, C.value.format) : E.value : ""), K = n(() => A(E.value, C.value)), q = n(() => K.value.valid);
777
+ function ue(e) {
778
+ let t = e.target;
779
+ E.value = k(t.value), J();
780
+ }
781
+ function de(e) {
782
+ e.preventDefault();
783
+ let t = e.clipboardData?.getData("text") ?? "", n = k(t);
784
+ if (t.startsWith("+")) {
785
+ let e = n;
786
+ for (let t of y) if (e.startsWith(t.dialCode)) {
787
+ C.value = t, E.value = e.slice(t.dialCode.length), S("country-changed", t), J();
788
+ return;
789
+ }
790
+ }
791
+ E.value = n, J();
792
+ }
793
+ function fe(e) {
794
+ [
795
+ "Backspace",
796
+ "Delete",
797
+ "Tab",
798
+ "Escape",
799
+ "Enter",
800
+ "ArrowLeft",
801
+ "ArrowRight",
802
+ "ArrowUp",
803
+ "ArrowDown",
804
+ "Home",
805
+ "End"
806
+ ].includes(e.key) || (e.ctrlKey || e.metaKey) && [
807
+ "a",
808
+ "c",
809
+ "v",
810
+ "x"
811
+ ].includes(e.key.toLowerCase()) || /^\d$/.test(e.key) || e.preventDefault();
812
+ }
813
+ function pe() {
814
+ D.value = !0, S("focus");
815
+ }
816
+ function me() {
817
+ D.value = !1, F.value = !0, S("blur");
818
+ }
819
+ function J() {
820
+ let e = K.value;
821
+ S("update:modelValue", e.e164), S("validate", {
822
+ valid: e.valid,
823
+ e164: e.e164,
824
+ nationalNumber: e.nationalNumber
825
+ });
826
+ }
827
+ function Y() {
828
+ x.disabled || (I.value = !I.value, I.value && (ve(), c(() => U.value?.focus())));
829
+ }
830
+ function X() {
831
+ I.value = !1, L.value = "", R.value = 0;
832
+ }
833
+ function Z(e) {
834
+ C.value = e, X(), S("country-changed", e), J(), c(() => B.value?.focus());
835
+ }
836
+ function he() {
837
+ let e = G.value[R.value];
838
+ e && Z(e);
839
+ }
840
+ function ge() {
841
+ R.value < G.value.length - 1 && (R.value++, Q());
842
+ }
843
+ function _e() {
844
+ R.value > 0 && (R.value--, Q());
845
+ }
846
+ function Q() {
847
+ c(() => {
848
+ (W.value?.children[R.value])?.scrollIntoView({ block: "nearest" });
849
+ });
850
+ }
851
+ function ve() {
852
+ let e = V.value?.getBoundingClientRect();
853
+ if (!e) return;
854
+ let t = window.innerHeight - e.bottom < 300;
855
+ z.value = {
856
+ position: "fixed",
857
+ left: `${e.left}px`,
858
+ width: "280px",
859
+ zIndex: "9999",
860
+ ...t ? { bottom: `${window.innerHeight - e.top + 4}px` } : { top: `${e.bottom + 4}px` }
861
+ };
862
+ }
863
+ function $(e) {
864
+ I.value && H.value && !H.value.contains(e.target) && !V.value?.contains(e.target) && X();
865
+ }
866
+ function ye(e) {
867
+ if (!e) return;
868
+ let t = k(e);
869
+ if (e.startsWith("+")) {
870
+ for (let e of y) if (t.startsWith(e.dialCode)) {
871
+ C.value = e, E.value = t.slice(e.dialCode.length);
872
+ return;
873
+ }
874
+ }
875
+ E.value = t;
876
+ }
877
+ return h(() => x.modelValue, (e) => {
878
+ ye(e);
879
+ }, { immediate: !0 }), h(() => x.defaultCountry, (e) => {
880
+ let t = b(e);
881
+ t && (C.value = t);
882
+ }), u(async () => {
883
+ document.addEventListener("click", $), x.autoDetectCountry && !x.modelValue && (C.value = await w());
884
+ }), te(() => {
885
+ document.removeEventListener("click", $);
886
+ }), (n, c) => (d(), a("div", { class: l(["vpi-wrapper", {
887
+ "vpi-focused": D.value,
888
+ "vpi-invalid": !q.value && F.value,
889
+ "vpi-disabled": s.disabled
890
+ }]) }, [
891
+ o("div", {
892
+ class: "vpi-country",
893
+ onClick: Y,
894
+ ref_key: "countryBtnRef",
895
+ ref: V,
896
+ tabindex: s.disabled ? -1 : 0,
897
+ onKeydown: [g(_(Y, ["prevent"]), ["enter"]), g(_(Y, ["prevent"]), ["space"])]
898
+ }, [
899
+ o("span", ae, m(C.value?.flag), 1),
900
+ o("span", j, "+" + m(C.value?.dialCode), 1),
901
+ c[1] ||= o("span", { class: "vpi-arrow" }, "▾", -1)
902
+ ], 40, ie),
903
+ o("input", {
904
+ ref_key: "inputRef",
905
+ ref: B,
906
+ type: "tel",
907
+ value: le.value,
908
+ placeholder: s.placeholder,
909
+ disabled: s.disabled,
910
+ readonly: s.readonly,
911
+ class: "vpi-input",
912
+ onInput: ue,
913
+ onFocus: pe,
914
+ onBlur: me,
915
+ onPaste: de,
916
+ onKeydown: fe
917
+ }, null, 40, oe),
918
+ F.value && s.showValidation ? (d(), a("span", {
919
+ key: 0,
920
+ class: l(["vpi-validation", q.value ? "vpi-valid" : "vpi-error"])
921
+ }, m(q.value ? "✓" : "✗"), 3)) : i("", !0),
922
+ (d(), r(t, { to: "body" }, [I.value ? (d(), a("div", {
923
+ key: 0,
924
+ class: "vpi-dropdown",
925
+ ref_key: "dropdownRef",
926
+ ref: H,
927
+ style: ee(z.value)
928
+ }, [re(o("input", {
929
+ ref_key: "searchRef",
930
+ ref: U,
931
+ type: "text",
932
+ class: "vpi-search",
933
+ "onUpdate:modelValue": c[0] ||= (e) => L.value = e,
934
+ placeholder: "Search country...",
935
+ onKeydown: [
936
+ g(X, ["escape"]),
937
+ g(_(ge, ["prevent"]), ["down"]),
938
+ g(_(_e, ["prevent"]), ["up"]),
939
+ g(_(he, ["prevent"]), ["enter"])
940
+ ]
941
+ }, null, 40, se), [[ne, L.value]]), o("ul", {
942
+ class: "vpi-country-list",
943
+ ref_key: "listRef",
944
+ ref: W
945
+ }, [(d(!0), a(e, null, p(G.value, (e, t) => (d(), a("li", {
946
+ key: e.iso2,
947
+ class: l(["vpi-country-item", { "vpi-highlighted": t === R.value }]),
948
+ onClick: (t) => Z(e),
949
+ onMouseenter: (e) => R.value = t
950
+ }, [
951
+ o("span", M, m(e.flag), 1),
952
+ o("span", N, m(e.name), 1),
953
+ o("span", P, "+" + m(e.dialCode), 1)
954
+ ], 42, ce))), 128))], 512)], 4)) : i("", !0)]))
955
+ ], 2));
956
+ }
957
+ });
958
+ //#endregion
959
+ export { F as PhoneInput, y as countries, w as detectCountryFromIP, x as findCountryByDialCode, b as findCountryByIso2, O as formatPhoneNumber, T as searchCountries, k as stripNonDigits, A as validatePhone };
@@ -0,0 +1,2 @@
1
+ .vpi-wrapper{background:#fff;border:1px solid #d1d5db;border-radius:8px;align-items:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:14px;transition:border-color .2s,box-shadow .2s;display:inline-flex;overflow:visible}.vpi-wrapper:hover{border-color:#9ca3af}.vpi-focused{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f626}.vpi-invalid{border-color:#ef4444}.vpi-invalid.vpi-focused{box-shadow:0 0 0 3px #ef444426}.vpi-disabled{opacity:.5;pointer-events:none;background:#f9fafb}.vpi-country{cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;border-right:1px solid #e5e7eb;align-items:center;gap:4px;padding:8px 8px 8px 12px;display:flex}.vpi-country:hover{background:#f3f4f6}.vpi-flag{font-size:18px;line-height:1}.vpi-dial-code{color:#6b7280;font-size:13px}.vpi-arrow{color:#9ca3af;margin-left:2px;font-size:10px}.vpi-input{background:0 0;border:none;outline:none;flex:1;min-width:0;padding:8px 12px;font-family:inherit;font-size:14px}.vpi-input::placeholder{color:#9ca3af}.vpi-validation{padding:0 10px;font-size:16px;font-weight:700}.vpi-valid{color:#22c55e}.vpi-error{color:#ef4444}.vpi-dropdown{background:#fff;border:1px solid #e5e7eb;border-radius:8px;overflow:hidden;box-shadow:0 10px 25px #0000001f}.vpi-search{box-sizing:border-box;border:none;border-bottom:1px solid #e5e7eb;outline:none;width:100%;padding:10px 12px;font-family:inherit;font-size:14px}.vpi-search::placeholder{color:#9ca3af}.vpi-country-list{max-height:250px;margin:0;padding:4px 0;list-style:none;overflow-y:auto}.vpi-country-item{cursor:pointer;align-items:center;gap:8px;padding:8px 12px;transition:background .1s;display:flex}.vpi-country-item:hover,.vpi-highlighted{background:#f3f4f6}.vpi-country-name{text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:13px;overflow:hidden}.vpi-country-code{color:#6b7280;flex-shrink:0;font-size:12px}
2
+ /*$vite$:1*/
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "vue-smart-phone-input",
3
+ "version": "1.0.0",
4
+ "description": "Vue 3 international phone number input with country flags, auto-formatting, validation, and country auto-detection",
5
+ "type": "module",
6
+ "main": "./dist/vue-phone-input.cjs",
7
+ "module": "./dist/vue-phone-input.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/vue-phone-input.mjs",
12
+ "require": "./dist/vue-phone-input.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "vite build && vue-tsc --declaration --emitDeclarationOnly --outDir dist",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "vue",
26
+ "vue3",
27
+ "phone",
28
+ "phone-input",
29
+ "telephone",
30
+ "international",
31
+ "country-code",
32
+ "phone-number",
33
+ "input",
34
+ "component",
35
+ "validation",
36
+ "flags"
37
+ ],
38
+ "author": "rstar327",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/rstar327/vue-phone-input"
43
+ },
44
+ "homepage": "https://github.com/rstar327/vue-phone-input#readme",
45
+ "peerDependencies": {
46
+ "vue": "^3.3.0"
47
+ },
48
+ "devDependencies": {
49
+ "@vitejs/plugin-vue": "^6.0.5",
50
+ "typescript": "^6.0.2",
51
+ "vite": "^8.0.3",
52
+ "vue": "^3.5.31",
53
+ "vue-tsc": "^3.2.6"
54
+ }
55
+ }