@visactor/vrender-components 0.16.17-alpha.4 → 0.16.17
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/cjs/axis/base.js +19 -12
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +1 -2
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/line.js +1 -1
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/type.d.ts +5 -6
- package/cjs/axis/type.js.map +1 -1
- package/cjs/constant.d.ts +6 -0
- package/cjs/constant.js +6 -1
- package/cjs/constant.js.map +1 -1
- package/cjs/core/type.d.ts +15 -0
- package/cjs/core/type.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/indicator.js +43 -7
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +2 -1
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/label/arc.d.ts +4 -3
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +11 -11
- package/cjs/label/base.js +15 -1
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/type.d.ts +8 -4
- package/cjs/label/type.js.map +1 -1
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +1 -1
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +14 -14
- package/cjs/marker/type.js.map +1 -1
- package/cjs/tag/tag.js +87 -41
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tag/type.d.ts +4 -5
- package/cjs/tag/type.js.map +1 -1
- package/cjs/title/title.js +85 -53
- package/cjs/title/title.js.map +1 -1
- package/cjs/title/type.d.ts +10 -5
- package/cjs/title/type.js.map +1 -1
- package/cjs/tooltip/tooltip.js +49 -12
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.d.ts +7 -2
- package/cjs/tooltip/type.js.map +1 -1
- package/cjs/tooltip/util.js +9 -1
- package/cjs/tooltip/util.js.map +1 -1
- package/dist/index.js +291 -163
- package/dist/index.min.js +1 -1
- package/es/axis/base.js +21 -11
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +1 -2
- package/es/axis/circle.js.map +1 -1
- package/es/axis/line.js +1 -1
- package/es/axis/line.js.map +1 -1
- package/es/axis/type.d.ts +5 -6
- package/es/axis/type.js.map +1 -1
- package/es/constant.d.ts +6 -0
- package/es/constant.js +7 -0
- package/es/constant.js.map +1 -1
- package/es/core/type.d.ts +15 -0
- package/es/core/type.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/indicator/indicator.js +44 -6
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +2 -1
- package/es/indicator/type.js.map +1 -1
- package/es/label/arc.d.ts +4 -3
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +11 -11
- package/es/label/base.js +17 -1
- package/es/label/base.js.map +1 -1
- package/es/label/type.d.ts +8 -4
- package/es/label/type.js.map +1 -1
- package/es/marker/area.js.map +1 -1
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +1 -1
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +14 -14
- package/es/marker/type.js.map +1 -1
- package/es/tag/tag.js +86 -38
- package/es/tag/tag.js.map +1 -1
- package/es/tag/type.d.ts +4 -5
- package/es/tag/type.js.map +1 -1
- package/es/title/title.js +84 -50
- package/es/title/title.js.map +1 -1
- package/es/title/type.d.ts +10 -5
- package/es/title/type.js.map +1 -1
- package/es/tooltip/tooltip.js +50 -11
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.d.ts +7 -2
- package/es/tooltip/type.js.map +1 -1
- package/es/tooltip/util.js +9 -1
- package/es/tooltip/util.js.map +1 -1
- package/package.json +8 -8
package/es/marker/type.d.ts
CHANGED
|
@@ -37,16 +37,16 @@ export type IMarkBackgroundAttributes = {
|
|
|
37
37
|
autoHeight?: boolean;
|
|
38
38
|
autoWidth?: boolean;
|
|
39
39
|
} & Partial<SymbolAttributes>;
|
|
40
|
-
export
|
|
40
|
+
export type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {
|
|
41
41
|
panel?: IMarkBackgroundAttributes;
|
|
42
|
-
}
|
|
43
|
-
export
|
|
42
|
+
};
|
|
43
|
+
export type IMarkRef = {
|
|
44
44
|
autoRotate?: boolean;
|
|
45
45
|
refX?: number;
|
|
46
46
|
refY?: number;
|
|
47
47
|
refAngle?: number;
|
|
48
|
-
}
|
|
49
|
-
export
|
|
48
|
+
};
|
|
49
|
+
export type MarkerAttrs = IGroupGraphicAttribute & {
|
|
50
50
|
type?: 'line' | 'area' | 'point';
|
|
51
51
|
interactive?: boolean;
|
|
52
52
|
visible?: boolean;
|
|
@@ -57,16 +57,16 @@ export interface MarkerAttrs extends IGroupGraphicAttribute {
|
|
|
57
57
|
width: number;
|
|
58
58
|
height: number;
|
|
59
59
|
};
|
|
60
|
-
}
|
|
61
|
-
export
|
|
60
|
+
};
|
|
61
|
+
export type MarkLineAttrs = MarkerAttrs & SegmentAttributes & {
|
|
62
62
|
type?: 'line';
|
|
63
63
|
points: Point[] | Point[][];
|
|
64
64
|
label?: {
|
|
65
65
|
position?: keyof typeof IMarkLineLabelPosition;
|
|
66
66
|
confine?: boolean;
|
|
67
67
|
} & IMarkRef & IMarkLabel;
|
|
68
|
-
}
|
|
69
|
-
export
|
|
68
|
+
};
|
|
69
|
+
export type MarkAreaAttrs = MarkerAttrs & {
|
|
70
70
|
type?: 'area';
|
|
71
71
|
points: Point[];
|
|
72
72
|
label?: {
|
|
@@ -74,8 +74,8 @@ export interface MarkAreaAttrs extends MarkerAttrs {
|
|
|
74
74
|
confine?: boolean;
|
|
75
75
|
} & IMarkLabel;
|
|
76
76
|
areaStyle?: IPolygonAttribute;
|
|
77
|
-
}
|
|
78
|
-
export
|
|
77
|
+
};
|
|
78
|
+
export type IItemContent = IMarkRef & {
|
|
79
79
|
type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';
|
|
80
80
|
position?: keyof typeof IMarkPointItemPosition;
|
|
81
81
|
offsetX?: number;
|
|
@@ -85,7 +85,7 @@ export interface IItemContent extends IMarkRef {
|
|
|
85
85
|
textStyle?: IMarkLabel;
|
|
86
86
|
richTextStyle?: IRichTextGraphicAttribute;
|
|
87
87
|
renderCustomCallback?: () => IGroup;
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
export type IItemLine = {
|
|
90
90
|
type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';
|
|
91
91
|
visible?: boolean;
|
|
@@ -94,8 +94,8 @@ export type IItemLine = {
|
|
|
94
94
|
length?: number;
|
|
95
95
|
};
|
|
96
96
|
} & Omit<SegmentAttributes, 'points'>;
|
|
97
|
-
export
|
|
97
|
+
export type MarkPointAttrs = Omit<MarkerAttrs, 'labelStyle'> & {
|
|
98
98
|
position: Point;
|
|
99
99
|
itemLine?: IItemLine;
|
|
100
100
|
itemContent?: IItemContent;
|
|
101
|
-
}
|
|
101
|
+
};
|
package/es/marker/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":"AAYA,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IPolygonAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { SegmentAttributes, SymbolAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\nimport type { Point } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<SymbolAttributes>;\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":"AAYA,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,qCAAW,CAAA;IACX,2DAAiC,CAAA;IACjC,iEAAuC,CAAA;IACvC,6DAAmC,CAAA;IACnC,mEAAyC,CAAA;IACzC,uDAA6B,CAAA;IAC7B,6DAAmC,CAAA;AACrC,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,qDAA2B,CAAA;IAC3B,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;AAC/B,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,iDAAuB,CAAA;IACvB,uDAA6B,CAAA;IAC7B,uDAA6B,CAAA;AAC/B,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC","file":"type.js","sourcesContent":["import type {\n IGroup,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IPolygonAttribute,\n IRichTextGraphicAttribute,\n ISymbolGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { SegmentAttributes, SymbolAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\nimport type { Point } from '../core/type';\n\nexport enum IMarkLineLabelPosition {\n start = 'start',\n middle = 'middle',\n end = 'end',\n insideStartTop = 'insideStartTop',\n insideStartBottom = 'insideStartBottom',\n insideMiddleTop = 'insideMiddleTop',\n insideMiddleBottom = 'insideMiddleBottom',\n insideEndTop = 'insideEndTop',\n insideEndBottom = 'insideEndBottom'\n}\n\nexport enum IMarkAreaLabelPosition {\n left = 'left',\n right = 'right',\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideLeft = 'insideLeft',\n insideRight = 'insideRight',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom'\n}\n\nexport enum IMarkPointItemPosition {\n top = 'top',\n bottom = 'bottom',\n middle = 'middle',\n insideTop = 'insideTop',\n insideBottom = 'insideBottom',\n insideMiddle = 'insideMiddle'\n}\n\nexport type IMarkBackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * TODO: 根据文字宽度进行背景 panel size自适应\n */\n autoHeight?: boolean;\n /**\n * TODO: 根据文高度度进行背景 panel size自适应\n */\n autoWidth?: boolean;\n} & Partial<SymbolAttributes>;\n\nexport type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n};\n\nexport type IMarkRef = {\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * label 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n};\n\nexport type MarkerAttrs = IGroupGraphicAttribute & {\n type?: 'line' | 'area' | 'point';\n /**\n * 是否支持交互\n * @default false\n */\n interactive?: boolean;\n /**\n * 是否显示marker组件\n * @default true\n */\n visible?: boolean;\n /**\n * 是否将组件在绘制区域内进行剪切\n * @default true\n */\n clipInRange?: boolean;\n /**\n * 组件绘制范围配置\n */\n limitRect?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n};\n\nexport type MarkLineAttrs = MarkerAttrs &\n SegmentAttributes & {\n type?: 'line';\n /**\n * 构成line的点: 如果是两个点,则为直线;多个点则为曲线\n */\n points: Point[] | Point[][];\n\n /**\n * 标签\n */\n label?: {\n /**\n * label 相对line的位置\n */\n position?: keyof typeof IMarkLineLabelPosition;\n /**\n * 当 mark 配置了 clip 之后,label 是否自动调整位置\n */\n confine?: boolean;\n } & IMarkRef &\n IMarkLabel;\n };\n\nexport type MarkAreaAttrs = MarkerAttrs & {\n type?: 'area';\n /**\n * 构成area的点\n */\n points: Point[];\n /**\n * 标签\n */\n label?: {\n position?: keyof typeof IMarkAreaLabelPosition;\n /**\n * 当 mark 配置了 clip 之后,label 是否自动调整位置\n */\n confine?: boolean;\n } & IMarkLabel;\n /**\n * area的样式\n */\n areaStyle?: IPolygonAttribute;\n};\n\nexport type IItemContent = IMarkRef & {\n /**\n * 标注类型\n * Tips: 保留'richText'与之前的定义做兼容\n */\n type?: 'symbol' | 'text' | 'image' | 'richText' | 'custom';\n position?: keyof typeof IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbolStyle?: ISymbolGraphicAttribute;\n /**\n * type为image时, image的样式\n */\n imageStyle?: IImageGraphicAttribute;\n /**\n * type为text时, text的配置\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上,继承自TagAttributes。\n */\n textStyle?: IMarkLabel;\n /**\n * type为rich text时, rich text的样式\n */\n richTextStyle?: IRichTextGraphicAttribute;\n /**\n * type为custom时,允许以callback的方式传入需要render的item\n */\n renderCustomCallback?: () => IGroup;\n // /**\n // * 当 mark 配置了 clip 之后,label 是否自动调整位置\n // */\n // confine?: boolean;\n};\n\nexport type IItemLine = {\n /** TODO:'type-opo' */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n visible?: boolean;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n visible?: boolean;\n length?: number;\n };\n} & Omit<SegmentAttributes, 'points'>;\n\nexport type MarkPointAttrs = Omit<MarkerAttrs, 'labelStyle'> & {\n /**\n * markPoint的位置(也是path的起点)\n */\n position: Point;\n /**\n * 标注引导线\n */\n itemLine?: IItemLine;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n};\n"]}
|
package/es/tag/tag.js
CHANGED
|
@@ -14,13 +14,15 @@ import { AbstractComponent } from "../core/base";
|
|
|
14
14
|
|
|
15
15
|
import { measureTextSize } from "../util";
|
|
16
16
|
|
|
17
|
+
import { DEFAULT_HTML_TEXT_SPEC } from "../constant";
|
|
18
|
+
|
|
17
19
|
export class Tag extends AbstractComponent {
|
|
18
20
|
constructor(attributes) {
|
|
19
21
|
super(merge({}, Tag.defaultAttributes, attributes)), this.name = "tag";
|
|
20
22
|
}
|
|
21
23
|
render() {
|
|
22
|
-
var _a;
|
|
23
|
-
const {text: text = "", textStyle: textStyle = {}, shape: shape = {}, panel: panel = {}, space: space = 4, minWidth: minWidth, maxWidth: maxWidth, padding: padding = 4, visible: visible, state: state} = this.attribute, parsedPadding = normalizePadding(padding), group = this.createOrUpdateChild("tag-content", {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
const {text: text = "", textStyle: textStyle = {}, shape: shape = {}, panel: panel = {}, space: space = 4, minWidth: minWidth, maxWidth: maxWidth, padding: padding = 4, visible: visible, state: state, type: type} = this.attribute, parsedPadding = normalizePadding(padding), group = this.createOrUpdateChild("tag-content", {
|
|
24
26
|
x: 0,
|
|
25
27
|
y: 0,
|
|
26
28
|
zIndex: 1
|
|
@@ -40,42 +42,88 @@ export class Tag extends AbstractComponent {
|
|
|
40
42
|
}), "symbol"), isEmpty(null == state ? void 0 : state.shape) || (symbol.states = state.shape),
|
|
41
43
|
shapeVisible && (symbolPlaceWidth = maxSize + space);
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
let textShape;
|
|
46
|
+
if (tagWidth += symbolPlaceWidth, textX += symbolPlaceWidth, "rich" === type) {
|
|
47
|
+
const richTextAttrs = Object.assign(Object.assign({
|
|
48
|
+
textConfig: text,
|
|
49
|
+
visible: isValid(text) && !1 !== visible
|
|
50
|
+
}, textStyle), {
|
|
51
|
+
x: textX,
|
|
52
|
+
y: 0,
|
|
53
|
+
width: null !== (_a = textStyle.width) && void 0 !== _a ? _a : 0,
|
|
54
|
+
height: null !== (_b = textStyle.height) && void 0 !== _b ? _b : 0
|
|
55
|
+
});
|
|
56
|
+
textShape = group.createOrUpdateChild("tag-text", richTextAttrs, "richtext");
|
|
57
|
+
const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
|
|
58
|
+
if (visible && isBoolean(bgVisible)) {
|
|
59
|
+
const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
|
|
60
|
+
visible: bgVisible && !!text,
|
|
61
|
+
x: textShape.AABBBounds.x1,
|
|
62
|
+
y: textShape.AABBBounds.y1,
|
|
63
|
+
width: textShape.AABBBounds.width(),
|
|
64
|
+
height: textShape.AABBBounds.height()
|
|
65
|
+
}), "rect");
|
|
66
|
+
isEmpty(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
|
|
67
|
+
}
|
|
68
|
+
} else if ("html" === type) {
|
|
69
|
+
const richTextAttrs = Object.assign(Object.assign({
|
|
70
|
+
textConfig: [],
|
|
71
|
+
visible: isValid(text) && !1 !== visible,
|
|
72
|
+
html: Object.assign(Object.assign({
|
|
73
|
+
dom: text
|
|
74
|
+
}, DEFAULT_HTML_TEXT_SPEC), textStyle)
|
|
75
|
+
}, textStyle), {
|
|
76
|
+
x: textX,
|
|
77
|
+
y: 0
|
|
78
|
+
});
|
|
79
|
+
textShape = group.createOrUpdateChild("tag-text", richTextAttrs, "richtext");
|
|
80
|
+
const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
|
|
81
|
+
if (visible && isBoolean(bgVisible)) {
|
|
82
|
+
const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
|
|
83
|
+
visible: bgVisible && !!text,
|
|
84
|
+
x: textShape.AABBBounds.x1,
|
|
85
|
+
y: textShape.AABBBounds.y1,
|
|
86
|
+
width: textShape.AABBBounds.width(),
|
|
87
|
+
height: textShape.AABBBounds.height()
|
|
88
|
+
}), "rect");
|
|
89
|
+
isEmpty(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
const textAttrs = Object.assign(Object.assign({
|
|
93
|
+
text: text,
|
|
94
|
+
visible: isValid(text) && !1 !== visible,
|
|
95
|
+
lineHeight: null == textStyle ? void 0 : textStyle.fontSize
|
|
96
|
+
}, textStyle), {
|
|
97
|
+
x: textX,
|
|
98
|
+
y: 0
|
|
99
|
+
});
|
|
100
|
+
isNil(textAttrs.lineHeight) && (textAttrs.lineHeight = textStyle.fontSize), textShape = group.createOrUpdateChild("tag-text", textAttrs, "text"),
|
|
101
|
+
isEmpty(null == state ? void 0 : state.text) || (textShape.states = state.text);
|
|
102
|
+
const textBounds = measureTextSize(textAttrs.text, textStyle), textWidth = textBounds.width, textHeight = textBounds.height;
|
|
103
|
+
tagWidth += textWidth;
|
|
104
|
+
const size = null !== (_c = shape.size) && void 0 !== _c ? _c : 10, maxSize = isNumber(size) ? size : Math.max(size[0], size[1]);
|
|
105
|
+
tagHeight += Math.max(textHeight, (null == shape ? void 0 : shape.visible) ? maxSize : 0);
|
|
106
|
+
const {textAlign: textAlign, textBaseline: textBaseline} = textStyle;
|
|
107
|
+
(isValid(minWidth) || isValid(maxWidth)) && (isValid(minWidth) && tagWidth < minWidth && (tagWidth = minWidth),
|
|
108
|
+
isValid(maxWidth) && tagWidth > maxWidth && (tagWidth = maxWidth, textShape.setAttribute("maxLineWidth", maxWidth - parsedPadding[1] - parsedPadding[2])));
|
|
109
|
+
let x = 0, y = 0;
|
|
110
|
+
"center" === textAlign ? (x -= tagWidth / 2, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth / 2),
|
|
111
|
+
group.setAttribute("x", -symbolPlaceWidth / 2)) : "right" === textAlign || "end" === textAlign ? (x -= tagWidth,
|
|
112
|
+
symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth), group.setAttribute("x", -parsedPadding[1] - symbolPlaceWidth)) : "left" !== textAlign && "start" !== textAlign || group.setAttribute("x", parsedPadding[3]),
|
|
113
|
+
"middle" === textBaseline ? (y -= tagHeight / 2, symbol && symbol.setAttribute("y", 0)) : "bottom" === textBaseline ? (y -= tagHeight,
|
|
114
|
+
symbol && symbol.setAttribute("y", -textHeight / 2), group.setAttribute("y", -parsedPadding[2])) : "top" === textBaseline && (group.setAttribute("y", parsedPadding[0]),
|
|
115
|
+
symbol && symbol.setAttribute("y", textHeight / 2));
|
|
116
|
+
const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
|
|
117
|
+
if (visible && isBoolean(bgVisible)) {
|
|
118
|
+
const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
|
|
119
|
+
visible: bgVisible && !!text,
|
|
120
|
+
x: x,
|
|
121
|
+
y: y,
|
|
122
|
+
width: tagWidth,
|
|
123
|
+
height: tagHeight
|
|
124
|
+
}), "rect");
|
|
125
|
+
isEmpty(null == state ? void 0 :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EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IAEV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport type { IGroup, IRect, ISymbol, IText, ITextAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { BackgroundAttributes } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\n\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\n\n static defaultAttributes: Partial<TagAttributes> = {\n visible: true,\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 4,\n padding: 4,\n // @ts-ignore\n shape: {\n fill: '#000'\n }\n };\n\n constructor(attributes: TagAttributes) {\n super(merge({}, Tag.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n text = '',\n textStyle = {} as ITextGraphicAttribute,\n shape = {} as TagShapeAttributes,\n panel = {} as BackgroundAttributes,\n space = 4,\n minWidth,\n maxWidth,\n padding = 4,\n visible,\n state\n } = this.attribute as TagAttributes;\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n let symbol;\n let tagWidth = parsedPadding[1] + parsedPadding[3];\n let tagHeight = parsedPadding[0] + parsedPadding[2];\n let textX = 0;\n let symbolPlaceWidth = 0;\n const { visible: shapeVisible, ...shapeStyle } = shape;\n if (isBoolean(shapeVisible)) {\n const size = shapeStyle?.size || 10;\n const maxSize = isNumber(size) ? size : Math.max(size[0], size[1]);\n\n symbol = group.createOrUpdateChild(\n 'tag-shape',\n {\n symbolType: 'circle',\n size,\n strokeBoundsBuffer: 0,\n ...shapeStyle,\n visible: shapeVisible,\n x: maxSize / 2,\n y: maxSize / 2\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.shape)) {\n symbol.states = state.shape;\n }\n\n if (shapeVisible) {\n symbolPlaceWidth = maxSize + space;\n }\n }\n\n tagWidth += symbolPlaceWidth;\n textX += symbolPlaceWidth;\n\n const textAttrs = {\n text,\n visible: isValid(text) && visible !== false,\n lineHeight: textStyle?.fontSize,\n ...textStyle,\n x: textX,\n y: 0\n };\n if (isNil(textAttrs.lineHeight)) {\n textAttrs.lineHeight = textAttrs.fontSize;\n }\n const textShape = group.createOrUpdateChild('tag-text', textAttrs, 'text') as IText;\n if (!isEmpty(state?.text)) {\n textShape.states = state.text;\n }\n\n // 因为文本可能发生旋转,所以需要使用 measureTextSize 方法\n const textBounds = measureTextSize(textAttrs.text, textStyle);\n const textWidth = textBounds.width;\n const textHeight = textBounds.height;\n tagWidth += textWidth;\n const size = shape.size ?? 10;\n const maxSize = isNumber(size) ? size : Math.max(size[0], size[1]);\n tagHeight += Math.max(textHeight, shape?.visible ? maxSize : 0);\n\n const { textAlign, textBaseline } = textStyle as ITextAttribute;\n\n if (isValid(minWidth) || isValid(maxWidth)) {\n if (isValid(minWidth) && tagWidth < minWidth) {\n tagWidth = minWidth;\n }\n if (isValid(maxWidth) && tagWidth > maxWidth) {\n tagWidth = maxWidth;\n textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);\n }\n }\n\n let x = 0;\n let y = 0;\n if (textAlign === 'center') {\n x -= tagWidth / 2;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);\n }\n\n group.setAttribute('x', -symbolPlaceWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n x -= tagWidth;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);\n }\n\n group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);\n } else if (textAlign === 'left' || textAlign === 'start') {\n group.setAttribute('x', parsedPadding[3]);\n }\n if (textBaseline === 'middle') {\n y -= tagHeight / 2;\n if (symbol) {\n symbol.setAttribute('y', 0);\n }\n } else if (textBaseline === 'bottom') {\n y -= tagHeight;\n if (symbol) {\n symbol.setAttribute('y', -textHeight / 2);\n }\n\n group.setAttribute('y', -parsedPadding[2]);\n } else if (textBaseline === 'top') {\n group.setAttribute('y', parsedPadding[0]);\n if (symbol) {\n symbol.setAttribute('y', textHeight / 2);\n }\n }\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x,\n y,\n width: tagWidth,\n height: tagHeight\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;;;;;;;AAcA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,OAAO,GAAI,SAAQ,iBAA0C;IAmBjE,YAAY,UAAyB;QACnC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAnBtD,SAAI,GAAG,KAAK,CAAC;IAoBb,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,IAAI,GAAG,EAAE,EACT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CAAC;oBACD,CAAC,EACD,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,KAEnB,MAAM,CACE,CAAC;gBACX,IAAI,CAAC,OAAO,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,EAAE;oBAC1B,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;iBAC7B;aACF;SACF;IACH,CAAC;;AA3OM,qBAAiB,GAA2B;IACjD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IAEV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;CACF,CAAC","file":"tag.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport type {\n IGroup,\n IRect,\n ISymbol,\n IText,\n ITextAttribute,\n ITextGraphicAttribute,\n IRichTextGraphicAttribute,\n IRichText,\n IRichTextCharacter\n} from '@visactor/vrender-core';\nimport { isBoolean, isEmpty, isNil, isNumber, isValid, merge, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { BackgroundAttributes } from '../interface';\nimport type { TagAttributes, TagShapeAttributes } from './type';\nimport { DEFAULT_HTML_TEXT_SPEC } from '../constant';\n\nexport class Tag extends AbstractComponent<Required<TagAttributes>> {\n name = 'tag';\n\n static defaultAttributes: Partial<TagAttributes> = {\n visible: true,\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'left',\n textBaseline: 'top'\n },\n space: 4,\n padding: 4,\n // @ts-ignore\n shape: {\n fill: '#000'\n }\n };\n\n constructor(attributes: TagAttributes) {\n super(merge({}, Tag.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n text = '',\n textStyle = {} as ITextGraphicAttribute | IRichTextGraphicAttribute,\n shape = {} as TagShapeAttributes,\n panel = {} as BackgroundAttributes,\n space = 4,\n minWidth,\n maxWidth,\n padding = 4,\n visible,\n state,\n type\n } = this.attribute as TagAttributes;\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild('tag-content', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n let symbol;\n let tagWidth = parsedPadding[1] + parsedPadding[3];\n let tagHeight = parsedPadding[0] + parsedPadding[2];\n let textX = 0;\n let symbolPlaceWidth = 0;\n const { visible: shapeVisible, ...shapeStyle } = shape;\n if (isBoolean(shapeVisible)) {\n const size = shapeStyle?.size || 10;\n const maxSize = isNumber(size) ? size : Math.max(size[0], size[1]);\n\n symbol = group.createOrUpdateChild(\n 'tag-shape',\n {\n symbolType: 'circle',\n size,\n strokeBoundsBuffer: 0,\n ...shapeStyle,\n visible: shapeVisible,\n x: maxSize / 2,\n y: maxSize / 2\n },\n 'symbol'\n ) as ISymbol;\n if (!isEmpty(state?.shape)) {\n symbol.states = state.shape;\n }\n\n if (shapeVisible) {\n symbolPlaceWidth = maxSize + space;\n }\n }\n\n tagWidth += symbolPlaceWidth;\n textX += symbolPlaceWidth;\n\n let textShape;\n if (type === 'rich') {\n const richTextAttrs = {\n textConfig: text as IRichTextCharacter[],\n visible: isValid(text) && visible !== false,\n ...(textStyle as IRichTextGraphicAttribute),\n x: textX,\n y: 0,\n width: (textStyle as IRichTextGraphicAttribute).width ?? 0,\n height: (textStyle as IRichTextGraphicAttribute).height ?? 0\n };\n textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x: textShape.AABBBounds.x1,\n y: textShape.AABBBounds.y1,\n width: textShape.AABBBounds.width(),\n height: textShape.AABBBounds.height()\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n } else if (type === 'html') {\n const richTextAttrs = {\n textConfig: [] as IRichTextCharacter[],\n visible: isValid(text) && visible !== false,\n html: {\n dom: text as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...textStyle\n },\n ...(textStyle as IRichTextGraphicAttribute),\n x: textX,\n y: 0\n };\n textShape = group.createOrUpdateChild('tag-text', richTextAttrs, 'richtext') as IRichText;\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x: textShape.AABBBounds.x1,\n y: textShape.AABBBounds.y1,\n width: textShape.AABBBounds.width(),\n height: textShape.AABBBounds.height()\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n } else {\n const textAttrs = {\n text: text as string | number | string[] | number[],\n visible: isValid(text) && visible !== false,\n lineHeight: (textStyle as ITextGraphicAttribute)?.fontSize,\n ...(textStyle as ITextGraphicAttribute),\n x: textX,\n y: 0\n };\n if (isNil(textAttrs.lineHeight)) {\n textAttrs.lineHeight = (textStyle as ITextGraphicAttribute).fontSize;\n }\n textShape = group.createOrUpdateChild('tag-text', textAttrs, 'text') as IText;\n if (!isEmpty(state?.text)) {\n textShape.states = state.text;\n }\n\n // 因为文本可能发生旋转,所以需要使用 measureTextSize 方法\n const textBounds = measureTextSize(textAttrs.text as string, textStyle);\n const textWidth = textBounds.width;\n const textHeight = textBounds.height;\n tagWidth += textWidth;\n const size = shape.size ?? 10;\n const maxSize = isNumber(size) ? size : Math.max(size[0], size[1]);\n tagHeight += Math.max(textHeight, shape?.visible ? maxSize : 0);\n\n const { textAlign, textBaseline } = textStyle as ITextAttribute;\n\n if (isValid(minWidth) || isValid(maxWidth)) {\n if (isValid(minWidth) && tagWidth < minWidth) {\n tagWidth = minWidth;\n }\n if (isValid(maxWidth) && tagWidth > maxWidth) {\n tagWidth = maxWidth;\n textShape.setAttribute('maxLineWidth', maxWidth - parsedPadding[1] - parsedPadding[2]);\n }\n }\n\n let x = 0;\n let y = 0;\n if (textAlign === 'center') {\n x -= tagWidth / 2;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth / 2);\n }\n\n group.setAttribute('x', -symbolPlaceWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n x -= tagWidth;\n if (symbol) {\n symbol.setAttribute('x', (symbol.attribute.x || 0) - textWidth);\n }\n\n group.setAttribute('x', -parsedPadding[1] - symbolPlaceWidth);\n } else if (textAlign === 'left' || textAlign === 'start') {\n group.setAttribute('x', parsedPadding[3]);\n }\n if (textBaseline === 'middle') {\n y -= tagHeight / 2;\n if (symbol) {\n symbol.setAttribute('y', 0);\n }\n } else if (textBaseline === 'bottom') {\n y -= tagHeight;\n if (symbol) {\n symbol.setAttribute('y', -textHeight / 2);\n }\n\n group.setAttribute('y', -parsedPadding[2]);\n } else if (textBaseline === 'top') {\n group.setAttribute('y', parsedPadding[0]);\n if (symbol) {\n symbol.setAttribute('y', textHeight / 2);\n }\n }\n\n // 绘制背景层\n const { visible: bgVisible, ...backgroundStyle } = panel;\n if (visible && isBoolean(bgVisible)) {\n const bgRect = this.createOrUpdateChild(\n 'tag-panel',\n {\n ...backgroundStyle,\n visible: bgVisible && !!text,\n x,\n y,\n width: tagWidth,\n height: tagHeight\n },\n 'rect'\n ) as IRect;\n if (!isEmpty(state?.panel)) {\n bgRect.states = state.panel;\n }\n }\n }\n }\n}\n"]}
|
package/es/tag/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ITextGraphicAttribute, ISymbolGraphicAttribute, IGroupGraphicAttribute, IRectGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
-
import type { Padding, State } from '../core/type';
|
|
1
|
+
import type { ITextGraphicAttribute, ISymbolGraphicAttribute, IGroupGraphicAttribute, IRectGraphicAttribute, IRichTextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
+
import type { Padding, State, TextContent } from '../core/type';
|
|
3
3
|
import type { BackgroundAttributes } from '../interface';
|
|
4
4
|
type StateStyle = {
|
|
5
5
|
text?: State<Partial<ITextGraphicAttribute>>;
|
|
@@ -7,8 +7,7 @@ type StateStyle = {
|
|
|
7
7
|
panel?: State<Partial<IRectGraphicAttribute>>;
|
|
8
8
|
};
|
|
9
9
|
export type TagAttributes = {
|
|
10
|
-
|
|
11
|
-
textStyle?: Partial<ITextGraphicAttribute>;
|
|
10
|
+
textStyle?: Partial<ITextGraphicAttribute> | Partial<IRichTextGraphicAttribute>;
|
|
12
11
|
shape?: TagShapeAttributes;
|
|
13
12
|
space?: number;
|
|
14
13
|
padding?: Padding;
|
|
@@ -17,7 +16,7 @@ export type TagAttributes = {
|
|
|
17
16
|
maxWidth?: number;
|
|
18
17
|
visible?: boolean;
|
|
19
18
|
state?: StateStyle;
|
|
20
|
-
} & Omit<IGroupGraphicAttribute, 'background'
|
|
19
|
+
} & Omit<IGroupGraphicAttribute, 'background'> & TextContent;
|
|
21
20
|
export type TagShapeAttributes = {
|
|
22
21
|
visible: boolean;
|
|
23
22
|
} & Partial<ISymbolGraphicAttribute>;
|
package/es/tag/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tag/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IGroupGraphicAttribute,\n IRectGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Padding, State } from '../core/type';\nimport type { BackgroundAttributes } from '../interface';\n\ntype StateStyle = {\n /**\n * text 文本的状态配置\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置ß\n */\n panel?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type TagAttributes = {\n
|
|
1
|
+
{"version":3,"sources":["../src/tag/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n IRichTextCharacter,\n IRichTextGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { Padding, State, TextContent } from '../core/type';\nimport type { BackgroundAttributes } from '../interface';\n\ntype StateStyle = {\n /**\n * text 文本的状态配置\n */\n text?: State<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: State<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置ß\n */\n panel?: State<Partial<IRectGraphicAttribute>>;\n};\n\nexport type TagAttributes = {\n /** 文本样式 */\n textStyle?: Partial<ITextGraphicAttribute> | Partial<IRichTextGraphicAttribute>;\n /** 文本前 mark 图元 */\n shape?: TagShapeAttributes;\n /**\n * shape 同文本之间的间距\n */\n space?: number;\n /**\n * 内部边距\n */\n padding?: Padding;\n /**\n * 标签的背景面板配置, TODO: 支持symbol形状\n */\n panel?: BackgroundAttributes;\n /**\n * 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n visible?: boolean;\n state?: StateStyle;\n} & Omit<IGroupGraphicAttribute, 'background'> &\n TextContent;\n\nexport type TagShapeAttributes = {\n /**\n * 是否展示 shape\n */\n visible: boolean;\n} & Partial<ISymbolGraphicAttribute>;\n"]}
|
package/es/title/title.js
CHANGED
|
@@ -2,19 +2,21 @@ import { merge, isValid, normalizePadding } from "@visactor/vutils";
|
|
|
2
2
|
|
|
3
3
|
import { AbstractComponent } from "../core/base";
|
|
4
4
|
|
|
5
|
+
import { DEFAULT_HTML_TEXT_SPEC } from "../constant";
|
|
6
|
+
|
|
5
7
|
export class Title extends AbstractComponent {
|
|
6
8
|
constructor(attributes) {
|
|
7
9
|
super(merge({}, Title.defaultAttributes, attributes)), this.name = "title";
|
|
8
10
|
}
|
|
9
11
|
render() {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37;
|
|
11
|
-
const {text: text, textStyle: textStyle, subtext: subtext, subtextStyle: subtextStyle, width: width, height: height, minWidth: minWidth, maxWidth: maxWidth, minHeight: minHeight, maxHeight: maxHeight, align: align, verticalAlign: verticalAlign, padding: padding = 0} = this.attribute, parsedPadding = normalizePadding(padding), group = this.createOrUpdateChild("title-container", {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55;
|
|
13
|
+
const {textType: textType, text: text, subtextType: subtextType, textStyle: textStyle, subtext: subtext, subtextStyle: subtextStyle, width: width, height: height, minWidth: minWidth, maxWidth: maxWidth, minHeight: minHeight, maxHeight: maxHeight, align: align, verticalAlign: verticalAlign, padding: padding = 0} = this.attribute, parsedPadding = normalizePadding(padding), group = this.createOrUpdateChild("title-container", {
|
|
12
14
|
x: parsedPadding[3],
|
|
13
15
|
y: parsedPadding[0],
|
|
14
16
|
zIndex: 1
|
|
15
17
|
}, "group");
|
|
16
|
-
if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if (
|
|
17
|
-
const attr = {
|
|
18
|
+
if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if ("rich" === textType || isValid(textStyle.character)) {
|
|
19
|
+
const attr = Object.assign({
|
|
18
20
|
x: null !== (_b = textStyle.x) && void 0 !== _b ? _b : 0,
|
|
19
21
|
y: null !== (_c = textStyle.y) && void 0 !== _c ? _c : 0,
|
|
20
22
|
width: null !== (_e = null !== (_d = textStyle.width) && void 0 !== _d ? _d : width) && void 0 !== _e ? _e : 0,
|
|
@@ -23,84 +25,116 @@ export class Title extends AbstractComponent {
|
|
|
23
25
|
wordBreak: null !== (_j = textStyle.wordBreak) && void 0 !== _j ? _j : "break-word",
|
|
24
26
|
maxHeight: textStyle.maxHeight,
|
|
25
27
|
maxWidth: textStyle.maxWidth,
|
|
26
|
-
textConfig: textStyle.character
|
|
27
|
-
};
|
|
28
|
+
textConfig: null !== (_k = textStyle.character) && void 0 !== _k ? _k : text
|
|
29
|
+
}, textStyle);
|
|
30
|
+
this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
|
|
31
|
+
} else if ("html" === textType) {
|
|
32
|
+
const attr = Object.assign({
|
|
33
|
+
html: Object.assign(Object.assign({
|
|
34
|
+
dom: text
|
|
35
|
+
}, DEFAULT_HTML_TEXT_SPEC), textStyle),
|
|
36
|
+
x: null !== (_l = textStyle.x) && void 0 !== _l ? _l : 0,
|
|
37
|
+
y: null !== (_m = textStyle.y) && void 0 !== _m ? _m : 0,
|
|
38
|
+
width: null !== (_p = null !== (_o = textStyle.width) && void 0 !== _o ? _o : width) && void 0 !== _p ? _p : 0,
|
|
39
|
+
height: null !== (_r = null !== (_q = textStyle.height) && void 0 !== _q ? _q : height) && void 0 !== _r ? _r : 0,
|
|
40
|
+
ellipsis: null === (_s = textStyle.ellipsis) || void 0 === _s || _s,
|
|
41
|
+
wordBreak: null !== (_t = textStyle.wordBreak) && void 0 !== _t ? _t : "break-word",
|
|
42
|
+
maxHeight: textStyle.maxHeight,
|
|
43
|
+
maxWidth: textStyle.maxWidth,
|
|
44
|
+
textConfig: []
|
|
45
|
+
}, textStyle);
|
|
28
46
|
this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
|
|
29
47
|
} else isValid(text) && (this._mainTitle = group.createOrUpdateChild("mainTitle", Object.assign(Object.assign({
|
|
30
48
|
text: [ text ]
|
|
31
49
|
}, textStyle), {
|
|
32
|
-
maxLineWidth: null !== (
|
|
50
|
+
maxLineWidth: null !== (_u = null == textStyle ? void 0 : textStyle.maxLineWidth) && void 0 !== _u ? _u : width,
|
|
33
51
|
heightLimit: null == textStyle ? void 0 : textStyle.heightLimit,
|
|
34
52
|
lineClamp: null == textStyle ? void 0 : textStyle.lineClamp,
|
|
35
|
-
ellipsis: null === (
|
|
53
|
+
ellipsis: null === (_v = null == textStyle ? void 0 : textStyle.ellipsis) || void 0 === _v || _v,
|
|
36
54
|
x: 0,
|
|
37
55
|
y: 0
|
|
38
56
|
}), "wrapText"));
|
|
39
|
-
const maintextHeight = this._mainTitle ? null === (
|
|
40
|
-
if (!1 !== (null === (
|
|
41
|
-
const attr = {
|
|
42
|
-
x: null !== (
|
|
43
|
-
y: null !== (
|
|
44
|
-
width: null !== (
|
|
45
|
-
height: null !== (
|
|
46
|
-
ellipsis: null === (
|
|
47
|
-
wordBreak: null !== (
|
|
57
|
+
const maintextHeight = this._mainTitle ? null === (_w = this._mainTitle) || void 0 === _w ? void 0 : _w.AABBBounds.height() : 0, maintextWidth = this._mainTitle ? null === (_x = this._mainTitle) || void 0 === _x ? void 0 : _x.AABBBounds.width() : 0;
|
|
58
|
+
if (!1 !== (null === (_y = this.attribute) || void 0 === _y ? void 0 : _y.visible) && !1 !== (null == subtextStyle ? void 0 : subtextStyle.visible)) if ("rich" === subtextType || isValid(subtextStyle.character)) {
|
|
59
|
+
const attr = Object.assign({
|
|
60
|
+
x: null !== (_z = subtextStyle.x) && void 0 !== _z ? _z : 0,
|
|
61
|
+
y: null !== (_0 = subtextStyle.y) && void 0 !== _0 ? _0 : 0,
|
|
62
|
+
width: null !== (_2 = null !== (_1 = subtextStyle.width) && void 0 !== _1 ? _1 : width) && void 0 !== _2 ? _2 : 0,
|
|
63
|
+
height: null !== (_4 = null !== (_3 = subtextStyle.height) && void 0 !== _3 ? _3 : height) && void 0 !== _4 ? _4 : 0,
|
|
64
|
+
ellipsis: null === (_5 = subtextStyle.ellipsis) || void 0 === _5 || _5,
|
|
65
|
+
wordBreak: null !== (_6 = subtextStyle.wordBreak) && void 0 !== _6 ? _6 : "break-word",
|
|
66
|
+
maxHeight: subtextStyle.maxHeight,
|
|
67
|
+
maxWidth: subtextStyle.maxWidth,
|
|
68
|
+
textConfig: null !== (_7 = subtextStyle.character) && void 0 !== _7 ? _7 : subtext
|
|
69
|
+
}, subtextStyle);
|
|
70
|
+
this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
|
|
71
|
+
} else if ("html" === subtextType) {
|
|
72
|
+
const attr = Object.assign({
|
|
73
|
+
html: Object.assign(Object.assign({
|
|
74
|
+
dom: subtext
|
|
75
|
+
}, DEFAULT_HTML_TEXT_SPEC), subtextStyle),
|
|
76
|
+
x: null !== (_8 = subtextStyle.x) && void 0 !== _8 ? _8 : 0,
|
|
77
|
+
y: null !== (_9 = subtextStyle.y) && void 0 !== _9 ? _9 : 0,
|
|
78
|
+
width: null !== (_11 = null !== (_10 = subtextStyle.width) && void 0 !== _10 ? _10 : width) && void 0 !== _11 ? _11 : 0,
|
|
79
|
+
height: null !== (_13 = null !== (_12 = subtextStyle.height) && void 0 !== _12 ? _12 : height) && void 0 !== _13 ? _13 : 0,
|
|
80
|
+
ellipsis: null === (_14 = subtextStyle.ellipsis) || void 0 === _14 || _14,
|
|
81
|
+
wordBreak: null !== (_15 = subtextStyle.wordBreak) && void 0 !== _15 ? _15 : "break-word",
|
|
48
82
|
maxHeight: subtextStyle.maxHeight,
|
|
49
83
|
maxWidth: subtextStyle.maxWidth,
|
|
50
|
-
textConfig:
|
|
51
|
-
};
|
|
84
|
+
textConfig: []
|
|
85
|
+
}, subtextStyle);
|
|
52
86
|
this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
|
|
53
87
|
} else isValid(subtext) && (this._subTitle = group.createOrUpdateChild("subTitle", Object.assign(Object.assign({
|
|
54
88
|
text: [ subtext ]
|
|
55
89
|
}, subtextStyle), {
|
|
56
|
-
maxLineWidth: null !== (
|
|
90
|
+
maxLineWidth: null !== (_16 = null == subtextStyle ? void 0 : subtextStyle.maxLineWidth) && void 0 !== _16 ? _16 : width,
|
|
57
91
|
heightLimit: null == subtextStyle ? void 0 : subtextStyle.heightLimit,
|
|
58
92
|
lineClamp: null == subtextStyle ? void 0 : subtextStyle.lineClamp,
|
|
59
|
-
ellipsis: null === (
|
|
93
|
+
ellipsis: null === (_17 = null == subtextStyle ? void 0 : subtextStyle.ellipsis) || void 0 === _17 || _17,
|
|
60
94
|
x: 0,
|
|
61
95
|
y: maintextHeight
|
|
62
96
|
}), "wrapText"));
|
|
63
|
-
const subtextHeight = this._subTitle ? null === (
|
|
64
|
-
let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (
|
|
65
|
-
if (isValid(width) && (titleWidth = width, null === (
|
|
66
|
-
null === (
|
|
97
|
+
const subtextHeight = this._subTitle ? null === (_18 = this._subTitle) || void 0 === _18 ? void 0 : _18.AABBBounds.height() : 0, subtextWidth = this._subTitle ? null === (_19 = this._subTitle) || void 0 === _19 ? void 0 : _19.AABBBounds.width() : 0;
|
|
98
|
+
let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_20 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _20 ? _20 : subtextHeight);
|
|
99
|
+
if (isValid(width) && (titleWidth = width, null === (_21 = this._mainTitle) || void 0 === _21 || _21.setAttribute("maxLineWidth", width),
|
|
100
|
+
null === (_22 = this._subTitle) || void 0 === _22 || _22.setAttribute("maxLineWidth", width)),
|
|
67
101
|
isValid(height) && (titleHeight = height), isValid(minWidth) && titleWidth < minWidth && (titleWidth = minWidth),
|
|
68
|
-
isValid(maxWidth) && (null === (
|
|
69
|
-
null === (
|
|
70
|
-
null === (
|
|
71
|
-
null === (
|
|
102
|
+
isValid(maxWidth) && (null === (_23 = this._mainTitle) || void 0 === _23 || _23.setAttribute("maxLineWidth", maxWidth),
|
|
103
|
+
null === (_24 = this._subTitle) || void 0 === _24 || _24.setAttribute("maxLineWidth", maxWidth),
|
|
104
|
+
null === (_25 = this._mainTitle) || void 0 === _25 || _25.setAttribute("maxWidth", maxWidth),
|
|
105
|
+
null === (_26 = this._subTitle) || void 0 === _26 || _26.setAttribute("maxWidth", maxWidth),
|
|
72
106
|
titleWidth > maxWidth && (titleWidth = maxWidth)), isValid(minHeight) && titleHeight < minHeight && (titleHeight = minHeight),
|
|
73
|
-
isValid(maxHeight) && (null === (
|
|
74
|
-
null === (
|
|
107
|
+
isValid(maxHeight) && (null === (_27 = this._mainTitle) || void 0 === _27 || _27.setAttribute("maxHeight", maxHeight),
|
|
108
|
+
null === (_28 = this._subTitle) || void 0 === _28 || _28.setAttribute("maxHeight", maxHeight - maintextHeight),
|
|
75
109
|
titleHeight > maxHeight && (titleHeight = maxHeight)), group.attribute.width = titleWidth,
|
|
76
110
|
group.attribute.height = titleHeight, group.attribute.boundsPadding = parsedPadding,
|
|
77
111
|
isValid(align) || isValid(null == textStyle ? void 0 : textStyle.align)) {
|
|
78
|
-
const mainTitleAlign = (null == textStyle ? void 0 : textStyle.align) ? null == textStyle ? void 0 : textStyle.align : align, mainTitleWidth = null !== (
|
|
79
|
-
"left" === mainTitleAlign ? (null === (
|
|
80
|
-
null === (
|
|
81
|
-
null === (
|
|
82
|
-
null === (
|
|
112
|
+
const mainTitleAlign = (null == textStyle ? void 0 : textStyle.align) ? null == textStyle ? void 0 : textStyle.align : align, mainTitleWidth = null !== (_29 = null == textStyle ? void 0 : textStyle.width) && void 0 !== _29 ? _29 : maintextWidth;
|
|
113
|
+
"left" === mainTitleAlign ? (null === (_30 = this._mainTitle) || void 0 === _30 || _30.setAttribute("x", 0),
|
|
114
|
+
null === (_31 = this._mainTitle) || void 0 === _31 || _31.setAttribute("textAlign", "left")) : "center" === mainTitleAlign ? (null === (_32 = this._mainTitle) || void 0 === _32 || _32.setAttribute("x", mainTitleWidth / 2),
|
|
115
|
+
null === (_33 = this._mainTitle) || void 0 === _33 || _33.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (null === (_34 = this._mainTitle) || void 0 === _34 || _34.setAttribute("x", mainTitleWidth),
|
|
116
|
+
null === (_35 = this._mainTitle) || void 0 === _35 || _35.setAttribute("textAlign", "right"));
|
|
83
117
|
}
|
|
84
118
|
if (isValid(verticalAlign) || isValid(null == textStyle ? void 0 : textStyle.verticalAlign)) {
|
|
85
119
|
const mainTitleVerticalAlign = (null == textStyle ? void 0 : textStyle.verticalAlign) ? null == textStyle ? void 0 : textStyle.verticalAlign : verticalAlign, mainTitleHeight = (null == textStyle ? void 0 : textStyle.height) ? null == textStyle ? void 0 : textStyle.height : titleHeight;
|
|
86
|
-
"top" === mainTitleVerticalAlign ? (null === (
|
|
87
|
-
null === (
|
|
88
|
-
null === (
|
|
89
|
-
null === (
|
|
120
|
+
"top" === mainTitleVerticalAlign ? (null === (_36 = this._mainTitle) || void 0 === _36 || _36.setAttribute("y", 0),
|
|
121
|
+
null === (_37 = this._mainTitle) || void 0 === _37 || _37.setAttribute("textBaseline", "top")) : "middle" === mainTitleVerticalAlign ? (null === (_38 = this._mainTitle) || void 0 === _38 || _38.setAttribute("y", mainTitleHeight / 2),
|
|
122
|
+
null === (_39 = this._mainTitle) || void 0 === _39 || _39.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (null === (_40 = this._mainTitle) || void 0 === _40 || _40.setAttribute("y", mainTitleHeight),
|
|
123
|
+
null === (_41 = this._mainTitle) || void 0 === _41 || _41.setAttribute("textBaseline", "bottom"));
|
|
90
124
|
}
|
|
91
125
|
if (isValid(align) || isValid(null == subtextStyle ? void 0 : subtextStyle.align)) {
|
|
92
|
-
const subTitleAlign = (null == subtextStyle ? void 0 : subtextStyle.align) ? null == subtextStyle ? void 0 : subtextStyle.align : align, subTitleWidth = null !== (
|
|
93
|
-
"left" === subTitleAlign ? (null === (
|
|
94
|
-
null === (
|
|
95
|
-
null === (
|
|
96
|
-
null === (
|
|
126
|
+
const subTitleAlign = (null == subtextStyle ? void 0 : subtextStyle.align) ? null == subtextStyle ? void 0 : subtextStyle.align : align, subTitleWidth = null !== (_42 = null == subtextStyle ? void 0 : subtextStyle.width) && void 0 !== _42 ? _42 : subtextWidth;
|
|
127
|
+
"left" === subTitleAlign ? (null === (_43 = this._subTitle) || void 0 === _43 || _43.setAttribute("x", 0),
|
|
128
|
+
null === (_44 = this._subTitle) || void 0 === _44 || _44.setAttribute("textAlign", "left")) : "center" === subTitleAlign ? (null === (_45 = this._subTitle) || void 0 === _45 || _45.setAttribute("x", subTitleWidth / 2),
|
|
129
|
+
null === (_46 = this._subTitle) || void 0 === _46 || _46.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (null === (_47 = this._subTitle) || void 0 === _47 || _47.setAttribute("x", subTitleWidth),
|
|
130
|
+
null === (_48 = this._subTitle) || void 0 === _48 || _48.setAttribute("textAlign", "right"));
|
|
97
131
|
}
|
|
98
132
|
if (isValid(verticalAlign) || isValid(null == textStyle ? void 0 : textStyle.verticalAlign)) {
|
|
99
|
-
const subTitleVerticalAlign = (null == subtextStyle ? void 0 : subtextStyle.verticalAlign) ? null == subtextStyle ? void 0 : subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (
|
|
100
|
-
"top" === subTitleVerticalAlign ? (null === (
|
|
101
|
-
null === (
|
|
102
|
-
null === (
|
|
103
|
-
null === (
|
|
133
|
+
const subTitleVerticalAlign = (null == subtextStyle ? void 0 : subtextStyle.verticalAlign) ? null == subtextStyle ? void 0 : subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (_49 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _49 ? _49 : 0;
|
|
134
|
+
"top" === subTitleVerticalAlign ? (null === (_50 = this._subTitle) || void 0 === _50 || _50.setAttribute("y", subTitleYStart),
|
|
135
|
+
null === (_51 = this._subTitle) || void 0 === _51 || _51.setAttribute("textBaseline", "top")) : "middle" === subTitleVerticalAlign ? (null === (_52 = this._subTitle) || void 0 === _52 || _52.setAttribute("y", subTitleYStart + subTitleHeight / 2),
|
|
136
|
+
null === (_53 = this._subTitle) || void 0 === _53 || _53.setAttribute("textBaseline", "middle")) : "bottom" === subTitleVerticalAlign && (null === (_54 = this._subTitle) || void 0 === _54 || _54.setAttribute("y", subTitleYStart + subTitleHeight),
|
|
137
|
+
null === (_55 = this._subTitle) || void 0 === _55 || _55.setAttribute("textBaseline", "bottom"));
|
|
104
138
|
}
|
|
105
139
|
}
|
|
106
140
|
}
|