update FramelessButton, PhoneInput, TextInput

- FramelessButton: use cursor-pointer
- PhoneInput: add setCountryByIP with geo lookup
- TextInput: add $bindable ref property
This commit is contained in:
Elijah Duffy
2025-05-06 10:59:42 -07:00
parent be7ef6bdfd
commit 8c27737404
3 changed files with 26 additions and 7 deletions

View File

@@ -63,6 +63,20 @@
}
};
// setCountryByIP queries ip-api.com for user location based on IP
export const setCountryByIP = async (ip: string) => {
const res = await fetch(`http://ip-api.com/json/${ip}`);
const locationData = await res.json();
let country = 'CA'; // default to Canada
if (locationData.status !== 'fail') {
const { countryCode } = locationData;
country = countryCode;
console.log('updating country code according to IP', country);
}
setCountryByISO(country);
};
// set the default country based on the provided ISO code
if (defaultISO) {
setCountryByISO(defaultISO);