ydb-ui-components 2.2.0 → 2.3.0
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/CHANGELOG.md +7 -0
- package/README.md +30 -0
- package/build/components/NavigationTree/i18n/index.js +4 -2
- package/build/components/i18n.d.ts +0 -1
- package/build/components/i18n.js +9 -7
- package/build/index.d.ts +1 -0
- package/build/index.js +15 -1
- package/build/utils/configure.d.ts +12 -0
- package/build/utils/configure.js +38 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +19 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.3.0](https://github.com/ydb-platform/ydb-ui-components/compare/v2.2.0...v2.3.0) (2022-07-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **i18n:** add configure function ([c48e58e](https://github.com/ydb-platform/ydb-ui-components/commit/c48e58e33e361cf4f507190cd0a8d0a896975fb1))
|
|
9
|
+
|
|
3
10
|
## [2.2.0](https://github.com/ydb-platform/ydb-ui-components/compare/v2.1.0...v2.2.0) (2022-07-05)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
1
|
# ydb-ui-components
|
|
2
|
+
|
|
3
|
+
A set of React components used in YDB interfaces.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install --save-dev ydb-ui-components @yandex-cloud/uikit @yandex-cloud/i18n @yandex-cloud/browserslist-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## I18N
|
|
12
|
+
|
|
13
|
+
Some components contain prepared text. For changing language use `configure` function.
|
|
14
|
+
|
|
15
|
+
**index.js**
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import {configure} from 'ydb-ui-components';
|
|
19
|
+
|
|
20
|
+
configure({
|
|
21
|
+
lang: 'en',
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
To start the dev storybook
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
npm run start
|
|
31
|
+
```
|
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _i18n = require("../../i18n");
|
|
9
9
|
|
|
10
|
+
var _utils = require("../../../utils");
|
|
11
|
+
|
|
10
12
|
var _en = _interopRequireDefault(require("./en.json"));
|
|
11
13
|
|
|
12
14
|
var _ru = _interopRequireDefault(require("./ru.json"));
|
|
@@ -15,9 +17,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
17
|
|
|
16
18
|
const COMPONENT = 'ydb-navigation-tree';
|
|
17
19
|
|
|
18
|
-
_i18n.i18n.registerKeyset(
|
|
20
|
+
_i18n.i18n.registerKeyset(_utils.Lang.En, COMPONENT, _en.default);
|
|
19
21
|
|
|
20
|
-
_i18n.i18n.registerKeyset(
|
|
22
|
+
_i18n.i18n.registerKeyset(_utils.Lang.Ru, COMPONENT, _ru.default);
|
|
21
23
|
|
|
22
24
|
var _default = _i18n.i18n.keyset(COMPONENT);
|
|
23
25
|
|
package/build/components/i18n.js
CHANGED
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "I18N", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _i18n.I18N;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
exports.i18n = void 0;
|
|
13
7
|
|
|
14
8
|
var _i18n = require("@yandex-cloud/i18n");
|
|
15
9
|
|
|
10
|
+
var _configure = require("../utils/configure");
|
|
11
|
+
|
|
16
12
|
const i18n = new _i18n.I18N();
|
|
17
|
-
exports.i18n = i18n;
|
|
13
|
+
exports.i18n = i18n;
|
|
14
|
+
i18n.setLang((0, _configure.getConfig)().lang || _configure.Lang.En);
|
|
15
|
+
(0, _configure.subscribeConfigure)(config => {
|
|
16
|
+
if (config.lang) {
|
|
17
|
+
i18n.setLang(config.lang);
|
|
18
|
+
}
|
|
19
|
+
});
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -41,4 +41,18 @@ Object.keys(_TreeView).forEach(function (key) {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
var _i18n = require("./components/i18n");
|
|
44
|
+
var _i18n = require("./components/i18n");
|
|
45
|
+
|
|
46
|
+
var _utils = require("./utils");
|
|
47
|
+
|
|
48
|
+
Object.keys(_utils).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
51
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
52
|
+
Object.defineProperty(exports, key, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return _utils[key];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum Lang {
|
|
2
|
+
Ru = "ru",
|
|
3
|
+
En = "en"
|
|
4
|
+
}
|
|
5
|
+
interface Config {
|
|
6
|
+
lang?: Lang;
|
|
7
|
+
}
|
|
8
|
+
declare type Subscriber = (config: Config) => void;
|
|
9
|
+
export declare const configure: (newConfig: Config) => void;
|
|
10
|
+
export declare const subscribeConfigure: (sub: Subscriber) => () => void;
|
|
11
|
+
export declare const getConfig: () => Config;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.subscribeConfigure = exports.getConfig = exports.configure = exports.Lang = void 0;
|
|
7
|
+
let Lang;
|
|
8
|
+
exports.Lang = Lang;
|
|
9
|
+
|
|
10
|
+
(function (Lang) {
|
|
11
|
+
Lang["Ru"] = "ru";
|
|
12
|
+
Lang["En"] = "en";
|
|
13
|
+
})(Lang || (exports.Lang = Lang = {}));
|
|
14
|
+
|
|
15
|
+
let subs = [];
|
|
16
|
+
const config = {};
|
|
17
|
+
|
|
18
|
+
const configure = newConfig => {
|
|
19
|
+
Object.assign(config, newConfig);
|
|
20
|
+
subs.forEach(sub => {
|
|
21
|
+
sub(config);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.configure = configure;
|
|
26
|
+
|
|
27
|
+
const subscribeConfigure = sub => {
|
|
28
|
+
subs.push(sub);
|
|
29
|
+
return () => {
|
|
30
|
+
subs = subs.filter(item => item !== sub);
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.subscribeConfigure = subscribeConfigure;
|
|
35
|
+
|
|
36
|
+
const getConfig = () => config;
|
|
37
|
+
|
|
38
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { configure, Lang } from './configure';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Lang", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _configure.Lang;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "configure", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _configure.configure;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _configure = require("./configure");
|