ydb-ui-components 2.0.0 → 2.1.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 +21 -0
- package/build/components/NavigationTree/NavigationTree.js +1 -7
- package/build/components/NavigationTree/NavigationTreeDirectory.js +1 -1
- package/build/components/NavigationTree/NavigationTreeNode.js +1 -5
- package/build/components/NavigationTree/state.d.ts +2 -1
- package/build/components/NavigationTree/state.js +11 -8
- package/build/components/NavigationTree/types.d.ts +6 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +14 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.0](https://github.com/ydb-platform/ydb-ui-components/compare/v2.0.2...v2.1.0) (2022-06-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **NavigationTree:** explicitly specify expandable nodes ([1791d59](https://github.com/ydb-platform/ydb-ui-components/commit/1791d59d4ed5b27050fdbd9c29500c4fe916f631))
|
|
9
|
+
|
|
10
|
+
### [2.0.2](https://github.com/ydb-platform/ydb-ui-components/compare/v2.0.1...v2.0.2) (2022-05-30)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* add i18n export ([13a34e0](https://github.com/ydb-platform/ydb-ui-components/commit/13a34e0056a9fa42b5ad02fc41e5323af0ac98e9))
|
|
16
|
+
|
|
17
|
+
### [2.0.1](https://github.com/ydb-platform/ydb-ui-components/compare/v2.0.0...v2.0.1) (2022-05-26)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### chore
|
|
21
|
+
|
|
22
|
+
* update @yandex-cloud/uikit to 2.4.0 ([663c8d2](https://github.com/ydb-platform/ydb-ui-components/commit/663c8d26c704bd83be97c81f4fd4080a7cfbb3d0))
|
|
23
|
+
|
|
3
24
|
## [2.0.0](https://github.com/ydb-platform/ydb-ui-components/compare/v1.2.3...v2.0.0) (2022-05-25)
|
|
4
25
|
|
|
5
26
|
|
|
@@ -15,12 +15,6 @@ var _NavigationTreeDirectory = require("./NavigationTreeDirectory");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
18
|
function NavigationTree(_ref) {
|
|
25
19
|
let {
|
|
26
20
|
rootState: partialRootState,
|
|
@@ -32,7 +26,7 @@ function NavigationTree(_ref) {
|
|
|
32
26
|
} = _ref;
|
|
33
27
|
|
|
34
28
|
const [state, dispatch] = _react.default.useReducer(_state.reducer, {
|
|
35
|
-
[partialRootState.path]:
|
|
29
|
+
[partialRootState.path]: (0, _state.getNodeState)(partialRootState)
|
|
36
30
|
});
|
|
37
31
|
|
|
38
32
|
const rootState = state[partialRootState.path];
|
|
@@ -76,7 +76,7 @@ function NavigationTreeDirectory(_ref) {
|
|
|
76
76
|
const childPath = `${path}/${childName}`;
|
|
77
77
|
let children;
|
|
78
78
|
|
|
79
|
-
if (state[childPath].
|
|
79
|
+
if (state[childPath].expandable) {
|
|
80
80
|
children = /*#__PURE__*/_react.default.createElement(NavigationTreeDirectory, {
|
|
81
81
|
state: state,
|
|
82
82
|
dispatch: dispatch,
|
|
@@ -45,10 +45,6 @@ function renderIcon(type, collapsed) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function isArrowVisible(type) {
|
|
49
|
-
return type === 'database' || type === 'directory';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
48
|
function NavigationTreeNode(_ref) {
|
|
53
49
|
let {
|
|
54
50
|
path,
|
|
@@ -86,7 +82,7 @@ function NavigationTreeNode(_ref) {
|
|
|
86
82
|
collapsed: nodeState.collapsed,
|
|
87
83
|
active: active,
|
|
88
84
|
actions: actions,
|
|
89
|
-
hasArrow:
|
|
85
|
+
hasArrow: nodeState.expandable,
|
|
90
86
|
onClick: handleClick,
|
|
91
87
|
onArrowClick: handleArrowClick
|
|
92
88
|
}, children);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NavigationTreeState } from './types';
|
|
1
|
+
import { NavigationTreeNodeState, NavigationTreeNodePartialState, NavigationTreeState } from './types';
|
|
2
2
|
export declare enum NavigationTreeActionType {
|
|
3
3
|
ToggleCollapsed = "toggle-collapsed",
|
|
4
4
|
StartLoading = "start-loading",
|
|
@@ -15,4 +15,5 @@ export declare function getDefaultNodeState(): {
|
|
|
15
15
|
error: boolean;
|
|
16
16
|
children: never[];
|
|
17
17
|
};
|
|
18
|
+
export declare function getNodeState(partialState: NavigationTreeNodePartialState): NavigationTreeNodeState;
|
|
18
19
|
export declare function reducer(state: NavigationTreeState | undefined, action: NavigationTreeAction): NavigationTreeState;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.NavigationTreeActionType = void 0;
|
|
7
7
|
exports.getDefaultNodeState = getDefaultNodeState;
|
|
8
|
+
exports.getNodeState = getNodeState;
|
|
8
9
|
exports.reducer = reducer;
|
|
9
10
|
|
|
10
11
|
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; }
|
|
@@ -32,6 +33,12 @@ function getDefaultNodeState() {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
function getNodeState(partialState) {
|
|
37
|
+
return _objectSpread(_objectSpread({}, getDefaultNodeState()), {}, {
|
|
38
|
+
expandable: partialState.type === 'database' || partialState.type === 'directory'
|
|
39
|
+
}, partialState);
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
function reducer() {
|
|
36
43
|
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
37
44
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -75,21 +82,17 @@ function reducer() {
|
|
|
75
82
|
for (const item of action.payload.data) {
|
|
76
83
|
var _state$path$collapsed, _state$path;
|
|
77
84
|
|
|
78
|
-
const path = `${action.payload.path}/${item.name}`;
|
|
79
|
-
const name = item.name;
|
|
80
|
-
const type = item.type; // expand the tree according to the active path
|
|
85
|
+
const path = `${action.payload.path}/${item.name}`; // expand the tree according to the active path
|
|
81
86
|
// prioritize the existing state to expand the tree only on first load
|
|
82
87
|
|
|
83
88
|
const {
|
|
84
89
|
activePath = ''
|
|
85
90
|
} = action.payload;
|
|
86
91
|
const 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(`${path}/`);
|
|
87
|
-
newState[path] = _objectSpread(_objectSpread({},
|
|
92
|
+
newState[path] = getNodeState(_objectSpread(_objectSpread({}, item), {}, {
|
|
88
93
|
collapsed,
|
|
89
|
-
path
|
|
90
|
-
|
|
91
|
-
type
|
|
92
|
-
});
|
|
94
|
+
path
|
|
95
|
+
}));
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
|
|
@@ -3,6 +3,8 @@ export declare type NavigationTreeNodeType = 'database' | 'directory' | 'table';
|
|
|
3
3
|
export interface NavigationTreeDataItem {
|
|
4
4
|
name: string;
|
|
5
5
|
type: NavigationTreeNodeType;
|
|
6
|
+
/** determined by type by default */
|
|
7
|
+
expandable?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export interface NavigationTreeState {
|
|
8
10
|
[path: string]: NavigationTreeNodeState;
|
|
@@ -11,14 +13,17 @@ export interface NavigationTreeNodeState {
|
|
|
11
13
|
path: string;
|
|
12
14
|
name: string;
|
|
13
15
|
type: NavigationTreeNodeType;
|
|
16
|
+
/** determined by type by default */
|
|
17
|
+
expandable?: boolean;
|
|
14
18
|
collapsed: boolean;
|
|
15
19
|
loading: boolean;
|
|
16
20
|
loaded: boolean;
|
|
17
21
|
error: boolean;
|
|
18
22
|
children: string[];
|
|
19
23
|
}
|
|
24
|
+
export declare type NavigationTreeNodePartialState = Omit<NavigationTreeNodeState, 'loading' | 'loaded' | 'error' | 'children'>;
|
|
20
25
|
export interface NavigationTreeProps<D = any> {
|
|
21
|
-
rootState:
|
|
26
|
+
rootState: NavigationTreeNodePartialState;
|
|
22
27
|
fetchPath: (path: string) => Promise<NavigationTreeDataItem[]>;
|
|
23
28
|
getActions?: (path: string, type: NavigationTreeNodeType) => DropdownMenuItemMixed<D>[];
|
|
24
29
|
activePath?: string;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
i18n: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "i18n", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _i18n.i18n;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
6
15
|
|
|
7
16
|
var _NavigationTree = require("./components/NavigationTree");
|
|
8
17
|
|
|
9
18
|
Object.keys(_NavigationTree).forEach(function (key) {
|
|
10
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
11
21
|
if (key in exports && exports[key] === _NavigationTree[key]) return;
|
|
12
22
|
Object.defineProperty(exports, key, {
|
|
13
23
|
enumerable: true,
|
|
@@ -21,6 +31,7 @@ var _TreeView = require("./components/TreeView");
|
|
|
21
31
|
|
|
22
32
|
Object.keys(_TreeView).forEach(function (key) {
|
|
23
33
|
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
24
35
|
if (key in exports && exports[key] === _TreeView[key]) return;
|
|
25
36
|
Object.defineProperty(exports, key, {
|
|
26
37
|
enumerable: true,
|
|
@@ -28,4 +39,6 @@ Object.keys(_TreeView).forEach(function (key) {
|
|
|
28
39
|
return _TreeView[key];
|
|
29
40
|
}
|
|
30
41
|
});
|
|
31
|
-
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var _i18n = require("./components/i18n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ydb-ui-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@yandex-cloud/prettier-config": "^1.0.0",
|
|
44
44
|
"@yandex-cloud/stylelint-config": "^1.1.0",
|
|
45
45
|
"@yandex-cloud/tsconfig": "^1.0.0",
|
|
46
|
-
"@yandex-cloud/uikit": "^2.
|
|
46
|
+
"@yandex-cloud/uikit": "^2.4.0",
|
|
47
47
|
"css-loader": "^5.2.7",
|
|
48
48
|
"eslint": "^8.11.0",
|
|
49
49
|
"gulp": "^4.0.2",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@yandex-cloud/browserslist-config": "^1.0.1",
|
|
69
69
|
"@yandex-cloud/i18n": "^0.6.0",
|
|
70
|
-
"@yandex-cloud/uikit": "^2.
|
|
70
|
+
"@yandex-cloud/uikit": "^2.4.0",
|
|
71
71
|
"react": "^16.0.0",
|
|
72
72
|
"react-dom": "^16.0.0"
|
|
73
73
|
},
|