@antv/g6 5.0.39 → 5.0.40-alpha.0
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/dist/g6.min.js +29 -29
- package/dist/lib/elements/combos/base-combo.d.ts +2 -1
- package/dist/lib/version.d.ts +1 -1
- package/esm/elements/combos/base-combo.d.ts +2 -1
- package/esm/elements/combos/base-combo.js +21 -17
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/combos/circle.js +1 -1
- package/esm/elements/combos/circle.js.map +1 -1
- package/esm/elements/combos/rect.js +2 -2
- package/esm/elements/combos/rect.js.map +1 -1
- package/esm/elements/edges/base-edge.js +60 -50
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/nodes/base-node.js +69 -43
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/donut.js +1 -0
- package/esm/elements/nodes/donut.js.map +1 -1
- package/esm/elements/nodes/image.js +9 -7
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/runtime/element.js +1 -1
- package/esm/runtime/element.js.map +1 -1
- package/esm/themes/base.js +69 -65
- package/esm/themes/base.js.map +1 -1
- package/esm/utils/transform.js +1 -1
- package/esm/utils/transform.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/esm/version.js.map +1 -1
- package/lib/elements/combos/base-combo.d.ts +2 -1
- package/lib/elements/combos/base-combo.js +21 -17
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/combos/circle.js +1 -1
- package/lib/elements/combos/circle.js.map +1 -1
- package/lib/elements/combos/rect.js +2 -2
- package/lib/elements/combos/rect.js.map +1 -1
- package/lib/elements/edges/base-edge.js +60 -50
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/base-node.js +69 -43
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/donut.js +1 -0
- package/lib/elements/nodes/donut.js.map +1 -1
- package/lib/elements/nodes/image.js +9 -7
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/runtime/element.js +1 -1
- package/lib/runtime/element.js.map +1 -1
- package/lib/themes/base.js +69 -65
- package/lib/themes/base.js.map +1 -1
- package/lib/utils/transform.js +1 -1
- package/lib/utils/transform.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +3 -2
- package/src/elements/combos/base-combo.ts +24 -18
- package/src/elements/combos/circle.ts +2 -3
- package/src/elements/combos/rect.ts +2 -3
- package/src/elements/edges/base-edge.ts +78 -53
- package/src/elements/nodes/base-node.ts +93 -48
- package/src/elements/nodes/donut.ts +1 -0
- package/src/elements/nodes/image.ts +11 -7
- package/src/runtime/element.ts +5 -1
- package/src/themes/base.ts +69 -65
- package/src/utils/transform.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
Keyframe,
|
|
13
13
|
LoopStyleProps,
|
|
14
14
|
Node,
|
|
15
|
+
NodeLabelStyleProps,
|
|
15
16
|
Point,
|
|
16
17
|
Prefix,
|
|
17
18
|
} from '../../types';
|
|
@@ -28,6 +29,41 @@ import { effect } from '../effect';
|
|
|
28
29
|
import type { BadgeStyleProps, BaseShapeStyleProps, LabelStyleProps } from '../shapes';
|
|
29
30
|
import { Badge, Label } from '../shapes';
|
|
30
31
|
|
|
32
|
+
const getDefaultKeyStyle = (): Partial<PathStyleProps> => ({
|
|
33
|
+
fillOpacity: 1,
|
|
34
|
+
increasedLineWidthForHitTesting: 2,
|
|
35
|
+
isBillboard: true,
|
|
36
|
+
lineWidth: 1,
|
|
37
|
+
strokeOpacity: 1,
|
|
38
|
+
});
|
|
39
|
+
const getDefaultHaloStyle = (): Partial<PathStyleProps> => ({
|
|
40
|
+
droppable: false,
|
|
41
|
+
lineDash: 0,
|
|
42
|
+
lineWidth: 12,
|
|
43
|
+
pointerEvents: 'none',
|
|
44
|
+
strokeOpacity: 1,
|
|
45
|
+
zIndex: -1,
|
|
46
|
+
});
|
|
47
|
+
const getDefaultLabelStyle = (): Partial<NodeLabelStyleProps> => ({
|
|
48
|
+
background: false,
|
|
49
|
+
backgroundLineWidth: 0,
|
|
50
|
+
backgroundOpacity: 0.75,
|
|
51
|
+
fontSize: 12,
|
|
52
|
+
fontWeight: 400,
|
|
53
|
+
isBillboard: true,
|
|
54
|
+
offsetX: 10,
|
|
55
|
+
opacity: 1,
|
|
56
|
+
padding: [4, 4, 4, 4],
|
|
57
|
+
textBaseline: 'middle',
|
|
58
|
+
});
|
|
59
|
+
const getDefaultBadgeStyle = (): Partial<BadgeStyleProps> => ({});
|
|
60
|
+
const getDefaultArrowStyle = () => ({
|
|
61
|
+
lineDash: 0,
|
|
62
|
+
lineJoin: 'round',
|
|
63
|
+
lineWidth: 1,
|
|
64
|
+
transformOrigin: 'center',
|
|
65
|
+
type: 'vee',
|
|
66
|
+
});
|
|
31
67
|
/**
|
|
32
68
|
* <zh/> 边的通用样式属性
|
|
33
69
|
*
|
|
@@ -175,42 +211,7 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implement
|
|
|
175
211
|
public type = 'edge';
|
|
176
212
|
|
|
177
213
|
static defaultStyleProps: Partial<BaseEdgeStyleProps> = {
|
|
178
|
-
|
|
179
|
-
badgeOffsetX: 0,
|
|
180
|
-
badgeOffsetY: 0,
|
|
181
|
-
badgePlacement: 'suffix',
|
|
182
|
-
isBillboard: true,
|
|
183
|
-
label: true,
|
|
184
|
-
labelAutoRotate: true,
|
|
185
|
-
labelIsBillboard: true,
|
|
186
|
-
labelMaxWidth: '80%',
|
|
187
|
-
labelOffsetX: 4,
|
|
188
|
-
labelOffsetY: 0,
|
|
189
|
-
labelPlacement: 'center',
|
|
190
|
-
labelTextBaseline: 'middle',
|
|
191
|
-
labelWordWrap: false,
|
|
192
|
-
halo: false,
|
|
193
|
-
haloDroppable: false,
|
|
194
|
-
haloLineDash: 0,
|
|
195
|
-
haloLineWidth: 12,
|
|
196
|
-
haloPointerEvents: 'none',
|
|
197
|
-
haloStrokeOpacity: 0.25,
|
|
198
|
-
haloZIndex: -1,
|
|
199
|
-
loop: true,
|
|
200
|
-
startArrow: false,
|
|
201
|
-
startArrowLineDash: 0,
|
|
202
|
-
startArrowLineJoin: 'round',
|
|
203
|
-
startArrowLineWidth: 1,
|
|
204
|
-
startArrowTransformOrigin: 'center',
|
|
205
|
-
startArrowType: 'vee',
|
|
206
|
-
endArrow: false,
|
|
207
|
-
endArrowLineDash: 0,
|
|
208
|
-
endArrowLineJoin: 'round',
|
|
209
|
-
endArrowLineWidth: 1,
|
|
210
|
-
endArrowTransformOrigin: 'center',
|
|
211
|
-
endArrowType: 'vee',
|
|
212
|
-
loopPlacement: 'top',
|
|
213
|
-
loopClockwise: true,
|
|
214
|
+
zIndex: 1,
|
|
214
215
|
};
|
|
215
216
|
|
|
216
217
|
constructor(options: DisplayObjectConfig<BaseEdgeStyleProps>) {
|
|
@@ -228,19 +229,21 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implement
|
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps {
|
|
231
|
-
const { loop, ...style } = this.getGraphicStyle(attributes);
|
|
232
|
+
const { loop = true, ...style } = this.getGraphicStyle(attributes);
|
|
232
233
|
const { sourceNode, targetNode } = this;
|
|
233
234
|
|
|
235
|
+
const defaultStyle = getDefaultKeyStyle();
|
|
236
|
+
|
|
234
237
|
const d = loop && isSameNode(sourceNode, targetNode) ? this.getLoopPath(attributes) : this.getKeyPath(attributes);
|
|
235
238
|
|
|
236
|
-
|
|
239
|
+
defaultStyle.d = d;
|
|
237
240
|
|
|
238
241
|
Path.PARSED_STYLE_LIST.forEach((key) => {
|
|
239
242
|
// @ts-expect-error skip type error
|
|
240
|
-
if (key in style)
|
|
243
|
+
if (key in style) defaultStyle[key] = style[key];
|
|
241
244
|
});
|
|
242
245
|
|
|
243
|
-
return
|
|
246
|
+
return defaultStyle;
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
protected abstract getKeyPath(attributes: ParsedBaseEdgeStyleProps): PathArray;
|
|
@@ -253,8 +256,8 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implement
|
|
|
253
256
|
const defaultDist = Math.max(getBBoxWidth(bbox), getBBoxHeight(bbox));
|
|
254
257
|
|
|
255
258
|
const {
|
|
256
|
-
placement,
|
|
257
|
-
clockwise,
|
|
259
|
+
placement = 'top',
|
|
260
|
+
clockwise = true,
|
|
258
261
|
dist = defaultDist,
|
|
259
262
|
} = subStyleProps<Required<LoopStyleProps>>(this.getGraphicStyle(attributes), 'loop');
|
|
260
263
|
|
|
@@ -288,19 +291,28 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implement
|
|
|
288
291
|
}
|
|
289
292
|
|
|
290
293
|
protected getHaloStyle(attributes: ParsedBaseEdgeStyleProps): false | PathStyleProps {
|
|
291
|
-
|
|
294
|
+
const { halo = false } = attributes;
|
|
295
|
+
if (halo === false) return false;
|
|
292
296
|
|
|
293
297
|
const keyStyle = this.getKeyStyle(attributes);
|
|
294
298
|
const haloStyle = subStyleProps<LineStyleProps>(this.getGraphicStyle(attributes), 'halo');
|
|
295
299
|
|
|
296
|
-
return { ...keyStyle, ...haloStyle };
|
|
300
|
+
return { ...keyStyle, ...getDefaultHaloStyle(), ...haloStyle };
|
|
297
301
|
}
|
|
298
302
|
|
|
299
303
|
protected getLabelStyle(attributes: ParsedBaseEdgeStyleProps): false | LabelStyleProps {
|
|
300
|
-
|
|
304
|
+
const { label = true, labelText } = attributes;
|
|
305
|
+
if (label === false || !labelText) return false;
|
|
301
306
|
|
|
302
307
|
const labelStyle = subStyleProps<Required<EdgeLabelStyleProps>>(this.getGraphicStyle(attributes), 'label');
|
|
303
|
-
const {
|
|
308
|
+
const {
|
|
309
|
+
placement = 'center',
|
|
310
|
+
offsetX = 4,
|
|
311
|
+
offsetY = 0,
|
|
312
|
+
autoRotate = true,
|
|
313
|
+
maxWidth = '80%',
|
|
314
|
+
...restStyle
|
|
315
|
+
} = labelStyle;
|
|
304
316
|
const labelPositionStyle = getLabelPositionStyle(
|
|
305
317
|
this.shapeMap.key as EdgeKey,
|
|
306
318
|
placement,
|
|
@@ -310,20 +322,31 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implement
|
|
|
310
322
|
);
|
|
311
323
|
|
|
312
324
|
const bbox = this.shapeMap.key.getLocalBounds();
|
|
313
|
-
const wordWrapWidth = getWordWrapWidthByEnds([bbox.min, bbox.max], maxWidth);
|
|
314
325
|
|
|
315
|
-
|
|
326
|
+
const defaultStyle = getDefaultLabelStyle();
|
|
327
|
+
|
|
328
|
+
if (attributes.labelWordWrap) {
|
|
329
|
+
Object.assign(defaultStyle, {
|
|
330
|
+
wordWrap: true,
|
|
331
|
+
wordWrapWidth: getWordWrapWidthByEnds([bbox.min, bbox.max], maxWidth),
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return Object.assign(defaultStyle, labelPositionStyle, restStyle);
|
|
316
336
|
}
|
|
317
337
|
|
|
318
338
|
protected getBadgeStyle(attributes: ParsedBaseEdgeStyleProps): false | BadgeStyleProps {
|
|
319
339
|
if (attributes.badge === false || !attributes.badgeText) return false;
|
|
320
340
|
|
|
321
|
-
const {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
341
|
+
const {
|
|
342
|
+
offsetX = 0,
|
|
343
|
+
offsetY = 0,
|
|
344
|
+
placement = 'suffix',
|
|
345
|
+
...badgeStyle
|
|
346
|
+
} = subStyleProps<Required<EdgeBadgeStyleProps>>(attributes, 'badge');
|
|
325
347
|
|
|
326
348
|
return Object.assign(
|
|
349
|
+
getDefaultBadgeStyle(),
|
|
327
350
|
badgeStyle,
|
|
328
351
|
getBadgePositionStyle(this.shapeMap, placement, attributes.labelPlacement, offsetX, offsetY),
|
|
329
352
|
);
|
|
@@ -373,9 +396,11 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implement
|
|
|
373
396
|
const arrowFn = isFunction(type) ? type : Symbol[type] || Symbol.triangle;
|
|
374
397
|
const d = arrowFn(width, height);
|
|
375
398
|
|
|
399
|
+
const defaultStyle = getDefaultArrowStyle();
|
|
400
|
+
|
|
376
401
|
return Object.assign(
|
|
377
402
|
pick(keyStyle, ['stroke', 'strokeOpacity', 'fillOpacity']),
|
|
378
|
-
{ width, height },
|
|
403
|
+
{ ...defaultStyle, width, height },
|
|
379
404
|
{ ...(d && { d, fill: type === 'simple' ? '' : keyStyle.stroke }) },
|
|
380
405
|
arrowStyle,
|
|
381
406
|
);
|
|
@@ -31,6 +31,51 @@ import type { BadgeStyleProps, BaseShapeStyleProps, IconStyleProps, LabelStylePr
|
|
|
31
31
|
import { Badge, Icon, Label } from '../shapes';
|
|
32
32
|
import { connectImage, dispatchPositionChange } from '../shapes/image';
|
|
33
33
|
|
|
34
|
+
const getDefaultKeyStyle = () => ({
|
|
35
|
+
fillOpacity: 1,
|
|
36
|
+
lineWidth: 0,
|
|
37
|
+
strokeOpacity: 1,
|
|
38
|
+
});
|
|
39
|
+
const getDefaultHaloStyle = () => ({
|
|
40
|
+
droppable: false,
|
|
41
|
+
lineDash: 0,
|
|
42
|
+
lineWidth: 12,
|
|
43
|
+
pointerEvents: 'none',
|
|
44
|
+
strokeOpacity: 0.25,
|
|
45
|
+
zIndex: -1,
|
|
46
|
+
});
|
|
47
|
+
const getDefaultIconStyle = (): Partial<IconStyleProps> => ({
|
|
48
|
+
fill: '#fff',
|
|
49
|
+
opacity: 1,
|
|
50
|
+
zIndex: 1,
|
|
51
|
+
});
|
|
52
|
+
const getDefaultLabelStyle = (): Partial<NodeLabelStyleProps> => ({
|
|
53
|
+
background: false,
|
|
54
|
+
backgroundLineWidth: 0,
|
|
55
|
+
backgroundOpacity: 0.75,
|
|
56
|
+
fillOpacity: 0.85,
|
|
57
|
+
fontSize: 12,
|
|
58
|
+
fontWeight: 400,
|
|
59
|
+
isBillboard: true,
|
|
60
|
+
lineHeight: 16,
|
|
61
|
+
offsetY: 2,
|
|
62
|
+
opacity: 1,
|
|
63
|
+
padding: [0, 2],
|
|
64
|
+
zIndex: 0,
|
|
65
|
+
});
|
|
66
|
+
const getDefaultPortStyle = (): Partial<PortStyleProps> => ({
|
|
67
|
+
lineWidth: 1,
|
|
68
|
+
strokeOpacity: 0.65,
|
|
69
|
+
zIndex: 2,
|
|
70
|
+
});
|
|
71
|
+
const getDefaultBadgeStyle = (): Partial<BadgeStyleProps> => ({
|
|
72
|
+
backgroundOpacity: 1,
|
|
73
|
+
fill: '#fff',
|
|
74
|
+
fontSize: 8,
|
|
75
|
+
padding: [0, 4],
|
|
76
|
+
zIndex: 3,
|
|
77
|
+
});
|
|
78
|
+
|
|
34
79
|
/**
|
|
35
80
|
* <zh/> 节点通用样式配置项
|
|
36
81
|
*
|
|
@@ -196,33 +241,9 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
196
241
|
public type = 'node';
|
|
197
242
|
|
|
198
243
|
static defaultStyleProps: Partial<BaseNodeStyleProps> = {
|
|
199
|
-
x: 0,
|
|
200
|
-
y: 0,
|
|
201
|
-
size: 32,
|
|
202
244
|
droppable: true,
|
|
203
245
|
draggable: true,
|
|
204
|
-
|
|
205
|
-
ports: [],
|
|
206
|
-
portZIndex: 2,
|
|
207
|
-
portLinkToCenter: false,
|
|
208
|
-
badge: true,
|
|
209
|
-
badges: [],
|
|
210
|
-
badgeZIndex: 3,
|
|
211
|
-
halo: false,
|
|
212
|
-
haloDroppable: false,
|
|
213
|
-
haloLineDash: 0,
|
|
214
|
-
haloLineWidth: 12,
|
|
215
|
-
haloStrokeOpacity: 0.25,
|
|
216
|
-
haloPointerEvents: 'none',
|
|
217
|
-
haloZIndex: -1,
|
|
218
|
-
icon: true,
|
|
219
|
-
iconZIndex: 1,
|
|
220
|
-
label: true,
|
|
221
|
-
labelIsBillboard: true,
|
|
222
|
-
labelMaxWidth: '200%',
|
|
223
|
-
labelPlacement: 'bottom',
|
|
224
|
-
labelWordWrap: false,
|
|
225
|
-
labelZIndex: 0,
|
|
246
|
+
zIndex: 2,
|
|
226
247
|
};
|
|
227
248
|
|
|
228
249
|
constructor(options: DisplayObjectConfig<S>) {
|
|
@@ -237,19 +258,28 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
237
258
|
protected getKeyStyle(attributes: Required<S>) {
|
|
238
259
|
const style = this.getGraphicStyle(attributes);
|
|
239
260
|
|
|
240
|
-
return Object.assign(
|
|
261
|
+
return Object.assign(
|
|
262
|
+
getDefaultKeyStyle(),
|
|
263
|
+
omitStyleProps(style, ['label', 'halo', 'icon', 'badge', 'port']),
|
|
264
|
+
) as any;
|
|
241
265
|
}
|
|
242
266
|
|
|
243
267
|
protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps {
|
|
244
|
-
|
|
268
|
+
const { label = true, labelText } = attributes;
|
|
245
269
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
270
|
+
if (label === false || !labelText) return false;
|
|
271
|
+
|
|
272
|
+
const {
|
|
273
|
+
placement = 'bottom',
|
|
274
|
+
maxWidth = '200%',
|
|
275
|
+
offsetX,
|
|
276
|
+
offsetY = 2,
|
|
277
|
+
...labelStyle
|
|
278
|
+
} = subStyleProps<Required<NodeLabelStyleProps>>(this.getGraphicStyle(attributes), 'label');
|
|
250
279
|
const keyBounds = this.getShape('key').getLocalBounds();
|
|
251
280
|
|
|
252
281
|
return Object.assign(
|
|
282
|
+
getDefaultLabelStyle(),
|
|
253
283
|
getTextStyleByPlacement(keyBounds, placement, offsetX, offsetY),
|
|
254
284
|
{ wordWrapWidth: getWordWrapWidthByBox(keyBounds, maxWidth) },
|
|
255
285
|
labelStyle,
|
|
@@ -257,42 +287,55 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
257
287
|
}
|
|
258
288
|
|
|
259
289
|
protected getHaloStyle(attributes: Required<S>) {
|
|
260
|
-
|
|
290
|
+
const { halo = false } = attributes;
|
|
291
|
+
if (!halo) return false;
|
|
261
292
|
|
|
262
293
|
const { fill, ...keyStyle } = this.getKeyStyle(attributes);
|
|
263
294
|
const haloStyle = subStyleProps(this.getGraphicStyle(attributes), 'halo');
|
|
264
295
|
|
|
265
|
-
return {
|
|
296
|
+
return {
|
|
297
|
+
...keyStyle,
|
|
298
|
+
...getDefaultHaloStyle(),
|
|
299
|
+
stroke: fill,
|
|
300
|
+
...haloStyle,
|
|
301
|
+
} as any;
|
|
266
302
|
}
|
|
267
303
|
|
|
268
304
|
protected getIconStyle(attributes: Required<S>): false | IconStyleProps {
|
|
269
|
-
|
|
305
|
+
const { icon = true, iconText, iconSrc } = attributes;
|
|
306
|
+
if (icon === false || (!iconText && !iconSrc)) return false;
|
|
270
307
|
|
|
271
308
|
const iconStyle = subStyleProps(this.getGraphicStyle(attributes), 'icon');
|
|
272
309
|
|
|
273
|
-
return Object.assign(inferIconStyle(attributes.size!, iconStyle), iconStyle);
|
|
310
|
+
return Object.assign(getDefaultIconStyle(), inferIconStyle(attributes.size!, iconStyle), iconStyle);
|
|
274
311
|
}
|
|
275
312
|
|
|
276
313
|
protected getBadgesStyle(attributes: Required<S>): Record<string, NodeBadgeStyleProps | false> {
|
|
277
|
-
const
|
|
314
|
+
const badgeShapes = subObject(this.shapeMap, 'badge-');
|
|
278
315
|
const badgesShapeStyle: Record<string, NodeBadgeStyleProps | false> = {};
|
|
279
316
|
|
|
280
|
-
Object.keys(
|
|
317
|
+
Object.keys(badgeShapes).forEach((key) => {
|
|
281
318
|
badgesShapeStyle[key] = false;
|
|
282
319
|
});
|
|
283
|
-
|
|
320
|
+
|
|
321
|
+
const { badge = true, badges = [] } = attributes;
|
|
322
|
+
|
|
323
|
+
if (badge === false || !badges.length) return badgesShapeStyle;
|
|
284
324
|
|
|
285
325
|
const { badges: badgeOptions = [], badgePalette, opacity = 1, ...restAttributes } = attributes;
|
|
286
326
|
const colors = getPaletteColors(badgePalette);
|
|
287
327
|
const badgeStyle = subStyleProps<BadgeStyleProps>(this.getGraphicStyle(restAttributes), 'badge');
|
|
288
328
|
|
|
289
329
|
badgeOptions.forEach((option, i) => {
|
|
290
|
-
badgesShapeStyle[i] =
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
330
|
+
badgesShapeStyle[i] = Object.assign(
|
|
331
|
+
getDefaultBadgeStyle(),
|
|
332
|
+
{
|
|
333
|
+
opacity,
|
|
334
|
+
backgroundFill: colors ? colors[i % colors?.length] : undefined,
|
|
335
|
+
},
|
|
336
|
+
badgeStyle,
|
|
337
|
+
this.getBadgeStyle(option),
|
|
338
|
+
);
|
|
296
339
|
});
|
|
297
340
|
|
|
298
341
|
return badgesShapeStyle;
|
|
@@ -306,20 +349,22 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
306
349
|
}
|
|
307
350
|
|
|
308
351
|
protected getPortsStyle(attributes: Required<S>): Record<string, PortStyleProps | false> {
|
|
309
|
-
const ports =
|
|
352
|
+
const { port = true, ports = [] } = attributes;
|
|
353
|
+
|
|
354
|
+
const portShapes = this.getPorts();
|
|
310
355
|
const portsShapeStyle: Record<string, PortStyleProps | false> = {};
|
|
311
356
|
|
|
312
|
-
Object.keys(
|
|
357
|
+
Object.keys(portShapes).forEach((key) => {
|
|
313
358
|
portsShapeStyle[key] = false;
|
|
314
359
|
});
|
|
315
360
|
|
|
316
|
-
if (
|
|
361
|
+
if (port === false || !ports.length) return portsShapeStyle;
|
|
317
362
|
|
|
318
363
|
const portStyle = subStyleProps<PortStyleProps>(this.getGraphicStyle(attributes), 'port');
|
|
319
364
|
const { ports: portOptions = [] } = attributes;
|
|
320
365
|
portOptions.forEach((option, index) => {
|
|
321
366
|
const key = option.key || index;
|
|
322
|
-
const mergedStyle =
|
|
367
|
+
const mergedStyle = Object.assign(getDefaultPortStyle(), portStyle, portStyle, option);
|
|
323
368
|
if (isSimplePort(mergedStyle)) {
|
|
324
369
|
portsShapeStyle[key] = false;
|
|
325
370
|
} else {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { DisplayObjectConfig, RectStyleProps as GRectStyleProps, Group } from '@antv/g';
|
|
2
2
|
import { ImageStyleProps as GImageStyleProps, Rect as GRect } from '@antv/g';
|
|
3
3
|
import { ICON_SIZE_RATIO } from '../../constants/element';
|
|
4
|
-
import { subStyleProps } from '../../utils/prefix';
|
|
5
4
|
import { mergeOptions } from '../../utils/style';
|
|
6
5
|
import { add } from '../../utils/vector';
|
|
7
6
|
import type { IconStyleProps } from '../shapes';
|
|
@@ -59,13 +58,18 @@ export class Image extends BaseNode<ImageStyleProps> {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
protected getHaloStyle(attributes: Required<ImageStyleProps>): false | GRectStyleProps {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const haloLineWidth = Number(
|
|
61
|
+
const style = super.getHaloStyle(attributes);
|
|
62
|
+
if (style === false) return false;
|
|
63
|
+
|
|
64
|
+
const haloLineWidth = Number(style.lineWidth);
|
|
66
65
|
const [width, height] = add(this.getSize(attributes), [haloLineWidth, haloLineWidth]);
|
|
67
|
-
|
|
68
|
-
return
|
|
66
|
+
|
|
67
|
+
return Object.assign(style, {
|
|
68
|
+
width,
|
|
69
|
+
height,
|
|
70
|
+
x: -width / 2,
|
|
71
|
+
y: -height / 2,
|
|
72
|
+
});
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
protected getIconStyle(attributes: Required<ImageStyleProps>): false | IconStyleProps {
|
package/src/runtime/element.ts
CHANGED
|
@@ -95,7 +95,11 @@ export class ElementController {
|
|
|
95
95
|
|
|
96
96
|
public getThemeStateStyle(elementType: ElementType, states: State[]) {
|
|
97
97
|
const { state = {} } = this.getTheme(elementType);
|
|
98
|
-
return Object.assign(
|
|
98
|
+
return Object.assign(
|
|
99
|
+
{},
|
|
100
|
+
this.context.graph.rendered ? {} : state.default,
|
|
101
|
+
...states.map((name) => state[name] || {}),
|
|
102
|
+
);
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
private paletteStyle: Record<ID, string> = {};
|
package/src/themes/base.ts
CHANGED
|
@@ -86,40 +86,41 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
86
86
|
node: {
|
|
87
87
|
palette: nodePaletteOptions,
|
|
88
88
|
style: {
|
|
89
|
-
donutOpacity: 1,
|
|
90
|
-
badgeBackgroundOpacity: 1,
|
|
91
|
-
badgeFill: '#fff',
|
|
92
|
-
badgeFontSize: 8,
|
|
93
|
-
badgePadding: [0, 4],
|
|
94
89
|
badgePalette: nodeBadgePalette,
|
|
95
90
|
fill: nodeColor,
|
|
96
|
-
fillOpacity: 1,
|
|
97
|
-
halo: false,
|
|
98
|
-
iconFill: '#fff',
|
|
99
|
-
iconOpacity: 1,
|
|
100
|
-
labelBackground: false,
|
|
101
91
|
labelBackgroundFill: bgColor,
|
|
102
|
-
labelBackgroundLineWidth: 0,
|
|
103
|
-
labelBackgroundOpacity: 0.75,
|
|
104
92
|
labelFill: textColor,
|
|
105
|
-
labelFillOpacity: 0.85,
|
|
106
|
-
labelLineHeight: 16,
|
|
107
|
-
labelPadding: [0, 2],
|
|
108
|
-
labelFontSize: 12,
|
|
109
|
-
labelFontWeight: 400,
|
|
110
|
-
labelOpacity: 1,
|
|
111
|
-
labelOffsetY: 2,
|
|
112
|
-
lineWidth: 0,
|
|
113
93
|
portFill: nodeColor,
|
|
114
|
-
portLineWidth: 1,
|
|
115
94
|
portStroke: nodeStroke,
|
|
116
|
-
portStrokeOpacity: 0.65,
|
|
117
95
|
size: 32,
|
|
118
96
|
stroke: nodeStroke,
|
|
119
|
-
strokeOpacity: 1,
|
|
120
|
-
zIndex: 2,
|
|
121
97
|
},
|
|
122
98
|
state: {
|
|
99
|
+
default: {
|
|
100
|
+
badgeBackgroundOpacity: 1,
|
|
101
|
+
badgeFill: '#fff',
|
|
102
|
+
badgeFontSize: 8,
|
|
103
|
+
badgePadding: [0, 4],
|
|
104
|
+
donutOpacity: 1,
|
|
105
|
+
fillOpacity: 1,
|
|
106
|
+
halo: false,
|
|
107
|
+
iconFill: '#fff',
|
|
108
|
+
iconOpacity: 1,
|
|
109
|
+
labelBackground: false,
|
|
110
|
+
labelBackgroundLineWidth: 0,
|
|
111
|
+
labelBackgroundOpacity: 0.75,
|
|
112
|
+
labelFillOpacity: 0.85,
|
|
113
|
+
labelFontSize: 12,
|
|
114
|
+
labelFontWeight: 400,
|
|
115
|
+
labelLineHeight: 16,
|
|
116
|
+
labelOffsetY: 2,
|
|
117
|
+
labelOpacity: 1,
|
|
118
|
+
labelPadding: [0, 2],
|
|
119
|
+
lineWidth: 0,
|
|
120
|
+
portLineWidth: 1,
|
|
121
|
+
portStrokeOpacity: 0.65,
|
|
122
|
+
strokeOpacity: 1,
|
|
123
|
+
},
|
|
123
124
|
selected: {
|
|
124
125
|
halo: true,
|
|
125
126
|
haloLineWidth: 24,
|
|
@@ -176,31 +177,32 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
176
177
|
palette: edgePaletteOptions,
|
|
177
178
|
style: {
|
|
178
179
|
badgeBackgroundFill: edgeColor,
|
|
179
|
-
badgeFill: '#fff',
|
|
180
|
-
badgeFontSize: 8,
|
|
181
|
-
badgeOffsetX: 10,
|
|
182
|
-
fillOpacity: 1,
|
|
183
|
-
halo: false,
|
|
184
|
-
haloLineWidth: 12,
|
|
185
|
-
haloStrokeOpacity: 1,
|
|
186
|
-
increasedLineWidthForHitTesting: 2,
|
|
187
|
-
labelBackground: false,
|
|
188
|
-
labelBackgroundFill: bgColor,
|
|
189
|
-
labelBackgroundLineWidth: 0,
|
|
190
|
-
labelBackgroundOpacity: 0.75,
|
|
191
|
-
labelBackgroundPadding: [4, 4, 4, 4],
|
|
192
|
-
labelFill: textColor,
|
|
193
|
-
labelFontSize: 12,
|
|
194
|
-
labelFontWeight: 400,
|
|
195
|
-
labelOpacity: 1,
|
|
196
|
-
labelPlacement: 'center',
|
|
197
|
-
labelTextBaseline: 'middle',
|
|
198
|
-
lineWidth: 1,
|
|
199
180
|
stroke: edgeColor,
|
|
200
|
-
strokeOpacity: 1,
|
|
201
|
-
zIndex: 1,
|
|
202
181
|
},
|
|
203
182
|
state: {
|
|
183
|
+
default: {
|
|
184
|
+
badgeFill: '#fff',
|
|
185
|
+
badgeFontSize: 8,
|
|
186
|
+
badgeOffsetX: 10,
|
|
187
|
+
fillOpacity: 1,
|
|
188
|
+
halo: false,
|
|
189
|
+
haloLineWidth: 12,
|
|
190
|
+
haloStrokeOpacity: 1,
|
|
191
|
+
increasedLineWidthForHitTesting: 2,
|
|
192
|
+
labelBackground: false,
|
|
193
|
+
labelBackgroundFill: bgColor,
|
|
194
|
+
labelBackgroundLineWidth: 0,
|
|
195
|
+
labelBackgroundOpacity: 0.75,
|
|
196
|
+
labelBackgroundPadding: [4, 4, 4, 4],
|
|
197
|
+
labelFill: textColor,
|
|
198
|
+
labelFontSize: 12,
|
|
199
|
+
labelFontWeight: 400,
|
|
200
|
+
labelOpacity: 1,
|
|
201
|
+
labelPlacement: 'center',
|
|
202
|
+
labelTextBaseline: 'middle',
|
|
203
|
+
lineWidth: 1,
|
|
204
|
+
strokeOpacity: 1,
|
|
205
|
+
},
|
|
204
206
|
selected: {
|
|
205
207
|
halo: true,
|
|
206
208
|
haloStrokeOpacity: 0.25,
|
|
@@ -245,32 +247,34 @@ export function create(tokens: ThemeTokens): Theme {
|
|
|
245
247
|
combo: {
|
|
246
248
|
style: {
|
|
247
249
|
collapsedMarkerFill: bgColor,
|
|
248
|
-
collapsedMarkerFontSize: 12,
|
|
249
|
-
collapsedMarkerFillOpacity: 1,
|
|
250
|
-
collapsedSize: 32,
|
|
251
|
-
collapsedFillOpacity: 1,
|
|
252
250
|
fill: comboColor,
|
|
253
|
-
halo: false,
|
|
254
|
-
haloLineWidth: 12,
|
|
255
251
|
haloStroke: comboStroke,
|
|
256
|
-
haloStrokeOpacity: 0.25,
|
|
257
|
-
labelBackground: false,
|
|
258
252
|
labelBackgroundFill: bgColor,
|
|
259
|
-
labelBackgroundLineWidth: 0,
|
|
260
|
-
labelBackgroundOpacity: 0.75,
|
|
261
|
-
labelBackgroundPadding: [2, 4, 2, 4],
|
|
262
253
|
labelFill: textColor,
|
|
263
|
-
labelFontSize: 12,
|
|
264
|
-
labelFontWeight: 400,
|
|
265
|
-
labelOpacity: 1,
|
|
266
|
-
lineDash: 0,
|
|
267
|
-
lineWidth: 1,
|
|
268
|
-
fillOpacity: 0.04,
|
|
269
|
-
strokeOpacity: 1,
|
|
270
|
-
padding: 10,
|
|
271
254
|
stroke: comboStroke,
|
|
272
255
|
},
|
|
273
256
|
state: {
|
|
257
|
+
default: {
|
|
258
|
+
collapsedMarkerFontSize: 12,
|
|
259
|
+
collapsedMarkerFillOpacity: 1,
|
|
260
|
+
collapsedSize: 32,
|
|
261
|
+
collapsedFillOpacity: 1,
|
|
262
|
+
halo: false,
|
|
263
|
+
haloLineWidth: 12,
|
|
264
|
+
haloStrokeOpacity: 0.25,
|
|
265
|
+
labelBackground: false,
|
|
266
|
+
labelBackgroundLineWidth: 0,
|
|
267
|
+
labelBackgroundOpacity: 0.75,
|
|
268
|
+
labelBackgroundPadding: [2, 4, 2, 4],
|
|
269
|
+
labelFontSize: 12,
|
|
270
|
+
labelFontWeight: 400,
|
|
271
|
+
labelOpacity: 1,
|
|
272
|
+
lineDash: 0,
|
|
273
|
+
lineWidth: 1,
|
|
274
|
+
fillOpacity: 0.04,
|
|
275
|
+
strokeOpacity: 1,
|
|
276
|
+
padding: 10,
|
|
277
|
+
},
|
|
274
278
|
selected: {
|
|
275
279
|
halo: true,
|
|
276
280
|
labelFontSize: 14,
|
package/src/utils/transform.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function replaceTranslateInTransform(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (translateIndex === -1) {
|
|
42
|
-
newTransform.splice(0, 0, isNumber(z) ? ['translate3d', x, y, z ?? 0] : ['translate', x, y]);
|
|
42
|
+
newTransform.splice(0, 0, isNumber(z) && z !== 0 ? ['translate3d', x, y, z ?? 0] : ['translate', x, y]);
|
|
43
43
|
}
|
|
44
44
|
if (newTransform.length === 0) return null;
|
|
45
45
|
return newTransform;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.40-alpha.0';
|