ydb-ui-components 3.2.2 → 3.3.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.3.0](https://github.com/ydb-platform/ydb-ui-components/compare/v3.2.2...v3.3.0) (2023-08-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * **NavigationTree:** add additionalNodeElements to NavigationTree ([#55](https://github.com/ydb-platform/ydb-ui-components/issues/55)) ([d462aaf](https://github.com/ydb-platform/ydb-ui-components/commit/d462aafd8dd61aca3cc17b17f57419af4c7e8910))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **NavigationTree:** add new NavigationTreeNodeType 'stream' ([#57](https://github.com/ydb-platform/ydb-ui-components/issues/57)) ([270f607](https://github.com/ydb-platform/ydb-ui-components/commit/270f607e952f197c51fccd89a313390fdd8f055d))
14
+
3
15
  ## [3.2.2](https://github.com/ydb-platform/ydb-ui-components/compare/v3.2.1...v3.2.2) (2023-08-03)
4
16
 
5
17
 
@@ -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, activePath, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps): JSX.Element;
4
+ export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, renderAdditionalNodeElements, activePath, onActivePathUpdate, cache, virtualize, }: NavigationTreeProps): JSX.Element;
@@ -64,6 +64,7 @@ function NavigationTree(_ref) {
64
64
  var partialRootState = _ref.rootState,
65
65
  fetchPath = _ref.fetchPath,
66
66
  getActions = _ref.getActions,
67
+ renderAdditionalNodeElements = _ref.renderAdditionalNodeElements,
67
68
  activePath = _ref.activePath,
68
69
  onActivePathUpdate = _ref.onActivePathUpdate,
69
70
  _ref$cache = _ref.cache,
@@ -90,6 +91,7 @@ function NavigationTree(_ref) {
90
91
  dispatch: dispatch,
91
92
  onActivate: onActivePathUpdate,
92
93
  getActions: getActions,
94
+ renderAdditionalNodeElements: renderAdditionalNodeElements,
93
95
  cache: cache,
94
96
  level: node.level
95
97
  });
@@ -11,6 +11,7 @@ export interface NavigationTreeNodeProps {
11
11
  children?: React.ReactNode;
12
12
  onActivate?: (path: string) => void;
13
13
  getActions?: NavigationTreeProps['getActions'];
14
+ renderAdditionalNodeElements?: NavigationTreeProps['renderAdditionalNodeElements'];
14
15
  cache?: boolean;
15
16
  }
16
- export declare function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatch, children, onActivate, getActions, cache, }: NavigationTreeNodeProps): JSX.Element;
17
+ export declare function NavigationTreeNode({ path, fetchPath, activePath, state, level, dispatch, children, onActivate, getActions, renderAdditionalNodeElements, cache, }: NavigationTreeNodeProps): JSX.Element;
@@ -62,6 +62,7 @@ function renderIcon(type, collapsed) {
62
62
  height: 16
63
63
  });
64
64
 
65
+ case 'stream':
65
66
  case 'topic':
66
67
  return /*#__PURE__*/_react["default"].createElement(_Topic.TopicIcon, {
67
68
  height: 16
@@ -92,6 +93,7 @@ function NavigationTreeNode(_ref) {
92
93
  children = _ref.children,
93
94
  onActivate = _ref.onActivate,
94
95
  getActions = _ref.getActions,
96
+ renderAdditionalNodeElements = _ref.renderAdditionalNodeElements,
95
97
  cache = _ref.cache;
96
98
  var nodeState = state[path];
97
99
 
@@ -154,6 +156,10 @@ function NavigationTreeNode(_ref) {
154
156
  });
155
157
  }, []);
156
158
 
159
+ var additionalNodeElements = _react["default"].useMemo(function () {
160
+ return renderAdditionalNodeElements === null || renderAdditionalNodeElements === void 0 ? void 0 : renderAdditionalNodeElements(nodeState.path, nodeState.type);
161
+ }, [renderAdditionalNodeElements, nodeState]);
162
+
157
163
  var actions = _react["default"].useMemo(function () {
158
164
  return getActions === null || getActions === void 0 ? void 0 : getActions(nodeState.path, nodeState.type);
159
165
  }, [getActions, nodeState]);
@@ -164,6 +170,7 @@ function NavigationTreeNode(_ref) {
164
170
  collapsed: nodeState.collapsed,
165
171
  active: nodeState.path === activePath,
166
172
  actions: actions,
173
+ additionalNodeElements: additionalNodeElements,
167
174
  hasArrow: nodeState.expandable,
168
175
  onClick: handleClick,
169
176
  onArrowClick: handleArrowClick,
@@ -1,5 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import { DropdownMenuItemMixed } from '@gravity-ui/uikit';
2
- export declare type NavigationTreeNodeType = 'database' | 'directory' | 'table' | 'column_table' | 'index_table' | 'index' | 'topic' | 'external_table' | 'external_data_source';
3
+ export declare type NavigationTreeNodeType = 'database' | 'directory' | 'table' | 'column_table' | 'index_table' | 'index' | 'topic' | 'stream' | 'external_table' | 'external_data_source';
3
4
  export interface NavigationTreeDataItem {
4
5
  name: string;
5
6
  type: NavigationTreeNodeType;
@@ -32,6 +33,7 @@ export interface NavigationTreeProps<D = any> {
32
33
  rootState: NavigationTreeNodePartialState;
33
34
  fetchPath: (path: string) => Promise<NavigationTreeDataItem[]>;
34
35
  getActions?: (path: string, type: NavigationTreeNodeType) => DropdownMenuItemMixed<D>[];
36
+ renderAdditionalNodeElements?: (path: string, type: NavigationTreeNodeType) => JSX.Element | undefined;
35
37
  activePath?: string;
36
38
  onActivePathUpdate?: (activePath: string) => void;
37
39
  cache?: boolean;
@@ -19,7 +19,7 @@
19
19
  background-color: var(--yc-color-base-simple-hover);
20
20
  }
21
21
  .ydb-tree-view__item:hover .ydb-tree-view__actions {
22
- display: block;
22
+ display: flex;
23
23
  }
24
24
  .ydb-tree-view__item_active {
25
25
  font-weight: bold;
@@ -55,6 +55,8 @@
55
55
  .ydb-tree-view__actions {
56
56
  display: none;
57
57
  margin-left: 6px;
58
+ align-items: center;
59
+ overflow: hidden;
58
60
  }
59
61
  .ydb-tree-view .tree-view_arrow {
60
62
  flex-shrink: 0;
@@ -12,6 +12,7 @@ export interface TreeViewProps {
12
12
  onArrowClick?: () => void;
13
13
  hasArrow?: boolean;
14
14
  actions?: DropdownMenuItemMixed<any>[];
15
+ additionalNodeElements?: JSX.Element;
15
16
  level?: number;
16
17
  }
17
- export declare function TreeView({ children, name, title, icon, collapsed, active, onClick, onArrowClick, hasArrow, actions, level, }: TreeViewProps): JSX.Element;
18
+ export declare function TreeView({ children, name, title, icon, collapsed, active, onClick, onArrowClick, hasArrow, actions, additionalNodeElements, level, }: TreeViewProps): JSX.Element;
@@ -36,6 +36,7 @@ function TreeView(_ref) {
36
36
  _ref$hasArrow = _ref.hasArrow,
37
37
  hasArrow = _ref$hasArrow === void 0 ? false : _ref$hasArrow,
38
38
  actions = _ref.actions,
39
+ additionalNodeElements = _ref.additionalNodeElements,
39
40
  level = _ref.level;
40
41
 
41
42
  var rootRef = _react["default"].useRef(null);
@@ -49,7 +50,7 @@ function TreeView(_ref) {
49
50
  title: title
50
51
  }, name), actions && actions.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
51
52
  className: b('actions')
52
- }, /*#__PURE__*/_react["default"].createElement(_uikit.DropdownMenu, {
53
+ }, additionalNodeElements, /*#__PURE__*/_react["default"].createElement(_uikit.DropdownMenu, {
53
54
  defaultSwitcherProps: {
54
55
  view: 'flat-secondary',
55
56
  size: 's',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-ui-components",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",