From d8077f4d55cfcd4118e538c208873f10dcdb7a8b Mon Sep 17 00:00:00 2001 From: Artyom Vancyan Date: Mon, 3 Feb 2025 11:21:20 +0400 Subject: [PATCH 1/2] Fix `distinct` filtering --- development/src/phone-hooks/index.ts | 1 + src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/development/src/phone-hooks/index.ts b/development/src/phone-hooks/index.ts index 1751612..f8b1aeb 100644 --- a/development/src/phone-hooks/index.ts +++ b/development/src/phone-hooks/index.ts @@ -149,6 +149,7 @@ export const usePhone = ({ ...filteredCountries.filter(([iso]) => preferredCountries.includes(iso)), ...filteredCountries.filter(([iso]) => !preferredCountries.includes(iso)), ]; + if (!distinct) return whitelistCountries; return whitelistCountries.filter(([iso]) => !seen.has(iso) && seen.add(iso)); }, [countriesOnly, preferredCountries, distinct, locale, query]) diff --git a/src/index.ts b/src/index.ts index 1751612..f8b1aeb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -149,6 +149,7 @@ export const usePhone = ({ ...filteredCountries.filter(([iso]) => preferredCountries.includes(iso)), ...filteredCountries.filter(([iso]) => !preferredCountries.includes(iso)), ]; + if (!distinct) return whitelistCountries; return whitelistCountries.filter(([iso]) => !seen.has(iso) && seen.add(iso)); }, [countriesOnly, preferredCountries, distinct, locale, query]) From 7cc4c41d620dbd3448a5e811bf8a7aa00c0effec Mon Sep 17 00:00:00 2001 From: Artyom Vancyan Date: Mon, 3 Feb 2025 11:21:37 +0400 Subject: [PATCH 2/2] Upgrade the version to `0.1.14` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d80e013..5df9ffb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.13", + "version": "0.1.14", "name": "react-phone-hooks", "description": "React hooks and utility functions for parsing and validating phone numbers.", "keywords": [