ydb-ui-components 1.1.2 → 1.2.2

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,33 @@
1
1
  # Changelog
2
2
 
3
+ ### [1.2.2](https://github.com/ydb-platform/ydb-ui-components/compare/v1.2.1...v1.2.2) (2022-05-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add missing index file for TreeView ([7496d9b](https://github.com/ydb-platform/ydb-ui-components/commit/7496d9b7074d6ee5c2f280030ca38cc9373b0f34))
9
+
10
+ ### [1.2.1](https://github.com/ydb-platform/ydb-ui-components/compare/v1.2.0...v1.2.1) (2022-05-23)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add missing component export ([9b71eb7](https://github.com/ydb-platform/ydb-ui-components/commit/9b71eb78f8c2adfd773e45edddc41ea97c64aa35))
16
+
17
+ ## [1.2.0](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.3...v1.2.0) (2022-05-23)
18
+
19
+
20
+ ### Features
21
+
22
+ * a param to always refetch nodes data ([6cee325](https://github.com/ydb-platform/ydb-ui-components/commit/6cee32581d0a16ecc8bb742eb8f2c27d2d9a1cad))
23
+
24
+ ### [1.1.3](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.2...v1.1.3) (2022-05-23)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * add @yandex-cloud/uikit to peer deps ([61d5628](https://github.com/ydb-platform/ydb-ui-components/commit/61d5628088528e5c532c096bacebb2eca3f68206))
30
+
3
31
  ### [1.1.2](https://github.com/ydb-platform/ydb-ui-components/compare/v1.1.1...v1.1.2) (2022-05-19)
4
32
 
5
33
 
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { NavigationTreeProps } from './types';
3
3
  export type { NavigationTreeProps };
4
- export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, activePath, onActivePathUpdate, }: NavigationTreeProps): JSX.Element;
4
+ export declare function NavigationTree({ rootState: partialRootState, fetchPath, getActions, activePath, onActivePathUpdate, cache, }: NavigationTreeProps): JSX.Element;
@@ -27,7 +27,8 @@ function NavigationTree(_ref) {
27
27
  fetchPath,
28
28
  getActions,
29
29
  activePath,
30
- onActivePathUpdate
30
+ onActivePathUpdate,
31
+ cache
31
32
  } = _ref;
32
33
 
33
34
  const [state, dispatch] = _react.default.useReducer(_state.reducer, {
@@ -49,6 +50,7 @@ function NavigationTree(_ref) {
49
50
  fetchPath: fetchPath,
50
51
  activePath: activePath,
51
52
  onItemActivate: onActivePathUpdate,
52
- getActions: getActions
53
+ getActions: getActions,
54
+ cache: cache
53
55
  }));
54
56
  }
@@ -9,5 +9,6 @@ export interface NavigationTreeDirectoryProps {
9
9
  activePath?: string;
10
10
  onItemActivate?: (itemPath: string) => void;
11
11
  getActions?: NavigationTreeProps['getActions'];
12
+ cache?: boolean;
12
13
  }
13
- export declare function NavigationTreeDirectory({ state, dispatch, path, fetchPath, activePath, onItemActivate, getActions, }: NavigationTreeDirectoryProps): JSX.Element;
14
+ export declare function NavigationTreeDirectory({ state, dispatch, path, fetchPath, activePath, onItemActivate, getActions, cache, }: NavigationTreeDirectoryProps): JSX.Element;
@@ -27,36 +27,39 @@ function NavigationTreeDirectory(_ref) {
27
27
  fetchPath,
28
28
  activePath,
29
29
  onItemActivate,
30
- getActions
30
+ getActions,
31
+ cache = true
31
32
  } = _ref;
32
33
  const nodeState = state[path];
33
34
 
34
35
  _react.default.useEffect(() => {
35
- if (!nodeState.loaded && !nodeState.loading) {
36
+ if (nodeState.loaded && cache || nodeState.loading) {
37
+ return;
38
+ }
39
+
40
+ dispatch({
41
+ type: _state.NavigationTreeActionType.StartLoading,
42
+ payload: {
43
+ path
44
+ }
45
+ });
46
+ fetchPath(path).then(data => {
36
47
  dispatch({
37
- type: _state.NavigationTreeActionType.StartLoading,
48
+ type: _state.NavigationTreeActionType.FinishLoading,
38
49
  payload: {
39
- path
50
+ path,
51
+ data
40
52
  }
41
53
  });
42
- fetchPath(path).then(data => {
43
- dispatch({
44
- type: _state.NavigationTreeActionType.FinishLoading,
45
- payload: {
46
- path,
47
- data
48
- }
49
- });
50
- }).catch(error => {
51
- dispatch({
52
- type: _state.NavigationTreeActionType.FinishLoading,
53
- payload: {
54
- path,
55
- error
56
- }
57
- });
54
+ }).catch(error => {
55
+ dispatch({
56
+ type: _state.NavigationTreeActionType.FinishLoading,
57
+ payload: {
58
+ path,
59
+ error
60
+ }
58
61
  });
59
- }
62
+ });
60
63
  }, []);
61
64
 
62
65
  if (nodeState.loading) {
@@ -80,7 +83,8 @@ function NavigationTreeDirectory(_ref) {
80
83
  fetchPath: fetchPath,
81
84
  activePath: activePath,
82
85
  onItemActivate: onItemActivate,
83
- getActions: getActions
86
+ getActions: getActions,
87
+ cache: cache
84
88
  });
85
89
  }
86
90
 
@@ -49,7 +49,8 @@ function reducer() {
49
49
  [action.payload.path]: _objectSpread(_objectSpread({}, state[action.payload.path]), {}, {
50
50
  loading: true,
51
51
  loaded: false,
52
- error: false
52
+ error: false,
53
+ children: []
53
54
  })
54
55
  });
55
56
 
@@ -23,4 +23,5 @@ export interface NavigationTreeProps<D = any> {
23
23
  getActions?: (path: string, type: NavigationTreeNodeType) => DropdownMenuItemMixed<D>[];
24
24
  activePath?: string;
25
25
  onActivePathUpdate?: (activePath: string) => void;
26
+ cache?: boolean;
26
27
  }
@@ -0,0 +1 @@
1
+ export * from './TreeView';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
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 () {
15
+ return _TreeView[key];
16
+ }
17
+ });
18
+ });
package/build/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './components/NavigationTree';
2
+ export * from './components/TreeView';
package/build/index.js CHANGED
@@ -15,4 +15,17 @@ Object.keys(_NavigationTree).forEach(function (key) {
15
15
  return _NavigationTree[key];
16
16
  }
17
17
  });
18
+ });
19
+
20
+ var _TreeView = require("./components/TreeView");
21
+
22
+ Object.keys(_TreeView).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _TreeView[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _TreeView[key];
29
+ }
30
+ });
18
31
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-ui-components",
3
- "version": "1.1.2",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",
@@ -67,6 +67,7 @@
67
67
  "peerDependencies": {
68
68
  "@yandex-cloud/browserslist-config": "^1.0.1",
69
69
  "@yandex-cloud/i18n": "^0.4.0",
70
+ "@yandex-cloud/uikit": "^1.8.0",
70
71
  "react": "^16.0.0",
71
72
  "react-dom": "^16.0.0"
72
73
  },