ydb-ui-components 4.6.0 → 4.7.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/NavigationTree.d.ts +1 -1
- package/build/cjs/components/NavigationTree/NavigationTreeNode.js +12 -3
- package/build/cjs/components/NavigationTree/types.d.ts +7 -5
- package/build/esm/components/NavigationTree/NavigationTree.d.ts +1 -1
- package/build/esm/components/NavigationTree/NavigationTreeNode.js +12 -3
- package/build/esm/components/NavigationTree/types.d.ts +7 -5
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { NavigationTreeProps } from './types';
|
|
3
3
|
export type { NavigationTreeProps };
|
|
4
|
-
export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, renderAdditionalNodeElements, activePath, onActionsOpenToggle, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps): JSX.Element;
|
|
4
|
+
export declare function NavigationTree<D = any, M = any>({ rootState: partialRootState, fetchPath, getActions, renderAdditionalNodeElements, activePath, onActionsOpenToggle, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps<D, M>): JSX.Element;
|
|
@@ -84,7 +84,16 @@ function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatc
|
|
|
84
84
|
payload: { path, error },
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
activePath,
|
|
89
|
+
cache,
|
|
90
|
+
dispatch,
|
|
91
|
+
fetchPath,
|
|
92
|
+
nodeState.collapsed,
|
|
93
|
+
nodeState.loaded,
|
|
94
|
+
nodeState.loading,
|
|
95
|
+
path,
|
|
96
|
+
]);
|
|
88
97
|
const handleClick = react_1.default.useCallback(() => {
|
|
89
98
|
if (onActivate) {
|
|
90
99
|
onActivate(path);
|
|
@@ -94,10 +103,10 @@ function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatc
|
|
|
94
103
|
dispatch({ type: state_1.NavigationTreeActionType.ToggleCollapsed, payload: { path } });
|
|
95
104
|
}, [dispatch, path]);
|
|
96
105
|
const additionalNodeElements = react_1.default.useMemo(() => {
|
|
97
|
-
return renderAdditionalNodeElements === null || renderAdditionalNodeElements === void 0 ? void 0 : renderAdditionalNodeElements(nodeState.path, nodeState.type);
|
|
106
|
+
return renderAdditionalNodeElements === null || renderAdditionalNodeElements === void 0 ? void 0 : renderAdditionalNodeElements(nodeState.path, nodeState.type, nodeState.meta);
|
|
98
107
|
}, [renderAdditionalNodeElements, nodeState]);
|
|
99
108
|
const actions = react_1.default.useMemo(() => {
|
|
100
|
-
return getActions === null || getActions === void 0 ? void 0 : getActions(nodeState.path, nodeState.type);
|
|
109
|
+
return getActions === null || getActions === void 0 ? void 0 : getActions(nodeState.path, nodeState.type, nodeState.meta);
|
|
101
110
|
}, [getActions, nodeState]);
|
|
102
111
|
const handleActionsOpenToggle = react_1.default.useCallback((isOpen) => {
|
|
103
112
|
onActionsOpenToggle === null || onActionsOpenToggle === void 0 ? void 0 : onActionsOpenToggle({
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DropdownMenuItemMixed } from '@gravity-ui/uikit';
|
|
3
3
|
export type NavigationTreeNodeType = 'async_replication' | 'column_table' | 'resource_pool' | 'database' | 'directory' | 'external_data_source' | 'external_table' | 'index_table' | 'index' | 'stream' | 'table' | 'topic' | 'transfer' | 'view';
|
|
4
|
-
export interface NavigationTreeDataItem {
|
|
4
|
+
export interface NavigationTreeDataItem<M = unknown> {
|
|
5
5
|
name: string;
|
|
6
6
|
type: NavigationTreeNodeType;
|
|
7
7
|
/** determined by type by default */
|
|
8
8
|
expandable?: boolean;
|
|
9
|
+
meta?: M;
|
|
9
10
|
}
|
|
10
11
|
export interface NavigationTreeState {
|
|
11
12
|
[path: string]: NavigationTreeNodeState;
|
|
@@ -22,6 +23,7 @@ export interface NavigationTreeNodeState {
|
|
|
22
23
|
error: boolean;
|
|
23
24
|
children: string[];
|
|
24
25
|
level?: number;
|
|
26
|
+
meta?: unknown;
|
|
25
27
|
}
|
|
26
28
|
export interface NavigationTreeServiceNode {
|
|
27
29
|
path: string;
|
|
@@ -29,16 +31,16 @@ export interface NavigationTreeServiceNode {
|
|
|
29
31
|
level?: number;
|
|
30
32
|
}
|
|
31
33
|
export type NavigationTreeNodePartialState = Omit<NavigationTreeNodeState, 'loading' | 'loaded' | 'error' | 'children'>;
|
|
32
|
-
export interface NavigationTreeProps<D = any> {
|
|
34
|
+
export interface NavigationTreeProps<D = any, M = any> {
|
|
33
35
|
rootState: NavigationTreeNodePartialState;
|
|
34
|
-
fetchPath: (path: string) => Promise<NavigationTreeDataItem[]>;
|
|
36
|
+
fetchPath: (path: string) => Promise<NavigationTreeDataItem<M>[]>;
|
|
35
37
|
onActionsOpenToggle?: (args: {
|
|
36
38
|
path: string;
|
|
37
39
|
type: NavigationTreeNodeType;
|
|
38
40
|
isOpen: boolean;
|
|
39
41
|
}) => void;
|
|
40
|
-
getActions?: (path: string, type: NavigationTreeNodeType) => DropdownMenuItemMixed<D>[];
|
|
41
|
-
renderAdditionalNodeElements?: (path: string, type: NavigationTreeNodeType) => JSX.Element | undefined;
|
|
42
|
+
getActions?: (path: string, type: NavigationTreeNodeType, meta: M) => DropdownMenuItemMixed<D>[];
|
|
43
|
+
renderAdditionalNodeElements?: (path: string, type: NavigationTreeNodeType, meta: M) => JSX.Element | undefined;
|
|
42
44
|
activePath?: string;
|
|
43
45
|
onActivePathUpdate?: (activePath: string) => void;
|
|
44
46
|
cache?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { NavigationTreeProps } from './types';
|
|
3
3
|
export type { NavigationTreeProps };
|
|
4
|
-
export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, renderAdditionalNodeElements, activePath, onActionsOpenToggle, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps): JSX.Element;
|
|
4
|
+
export declare function NavigationTree<D = any, M = any>({ rootState: partialRootState, fetchPath, getActions, renderAdditionalNodeElements, activePath, onActionsOpenToggle, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps<D, M>): JSX.Element;
|
|
@@ -80,7 +80,16 @@ export function NavigationTreeNode({ path, fetchPath, activePath, state, level,
|
|
|
80
80
|
payload: { path, error },
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
-
}, [
|
|
83
|
+
}, [
|
|
84
|
+
activePath,
|
|
85
|
+
cache,
|
|
86
|
+
dispatch,
|
|
87
|
+
fetchPath,
|
|
88
|
+
nodeState.collapsed,
|
|
89
|
+
nodeState.loaded,
|
|
90
|
+
nodeState.loading,
|
|
91
|
+
path,
|
|
92
|
+
]);
|
|
84
93
|
const handleClick = React.useCallback(() => {
|
|
85
94
|
if (onActivate) {
|
|
86
95
|
onActivate(path);
|
|
@@ -90,10 +99,10 @@ export function NavigationTreeNode({ path, fetchPath, activePath, state, level,
|
|
|
90
99
|
dispatch({ type: NavigationTreeActionType.ToggleCollapsed, payload: { path } });
|
|
91
100
|
}, [dispatch, path]);
|
|
92
101
|
const additionalNodeElements = React.useMemo(() => {
|
|
93
|
-
return renderAdditionalNodeElements === null || renderAdditionalNodeElements === void 0 ? void 0 : renderAdditionalNodeElements(nodeState.path, nodeState.type);
|
|
102
|
+
return renderAdditionalNodeElements === null || renderAdditionalNodeElements === void 0 ? void 0 : renderAdditionalNodeElements(nodeState.path, nodeState.type, nodeState.meta);
|
|
94
103
|
}, [renderAdditionalNodeElements, nodeState]);
|
|
95
104
|
const actions = React.useMemo(() => {
|
|
96
|
-
return getActions === null || getActions === void 0 ? void 0 : getActions(nodeState.path, nodeState.type);
|
|
105
|
+
return getActions === null || getActions === void 0 ? void 0 : getActions(nodeState.path, nodeState.type, nodeState.meta);
|
|
97
106
|
}, [getActions, nodeState]);
|
|
98
107
|
const handleActionsOpenToggle = React.useCallback((isOpen) => {
|
|
99
108
|
onActionsOpenToggle === null || onActionsOpenToggle === void 0 ? void 0 : onActionsOpenToggle({
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DropdownMenuItemMixed } from '@gravity-ui/uikit';
|
|
3
3
|
export type NavigationTreeNodeType = 'async_replication' | 'column_table' | 'resource_pool' | 'database' | 'directory' | 'external_data_source' | 'external_table' | 'index_table' | 'index' | 'stream' | 'table' | 'topic' | 'transfer' | 'view';
|
|
4
|
-
export interface NavigationTreeDataItem {
|
|
4
|
+
export interface NavigationTreeDataItem<M = unknown> {
|
|
5
5
|
name: string;
|
|
6
6
|
type: NavigationTreeNodeType;
|
|
7
7
|
/** determined by type by default */
|
|
8
8
|
expandable?: boolean;
|
|
9
|
+
meta?: M;
|
|
9
10
|
}
|
|
10
11
|
export interface NavigationTreeState {
|
|
11
12
|
[path: string]: NavigationTreeNodeState;
|
|
@@ -22,6 +23,7 @@ export interface NavigationTreeNodeState {
|
|
|
22
23
|
error: boolean;
|
|
23
24
|
children: string[];
|
|
24
25
|
level?: number;
|
|
26
|
+
meta?: unknown;
|
|
25
27
|
}
|
|
26
28
|
export interface NavigationTreeServiceNode {
|
|
27
29
|
path: string;
|
|
@@ -29,16 +31,16 @@ export interface NavigationTreeServiceNode {
|
|
|
29
31
|
level?: number;
|
|
30
32
|
}
|
|
31
33
|
export type NavigationTreeNodePartialState = Omit<NavigationTreeNodeState, 'loading' | 'loaded' | 'error' | 'children'>;
|
|
32
|
-
export interface NavigationTreeProps<D = any> {
|
|
34
|
+
export interface NavigationTreeProps<D = any, M = any> {
|
|
33
35
|
rootState: NavigationTreeNodePartialState;
|
|
34
|
-
fetchPath: (path: string) => Promise<NavigationTreeDataItem[]>;
|
|
36
|
+
fetchPath: (path: string) => Promise<NavigationTreeDataItem<M>[]>;
|
|
35
37
|
onActionsOpenToggle?: (args: {
|
|
36
38
|
path: string;
|
|
37
39
|
type: NavigationTreeNodeType;
|
|
38
40
|
isOpen: boolean;
|
|
39
41
|
}) => void;
|
|
40
|
-
getActions?: (path: string, type: NavigationTreeNodeType) => DropdownMenuItemMixed<D>[];
|
|
41
|
-
renderAdditionalNodeElements?: (path: string, type: NavigationTreeNodeType) => JSX.Element | undefined;
|
|
42
|
+
getActions?: (path: string, type: NavigationTreeNodeType, meta: M) => DropdownMenuItemMixed<D>[];
|
|
43
|
+
renderAdditionalNodeElements?: (path: string, type: NavigationTreeNodeType, meta: M) => JSX.Element | undefined;
|
|
42
44
|
activePath?: string;
|
|
43
45
|
onActivePathUpdate?: (activePath: string) => void;
|
|
44
46
|
cache?: boolean;
|