@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.mjs CHANGED
@@ -2354,7 +2354,7 @@ var InputPhone = forwardRef2(
2354
2354
  errorMessage,
2355
2355
  error,
2356
2356
  countries = allCountries,
2357
- selectedCountry,
2357
+ selectedCountry: selectedCountryProp,
2358
2358
  onCountryChange,
2359
2359
  extraClear = false,
2360
2360
  onRemove,
@@ -2371,6 +2371,11 @@ var InputPhone = forwardRef2(
2371
2371
  "default"
2372
2372
  );
2373
2373
  const [passValue, setPassValue] = useState(value ?? "");
2374
+ const [internalCountry, setInternalCountry] = useState(
2375
+ selectedCountryProp
2376
+ );
2377
+ const isCountryControlled = selectedCountryProp !== void 0;
2378
+ const selectedCountry = isCountryControlled ? selectedCountryProp : internalCountry;
2374
2379
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
2375
2380
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
2376
2381
  const [searchQuery, setSearchQuery] = useState("");
@@ -2494,6 +2499,9 @@ var InputPhone = forwardRef2(
2494
2499
  }
2495
2500
  };
2496
2501
  const handleCountrySelect = (country) => {
2502
+ if (!isCountryControlled) {
2503
+ setInternalCountry(country);
2504
+ }
2497
2505
  onCountryChange?.(country);
2498
2506
  setIsDropdownOpen(false);
2499
2507
  setHighlightedIndex(-1);