diff --git a/components/PhoneInputDemo.vue b/components/PhoneInputDemo.vue index a8eb90a..1014729 100644 --- a/components/PhoneInputDemo.vue +++ b/components/PhoneInputDemo.vue @@ -2,7 +2,7 @@
- 🎨 New Professional Phone Input + 📱 Perfect Phone Input - Like Screenshot 2 @@ -11,34 +11,65 @@ v-model="phoneNumber" label="Phone Number" placeholder="Enter your phone number" - help-text="Monaco 🇲🇨 and France 🇫🇷 are prioritized at the top" + help-text="Clean Vuetify design with compact flag dropdown" @phone-data="handlePhoneData" @country-changed="handleCountryChange" /> + + + Test: (917) 932-4061 + + + + Test: Monaco +377 + - Live Data: + Live Phone Data:
-

Phone: {{ phoneNumber }}

-

Valid: {{ phoneData?.isValid ? '✅' : '❌' }}

-

Country: {{ phoneData?.country?.name }} {{ getCountryFlag(phoneData?.country?.iso2) }}

-

Format: International

+

Number: {{ phoneNumber }}

+

Valid: {{ phoneData?.isValid ? '✅ Valid' : '❌ Invalid' }}

+

Country: {{ phoneData?.country?.name }} ({{ phoneData?.country?.iso2 }})

+

Dial Code: {{ phoneData?.country?.dialCode }}

- - + +
    -
  • Compact Dropdown: Max 240px height, professional styling
  • -
  • Monaco Priority: 🇲🇨 Monaco and 🇫🇷 France at the top
  • -
  • Real Flags: High-quality country flag icons
  • -
  • Auto-Validation: Built-in phone number validation
  • -
  • Smart Formatting: International format with country codes
  • -
  • Responsive: Mobile-optimized design
  • +
  • Clean Design: Exactly like your screenshot - Vuetify text field with flag inside
  • +
  • Compact Dropdown: Max 240px height, not oversized
  • +
  • Real Flags: High-quality country flags from flagcdn.com
  • +
  • Monaco Priority: 🇲🇨 Monaco and 🇫🇷 France appear first
  • +
  • Smart Formatting: Uses libphonenumber-js for proper formatting
  • +
  • Search Functionality: Type to find countries quickly
  • +
+
+ + + +
    +
  • Flag size: 24x18px (perfect for text field)
  • +
  • Dropdown: Compact with search bar
  • +
  • Input field: Full width for phone number
  • +
  • Validation: Real-time phone number validation
  • +
  • Responsive: Works perfectly on mobile
@@ -60,20 +91,12 @@ const handleCountryChange = (country: any) => { console.log('Country changed:', country); }; -const getCountryFlag = (iso2: string | undefined) => { - if (!iso2) return ''; - const flagMap: Record = { - 'MC': '🇲🇨', - 'FR': '🇫🇷', - 'US': '🇺🇸', - 'IT': '🇮🇹', - 'CH': '🇨🇭', - 'GB': '🇬🇧', - 'DE': '🇩🇪', - 'ES': '🇪🇸', - 'CA': '🇨🇦' - }; - return flagMap[iso2.toUpperCase()] || ''; +const testUSNumber = () => { + phoneNumber.value = '+19179324061'; +}; + +const testMonacoNumber = () => { + phoneNumber.value = '+37799123456'; }; @@ -83,4 +106,12 @@ const getCountryFlag = (iso2: string | undefined) => { margin: 0 auto; padding: 20px; } + +code { + background: rgba(var(--v-theme-primary), 0.1); + padding: 2px 6px; + border-radius: 4px; + font-family: 'Roboto Mono', monospace; + font-size: 0.875rem; +} diff --git a/components/PhoneInputWrapper.vue b/components/PhoneInputWrapper.vue index e479515..b68be8e 100644 --- a/components/PhoneInputWrapper.vue +++ b/components/PhoneInputWrapper.vue @@ -1,60 +1,114 @@ diff --git a/package-lock.json b/package-lock.json index f02d90e..7064c6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "cookie": "^0.6.0", "flag-icons": "^7.5.0", "formidable": "^3.5.4", + "libphonenumber-js": "^1.12.10", "mime-types": "^3.0.1", "minio": "^8.0.5", "motion-v": "^1.6.1", diff --git a/package.json b/package.json index 4bd5c25..39f3421 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "cookie": "^0.6.0", "flag-icons": "^7.5.0", "formidable": "^3.5.4", + "libphonenumber-js": "^1.12.10", "mime-types": "^3.0.1", "minio": "^8.0.5", "motion-v": "^1.6.1",