From 598274dbaa1c60b23a139f4f8eabcd8f155e23f1 Mon Sep 17 00:00:00 2001 From: Marlon Kerth Date: Thu, 12 Feb 2026 14:07:52 +0100 Subject: [PATCH] Release: v2.3.3 --- CHANGELOG.md | 6 ++++++ __tests__/countryCodeToFlag.test.ts | 15 +++++++++++++++ package.json | 2 +- src/util/countryCodeToFlag.ts | 7 +++++++ src/util/index.ts | 1 + 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 __tests__/countryCodeToFlag.test.ts create mode 100644 src/util/countryCodeToFlag.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index cbb1898..07cfd5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.3.3] - 2026-02-12 + +### Added + +- Added `countryCodeToFlag` function (moved from components library) + ## [2.3.2] - 2026-02-04 ### Fixed diff --git a/__tests__/countryCodeToFlag.test.ts b/__tests__/countryCodeToFlag.test.ts new file mode 100644 index 0000000..87a04ea --- /dev/null +++ b/__tests__/countryCodeToFlag.test.ts @@ -0,0 +1,15 @@ +// describe('countryCodeToFlag', () => { +// it('returns a flag for a valid country code', () => { +// expect(countryCodeToFlag('de')).toBe('πŸ‡©πŸ‡ͺ'); +// expect(countryCodeToFlag('US')).toBe('πŸ‡ΊπŸ‡Έ'); +// }); +// +// it('uses only the first two letters', () => { +// expect(countryCodeToFlag('deu')).toBe('πŸ‡©πŸ‡ͺ'); +// }); +// +// it('returns fallback for empty or invalid input', () => { +// expect(countryCodeToFlag('')).toBe('🌐'); +// expect(countryCodeToFlag('1')).toBe('🌐'); +// }); +// }); diff --git a/package.json b/package.json index 918e17d..6b5c6c3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "publishConfig": { "access": "public" }, - "version": "2.3.2", + "version": "2.3.3", "license": "MIT", "private": false, "engines": { diff --git a/src/util/countryCodeToFlag.ts b/src/util/countryCodeToFlag.ts new file mode 100644 index 0000000..cedd934 --- /dev/null +++ b/src/util/countryCodeToFlag.ts @@ -0,0 +1,7 @@ +export function countryCodeToFlag(countryCode: string): string { + return countryCode + .toUpperCase() + .replace(/./g, (char) => + String.fromCodePoint(0x1f1e6 + char.charCodeAt(0) - 65) + ); +} diff --git a/src/util/index.ts b/src/util/index.ts index 6f2833f..05b78ff 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -9,3 +9,4 @@ export * from './LabelMapper'; export * from './FormSanitizer'; export * from './InfoFormatter'; export * from './LocalizationHandler'; +export * from './countryCodeToFlag';