@riil-frontend/component-topology 6.0.7 → 6.0.9

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.
@@ -1,14 +1,12 @@
1
1
  import topoManager from '@riil-frontend/component-topology-graph/es/manager';
2
2
  import { getBasicIcons, getGroupDefaultIcons, getResourceIcons, transformCustomIcon2HtIcon } from "./icon";
3
-
4
- function useCustomIcons(topo) {
3
+ export function useCustomIcons(topo) {
5
4
  var _topo$store$useModelS = topo.store.useModelState('customIcon'),
6
5
  icons = _topo$store$useModelS.icons;
7
6
 
8
7
  var customIcons = icons.node.map(transformCustomIcon2HtIcon);
9
8
  return customIcons;
10
9
  }
11
-
12
10
  export function useNodeIcons(topo) {
13
11
  var customIcons = useCustomIcons(topo);
14
12
  var groups = [{
@@ -9,14 +9,15 @@ export default function GraphViewPanel(props) {
9
9
 
10
10
  var _useCanvasTheme = useCanvasTheme({
11
11
  topo: topo,
12
- themeName: themeName
12
+ themeName: themeName,
13
+ hideBackgroundColor: hideBackgroundColor
13
14
  }),
14
15
  canvasColor = _useCanvasTheme.canvasColor;
15
16
 
16
17
  return /*#__PURE__*/React.createElement("div", {
17
18
  className: styles.viewPanel,
18
19
  style: {
19
- background: hideBackgroundColor ? null : canvasColor
20
+ background: canvasColor
20
21
  }
21
22
  }, props.children);
22
23
  }
@@ -9,10 +9,8 @@ import HtCustomImagePanel from "./HtCustomImagePanel";
9
9
  */
10
10
 
11
11
  export default function CustomImagePanel(props) {
12
- var topo = props.topo;
13
- var icons = useMemo(function () {
14
- return getUserCustomIconsForHt(topo);
15
- }, []);
12
+ var topo = props.topo,
13
+ icons = props.icons;
16
14
  return /*#__PURE__*/React.createElement(HtCustomImagePanel, {
17
15
  icons: icons,
18
16
  topo: topo
@@ -1,18 +1,20 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _Button from "@alifd/next/es/button";
2
3
  import _Icon from "@alifd/next/es/icon";
3
4
  import React, { useMemo } from 'react';
4
- import classNames from 'classnames';
5
5
  import Collapse from "../../../../../../components/collapse/Collapse";
6
6
  import CiTypeImagePanel from "./CiTypeImagePanel";
7
7
  import CustomImagePanel from "./CustomImagePanel";
8
8
  import { getBasicIcons } from "../../../../../common/icons/icon";
9
9
  import ImagePalette from "./HtImagePalette";
10
+ import { useCustomIcons } from "../../../../../common/icons/useIcons";
10
11
  var CollapsePanel = Collapse.Panel;
11
12
  export default function ImagePanel(props) {
12
13
  var topo = props.topo;
13
14
  var basicIcons = useMemo(function () {
14
15
  return getBasicIcons(topo, false);
15
16
  }, []);
17
+ var customIcons = useCustomIcons(topo);
16
18
 
17
19
  var handleDownloadCustomImages = function handleDownloadCustomImages() {
18
20
  window.open('/topo/v1/api/shape/download/all');
@@ -40,9 +42,12 @@ export default function ImagePanel(props) {
40
42
  title: "\u81EA\u5B9A\u4E49\u56FE\u7247",
41
43
  extra: /*#__PURE__*/React.createElement(_Button, {
42
44
  title: "\u5BFC\u51FA",
43
- onClick: handleDownloadCustomImages
45
+ onClick: handleDownloadCustomImages,
46
+ disabled: !customIcons.length
44
47
  }, /*#__PURE__*/React.createElement(_Icon, {
45
48
  type: "topo_button_icon_export"
46
49
  }))
47
- }, /*#__PURE__*/React.createElement(CustomImagePanel, props)));
50
+ }, /*#__PURE__*/React.createElement(CustomImagePanel, _extends({}, props, {
51
+ icons: customIcons
52
+ }))));
48
53
  }
@@ -30,15 +30,16 @@ var themeMap = [{
30
30
  }, {});
31
31
  export default function useCanvasTheme(props) {
32
32
  var topo = props.topo,
33
- themeName = props.themeName; // 拓扑图是否加载
33
+ themeName = props.themeName,
34
+ hideBackgroundColor = props.hideBackgroundColor; // 拓扑图是否加载
34
35
 
35
36
  var _topo$store$useModelS = topo.store.useModelState('topoMod'),
36
37
  graphLoaded = _topo$store$useModelS.graphLoaded;
37
38
 
39
+ var themeConfig = themeMap[themeName || 'white'];
40
+ var canvasColor = hideBackgroundColor ? null : themeConfig.color;
38
41
  useEffect(function () {
39
42
  // 设置
40
- var themeConfig = themeMap[themeName || 'white'];
41
-
42
43
  if (graphLoaded && themeConfig) {
43
44
  try {
44
45
  topo.getHtTopo().setTheme(themeName);
@@ -47,8 +48,18 @@ export default function useCanvasTheme(props) {
47
48
  console.error('切换主题失败', error);
48
49
  }
49
50
  }
50
- }, [themeName, graphLoaded]);
51
+ }, [graphLoaded, themeName]);
52
+ useEffect(function () {
53
+ // 设置
54
+ if (graphLoaded) {
55
+ try {
56
+ topo.getHtTopo().getGraphView().dm().setBackground(canvasColor);
57
+ } catch (error) {
58
+ console.error('切换主题失败', error);
59
+ }
60
+ }
61
+ }, [graphLoaded, canvasColor]);
51
62
  return {
52
- canvasColor: themeMap[themeName].color
63
+ canvasColor: canvasColor
53
64
  };
54
65
  }
@@ -23,7 +23,7 @@ import topoFactory from "./topoFactory";
23
23
  import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
24
24
  import SelectionModel from "./SelectionModel"; // eslint-disable-next-line no-undef
25
25
 
26
- var version = typeof "6.0.7" === 'string' ? "6.0.7" : null;
26
+ var version = typeof "6.0.9" === 'string' ? "6.0.9" : null;
27
27
  console.info("\u62D3\u6251\u7248\u672C: " + version);
28
28
  /**
29
29
  * 拓扑显示和编辑
@@ -3,6 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
+ exports.useCustomIcons = useCustomIcons;
6
7
  exports.useGroupIcons = useGroupIcons;
7
8
  exports.useNodeIcons = useNodeIcons;
8
9
 
@@ -19,14 +19,15 @@ function GraphViewPanel(props) {
19
19
 
20
20
  var _useCanvasTheme = (0, _useCanvasTheme2["default"])({
21
21
  topo: topo,
22
- themeName: themeName
22
+ themeName: themeName,
23
+ hideBackgroundColor: hideBackgroundColor
23
24
  }),
24
25
  canvasColor = _useCanvasTheme.canvasColor;
25
26
 
26
27
  return /*#__PURE__*/_react["default"].createElement("div", {
27
28
  className: _TopoViewModule["default"].viewPanel,
28
29
  style: {
29
- background: hideBackgroundColor ? null : canvasColor
30
+ background: canvasColor
30
31
  }
31
32
  }, props.children);
32
33
  }
@@ -23,10 +23,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
23
  * @returns
24
24
  */
25
25
  function CustomImagePanel(props) {
26
- var topo = props.topo;
27
- var icons = (0, _react.useMemo)(function () {
28
- return (0, _icon.getUserCustomIconsForHt)(topo);
29
- }, []);
26
+ var topo = props.topo,
27
+ icons = props.icons;
30
28
  return /*#__PURE__*/_react["default"].createElement(_HtCustomImagePanel["default"], {
31
29
  icons: icons,
32
30
  topo: topo
@@ -5,14 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports["default"] = ImagePanel;
7
7
 
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
8
10
  var _button = _interopRequireDefault(require("@alifd/next/lib/button"));
9
11
 
10
12
  var _icon = _interopRequireDefault(require("@alifd/next/lib/icon"));
11
13
 
12
14
  var _react = _interopRequireWildcard(require("react"));
13
15
 
14
- var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
16
  var _Collapse = _interopRequireDefault(require("../../../../../../components/collapse/Collapse"));
17
17
 
18
18
  var _CiTypeImagePanel = _interopRequireDefault(require("./CiTypeImagePanel"));
@@ -23,6 +23,8 @@ var _icon2 = require("../../../../../common/icons/icon");
23
23
 
24
24
  var _HtImagePalette = _interopRequireDefault(require("./HtImagePalette"));
25
25
 
26
+ var _useIcons = require("../../../../../common/icons/useIcons");
27
+
26
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
29
 
28
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -34,6 +36,7 @@ function ImagePanel(props) {
34
36
  var basicIcons = (0, _react.useMemo)(function () {
35
37
  return (0, _icon2.getBasicIcons)(topo, false);
36
38
  }, []);
39
+ var customIcons = (0, _useIcons.useCustomIcons)(topo);
37
40
 
38
41
  var handleDownloadCustomImages = function handleDownloadCustomImages() {
39
42
  window.open('/topo/v1/api/shape/download/all');
@@ -61,9 +64,12 @@ function ImagePanel(props) {
61
64
  title: "\u81EA\u5B9A\u4E49\u56FE\u7247",
62
65
  extra: /*#__PURE__*/_react["default"].createElement(_button["default"], {
63
66
  title: "\u5BFC\u51FA",
64
- onClick: handleDownloadCustomImages
67
+ onClick: handleDownloadCustomImages,
68
+ disabled: !customIcons.length
65
69
  }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
66
70
  type: "topo_button_icon_export"
67
71
  }))
68
- }, /*#__PURE__*/_react["default"].createElement(_CustomImagePanel["default"], props)));
72
+ }, /*#__PURE__*/_react["default"].createElement(_CustomImagePanel["default"], (0, _extends2["default"])({}, props, {
73
+ icons: customIcons
74
+ }))));
69
75
  }
@@ -44,15 +44,16 @@ var themeMap = [{
44
44
 
45
45
  function useCanvasTheme(props) {
46
46
  var topo = props.topo,
47
- themeName = props.themeName; // 拓扑图是否加载
47
+ themeName = props.themeName,
48
+ hideBackgroundColor = props.hideBackgroundColor; // 拓扑图是否加载
48
49
 
49
50
  var _topo$store$useModelS = topo.store.useModelState('topoMod'),
50
51
  graphLoaded = _topo$store$useModelS.graphLoaded;
51
52
 
53
+ var themeConfig = themeMap[themeName || 'white'];
54
+ var canvasColor = hideBackgroundColor ? null : themeConfig.color;
52
55
  (0, _react.useEffect)(function () {
53
56
  // 设置
54
- var themeConfig = themeMap[themeName || 'white'];
55
-
56
57
  if (graphLoaded && themeConfig) {
57
58
  try {
58
59
  topo.getHtTopo().setTheme(themeName);
@@ -61,8 +62,18 @@ function useCanvasTheme(props) {
61
62
  console.error('切换主题失败', error);
62
63
  }
63
64
  }
64
- }, [themeName, graphLoaded]);
65
+ }, [graphLoaded, themeName]);
66
+ (0, _react.useEffect)(function () {
67
+ // 设置
68
+ if (graphLoaded) {
69
+ try {
70
+ topo.getHtTopo().getGraphView().dm().setBackground(canvasColor);
71
+ } catch (error) {
72
+ console.error('切换主题失败', error);
73
+ }
74
+ }
75
+ }, [graphLoaded, canvasColor]);
65
76
  return {
66
- canvasColor: themeMap[themeName].color
77
+ canvasColor: canvasColor
67
78
  };
68
79
  }
@@ -54,7 +54,7 @@ var _ElementTagTipConfig = _interopRequireDefault(require("./tagstips/ElementTag
54
54
  var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
55
55
 
56
56
  // eslint-disable-next-line no-undef
57
- var version = typeof "6.0.7" === 'string' ? "6.0.7" : null;
57
+ var version = typeof "6.0.9" === 'string' ? "6.0.9" : null;
58
58
  console.info("\u62D3\u6251\u7248\u672C: " + version);
59
59
  /**
60
60
  * 拓扑显示和编辑
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "6.0.7",
3
+ "version": "6.0.9",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -116,6 +116,6 @@
116
116
  "access": "public"
117
117
  },
118
118
  "license": "MIT",
119
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@6.0.7/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@6.0.9/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }