ydb-ui-components 3.6.0 → 4.0.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/build/cjs/components/NavigationTree/EmptyView/EmptyView.d.ts +1 -1
- package/build/cjs/components/NavigationTree/EmptyView/EmptyView.js +12 -28
- package/build/cjs/components/NavigationTree/ErrorView/ErrorView.d.ts +1 -1
- package/build/cjs/components/NavigationTree/ErrorView/ErrorView.js +12 -28
- package/build/cjs/components/NavigationTree/LoaderView/LoaderView.d.ts +1 -1
- package/build/cjs/components/NavigationTree/LoaderView/LoaderView.js +11 -30
- package/build/cjs/components/NavigationTree/NavigationTree.js +36 -116
- package/build/cjs/components/NavigationTree/NavigationTreeNode.d.ts +2 -2
- package/build/cjs/components/NavigationTree/NavigationTreeNode.js +86 -173
- package/build/cjs/components/NavigationTree/i18n/index.d.ts +1 -1
- package/build/cjs/components/NavigationTree/i18n/index.js +7 -25
- package/build/cjs/components/NavigationTree/index.d.ts +1 -1
- package/build/cjs/components/NavigationTree/index.js +3 -30
- package/build/cjs/components/NavigationTree/state.d.ts +31 -5
- package/build/cjs/components/NavigationTree/state.js +58 -122
- package/build/cjs/components/NavigationTree/types.d.ts +3 -3
- package/build/cjs/components/NavigationTree/types.js +1 -4
- package/build/cjs/components/NavigationTree/utils.d.ts +1 -1
- package/build/cjs/components/NavigationTree/utils.js +42 -72
- package/build/cjs/components/TreeView/TreeView.d.ts +2 -2
- package/build/cjs/components/TreeView/TreeView.js +43 -104
- package/build/cjs/components/TreeView/index.js +3 -17
- package/build/cjs/components/icons/ColumnTable.js +6 -22
- package/build/cjs/components/icons/Database.js +6 -20
- package/build/cjs/components/icons/ExternalDataSource.js +6 -22
- package/build/cjs/components/icons/ExternalTable.js +6 -22
- package/build/cjs/components/icons/Folder.js +6 -20
- package/build/cjs/components/icons/FolderOpen.js +6 -20
- package/build/cjs/components/icons/Index.js +6 -22
- package/build/cjs/components/icons/Table.js +6 -22
- package/build/cjs/components/icons/Topic.js +6 -36
- package/build/cjs/index.d.ts +0 -1
- package/build/cjs/index.js +4 -43
- package/build/cjs/utils/cn.d.ts +1 -0
- package/build/cjs/utils/cn.js +5 -0
- package/build/esm/components/NavigationTree/EmptyView/EmptyView.d.ts +1 -1
- package/build/esm/components/NavigationTree/EmptyView/EmptyView.js +7 -13
- package/build/esm/components/NavigationTree/ErrorView/ErrorView.d.ts +1 -1
- package/build/esm/components/NavigationTree/ErrorView/ErrorView.js +7 -13
- package/build/esm/components/NavigationTree/LoaderView/LoaderView.d.ts +1 -1
- package/build/esm/components/NavigationTree/LoaderView/LoaderView.js +6 -14
- package/build/esm/components/NavigationTree/NavigationTree.js +29 -98
- package/build/esm/components/NavigationTree/NavigationTreeNode.d.ts +2 -2
- package/build/esm/components/NavigationTree/NavigationTreeNode.js +76 -142
- package/build/esm/components/NavigationTree/i18n/index.d.ts +1 -1
- package/build/esm/components/NavigationTree/i18n/index.js +3 -6
- package/build/esm/components/NavigationTree/index.d.ts +1 -1
- package/build/esm/components/NavigationTree/index.js +0 -1
- package/build/esm/components/NavigationTree/state.d.ts +31 -5
- package/build/esm/components/NavigationTree/state.js +51 -106
- package/build/esm/components/NavigationTree/types.d.ts +3 -3
- package/build/esm/components/NavigationTree/types.js +1 -1
- package/build/esm/components/NavigationTree/utils.d.ts +1 -1
- package/build/esm/components/NavigationTree/utils.js +37 -62
- package/build/esm/components/TreeView/TreeView.d.ts +2 -2
- package/build/esm/components/TreeView/TreeView.js +38 -84
- package/build/esm/components/TreeView/index.js +1 -1
- package/build/esm/components/icons/ColumnTable.js +3 -12
- package/build/esm/components/icons/Database.js +3 -10
- package/build/esm/components/icons/ExternalDataSource.js +3 -12
- package/build/esm/components/icons/ExternalTable.js +3 -12
- package/build/esm/components/icons/Folder.js +3 -10
- package/build/esm/components/icons/FolderOpen.js +3 -10
- package/build/esm/components/icons/Index.js +3 -12
- package/build/esm/components/icons/Table.js +3 -12
- package/build/esm/components/icons/Topic.js +3 -26
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.js +0 -1
- package/build/esm/utils/cn.d.ts +1 -0
- package/build/esm/utils/cn.js +2 -0
- package/package.json +52 -29
- package/CHANGELOG.md +0 -233
- package/build/cjs/components/i18n.d.ts +0 -2
- package/build/cjs/components/i18n.js +0 -19
- package/build/cjs/utils/configure.d.ts +0 -12
- package/build/cjs/utils/configure.js +0 -42
- package/build/cjs/utils/index.d.ts +0 -1
- package/build/cjs/utils/index.js +0 -19
- package/build/esm/components/i18n.d.ts +0 -2
- package/build/esm/components/i18n.js +0 -9
- package/build/esm/utils/configure.d.ts +0 -12
- package/build/esm/utils/configure.js +0 -26
- package/build/esm/utils/index.d.ts +0 -1
- package/build/esm/utils/index.js +0 -1
|
@@ -1,31 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _NavigationTree = require("./NavigationTree");
|
|
8
|
-
|
|
9
|
-
Object.keys(_NavigationTree).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _NavigationTree[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _NavigationTree[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _types = require("./types");
|
|
21
|
-
|
|
22
|
-
Object.keys(_types).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function get() {
|
|
28
|
-
return _types[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./NavigationTree"), exports);
|
|
@@ -1,14 +1,40 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NavigationTreeDataItem, NavigationTreeNodePartialState, NavigationTreeNodeState, NavigationTreeServiceNode, NavigationTreeState } from './types';
|
|
2
2
|
export declare enum NavigationTreeActionType {
|
|
3
3
|
ToggleCollapsed = "toggle-collapsed",
|
|
4
4
|
StartLoading = "start-loading",
|
|
5
5
|
FinishLoading = "finish-loading",
|
|
6
|
+
ErrorLoading = "error-loading",
|
|
6
7
|
ResetNode = "reset-node"
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
-
type: NavigationTreeActionType;
|
|
10
|
-
payload:
|
|
11
|
-
|
|
9
|
+
export type NavigationTreeAction = {
|
|
10
|
+
type: NavigationTreeActionType.ToggleCollapsed;
|
|
11
|
+
payload: {
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
type: NavigationTreeActionType.StartLoading;
|
|
16
|
+
payload: {
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
} | {
|
|
20
|
+
type: NavigationTreeActionType.FinishLoading;
|
|
21
|
+
payload: {
|
|
22
|
+
path: string;
|
|
23
|
+
activePath?: string;
|
|
24
|
+
data: NavigationTreeDataItem[];
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
type: NavigationTreeActionType.ErrorLoading;
|
|
28
|
+
payload: {
|
|
29
|
+
path: string;
|
|
30
|
+
error: unknown;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
type: NavigationTreeActionType.ResetNode;
|
|
34
|
+
payload: {
|
|
35
|
+
path: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
12
38
|
export declare function getDefaultNodeState(): {
|
|
13
39
|
collapsed: boolean;
|
|
14
40
|
loading: boolean;
|
|
@@ -1,134 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.NavigationTreeActionType = void 0;
|
|
7
|
-
exports.getDefaultNodeState = getDefaultNodeState;
|
|
8
|
-
exports.getNodeState = getNodeState;
|
|
9
|
-
exports.reducer = reducer;
|
|
10
|
-
exports.selectTreeAsList = selectTreeAsList;
|
|
11
|
-
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
|
|
14
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
15
|
-
|
|
16
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
|
|
24
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectTreeAsList = exports.reducer = exports.getNodeState = exports.getDefaultNodeState = exports.NavigationTreeActionType = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
26
5
|
var NavigationTreeActionType;
|
|
27
|
-
exports.NavigationTreeActionType = NavigationTreeActionType;
|
|
28
|
-
|
|
29
6
|
(function (NavigationTreeActionType) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
NavigationTreeActionType["ToggleCollapsed"] = "toggle-collapsed";
|
|
8
|
+
NavigationTreeActionType["StartLoading"] = "start-loading";
|
|
9
|
+
NavigationTreeActionType["FinishLoading"] = "finish-loading";
|
|
10
|
+
NavigationTreeActionType["ErrorLoading"] = "error-loading";
|
|
11
|
+
NavigationTreeActionType["ResetNode"] = "reset-node";
|
|
34
12
|
})(NavigationTreeActionType || (exports.NavigationTreeActionType = NavigationTreeActionType = {}));
|
|
35
|
-
|
|
36
13
|
function getDefaultNodeState() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
14
|
+
return {
|
|
15
|
+
collapsed: true,
|
|
16
|
+
loading: false,
|
|
17
|
+
loaded: false,
|
|
18
|
+
error: false,
|
|
19
|
+
children: [],
|
|
20
|
+
};
|
|
44
21
|
}
|
|
45
|
-
|
|
22
|
+
exports.getDefaultNodeState = getDefaultNodeState;
|
|
46
23
|
function getNodeState(partialState) {
|
|
47
|
-
|
|
48
|
-
expandable: partialState.type === 'database' || partialState.type === 'directory'
|
|
49
|
-
}, partialState);
|
|
24
|
+
return Object.assign(Object.assign(Object.assign({}, getDefaultNodeState()), { expandable: partialState.type === 'database' || partialState.type === 'directory' }), partialState);
|
|
50
25
|
}
|
|
51
|
-
|
|
52
|
-
function reducer() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var newState = _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.payload.path, _objectSpread(_objectSpread({}, state[action.payload.path]), {}, {
|
|
73
|
-
loading: false,
|
|
74
|
-
loaded: Boolean(action.payload.data),
|
|
75
|
-
error: Boolean(action.payload.error)
|
|
76
|
-
})));
|
|
77
|
-
|
|
78
|
-
if (action.payload.data) {
|
|
79
|
-
newState[action.payload.path].children = action.payload.data.map(function (_ref) {
|
|
80
|
-
var name = _ref.name;
|
|
81
|
-
return name;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
var _iterator = _createForOfIteratorHelper(action.payload.data),
|
|
85
|
-
_step;
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
89
|
-
var _state$path$collapsed, _state$path;
|
|
90
|
-
|
|
91
|
-
var item = _step.value;
|
|
92
|
-
var path = "".concat(action.payload.path, "/").concat(item.name); // expand the tree according to the active path
|
|
93
|
-
// prioritize the existing state to expand the tree only on first load
|
|
94
|
-
|
|
95
|
-
var _action$payload$activ = action.payload.activePath,
|
|
96
|
-
activePath = _action$payload$activ === void 0 ? '' : _action$payload$activ;
|
|
97
|
-
var collapsed = (_state$path$collapsed = (_state$path = state[path]) === null || _state$path === void 0 ? void 0 : _state$path.collapsed) !== null && _state$path$collapsed !== void 0 ? _state$path$collapsed : !activePath.startsWith("".concat(path, "/"));
|
|
98
|
-
newState[path] = getNodeState(_objectSpread(_objectSpread({}, item), {}, {
|
|
99
|
-
collapsed: collapsed,
|
|
100
|
-
path: path
|
|
101
|
-
}));
|
|
26
|
+
exports.getNodeState = getNodeState;
|
|
27
|
+
function reducer(state = {}, action) {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
switch (action.type) {
|
|
30
|
+
case NavigationTreeActionType.ToggleCollapsed:
|
|
31
|
+
return Object.assign(Object.assign({}, state), { [action.payload.path]: Object.assign(Object.assign({}, state[action.payload.path]), { collapsed: !state[action.payload.path].collapsed }) });
|
|
32
|
+
case NavigationTreeActionType.StartLoading:
|
|
33
|
+
return Object.assign(Object.assign({}, state), { [action.payload.path]: Object.assign(Object.assign({}, state[action.payload.path]), { loading: true, loaded: false, error: false, children: [] }) });
|
|
34
|
+
case NavigationTreeActionType.FinishLoading: {
|
|
35
|
+
const newState = Object.assign(Object.assign({}, state), { [action.payload.path]: Object.assign(Object.assign({}, state[action.payload.path]), { loading: false, loaded: Boolean(action.payload.data), error: false }) });
|
|
36
|
+
if (action.payload.data) {
|
|
37
|
+
newState[action.payload.path].children = action.payload.data.map(({ name }) => name);
|
|
38
|
+
for (const item of action.payload.data) {
|
|
39
|
+
const path = `${action.payload.path}/${item.name}`;
|
|
40
|
+
// expand the tree according to the active path
|
|
41
|
+
// prioritize the existing state to expand the tree only on first load
|
|
42
|
+
const { activePath = '' } = action.payload;
|
|
43
|
+
const collapsed = (_b = (_a = state[path]) === null || _a === void 0 ? void 0 : _a.collapsed) !== null && _b !== void 0 ? _b : !activePath.startsWith(`${path}/`);
|
|
44
|
+
newState[path] = getNodeState(Object.assign(Object.assign({}, item), { collapsed,
|
|
45
|
+
path }));
|
|
46
|
+
}
|
|
102
47
|
}
|
|
103
|
-
|
|
104
|
-
_iterator.e(err);
|
|
105
|
-
} finally {
|
|
106
|
-
_iterator.f();
|
|
107
|
-
}
|
|
48
|
+
return newState;
|
|
108
49
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
default:
|
|
117
|
-
return state;
|
|
118
|
-
}
|
|
50
|
+
case NavigationTreeActionType.ErrorLoading:
|
|
51
|
+
return Object.assign(Object.assign({}, state), { [action.payload.path]: Object.assign(Object.assign({}, state[action.payload.path]), { loading: false, loaded: false, error: true }) });
|
|
52
|
+
case NavigationTreeActionType.ResetNode:
|
|
53
|
+
return Object.assign(Object.assign({}, state), { [action.payload.path]: Object.assign(Object.assign({}, state[action.payload.path]), getDefaultNodeState()) });
|
|
54
|
+
default:
|
|
55
|
+
return state;
|
|
56
|
+
}
|
|
119
57
|
}
|
|
120
|
-
|
|
58
|
+
exports.reducer = reducer;
|
|
121
59
|
function selectTreeAsList(state, rootPath) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return list;
|
|
134
|
-
}
|
|
60
|
+
const list = [];
|
|
61
|
+
(0, utils_1.traverseDFS)(state, rootPath, (node, level) => {
|
|
62
|
+
list.push(Object.assign(Object.assign({}, node), { level }));
|
|
63
|
+
const serviceNode = (0, utils_1.getServiceNode)(node, level);
|
|
64
|
+
if (serviceNode) {
|
|
65
|
+
list.push(serviceNode);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return list;
|
|
69
|
+
}
|
|
70
|
+
exports.selectTreeAsList = selectTreeAsList;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DropdownMenuItemMixed } from '@gravity-ui/uikit';
|
|
3
|
-
export
|
|
2
|
+
import type { DropdownMenuItemMixed } from '@gravity-ui/uikit';
|
|
3
|
+
export type NavigationTreeNodeType = 'database' | 'directory' | 'table' | 'column_table' | 'index_table' | 'index' | 'topic' | 'stream' | 'external_table' | 'external_data_source';
|
|
4
4
|
export interface NavigationTreeDataItem {
|
|
5
5
|
name: string;
|
|
6
6
|
type: NavigationTreeNodeType;
|
|
@@ -28,7 +28,7 @@ export interface NavigationTreeServiceNode {
|
|
|
28
28
|
status: 'loading' | 'error' | 'empty';
|
|
29
29
|
level?: number;
|
|
30
30
|
}
|
|
31
|
-
export
|
|
31
|
+
export type NavigationTreeNodePartialState = Omit<NavigationTreeNodeState, 'loading' | 'loaded' | 'error' | 'children'>;
|
|
32
32
|
export interface NavigationTreeProps<D = any> {
|
|
33
33
|
rootState: NavigationTreeNodePartialState;
|
|
34
34
|
fetchPath: (path: string) => Promise<NavigationTreeDataItem[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NavigationTreeNodeState, NavigationTreeServiceNode, NavigationTreeState } from './types';
|
|
2
2
|
export declare function isServiceNode(node: NavigationTreeNodeState | NavigationTreeServiceNode): node is NavigationTreeServiceNode;
|
|
3
3
|
export declare function getServiceNode(node: NavigationTreeNodeState, level: number): NavigationTreeServiceNode | void;
|
|
4
|
-
|
|
4
|
+
type TraverseDFSVisit = (node: NavigationTreeNodeState, level: number, path: string, state: NavigationTreeState) => void;
|
|
5
5
|
export declare function traverseDFS(state: NavigationTreeState, path: string, visit: TraverseDFSVisit, level?: number): void;
|
|
6
6
|
export {};
|
|
@@ -1,79 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getServiceNode = getServiceNode;
|
|
7
|
-
exports.isServiceNode = isServiceNode;
|
|
8
|
-
exports.traverseDFS = traverseDFS;
|
|
9
|
-
|
|
10
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
11
|
-
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traverseDFS = exports.getServiceNode = exports.isServiceNode = void 0;
|
|
16
4
|
function isServiceNode(node) {
|
|
17
|
-
|
|
5
|
+
return 'status' in node;
|
|
18
6
|
}
|
|
19
|
-
|
|
7
|
+
exports.isServiceNode = isServiceNode;
|
|
20
8
|
function getServiceNode(node, level) {
|
|
21
|
-
|
|
9
|
+
if (node.collapsed) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (node.loading) {
|
|
13
|
+
return {
|
|
14
|
+
path: node.path,
|
|
15
|
+
status: 'loading',
|
|
16
|
+
level: level + 1,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (node.error) {
|
|
20
|
+
return {
|
|
21
|
+
path: node.path,
|
|
22
|
+
status: 'error',
|
|
23
|
+
level: level + 1,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (node.loaded && node.children.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
path: node.path,
|
|
29
|
+
status: 'empty',
|
|
30
|
+
level: level + 1,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
22
33
|
return undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (node.loading) {
|
|
26
|
-
return {
|
|
27
|
-
path: node.path,
|
|
28
|
-
status: 'loading',
|
|
29
|
-
level: level + 1
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (node.error) {
|
|
34
|
-
return {
|
|
35
|
-
path: node.path,
|
|
36
|
-
status: 'error',
|
|
37
|
-
level: level + 1
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (node.loaded && node.children.length === 0) {
|
|
42
|
-
return {
|
|
43
|
-
path: node.path,
|
|
44
|
-
status: 'empty',
|
|
45
|
-
level: level + 1
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return undefined;
|
|
50
34
|
}
|
|
51
|
-
|
|
52
|
-
function traverseDFS(state, path, visit) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
visit(currentNode, level, path, state);
|
|
61
|
-
|
|
62
|
-
if (currentNode.collapsed) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var _iterator = _createForOfIteratorHelper(currentNode.children),
|
|
67
|
-
_step;
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
71
|
-
var childPath = _step.value;
|
|
72
|
-
traverseDFS(state, "".concat(path, "/").concat(childPath), visit, level + 1);
|
|
35
|
+
exports.getServiceNode = getServiceNode;
|
|
36
|
+
function traverseDFS(state, path, visit, level = 0) {
|
|
37
|
+
const currentNode = state[path];
|
|
38
|
+
if (!currentNode) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
visit(currentNode, level, path, state);
|
|
42
|
+
if (currentNode.collapsed) {
|
|
43
|
+
return;
|
|
73
44
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
45
|
+
for (const childPath of currentNode.children) {
|
|
46
|
+
traverseDFS(state, `${path}/${childPath}`, visit, level + 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.traverseDFS = traverseDFS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DropdownMenuItemMixed } from '@gravity-ui/uikit';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import '
|
|
2
|
+
import type { DropdownMenuItemMixed } from '@gravity-ui/uikit';
|
|
3
|
+
import './TreeView.css';
|
|
4
4
|
export interface TreeViewProps {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
name: React.ReactNode;
|
|
@@ -1,106 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _uikit = require("@gravity-ui/uikit");
|
|
11
|
-
|
|
12
|
-
var _bemCnLite = _interopRequireDefault(require("bem-cn-lite"));
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TreeView = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const cn_1 = require("../../utils/cn");
|
|
16
9
|
require("./TreeView.css");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* These `className`s are left here for backward compatibility of CSS selectors.
|
|
55
|
-
* @link https://github.com/ydb-platform/ydb-ui-components/pull/64
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
var itemClassName = 'tree-view_item';
|
|
59
|
-
var arrowClassName = 'tree-view_arrow';
|
|
60
|
-
var containerClassName = 'tree-view_children';
|
|
61
|
-
|
|
62
|
-
if (collapsed) {
|
|
63
|
-
arrowClassName += ' tree-view_arrow-collapsed';
|
|
64
|
-
containerClassName += ' tree-view_children-collapsed';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
68
|
-
className: b(),
|
|
69
|
-
style: _defineProperty({}, TREE_LEVEL_CSS_VAR, level)
|
|
70
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
71
|
-
className: "tree-view"
|
|
72
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
73
|
-
className: "".concat(itemClassName, " ").concat(b('item', {
|
|
74
|
-
active: active
|
|
75
|
-
})),
|
|
76
|
-
onClick: handleClick
|
|
77
|
-
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
78
|
-
type: "button",
|
|
79
|
-
className: "".concat(arrowClassName, " ").concat(b('arrow', {
|
|
80
|
-
collapsed: collapsed,
|
|
81
|
-
hidden: !hasArrow
|
|
82
|
-
})),
|
|
83
|
-
disabled: !handleArrowClick,
|
|
84
|
-
onClick: handleArrowClick
|
|
85
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
86
|
-
className: b('content')
|
|
87
|
-
}, icon && /*#__PURE__*/_react["default"].createElement("div", {
|
|
88
|
-
className: b('icon')
|
|
89
|
-
}, icon), /*#__PURE__*/_react["default"].createElement("div", {
|
|
90
|
-
className: b('text'),
|
|
91
|
-
title: title
|
|
92
|
-
}, name), actions && actions.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
|
|
93
|
-
className: b('actions')
|
|
94
|
-
}, additionalNodeElements, /*#__PURE__*/_react["default"].createElement(_uikit.DropdownMenu, {
|
|
95
|
-
defaultSwitcherProps: {
|
|
96
|
-
view: 'flat-secondary',
|
|
97
|
-
size: 's',
|
|
98
|
-
pin: 'brick-brick'
|
|
99
|
-
},
|
|
100
|
-
items: actions
|
|
101
|
-
})))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
102
|
-
className: "".concat(containerClassName, " ").concat(b('container', {
|
|
103
|
-
collapsed: collapsed
|
|
104
|
-
}))
|
|
105
|
-
}, collapsed ? null : children)));
|
|
106
|
-
}
|
|
10
|
+
const TREE_LEVEL_CSS_VAR = '--ydb-tree-view-level';
|
|
11
|
+
const b = (0, cn_1.block)('ydb-tree-view');
|
|
12
|
+
function TreeView({ children, name, title, icon, collapsed = true, active = false, onClick, onArrowClick, hasArrow = false, actions, additionalNodeElements, level, }) {
|
|
13
|
+
const handleClick = react_1.default.useCallback((event) => {
|
|
14
|
+
if (!onClick)
|
|
15
|
+
return;
|
|
16
|
+
const shouldSkip = event.nativeEvent
|
|
17
|
+
.composedPath()
|
|
18
|
+
.some((target) => target instanceof HTMLElement &&
|
|
19
|
+
((target.nodeName === 'BUTTON' && !target.hasAttribute('disabled')) ||
|
|
20
|
+
(target.hasAttribute('tabindex') && target.tabIndex > -1)));
|
|
21
|
+
if (!shouldSkip)
|
|
22
|
+
onClick();
|
|
23
|
+
}, [onClick]);
|
|
24
|
+
const handleArrowClick = onArrowClick || onClick;
|
|
25
|
+
/**
|
|
26
|
+
* These `className`s are left here for backward compatibility of CSS selectors.
|
|
27
|
+
* @link https://github.com/ydb-platform/ydb-ui-components/pull/64
|
|
28
|
+
*/
|
|
29
|
+
const itemClassName = 'tree-view_item';
|
|
30
|
+
let arrowClassName = 'tree-view_arrow';
|
|
31
|
+
let containerClassName = 'tree-view_children';
|
|
32
|
+
if (collapsed) {
|
|
33
|
+
arrowClassName += ' tree-view_arrow-collapsed';
|
|
34
|
+
containerClassName += ' tree-view_children-collapsed';
|
|
35
|
+
}
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: b(), style: { [TREE_LEVEL_CSS_VAR]: level }, children: (0, jsx_runtime_1.jsxs)("div", { className: "tree-view", children: [(0, jsx_runtime_1.jsxs)("div", { className: `${itemClassName} ${b('item', { active })}`, onClick: handleClick, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: `${arrowClassName} ${b('arrow', {
|
|
37
|
+
collapsed,
|
|
38
|
+
hidden: !hasArrow,
|
|
39
|
+
})}`, disabled: !handleArrowClick, onClick: handleArrowClick }), (0, jsx_runtime_1.jsxs)("div", { className: b('content'), children: [icon && (0, jsx_runtime_1.jsx)("div", { className: b('icon'), children: icon }), (0, jsx_runtime_1.jsx)("div", { className: b('text'), title: title, children: name }), actions && actions.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: b('actions'), children: [additionalNodeElements, (0, jsx_runtime_1.jsx)(uikit_1.DropdownMenu, { defaultSwitcherProps: {
|
|
40
|
+
view: 'flat-secondary',
|
|
41
|
+
size: 's',
|
|
42
|
+
pin: 'brick-brick',
|
|
43
|
+
}, items: actions })] }))] })] }), (0, jsx_runtime_1.jsx)("div", { className: `${containerClassName} ${b('container', { collapsed })}`, children: collapsed ? null : children })] }) }));
|
|
44
|
+
}
|
|
45
|
+
exports.TreeView = TreeView;
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _TreeView = require("./TreeView");
|
|
8
|
-
|
|
9
|
-
Object.keys(_TreeView).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _TreeView[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _TreeView[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./TreeView"), exports);
|