js-kompo-utils 1.0.15 → 1.0.17

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.
@@ -558,7 +558,8 @@ export default {
558
558
  try {
559
559
  // Try multiple geolocation services for better reliability
560
560
  const countryCode = await this.getCountryFromIP()
561
- if (countryCode && this.countries.find(c => c.code === countryCode)) {
561
+ // Only apply geolocation result if no phone value has been set in the meantime
562
+ if (countryCode && !this.phoneValue && this.countries.find(c => c.code === countryCode)) {
562
563
  this.selectedCountryCode = countryCode
563
564
  }
564
565
  } catch (error) {
@@ -606,18 +607,40 @@ export default {
606
607
  },
607
608
 
608
609
  // Auto-detect country from existing phone number
609
- autoDetectCountryFromPhone(phoneValue) {;
610
+ autoDetectCountryFromPhone(phoneValue) {
610
611
  try {
611
612
  const phoneNumber = parsePhoneNumberFromString(phoneValue)
612
613
  if (phoneNumber && phoneNumber.country) {
613
614
  this.selectedCountryCode = phoneNumber.country
614
-
615
615
  return true;
616
616
  }
617
617
  } catch (error) {
618
618
  console.warn('Failed to auto-detect country from phone:', error)
619
619
  }
620
620
 
621
+ // Fallback: try to match by dial code when parsePhoneNumberFromString
622
+ // can't determine country (e.g. +1 is shared by US, CA, etc.)
623
+ if (phoneValue && phoneValue.startsWith('+')) {
624
+ // Preferred country for ambiguous shared dial codes
625
+ const preferredByDialCode = { '1': 'CA' }
626
+
627
+ const digits = phoneValue.replace(/\D/g, '')
628
+ for (let len = Math.min(digits.length, 4); len >= 1; len--) {
629
+ const potentialCode = digits.substring(0, len)
630
+ // Check preferred country first
631
+ const preferred = preferredByDialCode[potentialCode]
632
+ if (preferred && this.countries.find(c => c.code === preferred)) {
633
+ this.selectedCountryCode = preferred
634
+ return true
635
+ }
636
+ const country = this.countries.find(c => c.dialCode === potentialCode)
637
+ if (country) {
638
+ this.selectedCountryCode = country.code
639
+ return true
640
+ }
641
+ }
642
+ }
643
+
621
644
  return false;
622
645
  },
623
646
 
@@ -40,6 +40,10 @@ export default {
40
40
  return content;
41
41
  },
42
42
  showMoreBtn() {
43
+ if (!this.showMoreText && !this.showLessText) {
44
+ return false;
45
+ }
46
+
43
47
  return (this.maxLines != null || this.maxChars != null) &&
44
48
  (this.$_config('content').length != this.content.length || this.showingMore);
45
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-kompo-utils",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {