@xsolla/xui-input-phone 0.153.2 → 0.154.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/native/index.d.mts +10 -2
- package/native/index.d.ts +10 -2
- package/native/index.js +28 -6
- package/native/index.js.map +1 -1
- package/native/index.mjs +22 -1
- package/native/index.mjs.map +1 -1
- package/package.json +3 -3
- package/web/index.d.mts +10 -2
- package/web/index.d.ts +10 -2
- package/web/index.js +28 -6
- package/web/index.js.map +1 -1
- package/web/index.mjs +22 -1
- package/web/index.mjs.map +1 -1
package/web/index.mjs
CHANGED
|
@@ -1770,6 +1770,8 @@ var svgContent246 = `<svg viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.o
|
|
|
1770
1770
|
var FlagZW = (props) => /* @__PURE__ */ jsx256(FlagIcon, { ...props, svgContent: svgContent246 });
|
|
1771
1771
|
|
|
1772
1772
|
// src/countries.tsx
|
|
1773
|
+
import { getExampleNumber } from "libphonenumber-js";
|
|
1774
|
+
import examples from "libphonenumber-js/examples.mobile.json";
|
|
1773
1775
|
import { jsx as jsx257 } from "react/jsx-runtime";
|
|
1774
1776
|
var flagMap = {
|
|
1775
1777
|
AD: FlagAD,
|
|
@@ -2286,6 +2288,19 @@ var getCountryByDialCode = (dialCode) => {
|
|
|
2286
2288
|
(country) => country.dialCode === normalizedDialCode
|
|
2287
2289
|
);
|
|
2288
2290
|
};
|
|
2291
|
+
function getPlaceholderByCode(code) {
|
|
2292
|
+
if (!code) return void 0;
|
|
2293
|
+
try {
|
|
2294
|
+
const example = getExampleNumber(
|
|
2295
|
+
code.toUpperCase(),
|
|
2296
|
+
examples
|
|
2297
|
+
);
|
|
2298
|
+
if (!example) return void 0;
|
|
2299
|
+
return "+" + example.countryCallingCode + example.formatInternational().slice(example.countryCallingCode.length + 1).replace(/\d/g, "0");
|
|
2300
|
+
} catch {
|
|
2301
|
+
return void 0;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2289
2304
|
var defaultCountries = [
|
|
2290
2305
|
getCountryByCode("US"),
|
|
2291
2306
|
getCountryByCode("GB"),
|
|
@@ -3025,7 +3040,7 @@ var InputPhone = forwardRef2(
|
|
|
3025
3040
|
InputPhone.displayName = "InputPhone";
|
|
3026
3041
|
|
|
3027
3042
|
// src/usePhoneNumber.ts
|
|
3028
|
-
import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
|
|
3043
|
+
import { useState as useState2, useEffect as useEffect2, useCallback, useMemo } from "react";
|
|
3029
3044
|
import {
|
|
3030
3045
|
AsYouType,
|
|
3031
3046
|
formatIncompletePhoneNumber,
|
|
@@ -3189,11 +3204,16 @@ var usePhoneNumber = (options = {}) => {
|
|
|
3189
3204
|
}
|
|
3190
3205
|
}
|
|
3191
3206
|
}, [initialValue]);
|
|
3207
|
+
const placeholder = useMemo(
|
|
3208
|
+
() => getPlaceholderByCode(country?.code),
|
|
3209
|
+
[country?.code]
|
|
3210
|
+
);
|
|
3192
3211
|
return {
|
|
3193
3212
|
phoneNumber,
|
|
3194
3213
|
formattedPhoneNumber,
|
|
3195
3214
|
country,
|
|
3196
3215
|
countries: allCountries,
|
|
3216
|
+
placeholder,
|
|
3197
3217
|
handlePhoneChange,
|
|
3198
3218
|
handleCountryChange,
|
|
3199
3219
|
setPhoneNumber
|
|
@@ -3206,6 +3226,7 @@ export {
|
|
|
3206
3226
|
getCountryByCode,
|
|
3207
3227
|
getCountryByDialCode,
|
|
3208
3228
|
getFlag,
|
|
3229
|
+
getPlaceholderByCode,
|
|
3209
3230
|
usePhoneNumber
|
|
3210
3231
|
};
|
|
3211
3232
|
//# sourceMappingURL=index.mjs.map
|