@djangocfg/ui-core 2.1.165 → 2.1.166

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ui-core",
3
- "version": "2.1.165",
3
+ "version": "2.1.166",
4
4
  "description": "Pure React UI component library without Next.js dependencies - for Electron, Vite, CRA apps",
5
5
  "keywords": [
6
6
  "ui-components",
@@ -76,7 +76,7 @@
76
76
  "playground": "playground dev"
77
77
  },
78
78
  "peerDependencies": {
79
- "@djangocfg/i18n": "^2.1.165",
79
+ "@djangocfg/i18n": "^2.1.166",
80
80
  "react-device-detect": "^2.2.3",
81
81
  "consola": "^3.4.2",
82
82
  "lucide-react": "^0.545.0",
@@ -138,9 +138,9 @@
138
138
  "vaul": "1.1.2"
139
139
  },
140
140
  "devDependencies": {
141
- "@djangocfg/i18n": "^2.1.165",
141
+ "@djangocfg/i18n": "^2.1.166",
142
142
  "@djangocfg/playground": "workspace:*",
143
- "@djangocfg/typescript-config": "^2.1.165",
143
+ "@djangocfg/typescript-config": "^2.1.166",
144
144
  "@types/node": "^24.7.2",
145
145
  "@types/react": "^19.1.0",
146
146
  "@types/react-dom": "^19.1.0",
@@ -266,7 +266,22 @@ const LANGUAGE_TO_COUNTRY: Partial<Record<TLanguageCode, TCountryCode>> = {
266
266
  * @returns Emoji flag string or empty string if no mapping exists
267
267
  */
268
268
  export function getLanguageFlag(languageCode: TLanguageCode | string): string {
269
- const countryCode = LANGUAGE_TO_COUNTRY[languageCode as TLanguageCode];
269
+ const code = languageCode.toLowerCase();
270
+
271
+ // Handle locale with region: pt-BR, pt-br, zh-CN, etc.
272
+ if (code.includes('-') || code.includes('_')) {
273
+ const parts = code.split(/[-_]/);
274
+ const region = parts[1]?.toUpperCase() as TCountryCode;
275
+ // Try region code as country first (pt-BR → BR)
276
+ if (region && region.length === 2) {
277
+ const flag = getEmojiFlag(region);
278
+ if (flag) return flag;
279
+ }
280
+ }
281
+
282
+ // Fall back to language → country mapping
283
+ const langCode = code.split(/[-_]/)[0] as TLanguageCode;
284
+ const countryCode = LANGUAGE_TO_COUNTRY[langCode];
270
285
  if (!countryCode) return '';
271
286
  return getEmojiFlag(countryCode);
272
287
  }