From 16f5465c463daae2837af745a14a008876350599 Mon Sep 17 00:00:00 2001 From: wael gharbi Date: Mon, 30 Jun 2025 15:42:00 +0100 Subject: [PATCH 1/4] palestine --- src/rawCountries.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rawCountries.js b/src/rawCountries.js index f04511f8..54c5bffe 100644 --- a/src/rawCountries.js +++ b/src/rawCountries.js @@ -60,7 +60,7 @@ const rawCountries = [ '54', '(..) ........', 0, - ['11', '221', '223', '261', '264', '2652', '280', '2905', '291', '2920', '2966', '299', '341', '342', '343', '351', '376', '379', '381', '3833', '385', '387', '388' ] + ['11', '221', '223', '261', '264', '2652', '280', '2905', '291', '2920', '2966', '299', '341', '342', '343', '351', '376', '379', '381', '3833', '385', '387', '388'] ], [ 'Armenia', @@ -937,7 +937,7 @@ const rawCountries = [ '680' ], [ - 'Palestine', + 'State of Palestine', ['middle-east'], 'ps', '970' From 91ba929edaccd6fc992ce34ee6af96e935bf63c6 Mon Sep 17 00:00:00 2001 From: wael gharbi Date: Mon, 30 Jun 2025 16:01:47 +0100 Subject: [PATCH 2/4] t' --- main.js | 1 + package.json | 20 +++++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 main.js diff --git a/main.js b/main.js new file mode 100644 index 00000000..41367aa6 --- /dev/null +++ b/main.js @@ -0,0 +1 @@ +!function(t){var e={};function r(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return t[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var u in t)r.d(n,u,function(e){return t[e]}.bind(null,u));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([,,function(t,e,r){r(3),r(4),r(5),r(6),r(7),t.exports=r(8)},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/style.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/high-res.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/material.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/bootstrap.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/semantic-ui.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/plain.css"}]); \ No newline at end of file diff --git a/package.json b/package.json index 369c297e..f9ad27b9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-phone-input-2", + "name": "react-phone-input-2-gis", "version": "2.15.1", "description": "A react component to format phone numbers", "main": "lib/lib.js", @@ -8,15 +8,15 @@ "test": "jest", "start": "TARGET=dev_js NODE_ENV=development webpack-dev-server --progress", "start:css": "TARGET=dev_css NODE_ENV=development webpack-dev-server --progress", - "build": "export SET NODE_OPTIONS=--openssl-legacy-provider && npm run build:js && npm run build:css", - "build:js": "TARGET=build_js NODE_ENV=production webpack -p --progress", - "build:css": "TARGET=build_css NODE_ENV=production webpack -p --progress && rm ./main.js", + "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build:js && npm run build:css", + "build:js": "cross-env TARGET=build_js NODE_ENV=production webpack -p --progress", + "build:css": "cross-env TARGET=build_css NODE_ENV=production webpack -p --progress && del ./main.js", "prepublishOnly": "npm run build", "analyze": "TARGET=analyze NODE_ENV=production webpack -p --progress" }, "repository": { "type": "git", - "url": "git+https://github.com/bl00mber/react-phone-input-2.git" + "url": "git+https://github.com/wolfy-gh/react-phone-input-2" }, "keywords": [ "react", @@ -40,15 +40,12 @@ "README.md", "index.d.ts" ], - "author": "Nick Reiley (https://github.com/bl00mber)", - "contributors": [ - "Raza Gill (https://github.com/razagill)" - ], + "author": "Nick Reiley (https://github.com/wolfy-gh)", "license": "MIT", "bugs": { - "url": "https://github.com/bl00mber/react-phone-input-2/issues" + "url": "https://github.com/wolfy-gh/react-phone-input-2/issues" }, - "homepage": "https://github.com/bl00mber/react-phone-input-2", + "homepage": "https://github.com/wolfy-gh/react-phone-input-2", "jest": { "moduleNameMapper": { "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)$": "/test/__mocks__/fileMock.js", @@ -62,6 +59,7 @@ "@babel/core": "^7.3.3", "babel-loader": "^8.0.5", "babel-preset-react-app": "^7.0.1", + "cross-env": "^7.0.3", "css-loader": "^2.1.0", "extract-loader": "^3.1.0", "file-loader": "^5.0.2", From d56ef3ea5e7ac5fd5da2969ba7e41c0d6a51c5ba Mon Sep 17 00:00:00 2001 From: wael gharbi Date: Mon, 30 Jun 2025 16:03:44 +0100 Subject: [PATCH 3/4] t --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f9ad27b9..2c49c164 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "start:css": "TARGET=dev_css NODE_ENV=development webpack-dev-server --progress", "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build:js && npm run build:css", "build:js": "cross-env TARGET=build_js NODE_ENV=production webpack -p --progress", - "build:css": "cross-env TARGET=build_css NODE_ENV=production webpack -p --progress && del ./main.js", + "build:css": "cross-env TARGET=build_css NODE_ENV=production webpack -p --progress && rimraf main.js", "prepublishOnly": "npm run build", "analyze": "TARGET=analyze NODE_ENV=production webpack -p --progress" }, @@ -70,6 +70,7 @@ "react-dom": "^17.0.2", "react-hot-loader": "^4.6.5", "react-testing-library": "^6.0.4", + "rimraf": "^6.0.1", "style-loader": "^0.23.1", "url-loader": "^1.1.2", "webpack": "^4.29.5", From 6b04d0287af4e596341ee969c6d367ec1d0206eb Mon Sep 17 00:00:00 2001 From: wael gharbi Date: Mon, 30 Jun 2025 16:23:31 +0100 Subject: [PATCH 4/4] st --- main.js | 1 - package.json | 2 +- src/CountryData.js | 184 +++++++++++++++++++-------------------------- 3 files changed, 79 insertions(+), 108 deletions(-) delete mode 100644 main.js diff --git a/main.js b/main.js deleted file mode 100644 index 41367aa6..00000000 --- a/main.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return t[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var u in t)r.d(n,u,function(e){return t[e]}.bind(null,u));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([,,function(t,e,r){r(3),r(4),r(5),r(6),r(7),t.exports=r(8)},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/style.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/high-res.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/material.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/bootstrap.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/semantic-ui.css"},function(t,e,r){"use strict";r.r(e),e.default=r.p+"lib/plain.css"}]); \ No newline at end of file diff --git a/package.json b/package.json index 2c49c164..dc242d68 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-phone-input-2-gis", + "name": "react-phone-tt", "version": "2.15.1", "description": "A react component to format phone numbers", "main": "lib/lib.js", diff --git a/src/CountryData.js b/src/CountryData.js index 17e64d0e..6605fb85 100644 --- a/src/CountryData.js +++ b/src/CountryData.js @@ -1,21 +1,23 @@ -import _rawCountries from './rawCountries' -import _rawTerritories from './rawTerritories' +import _rawCountries from './rawCountries'; +import _rawTerritories from './rawTerritories'; function getMask(prefix, dialCode, predefinedMask, defaultMask, alwaysDefaultMask) { if (!predefinedMask || alwaysDefaultMask) { - return prefix+''.padEnd(dialCode.length,'.')+' '+defaultMask; + return prefix + ''.padEnd(dialCode.length, '.') + ' ' + defaultMask; } else { - return prefix+''.padEnd(dialCode.length,'.')+' '+predefinedMask; + return prefix + ''.padEnd(dialCode.length, '.') + ' ' + predefinedMask; } } -// enableAreaCodes: boolean || array of iso2 codes function initCountries(countries, enableAreaCodes, prefix, defaultMask, alwaysDefaultMask) { let hiddenAreaCodes = []; let enableAllCodes; - if (enableAreaCodes === true) { enableAllCodes = true } - else { enableAllCodes = false } + if (enableAreaCodes === true) { + enableAllCodes = true; + } else { + enableAllCodes = false; + } const initializedCountries = [].concat(...countries.map((country) => { const countryItem = { @@ -32,7 +34,7 @@ function initCountries(countries, enableAreaCodes, prefix, defaultMask, alwaysDe country[6] && country[6].map((areaCode) => { - const areaItem = {...countryItem}; + const areaItem = { ...countryItem }; areaItem.dialCode = country[3] + areaCode; areaItem.isAreaCode = true; areaItem.areaCodeLength = areaCode.length; @@ -54,188 +56,158 @@ function initCountries(countries, enableAreaCodes, prefix, defaultMask, alwaysDe } })); - return [initializedCountries, hiddenAreaCodes] + return [initializedCountries, hiddenAreaCodes]; } - function extendUserContent(userContent, contentItemIndex, extendingObject, firstExtension) { if (extendingObject === null) return; - const keys = Object.keys(extendingObject) - const values = Object.values(extendingObject) + const keys = Object.keys(extendingObject); + const values = Object.values(extendingObject); keys.forEach((iso2, index) => { - if (firstExtension) { // masks - return userContent.push([iso2, values[index]]) + if (firstExtension) { + return userContent.push([iso2, values[index]]); } const countryIndex = userContent.findIndex(arr => arr[0] === iso2); if (countryIndex === -1) { - const newUserContent = [iso2] - newUserContent[contentItemIndex] = values[index] - userContent.push(newUserContent) + const newUserContent = [iso2]; + newUserContent[contentItemIndex] = values[index]; + userContent.push(newUserContent); } else { - userContent[countryIndex][contentItemIndex] = values[index] + userContent[countryIndex][contentItemIndex] = values[index]; } - }) + }); } - function initUserContent(masks, priority, areaCodes) { let userContent = []; - extendUserContent(userContent, 1, masks, true) - extendUserContent(userContent, 3, priority) - extendUserContent(userContent, 2, areaCodes) + extendUserContent(userContent, 1, masks, true); + extendUserContent(userContent, 3, priority); + extendUserContent(userContent, 2, areaCodes); return userContent; } - function extendRawCountries(countries, userContent) { if (userContent.length === 0) return countries; - // userContent index -> rawCountries index of country array to extend - // [iso2 (0 -> 2), mask (1 -> 4), priority (3 -> 5), areaCodes (2 -> 6)] - return countries.map(o => { - const userContentIndex = userContent.findIndex(arr => arr[0] === o[2]); // find by iso2 - if (userContentIndex === -1) return o; // if iso2 not in userContent, return source country object + const userContentIndex = userContent.findIndex(arr => arr[0] === o[2]); + if (userContentIndex === -1) return o; const userContentCountry = userContent[userContentIndex]; - if (userContentCountry[1]) o[4] = userContentCountry[1]; // mask - if (userContentCountry[3]) o[5] = userContentCountry[3]; // priority - if (userContentCountry[2]) o[6] = userContentCountry[2]; // areaCodes + if (userContentCountry[1]) o[4] = userContentCountry[1]; + if (userContentCountry[3]) o[5] = userContentCountry[3]; + if (userContentCountry[2]) o[6] = userContentCountry[2]; return o; - }) + }); } - export default class CountryData { - constructor ( - enableAreaCodes, enableTerritories, regions, - onlyCountries, preferredCountries, excludeCountries, preserveOrder, - masks, priority, areaCodes, localization, - prefix, defaultMask, alwaysDefaultMask, + constructor( + enableAreaCodes, + enableTerritories, + regions, + onlyCountries, + preferredCountries, + excludeCountries, + preserveOrder, + masks, + priority, + areaCodes, + localization, + prefix, + defaultMask, + alwaysDefaultMask, ) { - const userContent = initUserContent(masks, priority, areaCodes) - const rawCountries = extendRawCountries(JSON.parse(JSON.stringify(_rawCountries)), userContent) - const rawTerritories = extendRawCountries(JSON.parse(JSON.stringify(_rawTerritories)), userContent) + const userContent = initUserContent(masks, priority, areaCodes); + const rawCountries = extendRawCountries(JSON.parse(JSON.stringify(_rawCountries)), userContent); + const rawTerritories = extendRawCountries(JSON.parse(JSON.stringify(_rawTerritories)), userContent); - let [ initializedCountries, hiddenAreaCodes ] = initCountries(rawCountries, enableAreaCodes, prefix, defaultMask, alwaysDefaultMask); + let [initializedCountries, hiddenAreaCodes] = initCountries(rawCountries, enableAreaCodes, prefix, defaultMask, alwaysDefaultMask); if (enableTerritories) { - let [ initializedTerritories, hiddenAreaCodes ] = initCountries(rawTerritories, enableAreaCodes, prefix, defaultMask, alwaysDefaultMask); + let [initializedTerritories, hiddenTerritoryAreaCodes] = initCountries(rawTerritories, enableAreaCodes, prefix, defaultMask, alwaysDefaultMask); initializedCountries = this.sortTerritories(initializedTerritories, initializedCountries); + hiddenAreaCodes = hiddenAreaCodes.concat(hiddenTerritoryAreaCodes); } if (regions) initializedCountries = this.filterRegions(regions, initializedCountries); this.onlyCountries = this.localizeCountries( - this.excludeCountries(this.getFilteredCountryList(onlyCountries, initializedCountries, preserveOrder.includes('onlyCountries')), - excludeCountries), + this.excludeCountries(this.getFilteredCountryList(onlyCountries, initializedCountries, preserveOrder.includes('onlyCountries')), excludeCountries), localization, - preserveOrder.includes('onlyCountries') + preserveOrder.includes('onlyCountries'), ); - this.preferredCountries = preferredCountries.length === 0 ? [] : - this.localizeCountries( - this.getFilteredCountryList(preferredCountries, initializedCountries, preserveOrder.includes('preferredCountries')), - localization, - preserveOrder.includes('preferredCountries') - ); + this.preferredCountries = preferredCountries.length === 0 ? [] : this.localizeCountries( + this.getFilteredCountryList(preferredCountries, initializedCountries, preserveOrder.includes('preferredCountries')), + localization, + preserveOrder.includes('preferredCountries'), + ); - // apply filters to hiddenAreaCodes this.hiddenAreaCodes = this.excludeCountries( this.getFilteredCountryList(onlyCountries, hiddenAreaCodes), - excludeCountries + excludeCountries, ); } filterRegions = (regions, countries) => { if (typeof regions === 'string') { const region = regions; - return countries.filter((country) => { - return country.regions.some((element) => { - return element === region; - }); - }); + return countries.filter((country) => country.regions.some((element) => element === region)); } return countries.filter((country) => { - const matches = regions.map((region) => { - return country.regions.some((element) => { - return element === region; - }); - }); + const matches = regions.map((region) => country.regions.some((element) => element === region)); return matches.some(el => el); }); - } + }; sortTerritories = (initializedTerritories, initializedCountries) => { const fullCountryList = [...initializedTerritories, ...initializedCountries]; - fullCountryList.sort(function(a, b){ - if(a.name < b.name) { return -1; } - if(a.name > b.name) { return 1; } - return 0; - }); + // Sort alphabetically by name + fullCountryList.sort((a, b) => a.name.localeCompare(b.name)); return fullCountryList; - } + }; getFilteredCountryList = (countryCodes, sourceCountryList, preserveOrder) => { if (countryCodes.length === 0) return sourceCountryList; let filteredCountries; if (preserveOrder) { - // filter using iso2 user-defined order filteredCountries = countryCodes.map(countryCode => { const country = sourceCountryList.find(country => country.iso2 === countryCode); if (country) return country; - }).filter(country => country); // remove any not found - } - else { - // filter using alphabetical order - filteredCountries = sourceCountryList.filter((country) => { - return countryCodes.some((element) => { - return element === country.iso2; - }); - }); + }).filter(country => country); + } else { + filteredCountries = sourceCountryList.filter((country) => countryCodes.some((element) => element === country.iso2)); } return filteredCountries; - } + }; localizeCountries = (countries, localization, preserveOrder) => { for (let i = 0; i < countries.length; i++) { if (localization[countries[i].iso2] !== undefined) { countries[i].localName = localization[countries[i].iso2]; - } - else if (localization[countries[i].name] !== undefined) { + } else if (localization[countries[i].name] !== undefined) { countries[i].localName = localization[countries[i].name]; + } else { + countries[i].localName = countries[i].name; } } + if (!preserveOrder) { - countries.sort(function(a, b){ - if(a.localName < b.localName) { return -1; } - if(a.localName > b.localName) { return 1; } - return 0; - }); + countries.sort((a, b) => a.localName.localeCompare(b.localName)); } - return countries; - } - getCustomAreas = (country, areaCodes) => { - let customAreas = []; - for (let i = 0; i < areaCodes.length; i++) { - let newCountry = JSON.parse(JSON.stringify(country)); - newCountry.dialCode += areaCodes[i]; - customAreas.push(newCountry); - } - return customAreas; - } + return countries; + }; excludeCountries = (onlyCountries, excludedCountries) => { if (excludedCountries.length === 0) { return onlyCountries; } else { - return onlyCountries.filter((country) => { - return !excludedCountries.includes(country.iso2); - }); + return onlyCountries.filter((country) => !excludedCountries.includes(country.iso2)); } - } -} + }; +} \ No newline at end of file