@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.mjs CHANGED
@@ -1750,6 +1750,8 @@ var svgContent246 = `<svg viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.o
1750
1750
  var FlagZW = (props) => /* @__PURE__ */ jsx256(FlagIcon, { ...props, svgContent: svgContent246 });
1751
1751
 
1752
1752
  // src/countries.tsx
1753
+ import { getExampleNumber } from "libphonenumber-js";
1754
+ import examples from "libphonenumber-js/examples.mobile.json";
1753
1755
  import { jsx as jsx257 } from "react/jsx-runtime";
1754
1756
  var flagMap = {
1755
1757
  AD: FlagAD,
@@ -2266,6 +2268,19 @@ var getCountryByDialCode = (dialCode) => {
2266
2268
  (country) => country.dialCode === normalizedDialCode
2267
2269
  );
2268
2270
  };
2271
+ function getPlaceholderByCode(code) {
2272
+ if (!code) return void 0;
2273
+ try {
2274
+ const example = getExampleNumber(
2275
+ code.toUpperCase(),
2276
+ examples
2277
+ );
2278
+ if (!example) return void 0;
2279
+ return "+" + example.countryCallingCode + example.formatInternational().slice(example.countryCallingCode.length + 1).replace(/\d/g, "0");
2280
+ } catch {
2281
+ return void 0;
2282
+ }
2283
+ }
2269
2284
  var defaultCountries = [
2270
2285
  getCountryByCode("US"),
2271
2286
  getCountryByCode("GB"),
@@ -3005,7 +3020,7 @@ var InputPhone = forwardRef2(
3005
3020
  InputPhone.displayName = "InputPhone";
3006
3021
 
3007
3022
  // src/usePhoneNumber.ts
3008
- import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
3023
+ import { useState as useState2, useEffect as useEffect2, useCallback, useMemo } from "react";
3009
3024
  import {
3010
3025
  AsYouType,
3011
3026
  formatIncompletePhoneNumber,
@@ -3169,11 +3184,16 @@ var usePhoneNumber = (options = {}) => {
3169
3184
  }
3170
3185
  }
3171
3186
  }, [initialValue]);
3187
+ const placeholder = useMemo(
3188
+ () => getPlaceholderByCode(country?.code),
3189
+ [country?.code]
3190
+ );
3172
3191
  return {
3173
3192
  phoneNumber,
3174
3193
  formattedPhoneNumber,
3175
3194
  country,
3176
3195
  countries: allCountries,
3196
+ placeholder,
3177
3197
  handlePhoneChange,
3178
3198
  handleCountryChange,
3179
3199
  setPhoneNumber
@@ -3186,6 +3206,7 @@ export {
3186
3206
  getCountryByCode,
3187
3207
  getCountryByDialCode,
3188
3208
  getFlag,
3209
+ getPlaceholderByCode,
3189
3210
  usePhoneNumber
3190
3211
  };
3191
3212
  //# sourceMappingURL=index.mjs.map