@byai/topology
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -5,2 +5,16 @@ # Changelog | ||
## [1.8.0](https://github.com/byai/topology/compare/v1.7.0...v1.8.0) (2023-11-07) | ||
### Features | ||
* add autoLayoutForBoxSelection computeLayout logic ([06cbd7f](https://github.com/byai/topology/commit/06cbd7f86a02c2dcac2195cf3f4626cecfc5b88f)) | ||
* add selected autoLayout ([8f17c10](https://github.com/byai/topology/commit/8f17c10a67110217ce5fedefb99bbdfed5256a22)) | ||
* compute LR layout ([4bc928b](https://github.com/byai/topology/commit/4bc928bd9a1e9055d8165d27b749c14c85a67f68)) | ||
### Bug Fixes | ||
* update word ([4be67ec](https://github.com/byai/topology/commit/4be67ec4773d6290b3edbb8e42dbec33f28b2bec)) | ||
## [1.7.0](https://github.com/byai/topology/compare/v1.6.2...v1.7.0) (2023-10-23) | ||
@@ -7,0 +21,0 @@ |
import React, { PureComponent } from 'react'; | ||
import './index.less'; | ||
export interface ISelectionProps { | ||
ref?: any; | ||
xPos?: string; | ||
@@ -12,3 +13,3 @@ yPos?: string; | ||
} | ||
interface ISelectionState { | ||
export interface ISelectionState { | ||
minX: number; | ||
@@ -15,0 +16,0 @@ minY: number; |
@@ -62,4 +62,4 @@ var __extends = (this && this.__extends) || (function () { | ||
Selection.prototype.render = function () { | ||
var visible = this.props.visible; | ||
var _a = this.state, minX = _a.minX, minY = _a.minY, width = _a.width, height = _a.height; | ||
var _a = this.props, visible = _a.visible, ref = _a.ref; | ||
var _b = this.state, minX = _b.minX, minY = _b.minY, width = _b.width, height = _b.height; | ||
return (React.createElement("div", { className: classNames('byai-topology-selection', { | ||
@@ -69,3 +69,3 @@ visible: visible | ||
left: "".concat(minX, "px"), top: "".concat(minY, "px"), width: "".concat(width, "px"), height: "".concat(height, "px") | ||
} }, this.props.toolVisible && this.props.renderTool | ||
}, ref: ref }, this.props.toolVisible && this.props.renderTool | ||
&& (React.createElement("div", { key: "box-selection", ref: function () { | ||
@@ -72,0 +72,0 @@ // TODO: 还有点bug, 悬浮到其他节点时会触发 |
@@ -5,2 +5,3 @@ import React, { HTMLAttributes } from 'react'; | ||
import { IPosition, ITopologyNode, ITopologyLine, IWrapperOptions, ITopologyData, ITopologyContext, ValuesOf, ChangeType } from '../../declare'; | ||
import { DagreDirection } from '../../utils'; | ||
import './index.less'; | ||
@@ -10,2 +11,3 @@ export interface AutoLayoutOptions { | ||
resultProcess?: (data: ITopologyData) => ITopologyData; | ||
rankDir?: DagreDirection; | ||
} | ||
@@ -107,2 +109,3 @@ export interface ITopologyProps { | ||
hoverThreshold: number; | ||
boxSelectionRef: any; | ||
constructor(props: ITopologyProps); | ||
@@ -131,2 +134,4 @@ componentWillMount(): void; | ||
clearSelectData: (updated?: boolean) => void; | ||
mergeArrays: (data: any, selectData: any) => any[]; | ||
autoLayoutForBoxSelection: (options?: AutoLayoutOptions) => void; | ||
autoLayout: (options?: AutoLayoutOptions) => void; | ||
@@ -133,0 +138,0 @@ listenerWheel: (event: any) => void; |
import { ITopologyData, ITopologyNode } from '../declare'; | ||
import { DagreDirection } from '.'; | ||
import { ISelectionState } from '../components/selection'; | ||
type SortChilren = (parent: ITopologyNode, childrenList: ITopologyNode[]) => ITopologyNode[]; | ||
interface LayoutOptions { | ||
sortChildren?: SortChilren; | ||
boxSelectionBoundary?: ISelectionState; | ||
rankDir?: DagreDirection; | ||
} | ||
@@ -6,0 +10,0 @@ declare function computeLayout(data: ITopologyData, options: LayoutOptions): { |
@@ -17,3 +17,5 @@ var __assign = (this && this.__assign) || function () { | ||
console.log(options); | ||
var layoutGraph = new Graph(); | ||
var layoutGraph = new Graph({ | ||
rankDir: options === null || options === void 0 ? void 0 : options.rankDir | ||
}); | ||
layoutGraph.setNodeList(data.nodes.map(function (node) { | ||
@@ -40,7 +42,14 @@ var nodeSize = getNodeSize(node.id); | ||
var topOffset = containerSize.height / 2; | ||
var offsetX = 0; | ||
var offsetY = 0; | ||
if (options === null || options === void 0 ? void 0 : options.boxSelectionBoundary) { | ||
var _a = (options === null || options === void 0 ? void 0 : options.boxSelectionBoundary) || {}, minX = _a.minX, minY = _a.minY, boxWidth = _a.width, boxHeight = _a.height; | ||
offsetX = config.canvas.width / 2 - minX - boxWidth / 2; | ||
offsetY = config.canvas.height / 2 - minY - boxHeight / 2; | ||
} | ||
return data.nodes.map(function (node) { | ||
var infoPos = nodeMap.get(node.id); | ||
var newPosition = { | ||
x: config.canvas.width / 2 + infoPos.x - leftOffset, | ||
y: config.canvas.height / 2 + infoPos.y - topOffset, | ||
x: config.canvas.width / 2 + infoPos.x - leftOffset - offsetX, | ||
y: config.canvas.height / 2 + infoPos.y - topOffset - offsetY, | ||
}; | ||
@@ -47,0 +56,0 @@ return __assign(__assign({}, node), { position: newPosition }); |
{ | ||
"name": "@byai/topology", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "拓扑图组件", | ||
@@ -5,0 +5,0 @@ "bugs": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443824
5513