@etsoo/shared 1.1.79 → 1.1.80

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.
@@ -221,17 +221,19 @@ test('Tests for detectedCulture', () => {
221
221
  test('Tests for getCulture', () => {
222
222
  const cultures: DataTypes.CultureDefinition[] = [
223
223
  {
224
- name: 'zh-CN',
224
+ name: 'zh-Hans',
225
225
  label: '简体中文',
226
226
  resources: {},
227
- compatibleName: ['zh-SG']
227
+ compatibleNames: ['zh-CN', 'zh-SG']
228
228
  },
229
- { name: 'en-US', label: 'English', resources: {} }
229
+ { name: 'en', label: 'English', resources: {} }
230
230
  ];
231
231
 
232
- expect(DomUtils.getCulture(cultures, 'zh-CN')?.name).toBe('zh-CN');
233
- expect(DomUtils.getCulture(cultures, 'zh-SG')?.name).toBe('zh-CN');
234
- expect(DomUtils.getCulture(cultures, 'en-GB')?.name).toBe('en-US');
232
+ expect(DomUtils.getCulture(cultures, 'zh-CN')?.name).toBe('zh-Hans');
233
+ expect(DomUtils.getCulture(cultures, 'zh-Hans-CN')?.name).toBe('zh-Hans');
234
+ expect(DomUtils.getCulture(cultures, 'zh-Hans-HK')?.name).toBe('zh-Hans');
235
+ expect(DomUtils.getCulture(cultures, 'zh-SG')?.name).toBe('zh-Hans');
236
+ expect(DomUtils.getCulture(cultures, 'en-GB')?.name).toBe('en');
235
237
  });
236
238
 
237
239
  test('Tests for getLocationKey', () => {
@@ -240,7 +240,7 @@ export declare namespace DataTypes {
240
240
  /**
241
241
  * Compatible names
242
242
  */
243
- compatibleName?: string[];
243
+ compatibleNames?: string[];
244
244
  }>;
245
245
  /**
246
246
  * Dynamic interface with multiple properties
@@ -73,14 +73,14 @@ export declare namespace DomUtils {
73
73
  resources: T; /**
74
74
  * Current detected culture
75
75
  */
76
- compatibleName?: string[] | undefined;
76
+ compatibleNames?: string[] | undefined;
77
77
  }>[], culture: string) => Readonly<{
78
78
  name: string;
79
79
  label: string;
80
80
  resources: T; /**
81
81
  * Current detected culture
82
82
  */
83
- compatibleName?: string[] | undefined;
83
+ compatibleNames?: string[] | undefined;
84
84
  }> | undefined;
85
85
  /**
86
86
  * Get input value depending on its type
@@ -282,7 +282,11 @@ var DomUtils;
282
282
  if (exactMatch)
283
283
  return exactMatch;
284
284
  // Compatible match
285
- const compatibleMatch = items.find((item) => { var _a; return (_a = item.compatibleName) === null || _a === void 0 ? void 0 : _a.includes(culture); });
285
+ const compatibleMatch = items.find((item) => {
286
+ var _a;
287
+ return ((_a = item.compatibleNames) === null || _a === void 0 ? void 0 : _a.includes(culture)) ||
288
+ culture.startsWith(item + '-');
289
+ });
286
290
  if (compatibleMatch)
287
291
  return compatibleMatch;
288
292
  // Same part, like zh-CN and zh-HK
@@ -240,7 +240,7 @@ export declare namespace DataTypes {
240
240
  /**
241
241
  * Compatible names
242
242
  */
243
- compatibleName?: string[];
243
+ compatibleNames?: string[];
244
244
  }>;
245
245
  /**
246
246
  * Dynamic interface with multiple properties
@@ -73,14 +73,14 @@ export declare namespace DomUtils {
73
73
  resources: T; /**
74
74
  * Current detected culture
75
75
  */
76
- compatibleName?: string[] | undefined;
76
+ compatibleNames?: string[] | undefined;
77
77
  }>[], culture: string) => Readonly<{
78
78
  name: string;
79
79
  label: string;
80
80
  resources: T; /**
81
81
  * Current detected culture
82
82
  */
83
- compatibleName?: string[] | undefined;
83
+ compatibleNames?: string[] | undefined;
84
84
  }> | undefined;
85
85
  /**
86
86
  * Get input value depending on its type
@@ -279,7 +279,11 @@ export var DomUtils;
279
279
  if (exactMatch)
280
280
  return exactMatch;
281
281
  // Compatible match
282
- const compatibleMatch = items.find((item) => { var _a; return (_a = item.compatibleName) === null || _a === void 0 ? void 0 : _a.includes(culture); });
282
+ const compatibleMatch = items.find((item) => {
283
+ var _a;
284
+ return ((_a = item.compatibleNames) === null || _a === void 0 ? void 0 : _a.includes(culture)) ||
285
+ culture.startsWith(item + '-');
286
+ });
283
287
  if (compatibleMatch)
284
288
  return compatibleMatch;
285
289
  // Same part, like zh-CN and zh-HK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.79",
3
+ "version": "1.1.80",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -58,7 +58,7 @@
58
58
  "@types/lodash.isequal": "^4.5.6",
59
59
  "@typescript-eslint/eslint-plugin": "^5.45.0",
60
60
  "@typescript-eslint/parser": "^5.45.0",
61
- "eslint": "^8.28.0",
61
+ "eslint": "^8.29.0",
62
62
  "eslint-config-airbnb-base": "^15.0.0",
63
63
  "eslint-plugin-import": "^2.26.0",
64
64
  "jest": "^29.3.1",
package/src/DataTypes.ts CHANGED
@@ -305,7 +305,7 @@ export namespace DataTypes {
305
305
  /**
306
306
  * Compatible names
307
307
  */
308
- compatibleName?: string[];
308
+ compatibleNames?: string[];
309
309
  }>;
310
310
 
311
311
  /**
package/src/DomUtils.ts CHANGED
@@ -325,8 +325,10 @@ export namespace DomUtils {
325
325
  if (exactMatch) return exactMatch;
326
326
 
327
327
  // Compatible match
328
- const compatibleMatch = items.find((item) =>
329
- item.compatibleName?.includes(culture)
328
+ const compatibleMatch = items.find(
329
+ (item) =>
330
+ item.compatibleNames?.includes(culture) ||
331
+ culture.startsWith(item + '-')
330
332
  );
331
333
  if (compatibleMatch) return compatibleMatch;
332
334