@logicflow/core 2.0.0-beta.0 → 2.0.0-beta.1
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/.turbo/turbo-build$colon$dev.log +2 -2
- package/.turbo/turbo-build.log +15 -21
- package/dist/index.min.js +26 -0
- package/dist/index.min.js.map +1 -0
- package/es/model/edge/BaseEdgeModel.js.map +1 -1
- package/es/options.d.ts +5 -11
- package/es/options.js +1 -31
- package/es/options.js.map +1 -1
- package/es/view/Graph.js +2 -2
- package/es/view/Graph.js.map +1 -1
- package/es/view/overlay/Grid.d.ts +35 -20
- package/es/view/overlay/Grid.js +35 -26
- package/es/view/overlay/Grid.js.map +1 -1
- package/lib/model/edge/BaseEdgeModel.js.map +1 -1
- package/lib/options.d.ts +5 -11
- package/lib/options.js +1 -31
- package/lib/options.js.map +1 -1
- package/lib/view/Graph.js +2 -2
- package/lib/view/Graph.js.map +1 -1
- package/lib/view/overlay/Grid.d.ts +35 -20
- package/lib/view/overlay/Grid.js +35 -26
- package/lib/view/overlay/Grid.js.map +1 -1
- package/package.json +4 -4
- package/src/model/edge/BaseEdgeModel.ts +32 -0
- package/src/options.ts +8 -39
- package/src/view/Graph.tsx +2 -2
- package/src/view/overlay/Grid.tsx +75 -53
- package/dist/index.js +0 -26
- package/dist/index.js.map +0 -1
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
import { Component } from 'preact/compat'
|
|
2
|
+
import { cloneDeep, assign } from 'lodash-es'
|
|
2
3
|
import { observer } from '../..'
|
|
3
4
|
import { createUuid } from '../../util'
|
|
4
5
|
import { GraphModel } from '../../model'
|
|
5
6
|
import { DEFAULT_GRID_SIZE } from '../../constant'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 网格格子间距
|
|
10
|
-
*/
|
|
11
|
-
size?: number
|
|
12
|
-
/**
|
|
13
|
-
* 网格是否可见
|
|
14
|
-
*/
|
|
15
|
-
visible?: boolean
|
|
8
|
+
import GridOptions = Grid.GridOptions
|
|
16
9
|
|
|
10
|
+
type IProps = GridOptions & {
|
|
17
11
|
graphModel: GraphModel
|
|
18
|
-
/**
|
|
19
|
-
* 网格类型
|
|
20
|
-
* 'dot' || 'mesh'
|
|
21
|
-
*/
|
|
22
|
-
type?: string
|
|
23
|
-
config?: {
|
|
24
|
-
color: string
|
|
25
|
-
thickness?: number
|
|
26
|
-
}
|
|
27
12
|
}
|
|
28
13
|
|
|
29
|
-
type IProps = GridOptions
|
|
30
|
-
|
|
31
14
|
@observer
|
|
32
15
|
export class Grid extends Component<IProps> {
|
|
33
16
|
readonly id = createUuid()
|
|
@@ -38,21 +21,16 @@ export class Grid extends Component<IProps> {
|
|
|
38
21
|
|
|
39
22
|
const { color, thickness = 2 } = config ?? {}
|
|
40
23
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
opacity = 0
|
|
45
|
-
}
|
|
46
|
-
/* eslint-disable-next-line */
|
|
24
|
+
// 对于点状网格,点的半径不能大于网格大小的四分之一
|
|
25
|
+
const radius = Math.min(Math.max(2, thickness), size / 4)
|
|
26
|
+
const opacity = visible ? 1 : 0
|
|
47
27
|
return (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
opacity={opacity}
|
|
55
|
-
/>
|
|
28
|
+
<g fill={color} opacity={opacity}>
|
|
29
|
+
<circle cx={0} cy={0} r={radius / 2} />
|
|
30
|
+
<circle cx={0} cy={size} r={radius / 2} />
|
|
31
|
+
<circle cx={size} cy={0} r={radius / 2} />
|
|
32
|
+
<circle cx={size} cy={size} r={radius / 2} />
|
|
33
|
+
</g>
|
|
56
34
|
)
|
|
57
35
|
}
|
|
58
36
|
|
|
@@ -61,22 +39,26 @@ export class Grid extends Component<IProps> {
|
|
|
61
39
|
renderMesh() {
|
|
62
40
|
const { config, size = 1, visible } = this.props
|
|
63
41
|
const { color, thickness = 1 } = config ?? {}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
42
|
+
|
|
43
|
+
// 对于交叉线网格,线的宽度不能大于网格大小的一半
|
|
44
|
+
const strokeWidth = Math.min(Math.max(1, thickness), size / 2)
|
|
45
|
+
const d = `M 0 0 H ${size} V ${size} H 0 Z`
|
|
46
|
+
const opacity = visible ? 1 : 0
|
|
70
47
|
return (
|
|
71
|
-
<path
|
|
48
|
+
<path
|
|
49
|
+
d={d}
|
|
50
|
+
stroke={color}
|
|
51
|
+
strokeWidth={strokeWidth}
|
|
52
|
+
opacity={opacity}
|
|
53
|
+
fill="transparent"
|
|
54
|
+
/>
|
|
72
55
|
)
|
|
73
56
|
}
|
|
74
57
|
|
|
75
58
|
render() {
|
|
76
|
-
// TODO 生成网格️️️✔、网格支持 options(size)✔
|
|
77
59
|
const {
|
|
78
60
|
type,
|
|
79
|
-
size,
|
|
61
|
+
size = 1,
|
|
80
62
|
graphModel: { transformModel },
|
|
81
63
|
} = this.props
|
|
82
64
|
const { SCALE_X, SKEW_Y, SKEW_X, SCALE_Y, TRANSLATE_X, TRANSLATE_Y } =
|
|
@@ -122,14 +104,54 @@ export class Grid extends Component<IProps> {
|
|
|
122
104
|
}
|
|
123
105
|
}
|
|
124
106
|
|
|
125
|
-
Grid
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
107
|
+
export namespace Grid {
|
|
108
|
+
export type GridOptions = {
|
|
109
|
+
/**
|
|
110
|
+
* 网格格子间距
|
|
111
|
+
*/
|
|
112
|
+
size?: number
|
|
113
|
+
/**
|
|
114
|
+
* 网格是否可见
|
|
115
|
+
*/
|
|
116
|
+
visible?: boolean
|
|
117
|
+
/**
|
|
118
|
+
* 网格类型
|
|
119
|
+
* - `dot` 点状网格
|
|
120
|
+
* - `mesh` 交叉线网格
|
|
121
|
+
*/
|
|
122
|
+
type?: 'dot' | 'mesh'
|
|
123
|
+
config?: {
|
|
124
|
+
/**
|
|
125
|
+
* 网格的颜色
|
|
126
|
+
*/
|
|
127
|
+
color: string
|
|
128
|
+
/**
|
|
129
|
+
* 网格的宽度
|
|
130
|
+
* - 对于 `dot` 点状网格,表示点的大小
|
|
131
|
+
* - 对于 `mesh` 交叉线网格,表示线的宽度
|
|
132
|
+
*/
|
|
133
|
+
thickness?: number
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const defaultProps: GridOptions = {
|
|
138
|
+
size: DEFAULT_GRID_SIZE,
|
|
139
|
+
visible: true,
|
|
140
|
+
type: 'dot',
|
|
141
|
+
config: {
|
|
142
|
+
color: '#ababab',
|
|
143
|
+
thickness: 1,
|
|
144
|
+
},
|
|
145
|
+
}
|
|
134
146
|
|
|
135
|
-
export
|
|
147
|
+
export function getGridOptions(options: number | boolean | GridOptions) {
|
|
148
|
+
const defaultOptions = cloneDeep(Grid.defaultProps)
|
|
149
|
+
if (typeof options === 'number') {
|
|
150
|
+
return assign(defaultOptions, { size: options })
|
|
151
|
+
} else if (typeof options === 'boolean') {
|
|
152
|
+
return assign(defaultOptions, { visible: options })
|
|
153
|
+
} else {
|
|
154
|
+
return assign(defaultOptions, options)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|