ydb-ui-components 4.5.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 +15 -3
- package/build/cjs/components/NavigationTree/types.d.ts +8 -6
- package/build/cjs/components/icons/Transfer.d.ts +2 -0
- package/build/cjs/components/icons/Transfer.js +8 -0
- package/build/esm/components/NavigationTree/NavigationTree.d.ts +1 -1
- package/build/esm/components/NavigationTree/NavigationTreeNode.js +15 -3
- package/build/esm/components/NavigationTree/types.d.ts +8 -6
- package/build/esm/components/icons/Transfer.d.ts +2 -0
- package/build/esm/components/icons/Transfer.js +5 -0
- 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;
|
|
@@ -16,12 +16,15 @@ const Index_1 = require("../icons/Index");
|
|
|
16
16
|
const ResourcePool_1 = require("../icons/ResourcePool");
|
|
17
17
|
const Table_1 = require("../icons/Table");
|
|
18
18
|
const Topic_1 = require("../icons/Topic");
|
|
19
|
+
const Transfer_1 = require("../icons/Transfer");
|
|
19
20
|
const View_1 = require("../icons/View");
|
|
20
21
|
const state_1 = require("./state");
|
|
21
22
|
function renderIcon(type, collapsed) {
|
|
22
23
|
switch (type) {
|
|
23
24
|
case 'async_replication':
|
|
24
25
|
return (0, jsx_runtime_1.jsx)(AsyncReplication_1.AsyncReplicationIcon, { height: 16 });
|
|
26
|
+
case 'transfer':
|
|
27
|
+
return (0, jsx_runtime_1.jsx)(Transfer_1.TransferIcon, { height: 16 });
|
|
25
28
|
case 'database':
|
|
26
29
|
// this icon is larger than the others, therefore 14 for a better fit
|
|
27
30
|
return (0, jsx_runtime_1.jsx)(Database_1.DatabaseIcon, { height: 14 });
|
|
@@ -81,7 +84,16 @@ function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatc
|
|
|
81
84
|
payload: { path, error },
|
|
82
85
|
});
|
|
83
86
|
});
|
|
84
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
activePath,
|
|
89
|
+
cache,
|
|
90
|
+
dispatch,
|
|
91
|
+
fetchPath,
|
|
92
|
+
nodeState.collapsed,
|
|
93
|
+
nodeState.loaded,
|
|
94
|
+
nodeState.loading,
|
|
95
|
+
path,
|
|
96
|
+
]);
|
|
85
97
|
const handleClick = react_1.default.useCallback(() => {
|
|
86
98
|
if (onActivate) {
|
|
87
99
|
onActivate(path);
|
|
@@ -91,10 +103,10 @@ function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatc
|
|
|
91
103
|
dispatch({ type: state_1.NavigationTreeActionType.ToggleCollapsed, payload: { path } });
|
|
92
104
|
}, [dispatch, path]);
|
|
93
105
|
const additionalNodeElements = react_1.default.useMemo(() => {
|
|
94
|
-
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);
|
|
95
107
|
}, [renderAdditionalNodeElements, nodeState]);
|
|
96
108
|
const actions = react_1.default.useMemo(() => {
|
|
97
|
-
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);
|
|
98
110
|
}, [getActions, nodeState]);
|
|
99
111
|
const handleActionsOpenToggle = react_1.default.useCallback((isOpen) => {
|
|
100
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
|
-
export type NavigationTreeNodeType = 'async_replication' | 'column_table' | 'resource_pool' | 'database' | 'directory' | 'external_data_source' | 'external_table' | 'index_table' | 'index' | 'stream' | 'table' | 'topic' | 'view';
|
|
4
|
-
export interface NavigationTreeDataItem {
|
|
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<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;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransferIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function TransferIcon(props) {
|
|
6
|
+
return ((0, jsx_runtime_1.jsx)("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor" }, props, { children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9.22 15.03s-.001 0 0 0a.75.75 0 0 0 1.06-1.06l-.47-.47H10a3.016 3.016 0 0 0 1.507-.405A2.999 2.999 0 0 0 13 10.5V7.896h.003a2.735 2.735 0 0 0 .785-.366 2.75 2.75 0 1 0-2.288.366V10.5A1.5 1.5 0 0 1 10 12h-.19l.47-.47s0 .001 0 0a.75.75 0 0 0-1.06-1.06l-.47.47-1.28 1.28a.75.75 0 0 0 0 1.06l1.75 1.75ZM5.72 2.97a.75.75 0 0 1 1.06 0l.47.47 1.28 1.28a.748.748 0 0 1 0 1.06L6.78 7.53c.001 0 0 0 0 0a.751.751 0 0 1-1.06-1.06L6.19 6H6a1.5 1.5 0 0 0-1.5 1.5v2.604a2.757 2.757 0 0 1 2 2.646 2.738 2.738 0 0 1-1.212 2.28 2.737 2.737 0 0 1-1.538.47A2.747 2.747 0 0 1 1 12.75a2.751 2.751 0 0 1 2-2.646V7.5a2.999 2.999 0 0 1 3-3h.19l-.47-.47a.75.75 0 0 1 0-1.06Zm-.908 9.121A1.246 1.246 0 0 1 5 12.75a1.25 1.25 0 1 1-.188-.659ZM11 5.25a1.25 1.25 0 1 1 2.5 0 1.25 1.25 0 0 1-2.5 0Z" }) })));
|
|
7
|
+
}
|
|
8
|
+
exports.TransferIcon = TransferIcon;
|
|
@@ -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;
|
|
@@ -12,12 +12,15 @@ import { IndexIcon } from '../icons/Index';
|
|
|
12
12
|
import { ResourcePoolIcon } from '../icons/ResourcePool';
|
|
13
13
|
import { TableIcon } from '../icons/Table';
|
|
14
14
|
import { TopicIcon } from '../icons/Topic';
|
|
15
|
+
import { TransferIcon } from '../icons/Transfer';
|
|
15
16
|
import { ViewIcon } from '../icons/View';
|
|
16
17
|
import { NavigationTreeActionType } from './state';
|
|
17
18
|
function renderIcon(type, collapsed) {
|
|
18
19
|
switch (type) {
|
|
19
20
|
case 'async_replication':
|
|
20
21
|
return _jsx(AsyncReplicationIcon, { height: 16 });
|
|
22
|
+
case 'transfer':
|
|
23
|
+
return _jsx(TransferIcon, { height: 16 });
|
|
21
24
|
case 'database':
|
|
22
25
|
// this icon is larger than the others, therefore 14 for a better fit
|
|
23
26
|
return _jsx(DatabaseIcon, { height: 14 });
|
|
@@ -77,7 +80,16 @@ export function NavigationTreeNode({ path, fetchPath, activePath, state, level,
|
|
|
77
80
|
payload: { path, error },
|
|
78
81
|
});
|
|
79
82
|
});
|
|
80
|
-
}, [
|
|
83
|
+
}, [
|
|
84
|
+
activePath,
|
|
85
|
+
cache,
|
|
86
|
+
dispatch,
|
|
87
|
+
fetchPath,
|
|
88
|
+
nodeState.collapsed,
|
|
89
|
+
nodeState.loaded,
|
|
90
|
+
nodeState.loading,
|
|
91
|
+
path,
|
|
92
|
+
]);
|
|
81
93
|
const handleClick = React.useCallback(() => {
|
|
82
94
|
if (onActivate) {
|
|
83
95
|
onActivate(path);
|
|
@@ -87,10 +99,10 @@ export function NavigationTreeNode({ path, fetchPath, activePath, state, level,
|
|
|
87
99
|
dispatch({ type: NavigationTreeActionType.ToggleCollapsed, payload: { path } });
|
|
88
100
|
}, [dispatch, path]);
|
|
89
101
|
const additionalNodeElements = React.useMemo(() => {
|
|
90
|
-
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);
|
|
91
103
|
}, [renderAdditionalNodeElements, nodeState]);
|
|
92
104
|
const actions = React.useMemo(() => {
|
|
93
|
-
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);
|
|
94
106
|
}, [getActions, nodeState]);
|
|
95
107
|
const handleActionsOpenToggle = React.useCallback((isOpen) => {
|
|
96
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
|
-
export type NavigationTreeNodeType = 'async_replication' | 'column_table' | 'resource_pool' | 'database' | 'directory' | 'external_data_source' | 'external_table' | 'index_table' | 'index' | 'stream' | 'table' | 'topic' | 'view';
|
|
4
|
-
export interface NavigationTreeDataItem {
|
|
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<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;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export function TransferIcon(props) {
|
|
4
|
+
return (_jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor" }, props, { children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9.22 15.03s-.001 0 0 0a.75.75 0 0 0 1.06-1.06l-.47-.47H10a3.016 3.016 0 0 0 1.507-.405A2.999 2.999 0 0 0 13 10.5V7.896h.003a2.735 2.735 0 0 0 .785-.366 2.75 2.75 0 1 0-2.288.366V10.5A1.5 1.5 0 0 1 10 12h-.19l.47-.47s0 .001 0 0a.75.75 0 0 0-1.06-1.06l-.47.47-1.28 1.28a.75.75 0 0 0 0 1.06l1.75 1.75ZM5.72 2.97a.75.75 0 0 1 1.06 0l.47.47 1.28 1.28a.748.748 0 0 1 0 1.06L6.78 7.53c.001 0 0 0 0 0a.751.751 0 0 1-1.06-1.06L6.19 6H6a1.5 1.5 0 0 0-1.5 1.5v2.604a2.757 2.757 0 0 1 2 2.646 2.738 2.738 0 0 1-1.212 2.28 2.737 2.737 0 0 1-1.538.47A2.747 2.747 0 0 1 1 12.75a2.751 2.751 0 0 1 2-2.646V7.5a2.999 2.999 0 0 1 3-3h.19l-.47-.47a.75.75 0 0 1 0-1.06Zm-.908 9.121A1.246 1.246 0 0 1 5 12.75a1.25 1.25 0 1 1-.188-.659ZM11 5.25a1.25 1.25 0 1 1 2.5 0 1.25 1.25 0 0 1-2.5 0Z" }) })));
|
|
5
|
+
}
|