ydb-ui-components 2.2.0 → 2.4.1
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 +22 -0
- package/README.md +30 -0
- package/build/components/NavigationTree/EmptyView/EmptyView.d.ts +5 -1
- package/build/components/NavigationTree/EmptyView/EmptyView.js +6 -2
- package/build/components/NavigationTree/ErrorView/ErrorView.d.ts +5 -1
- package/build/components/NavigationTree/ErrorView/ErrorView.js +6 -2
- package/build/components/NavigationTree/LoaderView/LoaderView.d.ts +5 -1
- package/build/components/NavigationTree/LoaderView/LoaderView.js +6 -2
- package/build/components/NavigationTree/NavigationTree.d.ts +2 -2
- package/build/components/NavigationTree/NavigationTree.js +64 -20
- package/build/components/NavigationTree/NavigationTreeNode.d.ts +5 -2
- package/build/components/NavigationTree/NavigationTreeNode.js +77 -8
- package/build/components/NavigationTree/i18n/index.js +4 -2
- package/build/components/NavigationTree/state.d.ts +4 -2
- package/build/components/NavigationTree/state.js +24 -0
- package/build/components/NavigationTree/types.d.ts +8 -1
- package/build/components/NavigationTree/utils.d.ts +6 -0
- package/build/components/NavigationTree/utils.js +63 -0
- package/build/components/TreeView/TreeView.css +2 -0
- package/build/components/TreeView/TreeView.d.ts +2 -1
- package/build/components/TreeView/TreeView.js +7 -2
- package/build/components/i18n.d.ts +0 -1
- package/build/components/i18n.js +9 -7
- package/build/components/icons/ColumnTable.d.ts +2 -0
- package/build/components/icons/ColumnTable.js +56 -0
- package/build/components/icons/Folder.js +2 -2
- package/build/components/icons/FolderOpen.js +2 -2
- package/build/components/icons/Index.d.ts +2 -0
- package/build/components/icons/Index.js +24 -0
- package/build/components/icons/Table.js +2 -2
- package/build/components/icons/Topic.d.ts +2 -0
- package/build/components/icons/Topic.js +22 -0
- 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 +3 -1
- package/build/components/NavigationTree/NavigationTreeDirectory.d.ts +0 -14
- package/build/components/NavigationTree/NavigationTreeDirectory.js +0 -106
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.1](https://github.com/ydb-platform/ydb-ui-components/compare/v2.4.0...v2.4.1) (2022-08-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **NavigationTree:** add node types & update icons ([909b560](https://github.com/ydb-platform/ydb-ui-components/commit/909b5607b6309cb42401afdb7b869f2a2e8ab908))
|
|
9
|
+
|
|
10
|
+
## [2.4.0](https://github.com/ydb-platform/ydb-ui-components/compare/v2.3.0...v2.4.0) (2022-07-28)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **NavigationTree:** virtualized render ([7388ff5](https://github.com/ydb-platform/ydb-ui-components/commit/7388ff5a5b05ffa30b86fb4ae2d8e52a7bd9dad8))
|
|
16
|
+
* **TreeView:** a prop to determine tree view nesting level ([2e5d42a](https://github.com/ydb-platform/ydb-ui-components/commit/2e5d42abf78e81fdd61747958822dc3b96eab42f))
|
|
17
|
+
|
|
18
|
+
## [2.3.0](https://github.com/ydb-platform/ydb-ui-components/compare/v2.2.0...v2.3.0) (2022-07-18)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **i18n:** add configure function ([c48e58e](https://github.com/ydb-platform/ydb-ui-components/commit/c48e58e33e361cf4f507190cd0a8d0a896975fb1))
|
|
24
|
+
|
|
3
25
|
## [2.2.0](https://github.com/ydb-platform/ydb-ui-components/compare/v2.1.0...v2.2.0) (2022-07-05)
|
|
4
26
|
|
|
5
27
|
|
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
|
+
```
|
|
@@ -19,10 +19,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
|
|
20
20
|
const b = (0, _bemCnLite.default)('ydb-navigation-tree-view-empty');
|
|
21
21
|
|
|
22
|
-
function EmptyView() {
|
|
22
|
+
function EmptyView(_ref) {
|
|
23
|
+
let {
|
|
24
|
+
level
|
|
25
|
+
} = _ref;
|
|
23
26
|
return /*#__PURE__*/_react.default.createElement(_TreeView.TreeView, {
|
|
24
27
|
name: /*#__PURE__*/_react.default.createElement("span", {
|
|
25
28
|
className: b()
|
|
26
|
-
}, (0, _i18n.default)('label_empty'))
|
|
29
|
+
}, (0, _i18n.default)('label_empty')),
|
|
30
|
+
level: level
|
|
27
31
|
});
|
|
28
32
|
}
|
|
@@ -19,10 +19,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
|
|
20
20
|
const b = (0, _bemCnLite.default)('ydb-navigation-tree-view-error');
|
|
21
21
|
|
|
22
|
-
function ErrorView() {
|
|
22
|
+
function ErrorView(_ref) {
|
|
23
|
+
let {
|
|
24
|
+
level
|
|
25
|
+
} = _ref;
|
|
23
26
|
return /*#__PURE__*/_react.default.createElement(_TreeView.TreeView, {
|
|
24
27
|
name: /*#__PURE__*/_react.default.createElement("span", {
|
|
25
28
|
className: b()
|
|
26
|
-
}, (0, _i18n.default)('label_error'))
|
|
29
|
+
}, (0, _i18n.default)('label_error')),
|
|
30
|
+
level: level
|
|
27
31
|
});
|
|
28
32
|
}
|
|
@@ -19,12 +19,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
|
|
20
20
|
const b = (0, _bemCnLite.default)('ydb-navigation-tree-view-loader');
|
|
21
21
|
|
|
22
|
-
function LoaderView() {
|
|
22
|
+
function LoaderView(_ref) {
|
|
23
|
+
let {
|
|
24
|
+
level
|
|
25
|
+
} = _ref;
|
|
23
26
|
return /*#__PURE__*/_react.default.createElement(_TreeView.TreeView, {
|
|
24
27
|
name: /*#__PURE__*/_react.default.createElement("div", {
|
|
25
28
|
className: b()
|
|
26
29
|
}, /*#__PURE__*/_react.default.createElement(_uikit.Spin, {
|
|
27
30
|
size: "xs"
|
|
28
|
-
}))
|
|
31
|
+
})),
|
|
32
|
+
level: level
|
|
29
33
|
});
|
|
30
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { NavigationTreeProps } from './types';
|
|
2
|
+
import type { NavigationTreeProps } from './types';
|
|
3
3
|
export type { NavigationTreeProps };
|
|
4
|
-
export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, activePath, onActivePathUpdate, cache, }: NavigationTreeProps): JSX.Element;
|
|
4
|
+
export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, activePath, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps): JSX.Element;
|
|
@@ -7,14 +7,45 @@ exports.NavigationTree = NavigationTree;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _reactList = _interopRequireDefault(require("react-list"));
|
|
11
|
+
|
|
10
12
|
var _state = require("./state");
|
|
11
13
|
|
|
14
|
+
var _utils = require("./utils");
|
|
15
|
+
|
|
12
16
|
var _NavigationTreeNode = require("./NavigationTreeNode");
|
|
13
17
|
|
|
14
|
-
var
|
|
18
|
+
var _LoaderView = require("./LoaderView/LoaderView");
|
|
19
|
+
|
|
20
|
+
var _ErrorView = require("./ErrorView/ErrorView");
|
|
21
|
+
|
|
22
|
+
var _EmptyView = require("./EmptyView/EmptyView");
|
|
15
23
|
|
|
16
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
25
|
|
|
26
|
+
const renderServiceNode = node => {
|
|
27
|
+
const key = `${node.path}|${node.status}`;
|
|
28
|
+
|
|
29
|
+
if (node.status === 'loading') {
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_LoaderView.LoaderView, {
|
|
31
|
+
key: key,
|
|
32
|
+
level: node.level
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (node.status === 'error') {
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_ErrorView.ErrorView, {
|
|
38
|
+
key: key,
|
|
39
|
+
level: node.level
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_EmptyView.EmptyView, {
|
|
44
|
+
key: key,
|
|
45
|
+
level: node.level
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
18
49
|
function NavigationTree(_ref) {
|
|
19
50
|
let {
|
|
20
51
|
rootState: partialRootState,
|
|
@@ -22,29 +53,42 @@ function NavigationTree(_ref) {
|
|
|
22
53
|
getActions,
|
|
23
54
|
activePath,
|
|
24
55
|
onActivePathUpdate,
|
|
25
|
-
cache = true
|
|
56
|
+
cache = true,
|
|
57
|
+
virtualize = false
|
|
26
58
|
} = _ref;
|
|
27
59
|
|
|
28
60
|
const [state, dispatch] = _react.default.useReducer(_state.reducer, {
|
|
29
61
|
[partialRootState.path]: (0, _state.getNodeState)(partialRootState)
|
|
30
62
|
});
|
|
31
63
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
const nodesList = _react.default.useMemo(() => (0, _state.selectTreeAsList)(state, partialRootState.path), [state]);
|
|
65
|
+
|
|
66
|
+
const renderNode = node => {
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_NavigationTreeNode.NavigationTreeNode, {
|
|
68
|
+
key: node.path,
|
|
69
|
+
state: state,
|
|
70
|
+
path: node.path,
|
|
71
|
+
activePath: activePath,
|
|
72
|
+
fetchPath: fetchPath,
|
|
73
|
+
dispatch: dispatch,
|
|
74
|
+
onActivate: onActivePathUpdate,
|
|
75
|
+
getActions: getActions,
|
|
76
|
+
cache: cache,
|
|
77
|
+
level: node.level
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const renderVirtualizedTree = () => /*#__PURE__*/_react.default.createElement(_reactList.default, {
|
|
82
|
+
type: "uniform",
|
|
83
|
+
length: nodesList.length,
|
|
84
|
+
useStaticSize: true,
|
|
85
|
+
itemRenderer: index => {
|
|
86
|
+
const node = nodesList[index];
|
|
87
|
+
return (0, _utils.isServiceNode)(node) ? renderServiceNode(node) : renderNode(node);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const renderSimpleTree = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, nodesList.map(node => (0, _utils.isServiceNode)(node) ? renderServiceNode(node) : renderNode(node)));
|
|
92
|
+
|
|
93
|
+
return virtualize ? renderVirtualizedTree() : renderSimpleTree();
|
|
50
94
|
}
|
|
@@ -3,11 +3,14 @@ import { NavigationTreeState, NavigationTreeProps } from './types';
|
|
|
3
3
|
import { NavigationTreeAction } from './state';
|
|
4
4
|
export interface NavigationTreeNodeProps {
|
|
5
5
|
path: string;
|
|
6
|
+
fetchPath: NavigationTreeProps['fetchPath'];
|
|
7
|
+
activePath?: string;
|
|
6
8
|
state: NavigationTreeState;
|
|
9
|
+
level?: number;
|
|
7
10
|
dispatch: React.Dispatch<NavigationTreeAction>;
|
|
8
11
|
children?: React.ReactNode;
|
|
9
|
-
active?: boolean;
|
|
10
12
|
onActivate?: (path: string) => void;
|
|
11
13
|
getActions?: NavigationTreeProps['getActions'];
|
|
14
|
+
cache?: boolean;
|
|
12
15
|
}
|
|
13
|
-
export declare function NavigationTreeNode({ path, state, dispatch, children,
|
|
16
|
+
export declare function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatch, children, onActivate, getActions, cache, }: NavigationTreeNodeProps): JSX.Element;
|
|
@@ -17,6 +17,12 @@ var _FolderOpen = require("../icons/FolderOpen");
|
|
|
17
17
|
|
|
18
18
|
var _Table = require("../icons/Table");
|
|
19
19
|
|
|
20
|
+
var _Topic = require("../icons/Topic");
|
|
21
|
+
|
|
22
|
+
var _Index = require("../icons/Index");
|
|
23
|
+
|
|
24
|
+
var _ColumnTable = require("../icons/ColumnTable");
|
|
25
|
+
|
|
20
26
|
var _TreeView = require("../TreeView/TreeView");
|
|
21
27
|
|
|
22
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -24,22 +30,37 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
30
|
function renderIcon(type, collapsed) {
|
|
25
31
|
switch (type) {
|
|
26
32
|
case 'database':
|
|
33
|
+
// this icon is larger than the others, therefore 14 for a better fit
|
|
27
34
|
return /*#__PURE__*/_react.default.createElement(_Database.DatabaseIcon, {
|
|
28
35
|
height: 14
|
|
29
36
|
});
|
|
30
37
|
|
|
31
38
|
case 'directory':
|
|
32
|
-
case 'index':
|
|
33
39
|
return collapsed ? /*#__PURE__*/_react.default.createElement(_Folder.FolderIcon, {
|
|
34
|
-
height:
|
|
40
|
+
height: 16
|
|
35
41
|
}) : /*#__PURE__*/_react.default.createElement(_FolderOpen.FolderOpenIcon, {
|
|
36
|
-
height:
|
|
42
|
+
height: 16
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
case 'index':
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_Index.IndexIcon, {
|
|
47
|
+
height: 16
|
|
37
48
|
});
|
|
38
49
|
|
|
39
50
|
case 'table':
|
|
40
51
|
case 'index_table':
|
|
41
52
|
return /*#__PURE__*/_react.default.createElement(_Table.TableIcon, {
|
|
42
|
-
height:
|
|
53
|
+
height: 16
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
case 'column_table':
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_ColumnTable.ColumnTableIcon, {
|
|
58
|
+
height: 16
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
case 'topic':
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_Topic.TopicIcon, {
|
|
63
|
+
height: 16
|
|
43
64
|
});
|
|
44
65
|
|
|
45
66
|
default:
|
|
@@ -50,15 +71,62 @@ function renderIcon(type, collapsed) {
|
|
|
50
71
|
function NavigationTreeNode(_ref) {
|
|
51
72
|
let {
|
|
52
73
|
path,
|
|
74
|
+
fetchPath,
|
|
75
|
+
activePath,
|
|
53
76
|
state,
|
|
77
|
+
level,
|
|
54
78
|
dispatch,
|
|
55
79
|
children,
|
|
56
|
-
active,
|
|
57
80
|
onActivate,
|
|
58
|
-
getActions
|
|
81
|
+
getActions,
|
|
82
|
+
cache
|
|
59
83
|
} = _ref;
|
|
60
84
|
const nodeState = state[path];
|
|
61
85
|
|
|
86
|
+
_react.default.useEffect(() => {
|
|
87
|
+
if (nodeState.collapsed) {
|
|
88
|
+
if (!cache) {
|
|
89
|
+
dispatch({
|
|
90
|
+
type: _state.NavigationTreeActionType.ResetNode,
|
|
91
|
+
payload: {
|
|
92
|
+
path
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (nodeState.loaded || nodeState.loading) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
dispatch({
|
|
105
|
+
type: _state.NavigationTreeActionType.StartLoading,
|
|
106
|
+
payload: {
|
|
107
|
+
path
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
fetchPath(path).then(data => {
|
|
111
|
+
dispatch({
|
|
112
|
+
type: _state.NavigationTreeActionType.FinishLoading,
|
|
113
|
+
payload: {
|
|
114
|
+
path,
|
|
115
|
+
activePath,
|
|
116
|
+
data
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}).catch(error => {
|
|
120
|
+
dispatch({
|
|
121
|
+
type: _state.NavigationTreeActionType.FinishLoading,
|
|
122
|
+
payload: {
|
|
123
|
+
path,
|
|
124
|
+
error
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}, [nodeState.collapsed]);
|
|
129
|
+
|
|
62
130
|
const handleClick = _react.default.useCallback(() => {
|
|
63
131
|
if (onActivate) {
|
|
64
132
|
onActivate(path);
|
|
@@ -82,10 +150,11 @@ function NavigationTreeNode(_ref) {
|
|
|
82
150
|
name: nodeState.name,
|
|
83
151
|
icon: renderIcon(nodeState.type, nodeState.collapsed),
|
|
84
152
|
collapsed: nodeState.collapsed,
|
|
85
|
-
active:
|
|
153
|
+
active: nodeState.path === activePath,
|
|
86
154
|
actions: actions,
|
|
87
155
|
hasArrow: nodeState.expandable,
|
|
88
156
|
onClick: handleClick,
|
|
89
|
-
onArrowClick: handleArrowClick
|
|
157
|
+
onArrowClick: handleArrowClick,
|
|
158
|
+
level: level
|
|
90
159
|
}, children);
|
|
91
160
|
}
|
|
@@ -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
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { NavigationTreeNodeState, NavigationTreeNodePartialState, NavigationTreeState } from './types';
|
|
1
|
+
import type { NavigationTreeNodeState, NavigationTreeNodePartialState, NavigationTreeState, NavigationTreeServiceNode } from './types';
|
|
2
2
|
export declare enum NavigationTreeActionType {
|
|
3
3
|
ToggleCollapsed = "toggle-collapsed",
|
|
4
4
|
StartLoading = "start-loading",
|
|
5
|
-
FinishLoading = "finish-loading"
|
|
5
|
+
FinishLoading = "finish-loading",
|
|
6
|
+
ResetNode = "reset-node"
|
|
6
7
|
}
|
|
7
8
|
export interface NavigationTreeAction {
|
|
8
9
|
type: NavigationTreeActionType;
|
|
@@ -17,3 +18,4 @@ export declare function getDefaultNodeState(): {
|
|
|
17
18
|
};
|
|
18
19
|
export declare function getNodeState(partialState: NavigationTreeNodePartialState): NavigationTreeNodeState;
|
|
19
20
|
export declare function reducer(state: NavigationTreeState | undefined, action: NavigationTreeAction): NavigationTreeState;
|
|
21
|
+
export declare function selectTreeAsList(state: NavigationTreeState, rootPath: string): (NavigationTreeNodeState | NavigationTreeServiceNode)[];
|
|
@@ -7,6 +7,9 @@ exports.NavigationTreeActionType = void 0;
|
|
|
7
7
|
exports.getDefaultNodeState = getDefaultNodeState;
|
|
8
8
|
exports.getNodeState = getNodeState;
|
|
9
9
|
exports.reducer = reducer;
|
|
10
|
+
exports.selectTreeAsList = selectTreeAsList;
|
|
11
|
+
|
|
12
|
+
var _utils = require("./utils");
|
|
10
13
|
|
|
11
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
15
|
|
|
@@ -21,6 +24,7 @@ exports.NavigationTreeActionType = NavigationTreeActionType;
|
|
|
21
24
|
NavigationTreeActionType["ToggleCollapsed"] = "toggle-collapsed";
|
|
22
25
|
NavigationTreeActionType["StartLoading"] = "start-loading";
|
|
23
26
|
NavigationTreeActionType["FinishLoading"] = "finish-loading";
|
|
27
|
+
NavigationTreeActionType["ResetNode"] = "reset-node";
|
|
24
28
|
})(NavigationTreeActionType || (exports.NavigationTreeActionType = NavigationTreeActionType = {}));
|
|
25
29
|
|
|
26
30
|
function getDefaultNodeState() {
|
|
@@ -99,7 +103,27 @@ function reducer() {
|
|
|
99
103
|
return newState;
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
case NavigationTreeActionType.ResetNode:
|
|
107
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
108
|
+
[action.payload.path]: _objectSpread(_objectSpread({}, state[action.payload.path]), getDefaultNodeState())
|
|
109
|
+
});
|
|
110
|
+
|
|
102
111
|
default:
|
|
103
112
|
return state;
|
|
104
113
|
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function selectTreeAsList(state, rootPath) {
|
|
117
|
+
const list = [];
|
|
118
|
+
(0, _utils.traverseDFS)(state, rootPath, (node, level) => {
|
|
119
|
+
list.push(_objectSpread(_objectSpread({}, node), {}, {
|
|
120
|
+
level
|
|
121
|
+
}));
|
|
122
|
+
const serviceNode = (0, _utils.getServiceNode)(node, level);
|
|
123
|
+
|
|
124
|
+
if (serviceNode) {
|
|
125
|
+
list.push(serviceNode);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return list;
|
|
105
129
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DropdownMenuItemMixed } from '@yandex-cloud/uikit';
|
|
2
|
-
export declare type NavigationTreeNodeType = 'database' | 'directory' | 'table' | 'index_table' | 'index';
|
|
2
|
+
export declare type NavigationTreeNodeType = 'database' | 'directory' | 'table' | 'column_table' | 'index_table' | 'index' | 'topic';
|
|
3
3
|
export interface NavigationTreeDataItem {
|
|
4
4
|
name: string;
|
|
5
5
|
type: NavigationTreeNodeType;
|
|
@@ -20,6 +20,12 @@ export interface NavigationTreeNodeState {
|
|
|
20
20
|
loaded: boolean;
|
|
21
21
|
error: boolean;
|
|
22
22
|
children: string[];
|
|
23
|
+
level?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface NavigationTreeServiceNode {
|
|
26
|
+
path: string;
|
|
27
|
+
status: 'loading' | 'error' | 'empty';
|
|
28
|
+
level?: number;
|
|
23
29
|
}
|
|
24
30
|
export declare type NavigationTreeNodePartialState = Omit<NavigationTreeNodeState, 'loading' | 'loaded' | 'error' | 'children'>;
|
|
25
31
|
export interface NavigationTreeProps<D = any> {
|
|
@@ -29,4 +35,5 @@ export interface NavigationTreeProps<D = any> {
|
|
|
29
35
|
activePath?: string;
|
|
30
36
|
onActivePathUpdate?: (activePath: string) => void;
|
|
31
37
|
cache?: boolean;
|
|
38
|
+
virtualize?: boolean;
|
|
32
39
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NavigationTreeNodeState, NavigationTreeServiceNode, NavigationTreeState } from './types';
|
|
2
|
+
export declare function isServiceNode(node: NavigationTreeNodeState | NavigationTreeServiceNode): node is NavigationTreeServiceNode;
|
|
3
|
+
export declare function getServiceNode(node: NavigationTreeNodeState, level: number): NavigationTreeServiceNode | void;
|
|
4
|
+
declare type TraverseDFSVisit = (node: NavigationTreeNodeState, level: number, path: string, state: NavigationTreeState) => void;
|
|
5
|
+
export declare function traverseDFS(state: NavigationTreeState, path: string, visit: TraverseDFSVisit, level?: number): void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getServiceNode = getServiceNode;
|
|
7
|
+
exports.isServiceNode = isServiceNode;
|
|
8
|
+
exports.traverseDFS = traverseDFS;
|
|
9
|
+
|
|
10
|
+
function isServiceNode(node) {
|
|
11
|
+
return 'status' in node;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getServiceNode(node, level) {
|
|
15
|
+
if (node.collapsed) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (node.loading) {
|
|
20
|
+
return {
|
|
21
|
+
path: node.path,
|
|
22
|
+
status: 'loading',
|
|
23
|
+
level: level + 1
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (node.error) {
|
|
28
|
+
return {
|
|
29
|
+
path: node.path,
|
|
30
|
+
status: 'error',
|
|
31
|
+
level: level + 1
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (node.loaded && node.children.length === 0) {
|
|
36
|
+
return {
|
|
37
|
+
path: node.path,
|
|
38
|
+
status: 'empty',
|
|
39
|
+
level: level + 1
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function traverseDFS(state, path, visit) {
|
|
47
|
+
let level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
48
|
+
const currentNode = state[path];
|
|
49
|
+
|
|
50
|
+
if (!currentNode) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
visit(currentNode, level, path, state);
|
|
55
|
+
|
|
56
|
+
if (currentNode.collapsed) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (const childPath of currentNode.children) {
|
|
61
|
+
traverseDFS(state, `${path}/${childPath}`, visit, level + 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.ydb-tree-view {
|
|
2
|
+
--ydb-tree-view-level: 0;
|
|
2
3
|
font-size: 13px;
|
|
3
4
|
line-height: 18px;
|
|
4
5
|
}
|
|
@@ -9,6 +10,7 @@
|
|
|
9
10
|
display: flex;
|
|
10
11
|
align-items: center;
|
|
11
12
|
height: 24px;
|
|
13
|
+
padding-left: calc(24px * var(--ydb-tree-view-level));
|
|
12
14
|
padding-right: 3px;
|
|
13
15
|
border-bottom: 1px solid var(--yc-color-line-solid);
|
|
14
16
|
cursor: pointer;
|
|
@@ -12,5 +12,6 @@ export interface TreeViewProps {
|
|
|
12
12
|
onArrowClick?: () => void;
|
|
13
13
|
hasArrow?: boolean;
|
|
14
14
|
actions?: DropdownMenuItemMixed<any>[];
|
|
15
|
+
level?: number;
|
|
15
16
|
}
|
|
16
|
-
export declare function TreeView({ children, name, title, icon, collapsed, active, onClick, onArrowClick, hasArrow, actions, }: TreeViewProps): JSX.Element;
|
|
17
|
+
export declare function TreeView({ children, name, title, icon, collapsed, active, onClick, onArrowClick, hasArrow, actions, level, }: TreeViewProps): JSX.Element;
|
|
@@ -17,6 +17,7 @@ require("./TreeView.css");
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
+
const TREE_LEVEL_CSS_VAR = '--ydb-tree-view-level';
|
|
20
21
|
const b = (0, _bemCnLite.default)('ydb-tree-view');
|
|
21
22
|
|
|
22
23
|
function TreeView(_ref) {
|
|
@@ -30,7 +31,8 @@ function TreeView(_ref) {
|
|
|
30
31
|
onClick,
|
|
31
32
|
onArrowClick,
|
|
32
33
|
hasArrow = false,
|
|
33
|
-
actions
|
|
34
|
+
actions,
|
|
35
|
+
level
|
|
34
36
|
} = _ref;
|
|
35
37
|
|
|
36
38
|
const rootRef = _react.default.useRef(null);
|
|
@@ -82,7 +84,10 @@ function TreeView(_ref) {
|
|
|
82
84
|
ref: rootRef,
|
|
83
85
|
className: b({
|
|
84
86
|
'no-arrow': !hasArrow
|
|
85
|
-
})
|
|
87
|
+
}),
|
|
88
|
+
style: {
|
|
89
|
+
[TREE_LEVEL_CSS_VAR]: level
|
|
90
|
+
}
|
|
86
91
|
}, /*#__PURE__*/_react.default.createElement(_reactTreeview.default, {
|
|
87
92
|
collapsed: collapsed,
|
|
88
93
|
itemClassName: b('item', {
|
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
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ColumnTableIcon = ColumnTableIcon;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
|
|
14
|
+
function ColumnTableIcon(props) {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement("svg", _extends({
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
fill: "currentColor"
|
|
19
|
+
}, props), /*#__PURE__*/_react.default.createElement("rect", {
|
|
20
|
+
x: "2",
|
|
21
|
+
y: "3",
|
|
22
|
+
width: "5",
|
|
23
|
+
height: "2.5",
|
|
24
|
+
rx: "0.5"
|
|
25
|
+
}), /*#__PURE__*/_react.default.createElement("rect", {
|
|
26
|
+
x: "2",
|
|
27
|
+
y: "7",
|
|
28
|
+
width: "5",
|
|
29
|
+
height: "2.5",
|
|
30
|
+
rx: "0.5"
|
|
31
|
+
}), /*#__PURE__*/_react.default.createElement("rect", {
|
|
32
|
+
x: "2",
|
|
33
|
+
y: "11",
|
|
34
|
+
width: "5",
|
|
35
|
+
height: "2.5",
|
|
36
|
+
rx: "0.5"
|
|
37
|
+
}), /*#__PURE__*/_react.default.createElement("rect", {
|
|
38
|
+
x: "9",
|
|
39
|
+
y: "3",
|
|
40
|
+
width: "5",
|
|
41
|
+
height: "2.5",
|
|
42
|
+
rx: "0.5"
|
|
43
|
+
}), /*#__PURE__*/_react.default.createElement("rect", {
|
|
44
|
+
x: "9",
|
|
45
|
+
y: "7",
|
|
46
|
+
width: "5",
|
|
47
|
+
height: "2.5",
|
|
48
|
+
rx: "0.5"
|
|
49
|
+
}), /*#__PURE__*/_react.default.createElement("rect", {
|
|
50
|
+
x: "9",
|
|
51
|
+
y: "11",
|
|
52
|
+
width: "5",
|
|
53
|
+
height: "2.5",
|
|
54
|
+
rx: "0.5"
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
@@ -14,9 +14,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
14
14
|
function FolderIcon(props) {
|
|
15
15
|
return /*#__PURE__*/_react.default.createElement("svg", _extends({
|
|
16
16
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
-
viewBox: "0 0
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
18
|
fill: "currentColor"
|
|
19
19
|
}, props), /*#__PURE__*/_react.default.createElement("path", {
|
|
20
|
-
d: "
|
|
20
|
+
d: "M13.2812 4.875H8.40625L6.78125 3.25H2.71875C2.0332 3.25 1.5 3.80859 1.5 4.46875V11.7812C1.5 12.4668 2.0332 13 2.71875 13H13.2812C13.9414 13 14.5 12.4668 14.5 11.7812V6.09375C14.5 5.43359 13.9414 4.875 13.2812 4.875Z"
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
@@ -14,9 +14,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
14
14
|
function FolderOpenIcon(props) {
|
|
15
15
|
return /*#__PURE__*/_react.default.createElement("svg", _extends({
|
|
16
16
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
-
viewBox: "0 0
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
18
|
fill: "currentColor"
|
|
19
19
|
}, props), /*#__PURE__*/_react.default.createElement("path", {
|
|
20
|
-
d: "
|
|
20
|
+
d: "M15.2109 9.06445C15.4648 8.6582 15.1602 8.125 14.6777 8.125H4.54688C4.01367 8.125 3.37891 8.50586 3.125 8.9375L1.29688 12.0859C1.04297 12.4922 1.34766 13 1.83008 13H11.9609C12.4941 13 13.1289 12.6445 13.3828 12.2129L15.2109 9.06445ZM4.54688 7.3125H12.875V6.09375C12.875 5.43359 12.3164 4.875 11.6562 4.875H7.59375L5.96875 3.25H1.90625C1.2207 3.25 0.6875 3.80859 0.6875 4.46875V11.5527L2.43945 8.53125C2.87109 7.79492 3.6582 7.3125 4.54688 7.3125Z"
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IndexIcon = IndexIcon;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
|
|
14
|
+
function IndexIcon(props) {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement("svg", _extends({
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
fill: "currentColor"
|
|
19
|
+
}, props), /*#__PURE__*/_react.default.createElement("path", {
|
|
20
|
+
"fill-rule": "evenodd",
|
|
21
|
+
"clip-rule": "evenodd",
|
|
22
|
+
d: "M2.21875 2H9.97675L6.6875 7.29469V5.25H2.625V7.6875H6.44347L6.10429 8.23348V8.23454C5.9286 8.50001 5.92847 8.93002 5.9286 9.03845C5.9286 9.13568 5.9579 9.2302 6.01212 9.3125H2.625V11.75H6.6875V9.57909L8.3125 9.60141V11.75H8.96364L8.68578 13.375H2.21875C1.5332 13.375 1 12.8418 1 12.1562V3.21875C1 2.55859 1.5332 2 2.21875 2ZM12.7812 13.375H11.5739L14 9.27358V12.1562C14 12.8418 13.4414 13.375 12.7812 13.375ZM14 3.21875V6H12L12.6784 2H12.7812C13.4414 2 14 2.55859 14 3.21875ZM10.962 2.06484C11.034 2.02249 11.1162 2.00009 11.2 2C11.3238 2 11.4425 2.04863 11.53 2.13518C11.6175 2.22174 11.6667 2.33913 11.6667 2.46154C11.6666 2.50769 11.6595 2.55358 11.6457 2.59766L10.9667 7.07692H13.5333C13.7909 7.07692 14 7.28369 14 7.53846C14 7.63899 13.9604 7.72676 13.9052 7.80258L13.9098 7.8107L10.2129 13.7539H10.212C10.1724 13.8281 10.1131 13.8902 10.0405 13.9335C9.96796 13.9769 9.8848 13.9999 9.8 14C9.67623 14 9.55753 13.9514 9.47002 13.8648C9.3825 13.7783 9.33333 13.6609 9.33333 13.5385C9.33325 13.5076 9.33631 13.4768 9.34245 13.4465L10.0333 8.92308H7.46667C7.3429 8.92308 7.2242 8.87445 7.13668 8.7879C7.04917 8.70134 7 8.58395 7 8.46154C6.9999 8.3686 7.02818 8.2778 7.08112 8.20102V8.20012L10.7908 2.24069C10.8308 2.16793 10.89 2.10719 10.962 2.06484Z"
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
@@ -14,9 +14,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
14
14
|
function TableIcon(props) {
|
|
15
15
|
return /*#__PURE__*/_react.default.createElement("svg", _extends({
|
|
16
16
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
-
viewBox: "0 0
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
18
|
fill: "currentColor"
|
|
19
19
|
}, props), /*#__PURE__*/_react.default.createElement("path", {
|
|
20
|
-
d: "
|
|
20
|
+
d: "M12.7812 2.4375H2.21875C1.5332 2.4375 1 2.99609 1 3.65625V12.5938C1 13.2793 1.5332 13.8125 2.21875 13.8125H12.7812C13.4414 13.8125 14 13.2793 14 12.5938V3.65625C14 2.99609 13.4414 2.4375 12.7812 2.4375ZM6.6875 12.1875H2.625V9.75H6.6875V12.1875ZM6.6875 8.125H2.625V5.6875H6.6875V8.125ZM12.375 12.1875H8.3125V9.75H12.375V12.1875ZM12.375 8.125H8.3125V5.6875H12.375V8.125Z"
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TopicIcon = TopicIcon;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
|
|
14
|
+
function TopicIcon(props) {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement("svg", _extends({
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
fill: "currentColor"
|
|
19
|
+
}, props), /*#__PURE__*/_react.default.createElement("path", {
|
|
20
|
+
d: "M1.90625 4.875H12.4688C12.6719 4.875 12.875 4.69727 12.875 4.46875V2.84375C12.875 2.64062 12.6719 2.4375 12.4688 2.4375H1.90625C1.67773 2.4375 1.5 2.64062 1.5 2.84375V4.46875C1.5 4.69727 1.67773 4.875 1.90625 4.875ZM14.0938 6.90625H3.53125C3.30273 6.90625 3.125 7.10938 3.125 7.3125V8.9375C3.125 9.16602 3.30273 9.34375 3.53125 9.34375H14.0938C14.2969 9.34375 14.5 9.16602 14.5 8.9375V7.3125C14.5 7.10938 14.2969 6.90625 14.0938 6.90625ZM12.4688 11.375H1.90625C1.67773 11.375 1.5 11.5781 1.5 11.7812V13.4062C1.5 13.6348 1.67773 13.8125 1.90625 13.8125H12.4688C12.6719 13.8125 12.875 13.6348 12.875 13.4062V11.7812C12.875 11.5781 12.6719 11.375 12.4688 11.375Z"
|
|
21
|
+
}));
|
|
22
|
+
}
|
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");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ydb-ui-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"bem-cn-lite": "^4.1.0",
|
|
27
|
+
"react-list": "^0.8.17",
|
|
27
28
|
"react-treeview": "^0.4.7"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"@storybook/addon-essentials": "^6.4.19",
|
|
37
38
|
"@storybook/preset-scss": "^1.0.3",
|
|
38
39
|
"@storybook/react": "^6.4.19",
|
|
40
|
+
"@types/react-list": "^0.8.7",
|
|
39
41
|
"@types/react-treeview": "^0.4.3",
|
|
40
42
|
"@yandex-cloud/browserslist-config": "^1.0.1",
|
|
41
43
|
"@yandex-cloud/eslint-config": "^1.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavigationTreeState, NavigationTreeProps } from './types';
|
|
3
|
-
import { NavigationTreeAction } from './state';
|
|
4
|
-
export interface NavigationTreeDirectoryProps {
|
|
5
|
-
state: NavigationTreeState;
|
|
6
|
-
dispatch: React.Dispatch<NavigationTreeAction>;
|
|
7
|
-
path: string;
|
|
8
|
-
fetchPath: NavigationTreeProps['fetchPath'];
|
|
9
|
-
activePath?: string;
|
|
10
|
-
onItemActivate?: (itemPath: string) => void;
|
|
11
|
-
getActions?: NavigationTreeProps['getActions'];
|
|
12
|
-
cache?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare function NavigationTreeDirectory({ state, dispatch, path, fetchPath, activePath, onItemActivate, getActions, cache, }: NavigationTreeDirectoryProps): JSX.Element;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NavigationTreeDirectory = NavigationTreeDirectory;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _state = require("./state");
|
|
11
|
-
|
|
12
|
-
var _NavigationTreeNode = require("./NavigationTreeNode");
|
|
13
|
-
|
|
14
|
-
var _LoaderView = require("./LoaderView/LoaderView");
|
|
15
|
-
|
|
16
|
-
var _ErrorView = require("./ErrorView/ErrorView");
|
|
17
|
-
|
|
18
|
-
var _EmptyView = require("./EmptyView/EmptyView");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
function NavigationTreeDirectory(_ref) {
|
|
23
|
-
let {
|
|
24
|
-
state,
|
|
25
|
-
dispatch,
|
|
26
|
-
path,
|
|
27
|
-
fetchPath,
|
|
28
|
-
activePath,
|
|
29
|
-
onItemActivate,
|
|
30
|
-
getActions,
|
|
31
|
-
cache
|
|
32
|
-
} = _ref;
|
|
33
|
-
const nodeState = state[path];
|
|
34
|
-
|
|
35
|
-
_react.default.useEffect(() => {
|
|
36
|
-
if (nodeState.loaded && cache || nodeState.loading) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
dispatch({
|
|
41
|
-
type: _state.NavigationTreeActionType.StartLoading,
|
|
42
|
-
payload: {
|
|
43
|
-
path
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
fetchPath(path).then(data => {
|
|
47
|
-
dispatch({
|
|
48
|
-
type: _state.NavigationTreeActionType.FinishLoading,
|
|
49
|
-
payload: {
|
|
50
|
-
path,
|
|
51
|
-
activePath,
|
|
52
|
-
data
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}).catch(error => {
|
|
56
|
-
dispatch({
|
|
57
|
-
type: _state.NavigationTreeActionType.FinishLoading,
|
|
58
|
-
payload: {
|
|
59
|
-
path,
|
|
60
|
-
error
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
if (nodeState.loading) {
|
|
67
|
-
return /*#__PURE__*/_react.default.createElement(_LoaderView.LoaderView, null);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (nodeState.error) {
|
|
71
|
-
return /*#__PURE__*/_react.default.createElement(_ErrorView.ErrorView, null);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (nodeState.loaded && nodeState.children.length > 0) {
|
|
75
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, nodeState.children.map(childName => {
|
|
76
|
-
const childPath = `${path}/${childName}`;
|
|
77
|
-
let children;
|
|
78
|
-
|
|
79
|
-
if (state[childPath].expandable) {
|
|
80
|
-
children = /*#__PURE__*/_react.default.createElement(NavigationTreeDirectory, {
|
|
81
|
-
state: state,
|
|
82
|
-
dispatch: dispatch,
|
|
83
|
-
path: childPath,
|
|
84
|
-
fetchPath: fetchPath,
|
|
85
|
-
activePath: activePath,
|
|
86
|
-
onItemActivate: onItemActivate,
|
|
87
|
-
getActions: getActions,
|
|
88
|
-
cache: cache
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return /*#__PURE__*/_react.default.createElement(_NavigationTreeNode.NavigationTreeNode, {
|
|
93
|
-
key: childPath,
|
|
94
|
-
path: childPath,
|
|
95
|
-
state: state,
|
|
96
|
-
dispatch: dispatch,
|
|
97
|
-
active: childPath === activePath,
|
|
98
|
-
onActivate: onItemActivate,
|
|
99
|
-
getActions: getActions,
|
|
100
|
-
children: children
|
|
101
|
-
});
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return /*#__PURE__*/_react.default.createElement(_EmptyView.EmptyView, null);
|
|
106
|
-
}
|