From 98db1e7238d28d1d1af47e028c15402cc67b7fca Mon Sep 17 00:00:00 2001 From: sharevb Date: Wed, 2 Oct 2024 22:16:58 +0200 Subject: [PATCH] feat(new tool): Countries/ISO 3166 Searcher Browser countries and iso 3166 codes (and more) FIx #983 --- components.d.ts | 2 + package.json | 2 + pnpm-lock.yaml | 21 +++- src/tools/index.ts | 2 + src/tools/iso-3166-searcher/countries-db.d.ts | 35 ++++++ src/tools/iso-3166-searcher/index.ts | 12 ++ .../iso-3166-searcher/iso-3166-searcher.vue | 104 ++++++++++++++++++ 7 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 src/tools/iso-3166-searcher/countries-db.d.ts create mode 100644 src/tools/iso-3166-searcher/index.ts create mode 100644 src/tools/iso-3166-searcher/iso-3166-searcher.vue diff --git a/components.d.ts b/components.d.ts index 3e65c3cc..4c6ee802 100644 --- a/components.d.ts +++ b/components.d.ts @@ -107,6 +107,7 @@ declare module '@vue/runtime-core' { Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default'] Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default'] Ipv6UlaGenerator: typeof import('./src/tools/ipv6-ula-generator/ipv6-ula-generator.vue')['default'] + Iso3166Searcher: typeof import('./src/tools/iso-3166-searcher/iso-3166-searcher.vue')['default'] JsonDiff: typeof import('./src/tools/json-diff/json-diff.vue')['default'] JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default'] JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default'] @@ -129,6 +130,7 @@ declare module '@vue/runtime-core' { MenuLayout: typeof import('./src/components/MenuLayout.vue')['default'] MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default'] MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] + NA: typeof import('naive-ui')['NA'] NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] NCheckbox: typeof import('naive-ui')['NCheckbox'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] diff --git a/package.json b/package.json index 8a1c069f..c3325136 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "change-case": "^4.1.2", "colord": "^2.9.3", "composerize-ts": "^0.6.2", + "countries-db": "^1.2.0", "country-code-lookup": "^0.1.0", "cron-validator": "^1.3.1", "cronstrue": "^2.26.0", @@ -68,6 +69,7 @@ "highlight.js": "^11.7.0", "iarna-toml-esm": "^3.0.5", "ibantools": "^4.3.3", + "iso-639-1": "^3.1.3", "js-base64": "^3.7.6", "json5": "^2.2.3", "jwt-decode": "^3.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e43a3217..c43c674d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,6 +59,9 @@ dependencies: composerize-ts: specifier: ^0.6.2 version: 0.6.2 + countries-db: + specifier: ^1.2.0 + version: 1.2.0 country-code-lookup: specifier: ^0.1.0 version: 0.1.0 @@ -101,6 +104,9 @@ dependencies: ibantools: specifier: ^4.3.3 version: 4.3.3 + iso-639-1: + specifier: ^3.1.3 + version: 3.1.3 js-base64: specifier: ^3.7.6 version: 3.7.7 @@ -3395,7 +3401,7 @@ packages: dependencies: '@unhead/dom': 0.5.1 '@unhead/schema': 0.5.1 - '@vueuse/shared': 11.0.3(vue@3.3.4) + '@vueuse/shared': 11.1.0(vue@3.3.4) unhead: 0.5.1 vue: 3.3.4 transitivePeerDependencies: @@ -4037,8 +4043,8 @@ packages: - vue dev: false - /@vueuse/shared@11.0.3(vue@3.3.4): - resolution: {integrity: sha512-0rY2m6HS5t27n/Vp5cTDsKTlNnimCqsbh/fmT2LgE+aaU42EMfXo8+bNX91W9I7DDmxfuACXMmrd7d79JxkqWA==} + /@vueuse/shared@11.1.0(vue@3.3.4): + resolution: {integrity: sha512-YUtIpY122q7osj+zsNMFAfMTubGz0sn5QzE5gPzAIiCmtt2ha3uQUY1+JPyL4gRCTsLPX82Y9brNbo/aqlA91w==} dependencies: vue-demi: 0.14.10(vue@3.3.4) transitivePeerDependencies: @@ -4657,6 +4663,10 @@ packages: browserslist: 4.22.1 dev: true + /countries-db@1.2.0: + resolution: {integrity: sha512-eZQgxVsNSRQ4yv9xQbgyR1psJBHDBhnhhU4OMXXUdrfbWW9gaiglKgueTq3ZWGuvxoR78g2ljVFsJmEptfNPmw==} + dev: false + /country-code-lookup@0.1.0: resolution: {integrity: sha512-IOI66HEG+8bXfWPy+sTzuN7161vmDZOHg1wgIPFf3WfD73FeLajnn6C+fnxOIa9RL1WRBDMXQQWW/FOaOYaQ3w==} dev: false @@ -6492,6 +6502,11 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true + /iso-639-1@3.1.3: + resolution: {integrity: sha512-1jz0Wh9hyLMRwqEPchb/KZCiTqfFWtc9R3nm7GHPygBAKS8wdKJ3FH4lvLsri6UtAE5Kz5SnowtXZa//6bqMyw==} + engines: {node: '>=6.0'} + dev: false + /isobject@3.0.1: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} engines: {node: '>=0.10.0'} diff --git a/src/tools/index.ts b/src/tools/index.ts index 388cfaf4..588c0583 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -12,6 +12,7 @@ import { tool as jsonToXml } from './json-to-xml'; import { tool as regexTester } from './regex-tester'; import { tool as regexMemo } from './regex-memo'; import { tool as markdownToHtml } from './markdown-to-html'; +import { tool as iso3166Searcher } from './iso-3166-searcher'; import { tool as pdfSignatureChecker } from './pdf-signature-checker'; import { tool as numeronymGenerator } from './numeronym-generator'; import { tool as macAddressGenerator } from './mac-address-generator'; @@ -184,6 +185,7 @@ export const toolsByCategory: ToolCategory[] = [ textDiff, numeronymGenerator, asciiTextDrawer, + iso3166Searcher, ], }, { diff --git a/src/tools/iso-3166-searcher/countries-db.d.ts b/src/tools/iso-3166-searcher/countries-db.d.ts new file mode 100644 index 00000000..87ec2a7c --- /dev/null +++ b/src/tools/iso-3166-searcher/countries-db.d.ts @@ -0,0 +1,35 @@ +declare module 'countries-db'{ + export interface CountryInfo { + id: string + name: string + officialName: string + emoji: string + emojiUnicode: string + iso2: string + iso3: string + isoNumeric: string + geonameId: number + continentId: string + population: number + elevation: number + areaSqKm: number + coordinates: { + latitude: number + longitude: number + }, + timezones: Array + domain: string + currencyCode: string + currencyName: string + postalCodeFormat: string + postalCodeRegex: string + phoneCode: string + neighborCountryIds: Array + languages: Array + locales: Array + } + + export function getAllCountries(): {[id:string]: CountryInfo}; + export function getCountry(id: string, property: string): string | Array | number; + export function getCountry(id: string): CountryInfo; +} \ No newline at end of file diff --git a/src/tools/iso-3166-searcher/index.ts b/src/tools/iso-3166-searcher/index.ts new file mode 100644 index 00000000..88fd3e33 --- /dev/null +++ b/src/tools/iso-3166-searcher/index.ts @@ -0,0 +1,12 @@ +import { Flag } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'ISO 3166 Country Codes Searcher', + path: '/iso-3166-searcher', + description: 'Allow searching for Country Code (ISO 3166) and info', + keywords: ['iso', 'iso2', 'iso3', 'phone', 'currency', 'timezones', 'domain', 'lang', 'iso3166', 'country', 'ccltd', 'searcher'], + component: () => import('./iso-3166-searcher.vue'), + icon: Flag, + createdAt: new Date('2024-04-20'), +}); diff --git a/src/tools/iso-3166-searcher/iso-3166-searcher.vue b/src/tools/iso-3166-searcher/iso-3166-searcher.vue new file mode 100644 index 00000000..4f19d382 --- /dev/null +++ b/src/tools/iso-3166-searcher/iso-3166-searcher.vue @@ -0,0 +1,104 @@ + + +