@riil-frontend/component-topology 6.0.0-alpha.8 → 6.0.0-alpha.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.
Files changed (53) hide show
  1. package/build/1.js +2 -2
  2. package/build/2.js +1 -1
  3. package/build/index.css +1 -1
  4. package/build/index.js +21 -21
  5. package/es/core/common/icons/useIcons.js +7 -1
  6. package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +13 -18
  7. package/es/core/editor/components/Toolbar/EditorToolbar.js +16 -9
  8. package/es/core/editor/components/Toolbar/buttons.js +20 -18
  9. package/es/core/editor/components/Toolbar/widgets/AddResourceButton.js +2 -2
  10. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +25 -8
  11. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +1 -3
  12. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +14 -5
  13. package/es/core/editor/components/Toolbar/widgets/HistoryRedoButton.js +1 -1
  14. package/es/core/editor/components/Toolbar/widgets/HistoryUndoButton.js +2 -2
  15. package/es/core/editor/components/Toolbar/widgets/IconSelect/IconSelect.js +109 -0
  16. package/es/core/editor/components/Toolbar/widgets/IconSelect/constant.js +64 -0
  17. package/es/core/editor/components/Toolbar/widgets/IconSelect/index.js +101 -0
  18. package/es/core/editor/components/Toolbar/widgets/IconSelect/index.module.scss +151 -0
  19. package/es/core/editor/components/Toolbar/widgets/IconSelect/popUpContent.js +50 -0
  20. package/es/core/editor/components/Toolbar/widgets/NodeImageButton/BoxBackgroundSetting.js +14 -4
  21. package/es/core/editor/components/Toolbar/widgets/NodeImageButton/NodeImageButton.js +36 -6
  22. package/es/core/editor/components/Toolbar/widgets/NodeSizeButton/NodeSizeButton.js +87 -8
  23. package/es/core/editor/components/settings/common/NodeSizeInput/NodeSizeInput.js +3 -3
  24. package/es/core/editor/components/settings/common/SizeInput/NodeSizeInput.js +10 -6
  25. package/es/core/editor/components/settings/common/SizeInput/NodeSizeNumberPicker.js +7 -6
  26. package/es/core/editor/components/settings/propertyViews/multipleElements/BatchSetNodeSize/BatchSetNodeSize.js +8 -9
  27. package/es/core/editor/components/settings/propertyViews/view/BatchSetNodeSize.js +9 -6
  28. package/es/core/models/TopoApp.js +1 -1
  29. package/lib/core/common/icons/useIcons.js +7 -1
  30. package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +13 -18
  31. package/lib/core/editor/components/Toolbar/EditorToolbar.js +14 -7
  32. package/lib/core/editor/components/Toolbar/buttons.js +21 -20
  33. package/lib/core/editor/components/Toolbar/widgets/AddResourceButton.js +2 -2
  34. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +25 -8
  35. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +1 -3
  36. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +15 -5
  37. package/lib/core/editor/components/Toolbar/widgets/HistoryRedoButton.js +1 -1
  38. package/lib/core/editor/components/Toolbar/widgets/HistoryUndoButton.js +2 -2
  39. package/lib/core/editor/components/Toolbar/widgets/IconSelect/IconSelect.js +126 -0
  40. package/lib/core/editor/components/Toolbar/widgets/IconSelect/constant.js +69 -0
  41. package/lib/core/editor/components/Toolbar/widgets/IconSelect/index.js +117 -0
  42. package/lib/core/editor/components/Toolbar/widgets/IconSelect/index.module.scss +151 -0
  43. package/lib/core/editor/components/Toolbar/widgets/IconSelect/popUpContent.js +62 -0
  44. package/lib/core/editor/components/Toolbar/widgets/NodeImageButton/BoxBackgroundSetting.js +20 -4
  45. package/lib/core/editor/components/Toolbar/widgets/NodeImageButton/NodeImageButton.js +35 -5
  46. package/lib/core/editor/components/Toolbar/widgets/NodeSizeButton/NodeSizeButton.js +87 -7
  47. package/lib/core/editor/components/settings/common/NodeSizeInput/NodeSizeInput.js +2 -2
  48. package/lib/core/editor/components/settings/common/SizeInput/NodeSizeInput.js +11 -7
  49. package/lib/core/editor/components/settings/common/SizeInput/NodeSizeNumberPicker.js +6 -6
  50. package/lib/core/editor/components/settings/propertyViews/multipleElements/BatchSetNodeSize/BatchSetNodeSize.js +6 -8
  51. package/lib/core/editor/components/settings/propertyViews/view/BatchSetNodeSize.js +7 -5
  52. package/lib/core/models/TopoApp.js +1 -1
  53. package/package.json +2 -2
@@ -11,7 +11,10 @@ function useCustomIcons(topo) {
11
11
  export function useNodeIcons(topo) {
12
12
  var customIcons = useCustomIcons(topo);
13
13
  var groups = [{
14
- name: '默认',
14
+ name: '资源图片',
15
+ icons: []
16
+ }, {
17
+ name: '基础图片',
15
18
  icons: getNodeDefaultIcons(topo)
16
19
  }];
17
20
 
@@ -27,6 +30,9 @@ export function useNodeIcons(topo) {
27
30
  export function useGroupIcons(topo) {
28
31
  var customIcons = useCustomIcons(topo);
29
32
  var groups = [{
33
+ name: '资源图片',
34
+ icons: []
35
+ }, {
30
36
  name: '默认',
31
37
  icons: getGroupDefaultIcons(topo)
32
38
  }];
@@ -2,36 +2,31 @@ import _Tag from "@alifd/next/es/tag";
2
2
  import React, { useState } from 'react';
3
3
  import styles from "./CanvasPanel.module.scss";
4
4
  var CANVAS_TOGGLE = [{
5
- value: 0,
5
+ value: 'white',
6
6
  label: '白色',
7
- color: '#FFFFFF',
8
- isSystem: 1
7
+ color: '#FFFFFF'
9
8
  }, {
10
- value: 1,
9
+ value: 'blue',
11
10
  label: '蓝色',
12
- color: '#F9FBFF',
13
- isSystem: 0
11
+ color: '#F9FBFF'
14
12
  }, {
15
- value: 2,
13
+ value: 'yellow',
16
14
  label: '黄色',
17
- color: '#FFFDE6',
18
- isSystem: 0
15
+ color: '#FFFDE6'
19
16
  }, {
20
- value: 3,
17
+ value: 'green',
21
18
  label: '绿色',
22
- color: '#EAFFE8',
23
- isSystem: 0
19
+ color: '#EAFFE8'
24
20
  }, {
25
- value: 4,
21
+ value: 'dark',
26
22
  label: '深色',
27
- color: '#031425',
28
- isSystem: 0
23
+ color: '#031425'
29
24
  }];
30
25
  export default function CanvasPanel(props) {
31
26
  var selected = props.selected,
32
27
  onSelect = props.onSelect;
33
28
 
34
- var _useState = useState(0),
29
+ var _useState = useState('white'),
35
30
  selectVal = _useState[0],
36
31
  setSelectVal = _useState[1];
37
32
 
@@ -39,13 +34,13 @@ export default function CanvasPanel(props) {
39
34
  className: styles.canvasToggle
40
35
  }, CANVAS_TOGGLE.map(function (item, index) {
41
36
  return /*#__PURE__*/React.createElement("div", {
42
- className: styles.canvas
37
+ className: styles.canvas,
38
+ key: index
43
39
  }, /*#__PURE__*/React.createElement(_Tag.Selectable, {
44
40
  className: styles.tag,
45
41
  style: {
46
42
  background: item.color
47
43
  },
48
- key: item.value,
49
44
  checked: selected ? selected === item.value : selectVal === item.value,
50
45
  onChange: function onChange(checked) {
51
46
  setSelectVal(item.value);
@@ -1,29 +1,36 @@
1
1
  import _Button from "@alifd/next/es/button";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import classNames from 'classnames';
4
- import React, { useState } from 'react';
5
- import buttons from "./buttons";
4
+ import React, { useMemo, useState } from 'react';
5
+ import getButtons from "./buttons";
6
6
  import Toolbar from "./Toolbar";
7
7
  import styles from "./Toolbar.module.scss";
8
8
 
9
9
  function EditorToolbar(props) {
10
- var _classNames;
10
+ var _topo$viewProps, _topo$viewProps$topoC, _classNames;
11
+
12
+ var topo = props.topo;
11
13
 
12
14
  var _useState = useState(true),
13
15
  expanded = _useState[0],
14
16
  setExpanded = _useState[1];
15
17
 
16
- return /*#__PURE__*/React.createElement("div", {
17
- className: classNames(styles.toolbarWrap, (_classNames = {}, _classNames[styles.normal] = expanded, _classNames[styles.expanded] = !expanded, _classNames))
18
- }, /*#__PURE__*/React.createElement("div", {
19
- className: styles.content
20
- }, /*#__PURE__*/React.createElement(Toolbar, null, buttons.map(function (ToolbarButton, index) {
18
+ var isNetworkTopo = (_topo$viewProps = topo.viewProps) === null || _topo$viewProps === void 0 ? void 0 : (_topo$viewProps$topoC = _topo$viewProps.topoContext) === null || _topo$viewProps$topoC === void 0 ? void 0 : _topo$viewProps$topoC.isNetworkTopo;
19
+ var buttons = useMemo(function () {
20
+ return getButtons(isNetworkTopo);
21
+ }, [isNetworkTopo]);
22
+ var buttonInstances = buttons.map(function (ToolbarButton, index) {
21
23
  return /*#__PURE__*/React.createElement(ToolbarButton, _extends({
22
24
  key: index
23
25
  }, props, {
24
26
  showLabel: expanded
25
27
  }));
26
- }))), /*#__PURE__*/React.createElement("div", {
28
+ });
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ className: classNames(styles.toolbarWrap, (_classNames = {}, _classNames[styles.normal] = expanded, _classNames[styles.expanded] = !expanded, _classNames))
31
+ }, /*#__PURE__*/React.createElement("div", {
32
+ className: styles.content
33
+ }, /*#__PURE__*/React.createElement(Toolbar, null, buttonInstances)), /*#__PURE__*/React.createElement("div", {
27
34
  className: styles.right
28
35
  }, /*#__PURE__*/React.createElement(_Button, {
29
36
  type: "normal",
@@ -16,21 +16,23 @@ import BoxBackgroundButton from "./widgets/BoxBackgroundButton";
16
16
  import EdgeColorButton from "./widgets/EdgeColorButton";
17
17
  import NodeImageButton from "./widgets/NodeImageButton";
18
18
  import NodeSizeButton from "./widgets/NodeSizeButton";
19
- export default [AddResourceButton, // 添加资源
20
- Divider, CanvasSelectWidget, // 选择
21
- CanvasMoveWidget, // 移动
22
- Divider, HistoryUndoButton, // 撤销
23
- HistoryRedoButton, // 恢复
24
- Divider, FontFamilyWidget, // 字体
25
- FontSizeWidget, // 字号
26
- FontStyleButton, // 文字样式
27
- FontColorButton, // 文字颜色
28
- Divider, BoxBackgroundButton, // 框背景
29
- Divider, EdgeColorButton, // 线条颜色
30
- EdgeTypeButton, // 线形
31
- Divider, NodeImageButton, // 替换图片
32
- NodeSizeButton, // 图片尺寸
33
- Divider, Layout, // 布局方式
34
- NodeAlignWidget, // 对齐方式
35
- SearchWidget // 搜索
36
- ];
19
+ export default function getButtons(isNetworkTopo) {
20
+ return [].concat(isNetworkTopo ? [AddResourceButton, // 添加资源
21
+ Divider] : [], [CanvasSelectWidget, // 选择
22
+ CanvasMoveWidget, // 移动
23
+ Divider], isNetworkTopo ? [HistoryUndoButton, // 撤销
24
+ // HistoryRedoButton, // 恢复
25
+ Divider] : [], [FontFamilyWidget, // 字体
26
+ FontSizeWidget, // 字号
27
+ FontStyleButton, // 文字样式
28
+ FontColorButton, // 文字颜色
29
+ Divider, BoxBackgroundButton, // 框背景
30
+ Divider, EdgeColorButton, // 线条颜色
31
+ EdgeTypeButton, // 线形
32
+ Divider, NodeImageButton, // 替换图片
33
+ NodeSizeButton, // 图片尺寸
34
+ Divider, Layout, // 布局方式
35
+ NodeAlignWidget, // 对齐方式
36
+ SearchWidget // 搜索
37
+ ]);
38
+ }
@@ -53,7 +53,7 @@ function AddResourceButton(props) {
53
53
  }
54
54
  };
55
55
 
56
- return /*#__PURE__*/React.createElement(WidgetBox, {
56
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WidgetBox, {
57
57
  label: "\u6DFB\u52A0\u8D44\u6E90",
58
58
  tooltip: "\u6DFB\u52A0\u8D44\u6E90",
59
59
  showLabel: showLabel
@@ -62,7 +62,7 @@ function AddResourceButton(props) {
62
62
  }, /*#__PURE__*/React.createElement("img", {
63
63
  src: "/img/topo/editor/toolbar/add/Normal.svg",
64
64
  alt: ""
65
- })), addType === 'layer' && /*#__PURE__*/React.createElement(LayerAddResourceDrawer, {
65
+ }))), addType === 'layer' && /*#__PURE__*/React.createElement(LayerAddResourceDrawer, {
66
66
  layer: selection[0],
67
67
  editorProps: editorProps,
68
68
  layerAddResource: layerAddResource
@@ -6,22 +6,39 @@ import styles from "./EdgeType.module.scss";
6
6
  import LineType from "./LineType";
7
7
  var FormItem = _Form.Item;
8
8
  var Option = _Select.Option;
9
- var START_END_TYPE_OPTIONS = [{
9
+ var START_TYPE_OPTIONS = [{
10
10
  value: 'nil',
11
11
  label: '无',
12
12
  icon: 'topo_startEndPoint_icon_nothing'
13
13
  }, {
14
14
  value: 'hollowCrcial',
15
15
  label: '空心圆',
16
- icon: 'topo_startEndPoint_icon_hollow_cricle'
16
+ icon: 'topo_startPoint_icon_hollow_cricle'
17
17
  }, {
18
18
  value: 'solidCricle',
19
19
  label: '实心圆',
20
- icon: 'topo_startEndPoint_icon_solid_cricle'
20
+ icon: 'topo_startPoint_icon_solid_cricle'
21
21
  }, {
22
22
  value: 'arrowPoint',
23
23
  label: '箭头',
24
- icon: 'topo_startEndPoint_icon_arrow'
24
+ icon: 'topo_startPoint_icon_arrow'
25
+ }];
26
+ var END_TYPE_OPTIONS = [{
27
+ value: 'nil',
28
+ label: '无',
29
+ icon: 'topo_startEndPoint_icon_nothing'
30
+ }, {
31
+ value: 'hollowCrcial',
32
+ label: '空心圆',
33
+ icon: 'topo_endPoint_icon_hollow_cricle'
34
+ }, {
35
+ value: 'solidCricle',
36
+ label: '实心圆',
37
+ icon: 'topo_endPoint_icon_solid_cricle'
38
+ }, {
39
+ value: 'arrowPoint',
40
+ label: '箭头',
41
+ icon: 'topo_endPoint_icon_arrow'
25
42
  }];
26
43
  var LINE_MOLD_OPTIONS = [{
27
44
  value: 'solidLine',
@@ -49,7 +66,7 @@ function EdgeType(props) {
49
66
  values: {
50
67
  startPoint: 'nil',
51
68
  endPoint: 'nil',
52
- type: null
69
+ type: 'solidLine'
53
70
  },
54
71
  onChange: function onChange(name, value) {
55
72
  if (['startPoint', 'endPoint'].includes(name) && value === 'nil') {
@@ -77,7 +94,7 @@ function EdgeType(props) {
77
94
  return trigger.parentNode;
78
95
  }
79
96
  }
80
- }, START_END_TYPE_OPTIONS.map(function (item, index, array) {
97
+ }, START_TYPE_OPTIONS.map(function (item, index) {
81
98
  return /*#__PURE__*/React.createElement(Option, {
82
99
  value: item.value,
83
100
  key: index,
@@ -97,7 +114,7 @@ function EdgeType(props) {
97
114
  return trigger.parentNode;
98
115
  }
99
116
  }
100
- }, START_END_TYPE_OPTIONS.map(function (item, index, array) {
117
+ }, END_TYPE_OPTIONS.map(function (item, index) {
101
118
  return /*#__PURE__*/React.createElement(Option, {
102
119
  value: item.value,
103
120
  key: index,
@@ -118,7 +135,7 @@ function EdgeType(props) {
118
135
  }
119
136
  },
120
137
  placeholder: ""
121
- }, LINE_MOLD_OPTIONS.map(function (item, index, array) {
138
+ }, LINE_MOLD_OPTIONS.map(function (item, index) {
122
139
  return /*#__PURE__*/React.createElement(Option, {
123
140
  value: item.value,
124
141
  key: index,
@@ -38,9 +38,7 @@
38
38
  }
39
39
  .#{$css-prefix}input.#{$css-prefix}medium .#{$css-prefix}input-text-field {
40
40
  line-height: calc(28px - 10px * 2);
41
- }
42
- .#{$css-prefix}select-trigger-search {
43
- height: 12px;
41
+ padding: 0 7px;
44
42
  }
45
43
  }
46
44
  }
@@ -1,6 +1,8 @@
1
1
  import _Button from "@alifd/next/es/button";
2
+ import _Balloon from "@alifd/next/es/balloon";
2
3
  import React, { useState } from 'react';
3
4
  import styles from "./LineType.module.scss";
5
+ var Tooltip = _Balloon.Tooltip;
4
6
  var LINE_TYPE_OPTIONS = [{
5
7
  value: 'boundary',
6
8
  label: '直线',
@@ -25,12 +27,9 @@ var LINE_TYPE_OPTIONS = [{
25
27
 
26
28
  function LineType(props) {
27
29
  var onChange = props.onChange;
28
- return /*#__PURE__*/React.createElement("div", {
29
- className: styles.lineType
30
- }, LINE_TYPE_OPTIONS.map(function (item, index, array) {
30
+
31
+ function lineButton(item) {
31
32
  return /*#__PURE__*/React.createElement(_Button, {
32
- key: index,
33
- title: item.label,
34
33
  className: "" + styles.redioBtn,
35
34
  onClick: function onClick() {
36
35
  onChange(item.value);
@@ -40,6 +39,16 @@ function LineType(props) {
40
39
  alt: "",
41
40
  className: styles.iconImg
42
41
  }));
42
+ }
43
+
44
+ return /*#__PURE__*/React.createElement("div", {
45
+ className: styles.lineType
46
+ }, LINE_TYPE_OPTIONS.map(function (item, index) {
47
+ return /*#__PURE__*/React.createElement(Tooltip, {
48
+ trigger: lineButton(item),
49
+ align: "br",
50
+ key: index
51
+ }, item.label);
43
52
  }));
44
53
  }
45
54
 
@@ -15,7 +15,7 @@ function HistoryRedoButton(props) {
15
15
  tooltip: "\u6062\u590D",
16
16
  showLabel: showLabel
17
17
  }, /*#__PURE__*/React.createElement(ButtonBox, null, /*#__PURE__*/React.createElement("img", {
18
- src: "/img/topo/editor/toolbar/redo/" + (disabled ? 'Disable' : 'Normal') + ".svg",
18
+ src: "/img/topo/editor/toolbar/undo/" + (disabled ? 'Disable' : 'Normal') + ".svg",
19
19
  alt: ""
20
20
  })));
21
21
  }
@@ -14,7 +14,7 @@ function HistoryUndoButton(props) {
14
14
  return /*#__PURE__*/React.createElement(WidgetBox, {
15
15
  disabled: disabled,
16
16
  label: "\u64A4\u9500",
17
- tooltip: "\u64A4\u9500",
17
+ tooltip: disabled ? '无法撤销' : '撤销(Ctrl/ ⌘+Z)',
18
18
  showLabel: showLabel
19
19
  }, /*#__PURE__*/React.createElement(ButtonBox, {
20
20
  disabled: disabled,
@@ -22,7 +22,7 @@ function HistoryUndoButton(props) {
22
22
  topo.historyManager.undo();
23
23
  }
24
24
  }, /*#__PURE__*/React.createElement("img", {
25
- src: "/img/topo/editor/toolbar/undo/" + (disabled ? 'Disable' : 'Normal') + ".svg",
25
+ src: "/img/topo/editor/toolbar/redo/" + (disabled ? 'Disable' : 'Normal') + ".svg",
26
26
  alt: ""
27
27
  })));
28
28
  }
@@ -0,0 +1,109 @@
1
+ import _Select from "@alifd/next/es/select";
2
+ import React, { useState, useEffect, useImperativeHandle } from 'react';
3
+ import styles from "./index.module.scss";
4
+ import PopUpContent from "./popUpContent";
5
+
6
+ var TopoIconSelect = function TopoIconSelect(props, ref) {
7
+ // 传入参数
8
+ var value = props.value,
9
+ iconList = props.iconList,
10
+ onChange = props.onChange;
11
+
12
+ var _useState = useState(value),
13
+ valueData = _useState[0],
14
+ setValue = _useState[1];
15
+
16
+ var _useState2 = useState(),
17
+ selectItem = _useState2[0],
18
+ setSelect = _useState2[1];
19
+
20
+ var _useState3 = useState(false),
21
+ visible = _useState3[0],
22
+ setVisible = _useState3[1];
23
+
24
+ useEffect(function () {
25
+ if (value) {
26
+ for (var i = 0; i < iconList.length; i++) {
27
+ var icons = iconList[i].icons;
28
+ var flag = false;
29
+
30
+ for (var m = 0; m < icons.length; m++) {
31
+ if (value === icons[m].id) {
32
+ flag = true;
33
+ setSelect(icons[m]);
34
+ break;
35
+ }
36
+ }
37
+
38
+ if (flag) {
39
+ break;
40
+ }
41
+ }
42
+ }
43
+ }, [value]);
44
+ useImperativeHandle(ref, function () {
45
+ return {
46
+ getSelectData: getSelectData
47
+ };
48
+ });
49
+
50
+ var handleChange = function handleChange(v) {
51
+ console.log('handleChange: ', v);
52
+
53
+ if (typeof onChange === 'function') {
54
+ onChange(v.id);
55
+ }
56
+
57
+ setSelect(v);
58
+ setValue(v.id);
59
+ setVisible(false);
60
+ };
61
+
62
+ var getSelectData = function getSelectData() {
63
+ return valueData;
64
+ };
65
+
66
+ var valueRender = function valueRender(v) {
67
+ return selectItem ? /*#__PURE__*/React.createElement("span", {
68
+ className: styles.selected
69
+ }, /*#__PURE__*/React.createElement("div", {
70
+ className: styles.iconImgWrapper
71
+ }, /*#__PURE__*/React.createElement("img", {
72
+ className: styles.iconImg,
73
+ alt: "",
74
+ src: selectItem === null || selectItem === void 0 ? void 0 : selectItem.url
75
+ })), /*#__PURE__*/React.createElement("span", {
76
+ className: styles.icontitle
77
+ }, selectItem === null || selectItem === void 0 ? void 0 : selectItem.name)) : null;
78
+ };
79
+
80
+ var onVisibleChange = function onVisibleChange(v) {
81
+ setVisible(v);
82
+ };
83
+
84
+ var popupContent = /*#__PURE__*/React.createElement(PopUpContent, {
85
+ iconList: iconList,
86
+ selectedId: selectItem === null || selectItem === void 0 ? void 0 : selectItem.id,
87
+ onChange: handleChange
88
+ });
89
+ var popupProps = {
90
+ triggerClickKeycode: [13, 32, 40] // space, enter, down-arrow
91
+
92
+ };
93
+ return /*#__PURE__*/React.createElement("div", {
94
+ className: styles.TopoIconSelect
95
+ }, /*#__PURE__*/React.createElement(_Select, {
96
+ placeholder: "\u8BF7\u9009\u62E9",
97
+ visible: visible,
98
+ className: styles.iconSelect,
99
+ onVisibleChange: onVisibleChange,
100
+ value: valueData,
101
+ valueRender: valueRender,
102
+ dataSource: iconList,
103
+ onChange: handleChange,
104
+ popupProps: popupProps,
105
+ popupContent: popupContent
106
+ }));
107
+ };
108
+
109
+ export default /*#__PURE__*/React.forwardRef(TopoIconSelect);
@@ -0,0 +1,64 @@
1
+ export var iconList = [{
2
+ id: '1',
3
+ name: '图片库1',
4
+ icons: [{
5
+ id: '001',
6
+ name: '图片一',
7
+ url: '/img/model/switch.svg',
8
+ icon: 'switch'
9
+ }, {
10
+ id: '002',
11
+ name: '图片二',
12
+ url: '/img/model/backupOnError.svg',
13
+ icon: 'res_terminal'
14
+ }, {
15
+ id: '003',
16
+ name: '图片三',
17
+ url: '/img/model/linuxServer.svg',
18
+ icon: 'res_linux'
19
+ }, {
20
+ id: '004',
21
+ name: '图片一',
22
+ url: '/img/model/switch.svg',
23
+ icon: 'switch'
24
+ }, {
25
+ id: '005',
26
+ name: '图片二',
27
+ url: '/img/model/backupOnError.svg',
28
+ icon: 'res_terminal'
29
+ }, {
30
+ id: '005',
31
+ name: '图片三',
32
+ url: '/img/model/linuxServer.svg',
33
+ icon: 'res_linux'
34
+ }, {
35
+ id: '006',
36
+ name: '图片一',
37
+ url: '/img/model/switch.svg',
38
+ icon: 'switch'
39
+ }, {
40
+ id: '007',
41
+ name: '图片二',
42
+ url: '/img/model/backupOnError.svg',
43
+ icon: 'res_terminal'
44
+ }, {
45
+ id: '008',
46
+ name: '图片三',
47
+ url: '/img/model/linuxServer.svg',
48
+ icon: 'res_linux'
49
+ }]
50
+ }, {
51
+ id: '2',
52
+ name: '图片库2',
53
+ icons: [{
54
+ id: '004',
55
+ name: '图片四',
56
+ url: '/img/model/tree_child.svg',
57
+ icon: 'tree_child'
58
+ }, {
59
+ id: '005',
60
+ name: '图片五',
61
+ url: '/img/model/commonNetwork.svg',
62
+ icon: 'res_storage'
63
+ }]
64
+ }];
@@ -0,0 +1,101 @@
1
+ import React, { useState, useEffect, useImperativeHandle } from 'react';
2
+ import styles from "./index.module.scss";
3
+ import PopUpContent from "./popUpContent";
4
+
5
+ var TopoIconSelect = function TopoIconSelect(props, ref) {
6
+ // 传入参数
7
+ var value = props.value,
8
+ iconList = props.iconList,
9
+ onChange = props.onChange;
10
+
11
+ var _useState = useState(value),
12
+ valueData = _useState[0],
13
+ setValue = _useState[1];
14
+
15
+ var _useState2 = useState(),
16
+ selectItem = _useState2[0],
17
+ setSelect = _useState2[1];
18
+
19
+ var _useState3 = useState(false),
20
+ visible = _useState3[0],
21
+ setVisible = _useState3[1];
22
+
23
+ useEffect(function () {
24
+ if (value) {
25
+ for (var i = 0; i < iconList.length; i++) {
26
+ var icons = iconList[i].icons;
27
+ var flag = false;
28
+
29
+ for (var m = 0; m < icons.length; m++) {
30
+ if (value === icons[m].id) {
31
+ flag = true;
32
+ setSelect(icons[m]);
33
+ break;
34
+ }
35
+ }
36
+
37
+ if (flag) {
38
+ break;
39
+ }
40
+ }
41
+ }
42
+ }, [value]);
43
+ useImperativeHandle(ref, function () {
44
+ return {
45
+ getSelectData: getSelectData
46
+ };
47
+ });
48
+
49
+ var handleChange = function handleChange(v) {
50
+ console.log('handleChange: ', v);
51
+
52
+ if (typeof onChange === 'function') {
53
+ onChange(v.id);
54
+ }
55
+
56
+ setSelect(v);
57
+ setValue(v.id);
58
+ setVisible(false);
59
+ };
60
+
61
+ var getSelectData = function getSelectData() {
62
+ return valueData;
63
+ };
64
+
65
+ var valueRender = function valueRender(v) {
66
+ return selectItem ? /*#__PURE__*/React.createElement("span", {
67
+ className: styles.selected
68
+ }, /*#__PURE__*/React.createElement("div", {
69
+ className: styles.iconImgWrapper
70
+ }, /*#__PURE__*/React.createElement("img", {
71
+ className: styles.iconImg,
72
+ alt: "",
73
+ src: selectItem === null || selectItem === void 0 ? void 0 : selectItem.url
74
+ })), /*#__PURE__*/React.createElement("span", {
75
+ className: styles.icontitle
76
+ }, selectItem === null || selectItem === void 0 ? void 0 : selectItem.name)) : null;
77
+ };
78
+
79
+ var onVisibleChange = function onVisibleChange(v) {
80
+ setVisible(v);
81
+ };
82
+
83
+ var popupContent = /*#__PURE__*/React.createElement(PopUpContent, {
84
+ iconList: iconList,
85
+ selectedId: selectItem === null || selectItem === void 0 ? void 0 : selectItem.id,
86
+ onChange: handleChange
87
+ });
88
+ var popupProps = {
89
+ triggerClickKeycode: [13, 32, 40] // space, enter, down-arrow
90
+
91
+ };
92
+ return /*#__PURE__*/React.createElement("div", {
93
+ className: styles.TopoIconSelect
94
+ }, /*#__PURE__*/React.createElement(PopUpContent, {
95
+ iconList: iconList,
96
+ selectedId: selectItem === null || selectItem === void 0 ? void 0 : selectItem.id,
97
+ onChange: handleChange
98
+ }));
99
+ };
100
+
101
+ export default /*#__PURE__*/React.forwardRef(TopoIconSelect);