This commit is contained in:
@@ -215,6 +215,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getAllCountries, searchCountries } from '~/utils/countries';
|
||||
import { getStaticDeviceInfo } from '~/utils/static-device-detection';
|
||||
|
||||
interface Props {
|
||||
modelValue?: string; // Comma-separated string like "FR,MC,US"
|
||||
@@ -241,9 +242,10 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Static mobile detection (no reactive dependencies)
|
||||
const isMobile = ref(false);
|
||||
const isMobileSafari = ref(false);
|
||||
const needsPerformanceMode = ref(false);
|
||||
const deviceInfo = getStaticDeviceInfo();
|
||||
const isMobile = ref(deviceInfo.isMobile);
|
||||
const isMobileSafari = ref(deviceInfo.isMobileSafari);
|
||||
const needsPerformanceMode = ref(deviceInfo.isMobileSafari || deviceInfo.isMobile);
|
||||
|
||||
// Parse initial nationalities from comma-separated string
|
||||
const parseNationalities = (value: string): string[] => {
|
||||
@@ -374,14 +376,6 @@ watch(nationalities, () => {
|
||||
|
||||
// Initialize the model value on mount if needed
|
||||
onMounted(() => {
|
||||
// Apply static device detection - no reactive dependencies
|
||||
const { isMobile: deviceIsMobile, isIos, isSafari } = useDevice();
|
||||
|
||||
// Set static values once
|
||||
isMobile.value = deviceIsMobile || false;
|
||||
isMobileSafari.value = (deviceIsMobile && isIos && isSafari) || false;
|
||||
needsPerformanceMode.value = isMobileSafari.value || isMobile.value;
|
||||
|
||||
if (!props.modelValue && validNationalities.value.length > 0) {
|
||||
updateNationalities();
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
<script setup lang="ts">
|
||||
import { parsePhoneNumber, AsYouType } from 'libphonenumber-js';
|
||||
import { getPhoneCountriesWithPreferred, searchPhoneCountries, getPhoneCountryByCode, type PhoneCountry } from '~/utils/phone-countries';
|
||||
import { getStaticDeviceInfo } from '~/utils/static-device-detection';
|
||||
|
||||
interface Props {
|
||||
modelValue?: string;
|
||||
@@ -188,8 +189,9 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Static mobile detection (no reactive dependencies)
|
||||
const isMobile = ref(false);
|
||||
const isMobileSafari = ref(false);
|
||||
const deviceInfo = getStaticDeviceInfo();
|
||||
const isMobile = ref(deviceInfo.isMobile);
|
||||
const isMobileSafari = ref(deviceInfo.isMobileSafari);
|
||||
|
||||
// Create computed-like object for template compatibility
|
||||
const mobileDetection = computed(() => ({
|
||||
@@ -324,14 +326,13 @@ watch(dropdownOpen, (isOpen) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Apply static device detection on mount
|
||||
// Component initialization - values already set from static detection
|
||||
onMounted(() => {
|
||||
// Static device detection from Nuxt Device Module - no reactive dependencies
|
||||
const { isMobile: deviceIsMobile, isIos, isSafari } = useDevice();
|
||||
|
||||
// Apply device state once (static, no reactivity)
|
||||
isMobile.value = deviceIsMobile || false;
|
||||
isMobileSafari.value = (deviceIsMobile && isIos && isSafari) || false;
|
||||
// Device detection already applied statically - no additional setup needed
|
||||
console.log('[PhoneInputWrapper] Initialized with device info:', {
|
||||
isMobile: deviceInfo.isMobile,
|
||||
isMobileSafari: deviceInfo.isMobileSafari
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user