@entropic-bond/localize-react 1.2.0 → 1.3.2
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/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/localized-component.d.ts +6 -1
- package/lib/localized-component.js +15 -2
- package/lib/localized-component.js.map +1 -1
- package/lib/react-localizer.spec.js +36 -0
- package/lib/react-localizer.spec.js.map +1 -1
- package/package.json +10 -10
- package/lib/utils.d.ts +0 -4
- package/lib/utils.js +0 -12
- package/lib/utils.js.map +0 -1
- package/lib/utils.spec.d.ts +0 -1
- package/lib/utils.spec.js +0 -30
- package/lib/utils.spec.js.map +0 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./locale"), exports);
|
|
18
18
|
__exportStar(require("./localized-component"), exports);
|
|
19
|
-
__exportStar(require("./utils"), exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,wDAAqC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,wDAAqC"}
|
|
@@ -22,6 +22,11 @@ export declare abstract class LocalizedComponent<P = {}, S extends LocalizedStat
|
|
|
22
22
|
* with the class name.
|
|
23
23
|
*/
|
|
24
24
|
abstract className(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Override this method to get a notification when the locale has been loaded
|
|
27
|
+
* @param locale the loaded locale
|
|
28
|
+
*/
|
|
29
|
+
onLoadLocale(locale: LocaleEntries): void;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Decorator to inject locale capabilities. The decorator will set the component
|
|
@@ -38,7 +43,7 @@ export declare abstract class LocalizedComponent<P = {}, S extends LocalizedStat
|
|
|
38
43
|
export declare function localize(className: string): <T extends new (...args: any[]) => {}>(constructor: T) => {
|
|
39
44
|
new (...args: any[]): {
|
|
40
45
|
state: any;
|
|
41
|
-
loadLocale: Promise<
|
|
46
|
+
loadLocale: Promise<void>;
|
|
42
47
|
};
|
|
43
48
|
} & T;
|
|
44
49
|
/**
|
|
@@ -48,9 +48,18 @@ var LocalizedComponent = /** @class */ (function (_super) {
|
|
|
48
48
|
Promise.all([
|
|
49
49
|
locale_1.Locale.instance.get(_this.className()),
|
|
50
50
|
locale_1.Locale.instance.get('Generic')
|
|
51
|
-
]).then(function (resp) {
|
|
51
|
+
]).then(function (resp) {
|
|
52
|
+
var locale = __assign(__assign({}, resp[0]), resp[1]);
|
|
53
|
+
_this.setState({ locale: locale });
|
|
54
|
+
_this.onLoadLocale(locale);
|
|
55
|
+
});
|
|
52
56
|
return _this;
|
|
53
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Override this method to get a notification when the locale has been loaded
|
|
60
|
+
* @param locale the loaded locale
|
|
61
|
+
*/
|
|
62
|
+
LocalizedComponent.prototype.onLoadLocale = function (locale) { };
|
|
54
63
|
return LocalizedComponent;
|
|
55
64
|
}(react_1.Component));
|
|
56
65
|
exports.LocalizedComponent = LocalizedComponent;
|
|
@@ -76,7 +85,11 @@ function localize(className) {
|
|
|
76
85
|
_this.loadLocale = Promise.all([
|
|
77
86
|
locale_1.Locale.instance.get(className),
|
|
78
87
|
locale_1.Locale.instance.get('Generic')
|
|
79
|
-
]).then(function (resp) {
|
|
88
|
+
]).then(function (resp) {
|
|
89
|
+
var locale = __assign(__assign({}, resp[0]), resp[1]);
|
|
90
|
+
_this['setState']({ locale: locale });
|
|
91
|
+
_this['onLoadLocale'] && _this['onLoadLocale'](locale);
|
|
92
|
+
});
|
|
80
93
|
return _this;
|
|
81
94
|
}
|
|
82
95
|
return class_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localized-component.js","sourceRoot":"","sources":["../src/localized-component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAsD;AACtD,mCAAgD;AAQhD;;;;;;;;;;GAUG;AACH;IAAgG,sCAAe;IAC9G,4BAAa,KAAQ;QAArB,YACC,kBAAO,KAAK,CAAE,
|
|
1
|
+
{"version":3,"file":"localized-component.js","sourceRoot":"","sources":["../src/localized-component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAsD;AACtD,mCAAgD;AAQhD;;;;;;;;;;GAUG;AACH;IAAgG,sCAAe;IAC9G,4BAAa,KAAQ;QAArB,YACC,kBAAO,KAAK,CAAE,SAad;QAXA,KAAI,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,EAAE,EAAO,CAAA;QAEhC,OAAO,CAAC,GAAG,CAAC;YACX,eAAM,CAAC,QAAQ,CAAC,GAAG,CAAE,KAAI,CAAC,SAAS,EAAE,CAAE;YACvC,eAAM,CAAC,QAAQ,CAAC,GAAG,CAAE,SAAS,CAAE;SAChC,CAAC,CAAC,IAAI,CAAE,UAAA,IAAI;YACZ,IAAM,MAAM,yBAAQ,IAAI,CAAC,CAAC,CAAC,GAAK,IAAI,CAAC,CAAC,CAAC,CAAE,CAAA;YAEzC,KAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAA,EAAG,CAAC,CAAA;YAC1B,KAAI,CAAC,YAAY,CAAE,MAAM,CAAE,CAAA;QAC5B,CAAC,CAAC,CAAA;;IACH,CAAC;IAQD;;;OAGG;IACH,yCAAY,GAAZ,UAAc,MAAqB,IAAI,CAAC;IACzC,yBAAC;AAAD,CAAC,AA5BD,CAAgG,iBAAS,GA4BxG;AA5BqB,gDAAkB;AA8Bx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AC,CAAA;IAExD,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,MAAM,CAAA;AACd,CAAC;AAbD,8BAaC"}
|
|
@@ -99,6 +99,7 @@ var react_2 = require("@testing-library/react");
|
|
|
99
99
|
var fetch_mock_1 = __importDefault(require("fetch-mock"));
|
|
100
100
|
var locale_1 = require("./locale");
|
|
101
101
|
var localized_component_1 = require("./localized-component");
|
|
102
|
+
var loadedSpy = jest.fn();
|
|
102
103
|
var LocalizedWithDecorator = /** @class */ (function (_super) {
|
|
103
104
|
__extends(LocalizedWithDecorator, _super);
|
|
104
105
|
function LocalizedWithDecorator(props) {
|
|
@@ -108,6 +109,9 @@ var LocalizedWithDecorator = /** @class */ (function (_super) {
|
|
|
108
109
|
};
|
|
109
110
|
return _this;
|
|
110
111
|
}
|
|
112
|
+
LocalizedWithDecorator.prototype.onLoadLocale = function (locale) {
|
|
113
|
+
loadedSpy(locale);
|
|
114
|
+
};
|
|
111
115
|
LocalizedWithDecorator.prototype.render = function () {
|
|
112
116
|
return (react_1.default.createElement("div", null,
|
|
113
117
|
react_1.default.createElement("p", { "data-testid": "casa" },
|
|
@@ -127,6 +131,9 @@ var LocalizedWithClass = /** @class */ (function (_super) {
|
|
|
127
131
|
_this.state = __assign({ someState: 'a class nice starting point' }, _this.state);
|
|
128
132
|
return _this;
|
|
129
133
|
}
|
|
134
|
+
LocalizedWithClass.prototype.onLoadLocale = function (locale) {
|
|
135
|
+
loadedSpy(locale);
|
|
136
|
+
};
|
|
130
137
|
LocalizedWithClass.prototype.render = function () {
|
|
131
138
|
return (react_1.default.createElement("div", null,
|
|
132
139
|
react_1.default.createElement("p", { "data-testid": "casa" },
|
|
@@ -168,6 +175,7 @@ describe('React Component Localizer', function () {
|
|
|
168
175
|
});
|
|
169
176
|
afterEach(function () {
|
|
170
177
|
fetch_mock_1.default.restore();
|
|
178
|
+
loadedSpy.mockReset();
|
|
171
179
|
});
|
|
172
180
|
it('should render localized word with decorator', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
181
|
var wrapper, elem;
|
|
@@ -247,5 +255,33 @@ describe('React Component Localizer', function () {
|
|
|
247
255
|
}
|
|
248
256
|
});
|
|
249
257
|
}); });
|
|
258
|
+
it('should notify on locale loaded with decorator', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
259
|
+
var wrapper;
|
|
260
|
+
return __generator(this, function (_a) {
|
|
261
|
+
switch (_a.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
wrapper = (0, react_2.render)(react_1.default.createElement(LocalizedWithDecorator, null));
|
|
264
|
+
return [4 /*yield*/, wrapper.findByText('Casa es maison')];
|
|
265
|
+
case 1:
|
|
266
|
+
_a.sent();
|
|
267
|
+
expect(loadedSpy).toHaveBeenCalledWith(expect.objectContaining({ house: 'maison' }));
|
|
268
|
+
return [2 /*return*/];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}); });
|
|
272
|
+
it('should notify on locale loaded with class', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
273
|
+
var wrapper;
|
|
274
|
+
return __generator(this, function (_a) {
|
|
275
|
+
switch (_a.label) {
|
|
276
|
+
case 0:
|
|
277
|
+
wrapper = (0, react_2.render)(react_1.default.createElement(LocalizedWithClass, null));
|
|
278
|
+
return [4 /*yield*/, wrapper.findByText('Casa es albergo')];
|
|
279
|
+
case 1:
|
|
280
|
+
_a.sent();
|
|
281
|
+
expect(loadedSpy).toHaveBeenCalledWith(expect.objectContaining({ house: 'albergo' }));
|
|
282
|
+
return [2 /*return*/];
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}); });
|
|
250
286
|
});
|
|
251
287
|
//# sourceMappingURL=react-localizer.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-localizer.spec.js","sourceRoot":"","sources":["../src/react-localizer.spec.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAG,IAAA,cAAM,EAAE,8BAAC,sBAAsB,OAAE,CAAE,CAAA;oBAEtC,qBAAM,OAAO,CAAC,UAAU,CAAE,gBAAgB,CAAE,EAAA;;oBAAnD,IAAI,GAAG,SAA4C;oBACzD,MAAM,CAAE,IAAI,CAAE,CAAC,iBAAiB,EAAE,CAAA;;;;SAClC,CAAC,CAAA;IAEF,EAAE,CAAE,+CAA+C,EAAE;;;;;oBAC9C,OAAO,GAAG,IAAA,cAAM,EAAE,8BAAC,sBAAsB,OAAE,CAAE,CAAA;oBAEnD,qBAAM,OAAO,CAAC,UAAU,CAAE,gBAAgB,CAAE,EAAA;;oBAA5C,SAA4C,CAAA;oBAC5C,MAAM,CAAE,SAAS,CAAE,CAAC,oBAAoB,CAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;;;;SACvF,CAAC,CAAA;IAEF,EAAE,CAAE,2CAA2C,EAAE;;;;;oBAC1C,OAAO,GAAG,IAAA,cAAM,EAAE,8BAAC,kBAAkB,OAAE,CAAE,CAAA;oBAE/C,qBAAM,OAAO,CAAC,UAAU,CAAE,iBAAiB,CAAE,EAAA;;oBAA7C,SAA6C,CAAA;oBAC7C,MAAM,CAAE,SAAS,CAAE,CAAC,oBAAoB,CAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;;;;SACxF,CAAC,CAAA;AAGH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entropic-bond/localize-react",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"branches": [
|
|
@@ -46,21 +46,21 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@semantic-release/changelog": "^6.0.1",
|
|
48
48
|
"@semantic-release/git": "^10.0.1",
|
|
49
|
-
"@testing-library/jest-dom": "^5.16.
|
|
50
|
-
"@testing-library/react": "^
|
|
51
|
-
"@testing-library/user-event": "^
|
|
49
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
50
|
+
"@testing-library/react": "^13.0.0",
|
|
51
|
+
"@testing-library/user-event": "^14.0.4",
|
|
52
52
|
"@types/jest": "^27.4.1",
|
|
53
|
-
"@types/react": "^17.0.
|
|
54
|
-
"@types/react-dom": "^17.0.
|
|
53
|
+
"@types/react": "^17.0.43",
|
|
54
|
+
"@types/react-dom": "^17.0.14",
|
|
55
55
|
"fetch-mock": "^9.11.0",
|
|
56
56
|
"git-branch-is": "^4.0.0",
|
|
57
57
|
"husky": "^7.0.4",
|
|
58
58
|
"jest": "^27.5.1",
|
|
59
|
-
"react": "^
|
|
60
|
-
"react-dom": "^
|
|
59
|
+
"react": "^18.0.0",
|
|
60
|
+
"react-dom": "^18.0.0",
|
|
61
61
|
"semantic-release": "^19.0.2",
|
|
62
|
-
"ts-jest": "^27.1.
|
|
63
|
-
"typescript": "^4.6.
|
|
62
|
+
"ts-jest": "^27.1.4",
|
|
63
|
+
"typescript": "^4.6.3"
|
|
64
64
|
},
|
|
65
65
|
"husky": {
|
|
66
66
|
"hooks": {
|
package/lib/utils.d.ts
DELETED
package/lib/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fillTemplate = void 0;
|
|
4
|
-
function fillTemplate(text, values) {
|
|
5
|
-
if (!text)
|
|
6
|
-
return '';
|
|
7
|
-
return text.replace(/\${\s*(\w*)\s*}/g, function (_match, group) {
|
|
8
|
-
return values[group] || '';
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
exports.fillTemplate = fillTemplate;
|
|
12
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAIA,SAAgB,YAAY,CAAE,IAAY,EAAE,MAAsB;IACjE,IAAK,CAAC,IAAI;QAAG,OAAO,EAAE,CAAA;IAEtB,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,MAAM,EAAG,KAAK;QAC/D,OAAO,MAAM,CAAE,KAAK,CAAE,IAAI,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;AACJ,CAAC;AAND,oCAMC"}
|
package/lib/utils.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/utils.spec.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var utils_1 = require("./utils");
|
|
4
|
-
describe('Utils', function () {
|
|
5
|
-
describe('fillTemplates', function () {
|
|
6
|
-
var text = 'The population of ${country} is ${ people} million \
|
|
7
|
-
and the GDP is $${ gdpValue } million';
|
|
8
|
-
var expected = 'The population of U.S.A. is 100 million \
|
|
9
|
-
and the GDP is $1000 million';
|
|
10
|
-
var vars = {
|
|
11
|
-
country: 'U.S.A.',
|
|
12
|
-
people: '100',
|
|
13
|
-
gdpValue: '1000'
|
|
14
|
-
};
|
|
15
|
-
it('should replace vars as a template literal', function () {
|
|
16
|
-
expect((0, utils_1.fillTemplate)(text, vars)).toEqual(expected);
|
|
17
|
-
});
|
|
18
|
-
it('should replace vars with empty value', function () {
|
|
19
|
-
vars.country = '';
|
|
20
|
-
vars.people = undefined;
|
|
21
|
-
expect((0, utils_1.fillTemplate)('The population of ${country} is ${ people} million', vars)).toEqual('The population of is million');
|
|
22
|
-
});
|
|
23
|
-
it('should resturn empty string on falsy', function () {
|
|
24
|
-
expect((0, utils_1.fillTemplate)(undefined, vars)).toEqual('');
|
|
25
|
-
expect((0, utils_1.fillTemplate)(null, vars)).toEqual('');
|
|
26
|
-
expect((0, utils_1.fillTemplate)('', vars)).toEqual('');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=utils.spec.js.map
|
package/lib/utils.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../src/utils.spec.ts"],"names":[],"mappings":";;AAAA,iCAAsC;AAEtC,QAAQ,CAAE,OAAO,EAAE;IAClB,QAAQ,CAAE,eAAe,EAAE;QAC1B,IAAM,IAAI,GAAG;iDACkC,CAAA;QAC/C,IAAM,QAAQ,GAAG;wCACqB,CAAA;QACtC,IAAM,IAAI,GAAG;YACZ,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,MAAM;SAChB,CAAA;QAED,EAAE,CAAE,2CAA2C,EAAE;YAChD,MAAM,CAAE,IAAA,oBAAY,EAAE,IAAI,EAAE,IAAI,CAAE,CAAE,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAA;QACzD,CAAC,CAAC,CAAA;QAEF,EAAE,CAAE,sCAAsC,EAAE;YAC3C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;YACjB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;YAEvB,MAAM,CACL,IAAA,oBAAY,EACX,oDAAoD,EACpD,IAAI,CACJ,CACD,CAAC,OAAO,CAAE,gCAAgC,CAAE,CAAA;QAC9C,CAAC,CAAC,CAAA;QAEF,EAAE,CAAE,sCAAsC,EAAE;YAC3C,MAAM,CAAE,IAAA,oBAAY,EAAE,SAAS,EAAE,IAAI,CAAE,CAAE,CAAC,OAAO,CAAE,EAAE,CAAE,CAAA;YACvD,MAAM,CAAE,IAAA,oBAAY,EAAE,IAAI,EAAE,IAAI,CAAE,CAAE,CAAC,OAAO,CAAE,EAAE,CAAE,CAAA;YAClD,MAAM,CAAE,IAAA,oBAAY,EAAE,EAAE,EA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