@riil-frontend/component-topology 6.0.0-alpha.44 → 6.0.0-alpha.46

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.
Files changed (36) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +12 -12
  4. package/es/components/ColorPanel/index.js +8 -4
  5. package/es/components/VerticalIconTab/VerticalIconTab.module.scss +1 -0
  6. package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +33 -25
  7. package/es/core/editor/components/Toolbar/widgets/Layout/index.js +11 -9
  8. package/es/core/editor/components/Toolbar/widgets/NodeAlignWidget.js +2 -2
  9. package/es/core/editor/components/Toolbar/widgets/NodeAlignWidget.module.scss +3 -3
  10. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +5 -1
  11. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +2 -1
  12. package/es/core/editor/components/settings/common/AlignSetting/AlignSetting.module.scss +1 -1
  13. package/es/core/editor/components/settings/common/NameInput.js +21 -0
  14. package/es/core/editor/components/settings/propertyViews/box/NameInput.js +5 -4
  15. package/es/core/editor/components/settings/propertyViews/group/SettingTab/GroupBasicSetting.js +3 -2
  16. package/es/core/editor/components/settings/propertyViews/layer/BasicSetting.js +3 -2
  17. package/es/core/editor/components/settings/propertyViews/node/Setting/NameInput.js +5 -4
  18. package/es/core/hooks/useCanvasTheme.js +1 -1
  19. package/es/core/models/TopoApp.js +1 -1
  20. package/lib/components/ColorPanel/index.js +8 -4
  21. package/lib/components/VerticalIconTab/VerticalIconTab.module.scss +1 -0
  22. package/lib/core/editor/components/Toolbar/widgets/FontColorButton.js +33 -25
  23. package/lib/core/editor/components/Toolbar/widgets/Layout/index.js +12 -10
  24. package/lib/core/editor/components/Toolbar/widgets/NodeAlignWidget.js +2 -2
  25. package/lib/core/editor/components/Toolbar/widgets/NodeAlignWidget.module.scss +3 -3
  26. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +7 -1
  27. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +2 -1
  28. package/lib/core/editor/components/settings/common/AlignSetting/AlignSetting.module.scss +1 -1
  29. package/lib/core/editor/components/settings/common/NameInput.js +33 -0
  30. package/lib/core/editor/components/settings/propertyViews/box/NameInput.js +6 -5
  31. package/lib/core/editor/components/settings/propertyViews/group/SettingTab/GroupBasicSetting.js +4 -3
  32. package/lib/core/editor/components/settings/propertyViews/layer/BasicSetting.js +4 -3
  33. package/lib/core/editor/components/settings/propertyViews/node/Setting/NameInput.js +6 -5
  34. package/lib/core/hooks/useCanvasTheme.js +1 -1
  35. package/lib/core/models/TopoApp.js +1 -1
  36. package/package.json +2 -2
@@ -71,14 +71,18 @@ function ColorPanel(props) {
71
71
  var rgba = "rgba(" + rgb.r + "," + rgb.g + "," + rgb.b + "," + rgb.a + ")";
72
72
 
73
73
  if (data !== prevValue) {
74
- setData(rgba);
75
- onChange({
74
+ setData({
76
75
  hex: prevValue,
77
76
  rgb: rgb
78
- }, 'change');
77
+ });
79
78
  }
80
79
  };
81
80
 
81
+ var pickerBlur = function pickerBlur() {
82
+ onChange(data, 'change');
83
+ onPickerBlur();
84
+ };
85
+
82
86
  var getColor16 = function getColor16(color) {
83
87
  var that = color;
84
88
 
@@ -157,7 +161,7 @@ function ColorPanel(props) {
157
161
  style: {
158
162
  paddingBottom: 0
159
163
  },
160
- onBlur: onPickerBlur,
164
+ onBlur: pickerBlur,
161
165
  onFocus: onPickerFocus
162
166
  }, /*#__PURE__*/React.createElement(SketchPicker, {
163
167
  color: data // width={230}
@@ -41,6 +41,7 @@
41
41
 
42
42
  .tab-title {
43
43
  margin-top: 3px;
44
+ font-weight: normal;
44
45
  }
45
46
  }
46
47
  }
@@ -16,36 +16,44 @@ function FontColorDropdown(props) {
16
16
  disabled = _useState[0],
17
17
  setDisabled = _useState[1];
18
18
 
19
- var onPickerFocus = function onPickerFocus() {
19
+ var backOpacityChange = function backOpacityChange(value) {
20
20
  topo.historyManager.beginTransaction();
21
- };
22
-
23
- var onPickerBlur = function onPickerBlur() {
24
- topo.historyManager.endTransaction();
25
- };
26
-
27
- var backOpacityChange = function backOpacityChange(value, type) {
28
- if (type === 'select') onPickerFocus();
29
21
  onChange({
30
22
  opacity: value / 100
31
23
  });
32
- if (type === 'select') onPickerBlur();
24
+ topo.historyManager.endTransaction();
25
+ };
26
+
27
+ var colorBackgroundChanges = function colorBackgroundChanges(type, name, value) {
28
+ if (type === 'select') topo.historyManager.beginTransaction();
29
+
30
+ if (name === 'color') {
31
+ onChange({
32
+ color: value
33
+ });
34
+ } else {
35
+ onChange({
36
+ background: value
37
+ });
38
+ }
39
+
40
+ if (type === 'select') topo.historyManager.endTransaction();
33
41
  };
34
42
 
35
43
  var colorChang = function colorChang(value, type) {
36
- if (type === 'select') onPickerFocus();
37
- onChange({
38
- color: value
39
- });
40
- if (type === 'select') onPickerBlur();
44
+ colorBackgroundChanges(type, 'color', value);
41
45
  };
42
46
 
43
- var backgroundChang = function backgroundChang(value) {
44
- onPickerFocus();
45
- onChange({
46
- background: value
47
- });
48
- onPickerBlur();
47
+ var backgroundChang = function backgroundChang(value, type) {
48
+ colorBackgroundChanges(type, 'background', value);
49
+ };
50
+
51
+ var onFocus = function onFocus() {
52
+ topo.historyManager.beginTransaction();
53
+ };
54
+
55
+ var onBlur = function onBlur() {
56
+ topo.historyManager.endTransaction();
49
57
  };
50
58
 
51
59
  var icon = disabled ? /*#__PURE__*/React.createElement("img", {
@@ -69,8 +77,8 @@ function FontColorDropdown(props) {
69
77
  }
70
78
  }, /*#__PURE__*/React.createElement(ColorPanel, {
71
79
  onChange: colorChang,
72
- onPickerFocus: onPickerFocus,
73
- onPickerBlur: onPickerBlur
80
+ onPickerFocus: onFocus,
81
+ onPickerBlur: onBlur
74
82
  }))), /*#__PURE__*/React.createElement("div", {
75
83
  className: styles.backgroundColor
76
84
  }, /*#__PURE__*/React.createElement("span", null, "\u80CC\u666F\u586B\u5145"), /*#__PURE__*/React.createElement("div", {
@@ -93,8 +101,8 @@ function FontColorDropdown(props) {
93
101
  }, /*#__PURE__*/React.createElement(ColorPanel, {
94
102
  showClear: true,
95
103
  onChange: backgroundChang,
96
- onPickerFocus: onPickerFocus,
97
- onPickerBlur: onPickerBlur
104
+ onPickerFocus: onFocus,
105
+ onPickerBlur: onBlur
98
106
  })))));
99
107
  }
100
108
 
@@ -7,7 +7,7 @@ import React, { useState, useMemo } from 'react';
7
7
  import LayoutSettings from "./components/LayoutSettings";
8
8
  import WidgetBox from "../WidgetBox";
9
9
  import DropdownButton from "../components/DropdownButton";
10
- import { isGroup, isLayer } from "../../../../../../utils/htElementUtils";
10
+ import { isGroup, isLayer } from "../../../../../../utils/htElementDataUtil";
11
11
 
12
12
  function Layout(props) {
13
13
  var topo = props.topo,
@@ -24,7 +24,7 @@ function Layout(props) {
24
24
  selection = _topo$store$useModelS.selection;
25
25
 
26
26
  var setDisabled = function setDisabled(data) {
27
- if (topoShowType == 'layers' && selection.length == 1) {
27
+ if (topoShowType == 'layers' && selection.length == 1 && !isGroup(selection[0])) {
28
28
  return data != 'rectangle';
29
29
  } else {
30
30
  return data == 'rectangle';
@@ -87,15 +87,17 @@ function LayoutWidget(props) {
87
87
  // type为partition且selection.length>=0时可以点击布局, selection[0].className != 'ht.Node'
88
88
  // type为auto且selection.length==0时可以点击布局
89
89
 
90
- var selectionElements = topo.selectionModel.useHtSelection();
90
+ var _topo$store$useModelS2 = topo.store.useModelState('selection'),
91
+ selection = _topo$store$useModelS2.selection;
92
+
91
93
  var topoShowType = topoState.type; // 获取ID以及拓扑类型 // 拓扑类型:auto自由布局,layers分层,partition分区
92
94
 
93
95
  var disabled = useMemo(function () {
94
96
  return !isLayoutEnabled({
95
97
  topoShowType: topoShowType,
96
- selectionElements: selectionElements
98
+ selection: selection
97
99
  });
98
- }, [topoShowType, selectionElements]);
100
+ }, [topoShowType, selection]);
99
101
  var icon = disabled ? /*#__PURE__*/React.createElement("img", {
100
102
  src: "/img/topo/editor/toolbar/layout/Disable.svg",
101
103
  alt: ""
@@ -119,19 +121,19 @@ function LayoutWidget(props) {
119
121
 
120
122
  function isLayoutEnabled(props) {
121
123
  var topoShowType = props.topoShowType,
122
- selectionElements = props.selectionElements; // 选中单个区域/集群后,该按钮亮起
124
+ selection = props.selection; // 选中单个区域/集群后,该按钮亮起
123
125
 
124
- if (isGroup(selectionElements[0])) {
126
+ if (selection.length === 1 && isGroup(selection[0]) && selection[0].expanded) {
125
127
  return true;
126
128
  } // 分层拓扑选中任意分层时,布局按钮亮起
127
129
 
128
130
 
129
- if (topoShowType === 'layers' && selectionElements.length === 1 && isLayer(selectionElements[0])) {
131
+ if (topoShowType === 'layers' && selection.length === 1 && isLayer(selection[0])) {
130
132
  return true;
131
133
  } // 空白拓扑未选中任何资源时,布局按钮亮起
132
134
 
133
135
 
134
- if (topoShowType !== 'layers' && !selectionElements.length) {
136
+ if (topoShowType !== 'layers' && !selection.length) {
135
137
  return true;
136
138
  }
137
139
 
@@ -72,8 +72,8 @@ function NodeAlignWidget(props) {
72
72
  if (nodes.length === 2) {
73
73
  var h = topo.view.topoClient.htTopoClient.getElementsSpace(nodes, 'h')[0];
74
74
  var v = topo.view.topoClient.htTopoClient.getElementsSpace(nodes, 'v')[0];
75
- setLeftInputVal(h * 1 > 0 ? h : 0);
76
- setRightInputVal(v * 1 > 0 ? v : 0);
75
+ setLeftInputVal(Math.round(h * 1 > 0 ? h : 0));
76
+ setRightInputVal(Math.round(v * 1 > 0 ? v : 0));
77
77
  }
78
78
  } // eslint-disable-next-line react-hooks/exhaustive-deps
79
79
 
@@ -1,6 +1,6 @@
1
1
  .leftInput{
2
- width: 100px !important;
3
- margin: 0px 10px 10px 9px;
2
+ width: 106px !important;
3
+ margin: 0px 9px 10px 9px;
4
4
  :global{
5
5
  input{
6
6
  background: url('/img/topo/editor/toolbar/对齐/水平间距_normal.svg')no-repeat 5px center !important;
@@ -16,7 +16,7 @@
16
16
  }
17
17
  }
18
18
  .rightInput{
19
- width: 100px !important;
19
+ width: 106px !important;
20
20
  :global{
21
21
  input{
22
22
  background: url('/img/topo/editor/toolbar/对齐/垂直间距 _normal.svg')no-repeat 5px center !important;
@@ -35,6 +35,10 @@ export function parseBackground(colorStr) {
35
35
  export function formatHexColor(color) {
36
36
  return color ? color.hex : null;
37
37
  }
38
+ export function formatRgbaColor(color) {
39
+ var rgb = color.rgb;
40
+ return "rgba(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + rgb.a + ")";
41
+ }
38
42
  /**
39
43
  * 格式化背景rgba颜色
40
44
  * @param {{background, opacity}} prevColor
@@ -43,7 +47,7 @@ export function formatHexColor(color) {
43
47
 
44
48
  export function formatBackgroundRgbaColor(prevColor, currentColor) {
45
49
  if (!('background' in currentColor) && !('opacity' in currentColor)) {
46
- return null;
50
+ return formatRgbaColor(prevColor.background);
47
51
  }
48
52
 
49
53
  var colorObj = Object.assign(prevColor, currentColor);
@@ -19,7 +19,8 @@ export function setTextStyle(element, style) {
19
19
 
20
20
 
21
21
  var prevStyle = getTextStyle(element);
22
- element.s('textBackground', formatBackgroundRgbaColor(prevStyle, style));
22
+ var background = formatBackgroundRgbaColor(prevStyle, style);
23
+ element.s('textBackground', background);
23
24
 
24
25
  var fontStyle = _extends({}, getTextStyle(element), style);
25
26
 
@@ -17,7 +17,7 @@
17
17
  border: none !important;
18
18
  color: #4D6277;
19
19
  padding-left: 2px;
20
- margin-right: 3px;
20
+ margin-right: 4px;
21
21
 
22
22
  &:active {
23
23
  background: #F2F7FD !important;
@@ -0,0 +1,21 @@
1
+ import _Input from "@alifd/next/es/input";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import React from 'react';
4
+ var NameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
5
+ var multipleLine = props.multipleLine;
6
+
7
+ if (multipleLine) {
8
+ return /*#__PURE__*/React.createElement(_Input.TextArea, _extends({
9
+ ref: ref,
10
+ autoHeight: {
11
+ minRows: 4,
12
+ maxRows: 4
13
+ }
14
+ }, props));
15
+ }
16
+
17
+ return /*#__PURE__*/React.createElement(_Input, _extends({
18
+ ref: ref
19
+ }, props));
20
+ });
21
+ export default NameInput;
@@ -1,7 +1,7 @@
1
- import _Input from "@alifd/next/es/input";
2
1
  import _extends from "@babel/runtime/helpers/extends";
3
2
  import React, { useEffect, useState } from 'react';
4
- var NameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
3
+ import NameInput from "../../common/NameInput";
4
+ var BoxNameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
5
5
  var onChange = props.onChange,
6
6
  topo = props.topo;
7
7
 
@@ -33,12 +33,13 @@ var NameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
33
33
  topo.historyManager.endTransaction();
34
34
  };
35
35
 
36
- return /*#__PURE__*/React.createElement(_Input, _extends({}, props, {
36
+ return /*#__PURE__*/React.createElement(NameInput, _extends({}, props, {
37
37
  ref: ref,
38
38
  value: value,
39
+ multipleLine: true,
39
40
  onChange: handleChange,
40
41
  onFocus: handleFocus,
41
42
  onBlur: handleBlur
42
43
  }));
43
44
  });
44
- export default NameInput;
45
+ export default BoxNameInput;
@@ -1,6 +1,5 @@
1
1
  import _Form from "@alifd/next/es/form";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
- import _Input from "@alifd/next/es/input";
4
3
  import _Field from "@alifd/next/es/field";
5
4
  import _Collapse from "@alifd/next/es/collapse";
6
5
  import React, { useEffect } from "react";
@@ -9,6 +8,7 @@ import GroupIconSelect from "./GroupIconSelect";
9
8
  import GroupExpandStatus from "./GroupExpandStatus";
10
9
  import GroupExpandSetting from "./GroupExpandSetting";
11
10
  import { SPECIAL_CHARACTER_FORM_ITEM_VALIDATE_PROPS, validateSpecialCharacter } from "../../../../../../../utils/SpecialCharacterValidateUtil";
11
+ import NameInput from "../../../common/NameInput";
12
12
  var CollapsePanel = _Collapse.Panel;
13
13
  export default function GroupBasicSetting(props) {
14
14
  var topo = props.topo,
@@ -51,8 +51,9 @@ export default function GroupBasicSetting(props) {
51
51
  label: isCluster ? '集群名称' : '区域名称'
52
52
  }, SPECIAL_CHARACTER_FORM_ITEM_VALIDATE_PROPS, {
53
53
  patternTrigger: "onChange"
54
- }), /*#__PURE__*/React.createElement(_Input, {
54
+ }), /*#__PURE__*/React.createElement(NameInput, {
55
55
  name: "attrObject.name",
56
+ multipleLine: true,
56
57
  maxLength: 30,
57
58
  placeholder: "\u8BF7\u8F93\u5165",
58
59
  onFocus: function onFocus() {
@@ -1,10 +1,10 @@
1
1
  import _Form from "@alifd/next/es/form";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
- import _Input from "@alifd/next/es/input";
4
3
  import _Field from "@alifd/next/es/field";
5
4
  import rlog from '@riil-frontend/component-topology-utils/es/rlog';
6
5
  import React, { useEffect } from 'react';
7
6
  import { SPECIAL_CHARACTER_FORM_ITEM_VALIDATE_PROPS, validateSpecialCharacter } from "../../../../../../utils/SpecialCharacterValidateUtil";
7
+ import NameInput from "../../common/NameInput";
8
8
  export default function BasicSetting(props) {
9
9
  var topo = props.topo,
10
10
  values = props.values,
@@ -43,8 +43,9 @@ export default function BasicSetting(props) {
43
43
  paddingLeft: 32,
44
44
  paddingRight: 16
45
45
  }
46
- }), /*#__PURE__*/React.createElement(_Input, {
46
+ }), /*#__PURE__*/React.createElement(NameInput, {
47
47
  name: "styleMap.label",
48
+ multipleLine: true,
48
49
  maxLength: 30,
49
50
  placeholder: "\u8BF7\u8F93\u5165",
50
51
  onFocus: function onFocus() {
@@ -1,7 +1,7 @@
1
- import _Input from "@alifd/next/es/input";
2
1
  import _extends from "@babel/runtime/helpers/extends";
3
2
  import React, { useEffect, useState } from 'react';
4
- var NameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
3
+ import NameInput from "../../../common/NameInput";
4
+ var NodeNameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
5
5
  var onChange = props.onChange,
6
6
  topo = props.topo;
7
7
 
@@ -33,12 +33,13 @@ var NameInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
33
33
  topo.historyManager.endTransaction();
34
34
  };
35
35
 
36
- return /*#__PURE__*/React.createElement(_Input, _extends({}, props, {
36
+ return /*#__PURE__*/React.createElement(NameInput, _extends({}, props, {
37
37
  ref: ref,
38
38
  value: value,
39
+ multipleLine: true,
39
40
  onChange: handleChange,
40
41
  onFocus: handleFocus,
41
42
  onBlur: handleBlur
42
43
  }));
43
44
  });
44
- export default NameInput;
45
+ export default NodeNameInput;
@@ -37,7 +37,7 @@ export default function useCanvasTheme(props) {
37
37
 
38
38
  useEffect(function () {
39
39
  // 设置
40
- var themeConfig = themeMap[canvasTheme];
40
+ var themeConfig = themeMap[canvasTheme || 'white'];
41
41
 
42
42
  if (graphLoaded && themeConfig) {
43
43
  var _topo$historyManager2;
@@ -22,7 +22,7 @@ import topoFactory from "./topoFactory";
22
22
  import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
23
23
  import SelectionModel from "./SelectionModel"; // eslint-disable-next-line no-undef
24
24
 
25
- var version = typeof "6.0.0-alpha.44" === 'string' ? "6.0.0-alpha.44" : null;
25
+ var version = typeof "6.0.0-alpha.46" === 'string' ? "6.0.0-alpha.46" : null;
26
26
  console.info("\u62D3\u6251\u7248\u672C: " + version);
27
27
  /**
28
28
  * 拓扑显示和编辑
@@ -87,14 +87,18 @@ function ColorPanel(props) {
87
87
  var rgba = "rgba(" + rgb.r + "," + rgb.g + "," + rgb.b + "," + rgb.a + ")";
88
88
 
89
89
  if (data !== prevValue) {
90
- setData(rgba);
91
- onChange({
90
+ setData({
92
91
  hex: prevValue,
93
92
  rgb: rgb
94
- }, 'change');
93
+ });
95
94
  }
96
95
  };
97
96
 
97
+ var pickerBlur = function pickerBlur() {
98
+ onChange(data, 'change');
99
+ onPickerBlur();
100
+ };
101
+
98
102
  var getColor16 = function getColor16(color) {
99
103
  var that = color;
100
104
 
@@ -174,7 +178,7 @@ function ColorPanel(props) {
174
178
  style: {
175
179
  paddingBottom: 0
176
180
  },
177
- onBlur: onPickerBlur,
181
+ onBlur: pickerBlur,
178
182
  onFocus: onPickerFocus
179
183
  }, /*#__PURE__*/_react["default"].createElement(_reactColor.SketchPicker, {
180
184
  color: data // width={230}
@@ -41,6 +41,7 @@
41
41
 
42
42
  .tab-title {
43
43
  margin-top: 3px;
44
+ font-weight: normal;
44
45
  }
45
46
  }
46
47
  }
@@ -33,36 +33,44 @@ function FontColorDropdown(props) {
33
33
  disabled = _useState[0],
34
34
  setDisabled = _useState[1];
35
35
 
36
- var onPickerFocus = function onPickerFocus() {
36
+ var backOpacityChange = function backOpacityChange(value) {
37
37
  topo.historyManager.beginTransaction();
38
- };
39
-
40
- var onPickerBlur = function onPickerBlur() {
41
- topo.historyManager.endTransaction();
42
- };
43
-
44
- var backOpacityChange = function backOpacityChange(value, type) {
45
- if (type === 'select') onPickerFocus();
46
38
  onChange({
47
39
  opacity: value / 100
48
40
  });
49
- if (type === 'select') onPickerBlur();
41
+ topo.historyManager.endTransaction();
42
+ };
43
+
44
+ var colorBackgroundChanges = function colorBackgroundChanges(type, name, value) {
45
+ if (type === 'select') topo.historyManager.beginTransaction();
46
+
47
+ if (name === 'color') {
48
+ onChange({
49
+ color: value
50
+ });
51
+ } else {
52
+ onChange({
53
+ background: value
54
+ });
55
+ }
56
+
57
+ if (type === 'select') topo.historyManager.endTransaction();
50
58
  };
51
59
 
52
60
  var colorChang = function colorChang(value, type) {
53
- if (type === 'select') onPickerFocus();
54
- onChange({
55
- color: value
56
- });
57
- if (type === 'select') onPickerBlur();
61
+ colorBackgroundChanges(type, 'color', value);
58
62
  };
59
63
 
60
- var backgroundChang = function backgroundChang(value) {
61
- onPickerFocus();
62
- onChange({
63
- background: value
64
- });
65
- onPickerBlur();
64
+ var backgroundChang = function backgroundChang(value, type) {
65
+ colorBackgroundChanges(type, 'background', value);
66
+ };
67
+
68
+ var onFocus = function onFocus() {
69
+ topo.historyManager.beginTransaction();
70
+ };
71
+
72
+ var onBlur = function onBlur() {
73
+ topo.historyManager.endTransaction();
66
74
  };
67
75
 
68
76
  var icon = disabled ? /*#__PURE__*/_react["default"].createElement("img", {
@@ -86,8 +94,8 @@ function FontColorDropdown(props) {
86
94
  }
87
95
  }, /*#__PURE__*/_react["default"].createElement(_ColorPanel["default"], {
88
96
  onChange: colorChang,
89
- onPickerFocus: onPickerFocus,
90
- onPickerBlur: onPickerBlur
97
+ onPickerFocus: onFocus,
98
+ onPickerBlur: onBlur
91
99
  }))), /*#__PURE__*/_react["default"].createElement("div", {
92
100
  className: _FontColorButtonModule["default"].backgroundColor
93
101
  }, /*#__PURE__*/_react["default"].createElement("span", null, "\u80CC\u666F\u586B\u5145"), /*#__PURE__*/_react["default"].createElement("div", {
@@ -110,8 +118,8 @@ function FontColorDropdown(props) {
110
118
  }, /*#__PURE__*/_react["default"].createElement(_ColorPanel["default"], {
111
119
  showClear: true,
112
120
  onChange: backgroundChang,
113
- onPickerFocus: onPickerFocus,
114
- onPickerBlur: onPickerBlur
121
+ onPickerFocus: onFocus,
122
+ onPickerBlur: onBlur
115
123
  })))));
116
124
  }
117
125
 
@@ -17,7 +17,7 @@ var _WidgetBox = _interopRequireDefault(require("../WidgetBox"));
17
17
 
18
18
  var _DropdownButton = _interopRequireDefault(require("../components/DropdownButton"));
19
19
 
20
- var _htElementUtils = require("../../../../../../utils/htElementUtils");
20
+ var _htElementDataUtil = require("../../../../../../utils/htElementDataUtil");
21
21
 
22
22
  var _excluded = ["topo", "showLabel"];
23
23
 
@@ -40,7 +40,7 @@ function Layout(props) {
40
40
  selection = _topo$store$useModelS.selection;
41
41
 
42
42
  var setDisabled = function setDisabled(data) {
43
- if (topoShowType == 'layers' && selection.length == 1) {
43
+ if (topoShowType == 'layers' && selection.length == 1 && !(0, _htElementDataUtil.isGroup)(selection[0])) {
44
44
  return data != 'rectangle';
45
45
  } else {
46
46
  return data == 'rectangle';
@@ -61,7 +61,7 @@ function Layout(props) {
61
61
  } // eslint-disable-next-line eqeqeq
62
62
 
63
63
 
64
- if ((0, _htElementUtils.isLayer)(firstElement)) {
64
+ if ((0, _htElementDataUtil.isLayer)(firstElement)) {
65
65
  topo.getHtTopo().layoutLayer(firstElement);
66
66
  }
67
67
  };
@@ -102,15 +102,17 @@ function LayoutWidget(props) {
102
102
  // type为partition且selection.length>=0时可以点击布局, selection[0].className != 'ht.Node'
103
103
  // type为auto且selection.length==0时可以点击布局
104
104
 
105
- var selectionElements = topo.selectionModel.useHtSelection();
105
+ var _topo$store$useModelS2 = topo.store.useModelState('selection'),
106
+ selection = _topo$store$useModelS2.selection;
107
+
106
108
  var topoShowType = topoState.type; // 获取ID以及拓扑类型 // 拓扑类型:auto自由布局,layers分层,partition分区
107
109
 
108
110
  var disabled = (0, _react.useMemo)(function () {
109
111
  return !isLayoutEnabled({
110
112
  topoShowType: topoShowType,
111
- selectionElements: selectionElements
113
+ selection: selection
112
114
  });
113
- }, [topoShowType, selectionElements]);
115
+ }, [topoShowType, selection]);
114
116
  var icon = disabled ? /*#__PURE__*/_react["default"].createElement("img", {
115
117
  src: "/img/topo/editor/toolbar/layout/Disable.svg",
116
118
  alt: ""
@@ -134,19 +136,19 @@ function LayoutWidget(props) {
134
136
 
135
137
  function isLayoutEnabled(props) {
136
138
  var topoShowType = props.topoShowType,
137
- selectionElements = props.selectionElements; // 选中单个区域/集群后,该按钮亮起
139
+ selection = props.selection; // 选中单个区域/集群后,该按钮亮起
138
140
 
139
- if ((0, _htElementUtils.isGroup)(selectionElements[0])) {
141
+ if (selection.length === 1 && (0, _htElementDataUtil.isGroup)(selection[0]) && selection[0].expanded) {
140
142
  return true;
141
143
  } // 分层拓扑选中任意分层时,布局按钮亮起
142
144
 
143
145
 
144
- if (topoShowType === 'layers' && selectionElements.length === 1 && (0, _htElementUtils.isLayer)(selectionElements[0])) {
146
+ if (topoShowType === 'layers' && selection.length === 1 && (0, _htElementDataUtil.isLayer)(selection[0])) {
145
147
  return true;
146
148
  } // 空白拓扑未选中任何资源时,布局按钮亮起
147
149
 
148
150
 
149
- if (topoShowType !== 'layers' && !selectionElements.length) {
151
+ if (topoShowType !== 'layers' && !selection.length) {
150
152
  return true;
151
153
  }
152
154
 
@@ -91,8 +91,8 @@ function NodeAlignWidget(props) {
91
91
  if (nodes.length === 2) {
92
92
  var h = topo.view.topoClient.htTopoClient.getElementsSpace(nodes, 'h')[0];
93
93
  var v = topo.view.topoClient.htTopoClient.getElementsSpace(nodes, 'v')[0];
94
- setLeftInputVal(h * 1 > 0 ? h : 0);
95
- setRightInputVal(v * 1 > 0 ? v : 0);
94
+ setLeftInputVal(Math.round(h * 1 > 0 ? h : 0));
95
+ setRightInputVal(Math.round(v * 1 > 0 ? v : 0));
96
96
  }
97
97
  } // eslint-disable-next-line react-hooks/exhaustive-deps
98
98
 
@@ -1,6 +1,6 @@
1
1
  .leftInput{
2
- width: 100px !important;
3
- margin: 0px 10px 10px 9px;
2
+ width: 106px !important;
3
+ margin: 0px 9px 10px 9px;
4
4
  :global{
5
5
  input{
6
6
  background: url('/img/topo/editor/toolbar/对齐/水平间距_normal.svg')no-repeat 5px center !important;
@@ -16,7 +16,7 @@
16
16
  }
17
17
  }
18
18
  .rightInput{
19
- width: 100px !important;
19
+ width: 106px !important;
20
20
  :global{
21
21
  input{
22
22
  background: url('/img/topo/editor/toolbar/对齐/垂直间距 _normal.svg')no-repeat 5px center !important;