@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/web/index.mjs CHANGED
@@ -2374,7 +2374,7 @@ var InputPhone = forwardRef2(
2374
2374
  errorMessage,
2375
2375
  error,
2376
2376
  countries = allCountries,
2377
- selectedCountry,
2377
+ selectedCountry: selectedCountryProp,
2378
2378
  onCountryChange,
2379
2379
  extraClear = false,
2380
2380
  onRemove,
@@ -2391,6 +2391,11 @@ var InputPhone = forwardRef2(
2391
2391
  "default"
2392
2392
  );
2393
2393
  const [passValue, setPassValue] = useState(value ?? "");
2394
+ const [internalCountry, setInternalCountry] = useState(
2395
+ selectedCountryProp
2396
+ );
2397
+ const isCountryControlled = selectedCountryProp !== void 0;
2398
+ const selectedCountry = isCountryControlled ? selectedCountryProp : internalCountry;
2394
2399
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
2395
2400
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
2396
2401
  const [searchQuery, setSearchQuery] = useState("");
@@ -2514,6 +2519,9 @@ var InputPhone = forwardRef2(
2514
2519
  }
2515
2520
  };
2516
2521
  const handleCountrySelect = (country) => {
2522
+ if (!isCountryControlled) {
2523
+ setInternalCountry(country);
2524
+ }
2517
2525
  onCountryChange?.(country);
2518
2526
  setIsDropdownOpen(false);
2519
2527
  setHighlightedIndex(-1);