@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.
- package/__tests__/DomUtils.ts +8 -6
- package/lib/cjs/DataTypes.d.ts +1 -1
- package/lib/cjs/DomUtils.d.ts +2 -2
- package/lib/cjs/DomUtils.js +5 -1
- package/lib/mjs/DataTypes.d.ts +1 -1
- package/lib/mjs/DomUtils.d.ts +2 -2
- package/lib/mjs/DomUtils.js +5 -1
- package/package.json +2 -2
- package/src/DataTypes.ts +1 -1
- package/src/DomUtils.ts +4 -2
package/__tests__/DomUtils.ts
CHANGED
|
@@ -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-
|
|
224
|
+
name: 'zh-Hans',
|
|
225
225
|
label: '简体中文',
|
|
226
226
|
resources: {},
|
|
227
|
-
|
|
227
|
+
compatibleNames: ['zh-CN', 'zh-SG']
|
|
228
228
|
},
|
|
229
|
-
{ name: 'en
|
|
229
|
+
{ name: 'en', label: 'English', resources: {} }
|
|
230
230
|
];
|
|
231
231
|
|
|
232
|
-
expect(DomUtils.getCulture(cultures, 'zh-CN')?.name).toBe('zh-
|
|
233
|
-
expect(DomUtils.getCulture(cultures, 'zh-
|
|
234
|
-
expect(DomUtils.getCulture(cultures, '
|
|
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', () => {
|
package/lib/cjs/DataTypes.d.ts
CHANGED
package/lib/cjs/DomUtils.d.ts
CHANGED
|
@@ -73,14 +73,14 @@ export declare namespace DomUtils {
|
|
|
73
73
|
resources: T; /**
|
|
74
74
|
* Current detected culture
|
|
75
75
|
*/
|
|
76
|
-
|
|
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
|
-
|
|
83
|
+
compatibleNames?: string[] | undefined;
|
|
84
84
|
}> | undefined;
|
|
85
85
|
/**
|
|
86
86
|
* Get input value depending on its type
|
package/lib/cjs/DomUtils.js
CHANGED
|
@@ -282,7 +282,11 @@ var DomUtils;
|
|
|
282
282
|
if (exactMatch)
|
|
283
283
|
return exactMatch;
|
|
284
284
|
// Compatible match
|
|
285
|
-
const compatibleMatch = items.find((item) => {
|
|
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
|
package/lib/mjs/DataTypes.d.ts
CHANGED
package/lib/mjs/DomUtils.d.ts
CHANGED
|
@@ -73,14 +73,14 @@ export declare namespace DomUtils {
|
|
|
73
73
|
resources: T; /**
|
|
74
74
|
* Current detected culture
|
|
75
75
|
*/
|
|
76
|
-
|
|
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
|
-
|
|
83
|
+
compatibleNames?: string[] | undefined;
|
|
84
84
|
}> | undefined;
|
|
85
85
|
/**
|
|
86
86
|
* Get input value depending on its type
|
package/lib/mjs/DomUtils.js
CHANGED
|
@@ -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) => {
|
|
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.
|
|
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.
|
|
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
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(
|
|
329
|
-
item
|
|
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
|
|