@xsolla/xui-input-phone 0.154.1 → 0.154.2

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.js CHANGED
@@ -2382,7 +2382,7 @@ var InputPhone = (0, import_react3.forwardRef)(
2382
2382
  errorMessage,
2383
2383
  error,
2384
2384
  countries = allCountries,
2385
- selectedCountry,
2385
+ selectedCountry: selectedCountryProp,
2386
2386
  onCountryChange,
2387
2387
  extraClear = false,
2388
2388
  onRemove,
@@ -2399,6 +2399,11 @@ var InputPhone = (0, import_react3.forwardRef)(
2399
2399
  "default"
2400
2400
  );
2401
2401
  const [passValue, setPassValue] = (0, import_react3.useState)(value ?? "");
2402
+ const [internalCountry, setInternalCountry] = (0, import_react3.useState)(
2403
+ selectedCountryProp
2404
+ );
2405
+ const isCountryControlled = selectedCountryProp !== void 0;
2406
+ const selectedCountry = isCountryControlled ? selectedCountryProp : internalCountry;
2402
2407
  const [isDropdownOpen, setIsDropdownOpen] = (0, import_react3.useState)(false);
2403
2408
  const [highlightedIndex, setHighlightedIndex] = (0, import_react3.useState)(-1);
2404
2409
  const [searchQuery, setSearchQuery] = (0, import_react3.useState)("");
@@ -2522,6 +2527,9 @@ var InputPhone = (0, import_react3.forwardRef)(
2522
2527
  }
2523
2528
  };
2524
2529
  const handleCountrySelect = (country) => {
2530
+ if (!isCountryControlled) {
2531
+ setInternalCountry(country);
2532
+ }
2525
2533
  onCountryChange?.(country);
2526
2534
  setIsDropdownOpen(false);
2527
2535
  setHighlightedIndex(-1);