@visactor/vrender-components 0.16.17-alpha.3 → 0.16.17-alpha.4
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 +11 -22
- package/cjs/axis/base.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 +3 -6
- package/cjs/axis/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 +6 -50
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +2 -5
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/label/arc.d.ts +3 -4
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/area.d.ts +1 -1
- package/cjs/label/area.js +2 -2
- package/cjs/label/area.js.map +1 -1
- package/cjs/label/base.d.ts +12 -12
- package/cjs/label/base.js +12 -24
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/index.d.ts +1 -0
- package/cjs/label/index.js +2 -1
- package/cjs/label/index.js.map +1 -1
- package/cjs/label/line.d.ts +1 -1
- package/cjs/label/line.js +3 -3
- package/cjs/label/line.js.map +1 -1
- package/cjs/label/type.d.ts +5 -8
- package/cjs/label/type.js.map +1 -1
- package/cjs/legend/discrete/discrete.js +2 -2
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/marker/point.d.ts +1 -1
- package/cjs/marker/type.js.map +1 -1
- package/cjs/tag/tag.js +40 -90
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tag/type.d.ts +3 -4
- package/cjs/tag/type.js.map +1 -1
- package/cjs/title/title.js +47 -111
- package/cjs/title/title.js.map +1 -1
- package/cjs/title/type.d.ts +5 -10
- package/cjs/title/type.js.map +1 -1
- package/cjs/tooltip/tooltip.js +11 -56
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.d.ts +2 -7
- package/cjs/tooltip/type.js.map +1 -1
- package/cjs/tooltip/util.js +1 -9
- package/cjs/tooltip/util.js.map +1 -1
- package/cjs/util/label-smartInvert.d.ts +2 -2
- package/cjs/util/label-smartInvert.js +9 -5
- package/cjs/util/label-smartInvert.js.map +1 -1
- package/dist/index.js +235 -335
- package/dist/index.min.js +1 -1
- package/es/axis/base.js +11 -23
- package/es/axis/base.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 +3 -6
- package/es/axis/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 +6 -50
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +2 -5
- package/es/indicator/type.js.map +1 -1
- package/es/label/arc.d.ts +3 -4
- package/es/label/arc.js.map +1 -1
- package/es/label/area.d.ts +1 -1
- package/es/label/area.js +2 -2
- package/es/label/area.js.map +1 -1
- package/es/label/base.d.ts +12 -12
- package/es/label/base.js +12 -25
- package/es/label/base.js.map +1 -1
- package/es/label/index.d.ts +1 -0
- package/es/label/index.js +2 -0
- package/es/label/index.js.map +1 -1
- package/es/label/line.d.ts +1 -1
- package/es/label/line.js +3 -3
- package/es/label/line.js.map +1 -1
- package/es/label/type.d.ts +5 -8
- package/es/label/type.js.map +1 -1
- package/es/legend/discrete/discrete.js +2 -2
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/marker/point.d.ts +1 -1
- package/es/marker/type.js.map +1 -1
- package/es/tag/tag.js +38 -88
- package/es/tag/tag.js.map +1 -1
- package/es/tag/type.d.ts +3 -4
- package/es/tag/type.js.map +1 -1
- package/es/title/title.js +45 -111
- package/es/title/title.js.map +1 -1
- package/es/title/type.d.ts +5 -10
- package/es/title/type.js.map +1 -1
- package/es/tooltip/tooltip.js +11 -56
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.d.ts +2 -7
- package/es/tooltip/type.js.map +1 -1
- package/es/tooltip/util.js +1 -9
- package/es/tooltip/util.js.map +1 -1
- package/es/util/label-smartInvert.d.ts +2 -2
- package/es/util/label-smartInvert.js +9 -5
- package/es/util/label-smartInvert.js.map +1 -1
- package/package.json +5 -5
package/es/title/title.js
CHANGED
|
@@ -7,14 +7,14 @@ export class Title extends AbstractComponent {
|
|
|
7
7
|
super(merge({}, Title.defaultAttributes, attributes)), this.name = "title";
|
|
8
8
|
}
|
|
9
9
|
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 {
|
|
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
12
|
x: parsedPadding[3],
|
|
13
13
|
y: parsedPadding[0],
|
|
14
14
|
zIndex: 1
|
|
15
15
|
}, "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 =
|
|
16
|
+
if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if (textStyle && isValid(null == textStyle ? void 0 : textStyle.character)) {
|
|
17
|
+
const attr = {
|
|
18
18
|
x: null !== (_b = textStyle.x) && void 0 !== _b ? _b : 0,
|
|
19
19
|
y: null !== (_c = textStyle.y) && void 0 !== _c ? _c : 0,
|
|
20
20
|
width: null !== (_e = null !== (_d = textStyle.width) && void 0 !== _d ? _d : width) && void 0 !== _e ? _e : 0,
|
|
@@ -23,94 +23,28 @@ export class Title extends AbstractComponent {
|
|
|
23
23
|
wordBreak: null !== (_j = textStyle.wordBreak) && void 0 !== _j ? _j : "break-word",
|
|
24
24
|
maxHeight: textStyle.maxHeight,
|
|
25
25
|
maxWidth: textStyle.maxWidth,
|
|
26
|
-
textConfig: text
|
|
27
|
-
}, textStyle);
|
|
28
|
-
this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
|
|
29
|
-
} else if ("html" === textType) {
|
|
30
|
-
const attr = Object.assign({
|
|
31
|
-
html: Object.assign({
|
|
32
|
-
dom: text,
|
|
33
|
-
container: "",
|
|
34
|
-
width: 30,
|
|
35
|
-
height: 30,
|
|
36
|
-
style: ""
|
|
37
|
-
}, textStyle),
|
|
38
|
-
x: null !== (_k = textStyle.x) && void 0 !== _k ? _k : 0,
|
|
39
|
-
y: null !== (_l = textStyle.y) && void 0 !== _l ? _l : 0,
|
|
40
|
-
width: null !== (_o = null !== (_m = textStyle.width) && void 0 !== _m ? _m : width) && void 0 !== _o ? _o : 0,
|
|
41
|
-
height: null !== (_q = null !== (_p = textStyle.height) && void 0 !== _p ? _p : height) && void 0 !== _q ? _q : 0,
|
|
42
|
-
ellipsis: null === (_r = textStyle.ellipsis) || void 0 === _r || _r,
|
|
43
|
-
wordBreak: null !== (_s = textStyle.wordBreak) && void 0 !== _s ? _s : "break-word",
|
|
44
|
-
maxHeight: textStyle.maxHeight,
|
|
45
|
-
maxWidth: textStyle.maxWidth,
|
|
46
|
-
textConfig: []
|
|
47
|
-
}, textStyle);
|
|
48
|
-
this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
|
|
49
|
-
} else if (textStyle && isValid(null == textStyle ? void 0 : textStyle.character)) {
|
|
50
|
-
const attr = {
|
|
51
|
-
x: null !== (_t = textStyle.x) && void 0 !== _t ? _t : 0,
|
|
52
|
-
y: null !== (_u = textStyle.y) && void 0 !== _u ? _u : 0,
|
|
53
|
-
width: null !== (_w = null !== (_v = textStyle.width) && void 0 !== _v ? _v : width) && void 0 !== _w ? _w : 0,
|
|
54
|
-
height: null !== (_y = null !== (_x = textStyle.height) && void 0 !== _x ? _x : height) && void 0 !== _y ? _y : 0,
|
|
55
|
-
ellipsis: null === (_z = textStyle.ellipsis) || void 0 === _z || _z,
|
|
56
|
-
wordBreak: null !== (_0 = textStyle.wordBreak) && void 0 !== _0 ? _0 : "break-word",
|
|
57
|
-
maxHeight: textStyle.maxHeight,
|
|
58
|
-
maxWidth: textStyle.maxWidth,
|
|
59
26
|
textConfig: textStyle.character
|
|
60
27
|
};
|
|
61
28
|
this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
|
|
62
29
|
} else isValid(text) && (this._mainTitle = group.createOrUpdateChild("mainTitle", Object.assign(Object.assign({
|
|
63
30
|
text: [ text ]
|
|
64
31
|
}, textStyle), {
|
|
65
|
-
maxLineWidth: null !== (
|
|
32
|
+
maxLineWidth: null !== (_k = null == textStyle ? void 0 : textStyle.maxLineWidth) && void 0 !== _k ? _k : width,
|
|
66
33
|
heightLimit: null == textStyle ? void 0 : textStyle.heightLimit,
|
|
67
34
|
lineClamp: null == textStyle ? void 0 : textStyle.lineClamp,
|
|
68
|
-
ellipsis: null === (
|
|
35
|
+
ellipsis: null === (_l = null == textStyle ? void 0 : textStyle.ellipsis) || void 0 === _l || _l,
|
|
69
36
|
x: 0,
|
|
70
37
|
y: 0
|
|
71
38
|
}), "wrapText"));
|
|
72
|
-
const maintextHeight = this._mainTitle ? null === (
|
|
73
|
-
if (!1 !== (null === (
|
|
74
|
-
const attr = Object.assign({
|
|
75
|
-
x: null !== (_6 = subtextStyle.x) && void 0 !== _6 ? _6 : 0,
|
|
76
|
-
y: null !== (_7 = subtextStyle.y) && void 0 !== _7 ? _7 : 0,
|
|
77
|
-
width: null !== (_9 = null !== (_8 = subtextStyle.width) && void 0 !== _8 ? _8 : width) && void 0 !== _9 ? _9 : 0,
|
|
78
|
-
height: null !== (_11 = null !== (_10 = subtextStyle.height) && void 0 !== _10 ? _10 : height) && void 0 !== _11 ? _11 : 0,
|
|
79
|
-
ellipsis: null === (_12 = subtextStyle.ellipsis) || void 0 === _12 || _12,
|
|
80
|
-
wordBreak: null !== (_13 = subtextStyle.wordBreak) && void 0 !== _13 ? _13 : "break-word",
|
|
81
|
-
maxHeight: subtextStyle.maxHeight,
|
|
82
|
-
maxWidth: subtextStyle.maxWidth,
|
|
83
|
-
textConfig: subtext
|
|
84
|
-
}, subtextStyle);
|
|
85
|
-
this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
|
|
86
|
-
} else if ("html" === textType) {
|
|
87
|
-
const attr = Object.assign({
|
|
88
|
-
html: Object.assign({
|
|
89
|
-
dom: subtext,
|
|
90
|
-
container: "",
|
|
91
|
-
width: 30,
|
|
92
|
-
height: 30,
|
|
93
|
-
style: {}
|
|
94
|
-
}, subtextStyle),
|
|
95
|
-
x: null !== (_14 = subtextStyle.x) && void 0 !== _14 ? _14 : 0,
|
|
96
|
-
y: null !== (_15 = subtextStyle.y) && void 0 !== _15 ? _15 : 0,
|
|
97
|
-
width: null !== (_17 = null !== (_16 = subtextStyle.width) && void 0 !== _16 ? _16 : width) && void 0 !== _17 ? _17 : 0,
|
|
98
|
-
height: null !== (_19 = null !== (_18 = subtextStyle.height) && void 0 !== _18 ? _18 : height) && void 0 !== _19 ? _19 : 0,
|
|
99
|
-
ellipsis: null === (_20 = subtextStyle.ellipsis) || void 0 === _20 || _20,
|
|
100
|
-
wordBreak: null !== (_21 = subtextStyle.wordBreak) && void 0 !== _21 ? _21 : "break-word",
|
|
101
|
-
maxHeight: subtextStyle.maxHeight,
|
|
102
|
-
maxWidth: subtextStyle.maxWidth,
|
|
103
|
-
textConfig: []
|
|
104
|
-
}, subtextStyle);
|
|
105
|
-
this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
|
|
106
|
-
} else if (subtextStyle && isValid(null == subtextStyle ? void 0 : subtextStyle.character)) {
|
|
39
|
+
const maintextHeight = this._mainTitle ? null === (_m = this._mainTitle) || void 0 === _m ? void 0 : _m.AABBBounds.height() : 0, maintextWidth = this._mainTitle ? null === (_o = this._mainTitle) || void 0 === _o ? void 0 : _o.AABBBounds.width() : 0;
|
|
40
|
+
if (!1 !== (null === (_p = this.attribute) || void 0 === _p ? void 0 : _p.visible) && !1 !== (null == subtextStyle ? void 0 : subtextStyle.visible)) if (subtextStyle && isValid(null == subtextStyle ? void 0 : subtextStyle.character)) {
|
|
107
41
|
const attr = {
|
|
108
|
-
x: null !== (
|
|
109
|
-
y: null !== (
|
|
110
|
-
width: null !== (
|
|
111
|
-
height: null !== (
|
|
112
|
-
ellipsis: null === (
|
|
113
|
-
wordBreak: null !== (
|
|
42
|
+
x: null !== (_q = subtextStyle.x) && void 0 !== _q ? _q : 0,
|
|
43
|
+
y: null !== (_r = subtextStyle.y) && void 0 !== _r ? _r : maintextHeight,
|
|
44
|
+
width: null !== (_t = null !== (_s = subtextStyle.width) && void 0 !== _s ? _s : width) && void 0 !== _t ? _t : 0,
|
|
45
|
+
height: null !== (_v = null !== (_u = subtextStyle.height) && void 0 !== _u ? _u : height) && void 0 !== _v ? _v : 0,
|
|
46
|
+
ellipsis: null === (_w = subtextStyle.ellipsis) || void 0 === _w || _w,
|
|
47
|
+
wordBreak: null !== (_x = subtextStyle.wordBreak) && void 0 !== _x ? _x : "break-word",
|
|
114
48
|
maxHeight: subtextStyle.maxHeight,
|
|
115
49
|
maxWidth: subtextStyle.maxWidth,
|
|
116
50
|
textConfig: subtextStyle.character
|
|
@@ -119,54 +53,54 @@ export class Title extends AbstractComponent {
|
|
|
119
53
|
} else isValid(subtext) && (this._subTitle = group.createOrUpdateChild("subTitle", Object.assign(Object.assign({
|
|
120
54
|
text: [ subtext ]
|
|
121
55
|
}, subtextStyle), {
|
|
122
|
-
maxLineWidth: null !== (
|
|
56
|
+
maxLineWidth: null !== (_y = null == subtextStyle ? void 0 : subtextStyle.maxLineWidth) && void 0 !== _y ? _y : width,
|
|
123
57
|
heightLimit: null == subtextStyle ? void 0 : subtextStyle.heightLimit,
|
|
124
58
|
lineClamp: null == subtextStyle ? void 0 : subtextStyle.lineClamp,
|
|
125
|
-
ellipsis: null === (
|
|
59
|
+
ellipsis: null === (_z = null == subtextStyle ? void 0 : subtextStyle.ellipsis) || void 0 === _z || _z,
|
|
126
60
|
x: 0,
|
|
127
61
|
y: maintextHeight
|
|
128
62
|
}), "wrapText"));
|
|
129
|
-
const subtextHeight = this._subTitle ? null === (
|
|
130
|
-
let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (
|
|
131
|
-
if (isValid(width) && (titleWidth = width, null === (
|
|
132
|
-
null === (
|
|
63
|
+
const subtextHeight = this._subTitle ? null === (_0 = this._subTitle) || void 0 === _0 ? void 0 : _0.AABBBounds.height() : 0, subtextWidth = this._subTitle ? null === (_1 = this._subTitle) || void 0 === _1 ? void 0 : _1.AABBBounds.width() : 0;
|
|
64
|
+
let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_2 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _2 ? _2 : subtextHeight);
|
|
65
|
+
if (isValid(width) && (titleWidth = width, null === (_3 = this._mainTitle) || void 0 === _3 || _3.setAttribute("maxLineWidth", width),
|
|
66
|
+
null === (_4 = this._subTitle) || void 0 === _4 || _4.setAttribute("maxLineWidth", width)),
|
|
133
67
|
isValid(height) && (titleHeight = height), isValid(minWidth) && titleWidth < minWidth && (titleWidth = minWidth),
|
|
134
|
-
isValid(maxWidth) && (null === (
|
|
135
|
-
null === (
|
|
136
|
-
null === (
|
|
137
|
-
null === (
|
|
68
|
+
isValid(maxWidth) && (null === (_5 = this._mainTitle) || void 0 === _5 || _5.setAttribute("maxLineWidth", maxWidth),
|
|
69
|
+
null === (_6 = this._subTitle) || void 0 === _6 || _6.setAttribute("maxLineWidth", maxWidth),
|
|
70
|
+
null === (_7 = this._mainTitle) || void 0 === _7 || _7.setAttribute("maxWidth", maxWidth),
|
|
71
|
+
null === (_8 = this._subTitle) || void 0 === _8 || _8.setAttribute("maxWidth", maxWidth),
|
|
138
72
|
titleWidth > maxWidth && (titleWidth = maxWidth)), isValid(minHeight) && titleHeight < minHeight && (titleHeight = minHeight),
|
|
139
|
-
isValid(maxHeight) && (null === (
|
|
140
|
-
null === (
|
|
73
|
+
isValid(maxHeight) && (null === (_9 = this._mainTitle) || void 0 === _9 || _9.setAttribute("maxHeight", maxHeight),
|
|
74
|
+
null === (_10 = this._subTitle) || void 0 === _10 || _10.setAttribute("maxHeight", maxHeight - maintextHeight),
|
|
141
75
|
titleHeight > maxHeight && (titleHeight = maxHeight)), group.attribute.width = titleWidth,
|
|
142
76
|
group.attribute.height = titleHeight, group.attribute.boundsPadding = parsedPadding,
|
|
143
77
|
isValid(align) || isValid(null == textStyle ? void 0 : textStyle.align)) {
|
|
144
|
-
const mainTitleAlign = (null == textStyle ? void 0 : textStyle.align) ? null == textStyle ? void 0 : textStyle.align : align, mainTitleWidth = null !== (
|
|
145
|
-
"left" === mainTitleAlign ? (null === (
|
|
146
|
-
null === (
|
|
147
|
-
null === (
|
|
148
|
-
null === (
|
|
78
|
+
const mainTitleAlign = (null == textStyle ? void 0 : textStyle.align) ? null == textStyle ? void 0 : textStyle.align : align, mainTitleWidth = null !== (_11 = null == textStyle ? void 0 : textStyle.width) && void 0 !== _11 ? _11 : maintextWidth;
|
|
79
|
+
"left" === mainTitleAlign ? (null === (_12 = this._mainTitle) || void 0 === _12 || _12.setAttribute("x", 0),
|
|
80
|
+
null === (_13 = this._mainTitle) || void 0 === _13 || _13.setAttribute("textAlign", "left")) : "center" === mainTitleAlign ? (null === (_14 = this._mainTitle) || void 0 === _14 || _14.setAttribute("x", mainTitleWidth / 2),
|
|
81
|
+
null === (_15 = this._mainTitle) || void 0 === _15 || _15.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (null === (_16 = this._mainTitle) || void 0 === _16 || _16.setAttribute("x", mainTitleWidth),
|
|
82
|
+
null === (_17 = this._mainTitle) || void 0 === _17 || _17.setAttribute("textAlign", "right"));
|
|
149
83
|
}
|
|
150
84
|
if (isValid(verticalAlign) || isValid(null == textStyle ? void 0 : textStyle.verticalAlign)) {
|
|
151
85
|
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;
|
|
152
|
-
"top" === mainTitleVerticalAlign ? (null === (
|
|
153
|
-
null === (
|
|
154
|
-
null === (
|
|
155
|
-
null === (
|
|
86
|
+
"top" === mainTitleVerticalAlign ? (null === (_18 = this._mainTitle) || void 0 === _18 || _18.setAttribute("y", 0),
|
|
87
|
+
null === (_19 = this._mainTitle) || void 0 === _19 || _19.setAttribute("textBaseline", "top")) : "middle" === mainTitleVerticalAlign ? (null === (_20 = this._mainTitle) || void 0 === _20 || _20.setAttribute("y", mainTitleHeight / 2),
|
|
88
|
+
null === (_21 = this._mainTitle) || void 0 === _21 || _21.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (null === (_22 = this._mainTitle) || void 0 === _22 || _22.setAttribute("y", mainTitleHeight),
|
|
89
|
+
null === (_23 = this._mainTitle) || void 0 === _23 || _23.setAttribute("textBaseline", "bottom"));
|
|
156
90
|
}
|
|
157
91
|
if (isValid(align) || isValid(null == subtextStyle ? void 0 : subtextStyle.align)) {
|
|
158
|
-
const subTitleAlign = (null == subtextStyle ? void 0 : subtextStyle.align) ? null == subtextStyle ? void 0 : subtextStyle.align : align, subTitleWidth = null !== (
|
|
159
|
-
"left" === subTitleAlign ? (null === (
|
|
160
|
-
null === (
|
|
161
|
-
null === (
|
|
162
|
-
null === (
|
|
92
|
+
const subTitleAlign = (null == subtextStyle ? void 0 : subtextStyle.align) ? null == subtextStyle ? void 0 : subtextStyle.align : align, subTitleWidth = null !== (_24 = null == subtextStyle ? void 0 : subtextStyle.width) && void 0 !== _24 ? _24 : subtextWidth;
|
|
93
|
+
"left" === subTitleAlign ? (null === (_25 = this._subTitle) || void 0 === _25 || _25.setAttribute("x", 0),
|
|
94
|
+
null === (_26 = this._subTitle) || void 0 === _26 || _26.setAttribute("textAlign", "left")) : "center" === subTitleAlign ? (null === (_27 = this._subTitle) || void 0 === _27 || _27.setAttribute("x", subTitleWidth / 2),
|
|
95
|
+
null === (_28 = this._subTitle) || void 0 === _28 || _28.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (null === (_29 = this._subTitle) || void 0 === _29 || _29.setAttribute("x", subTitleWidth),
|
|
96
|
+
null === (_30 = this._subTitle) || void 0 === _30 || _30.setAttribute("textAlign", "right"));
|
|
163
97
|
}
|
|
164
98
|
if (isValid(verticalAlign) || isValid(null == textStyle ? void 0 : textStyle.verticalAlign)) {
|
|
165
|
-
const subTitleVerticalAlign = (null == subtextStyle ? void 0 : subtextStyle.verticalAlign) ? null == subtextStyle ? void 0 : subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (
|
|
166
|
-
"top" === subTitleVerticalAlign ? (null === (
|
|
167
|
-
null === (
|
|
168
|
-
null === (
|
|
169
|
-
null === (
|
|
99
|
+
const subTitleVerticalAlign = (null == subtextStyle ? void 0 : subtextStyle.verticalAlign) ? null == subtextStyle ? void 0 : subtextStyle.verticalAlign : verticalAlign, subTitleYStart = maintextHeight, subTitleHeight = null !== (_31 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _31 ? _31 : 0;
|
|
100
|
+
"top" === subTitleVerticalAlign ? (null === (_32 = this._subTitle) || void 0 === _32 || _32.setAttribute("y", subTitleYStart),
|
|
101
|
+
null === (_33 = this._subTitle) || void 0 === _33 || _33.setAttribute("textBaseline", "top")) : "middle" === subTitleVerticalAlign ? (null === (_34 = this._subTitle) || void 0 === _34 || _34.setAttribute("y", subTitleYStart + subTitleHeight / 2),
|
|
102
|
+
null === (_35 = this._subTitle) || void 0 === _35 || _35.setAttribute("textBaseline", "middle")) : "bottom" === subTitleVerticalAlign && (null === (_36 = this._subTitle) || void 0 === _36 || _36.setAttribute("y", subTitleYStart + subTitleHeight),
|
|
103
|
+
null === (_37 = this._subTitle) || void 0 === _37 || _37.setAttribute("textBaseline", "bottom"));
|
|
170
104
|
}
|
|
171
105
|
}
|
|
172
106
|
}
|
package/es/title/title.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/title/title.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,OAAO,KAAM,SAAQ,iBAAuC;IAyBhE,YAAY,UAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAzBxD,SAAI,GAAG,OAAO,CAAC;IA0Bf,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EACT,OAAO,EACP,YAAY,EACZ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,EACL,aAAa,EACb,OAAO,GAAG,CAAC,EACZ,GAAG,IAAI,CAAC,SAAuB,CAAC;QAEjC,MAA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CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;aACxD;SACF;IACH,CAAC;;AAzSM,uBAAiB,GAAwB;IAC9C,SAAS,EAAE;QACT,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;CACF,CAAC","file":"title.js","sourcesContent":["/**\n * @description 标题组件\n */\nimport type { IGroup, IText, IRichText, IRichTextCharacter } from '@visactor/vrender-core';\nimport { merge, isValid, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { TitleAttrs } from './type';\n\nexport class Title extends AbstractComponent<Required<TitleAttrs>> {\n name = 'title';\n\n private _mainTitle?: IText | IRichText;\n private _subTitle?: IText | IRichText;\n\n static defaultAttributes: Partial<TitleAttrs> = {\n textStyle: {\n ellipsis: '...',\n fill: '#333',\n fontSize: 20,\n fontWeight: 'bold',\n textAlign: 'left',\n textBaseline: 'top'\n },\n subtextStyle: {\n ellipsis: '...',\n fill: '#6F6F6F',\n fontSize: 16,\n fontWeight: 'normal',\n textAlign: 'left',\n textBaseline: 'top'\n }\n };\n\n constructor(attributes: TitleAttrs) {\n super(merge({}, Title.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n textType,\n text,\n subtextType,\n textStyle,\n subtext,\n subtextStyle,\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n align,\n verticalAlign,\n padding = 0\n } = this.attribute as TitleAttrs;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild(\n 'title-container',\n { x: parsedPadding[3], y: parsedPadding[0], zIndex: 1 },\n 'group'\n ) as IGroup;\n\n if (this.attribute?.visible !== false && textStyle?.visible !== false) {\n if (textType === 'rich') {\n const attr = {\n x: textStyle.x ?? 0,\n y: textStyle.y ?? 0,\n width: textStyle.width ?? width ?? 0,\n height: textStyle.height ?? height ?? 0,\n ellipsis: textStyle.ellipsis ?? true,\n wordBreak: textStyle.wordBreak ?? 'break-word',\n maxHeight: textStyle.maxHeight,\n maxWidth: textStyle.maxWidth,\n textConfig: text as IRichTextCharacter[],\n ...textStyle\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (textType === 'html') {\n const attr = {\n html: {\n dom: text as string,\n container: '',\n width: 30,\n height: 30,\n style: '',\n ...textStyle\n },\n x: textStyle.x ?? 0,\n y: textStyle.y ?? 0,\n width: textStyle.width ?? width ?? 0,\n height: textStyle.height ?? height ?? 0,\n ellipsis: textStyle.ellipsis ?? true,\n wordBreak: textStyle.wordBreak ?? 'break-word',\n maxHeight: textStyle.maxHeight,\n maxWidth: textStyle.maxWidth,\n textConfig: [] as any[],\n ...textStyle\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (textStyle && isValid(textStyle?.character)) {\n // 富文本的老配置方法\n const attr = {\n x: textStyle.x ?? 0,\n y: textStyle.y ?? 0,\n width: textStyle.width ?? width ?? 0,\n height: textStyle.height ?? height ?? 0,\n ellipsis: textStyle.ellipsis ?? true,\n wordBreak: textStyle.wordBreak ?? 'break-word',\n maxHeight: textStyle.maxHeight,\n maxWidth: textStyle.maxWidth,\n textConfig: textStyle.character\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (isValid(text)) {\n this._mainTitle = group.createOrUpdateChild(\n 'mainTitle',\n {\n text: [text as string],\n ...textStyle,\n maxLineWidth: textStyle?.maxLineWidth ?? width,\n heightLimit: textStyle?.heightLimit,\n lineClamp: textStyle?.lineClamp,\n ellipsis: textStyle?.ellipsis ?? true,\n x: 0,\n y: 0\n },\n 'wrapText'\n ) as IText;\n }\n }\n\n const maintextHeight = this._mainTitle ? this._mainTitle?.AABBBounds.height() : 0;\n const maintextWidth = this._mainTitle ? this._mainTitle?.AABBBounds.width() : 0;\n\n if (this.attribute?.visible !== false && subtextStyle?.visible !== false) {\n if (subtextType === 'rich') {\n const attr: any = {\n x: subtextStyle.x ?? 0,\n y: subtextStyle.y ?? 0,\n width: subtextStyle.width ?? width ?? 0,\n height: subtextStyle.height ?? height ?? 0,\n ellipsis: subtextStyle.ellipsis ?? true,\n wordBreak: subtextStyle.wordBreak ?? 'break-word',\n maxHeight: subtextStyle.maxHeight,\n maxWidth: subtextStyle.maxWidth,\n textConfig: subtext,\n ...subtextStyle\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (textType === 'html') {\n const attr: any = {\n html: {\n dom: subtext as string,\n container: '',\n width: 30,\n height: 30,\n style: {},\n ...subtextStyle\n },\n x: subtextStyle.x ?? 0,\n y: subtextStyle.y ?? 0,\n width: subtextStyle.width ?? width ?? 0,\n height: subtextStyle.height ?? height ?? 0,\n ellipsis: subtextStyle.ellipsis ?? true,\n wordBreak: subtextStyle.wordBreak ?? 'break-word',\n maxHeight: subtextStyle.maxHeight,\n maxWidth: subtextStyle.maxWidth,\n textConfig: [] as any[],\n ...subtextStyle\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (subtextStyle && isValid(subtextStyle?.character)) {\n // 富文本的老配置方法\n const attr = {\n x: subtextStyle.x ?? 0,\n y: subtextStyle.y ?? maintextHeight,\n width: subtextStyle.width ?? width ?? 0,\n height: subtextStyle.height ?? height ?? 0,\n ellipsis: subtextStyle.ellipsis ?? true,\n wordBreak: subtextStyle.wordBreak ?? 'break-word',\n maxHeight: subtextStyle.maxHeight,\n maxWidth: subtextStyle.maxWidth,\n textConfig: subtextStyle.character\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (isValid(subtext)) {\n this._subTitle = group.createOrUpdateChild(\n 'subTitle',\n {\n text: [subtext as string],\n ...subtextStyle,\n maxLineWidth: subtextStyle?.maxLineWidth ?? width,\n heightLimit: subtextStyle?.heightLimit,\n lineClamp: subtextStyle?.lineClamp,\n ellipsis: subtextStyle?.ellipsis ?? true,\n x: 0,\n y: maintextHeight\n },\n 'wrapText'\n ) as IText;\n }\n }\n\n const subtextHeight = this._subTitle ? this._subTitle?.AABBBounds.height() : 0;\n const subtextWidth = this._subTitle ? this._subTitle?.AABBBounds.width() : 0;\n\n // 设置宽高\n let titleWidth = Math.max(maintextWidth, subtextWidth);\n let titleHeight = maintextHeight + (subtextStyle?.height ?? subtextHeight);\n\n if (isValid(width)) {\n titleWidth = width;\n this._mainTitle?.setAttribute('maxLineWidth', width);\n this._subTitle?.setAttribute('maxLineWidth', width);\n }\n\n if (isValid(height)) {\n titleHeight = height;\n }\n\n if (isValid(minWidth) && titleWidth < minWidth) {\n titleWidth = minWidth;\n }\n if (isValid(maxWidth)) {\n this._mainTitle?.setAttribute('maxLineWidth', maxWidth);\n this._subTitle?.setAttribute('maxLineWidth', maxWidth);\n this._mainTitle?.setAttribute('maxWidth', maxWidth);\n this._subTitle?.setAttribute('maxWidth', maxWidth);\n if (titleWidth > maxWidth) {\n titleWidth = maxWidth;\n }\n }\n\n if (isValid(minHeight) && titleHeight < minHeight) {\n titleHeight = minHeight;\n }\n if (isValid(maxHeight)) {\n this._mainTitle?.setAttribute('maxHeight', maxHeight);\n this._subTitle?.setAttribute('maxHeight', maxHeight - maintextHeight);\n if (titleHeight > maxHeight) {\n titleHeight = maxHeight;\n }\n }\n\n group.attribute.width = titleWidth;\n group.attribute.height = titleHeight;\n group.attribute.boundsPadding = parsedPadding;\n\n // 设置对齐\n if (isValid(align) || isValid(textStyle?.align)) {\n const mainTitleAlign = textStyle?.align ? textStyle?.align : align;\n const mainTitleWidth = textStyle?.width ?? maintextWidth;\n if (mainTitleAlign === 'left') {\n this._mainTitle?.setAttribute('x', 0);\n this._mainTitle?.setAttribute('textAlign', 'left');\n } else if (mainTitleAlign === 'center') {\n this._mainTitle?.setAttribute('x', mainTitleWidth / 2);\n this._mainTitle?.setAttribute('textAlign', 'center');\n } else if (mainTitleAlign === 'right') {\n this._mainTitle?.setAttribute('x', mainTitleWidth);\n this._mainTitle?.setAttribute('textAlign', 'right');\n }\n }\n\n if (isValid(verticalAlign) || isValid(textStyle?.verticalAlign)) {\n const mainTitleVerticalAlign = textStyle?.verticalAlign ? textStyle?.verticalAlign : verticalAlign;\n const mainTitleHeight = textStyle?.height ? textStyle?.height : titleHeight;\n if (mainTitleVerticalAlign === 'top') {\n this._mainTitle?.setAttribute('y', 0);\n this._mainTitle?.setAttribute('textBaseline', 'top');\n } else if (mainTitleVerticalAlign === 'middle') {\n this._mainTitle?.setAttribute('y', mainTitleHeight / 2);\n this._mainTitle?.setAttribute('textBaseline', 'middle');\n } else if (mainTitleVerticalAlign === 'bottom') {\n this._mainTitle?.setAttribute('y', mainTitleHeight);\n this._mainTitle?.setAttribute('textBaseline', 'bottom');\n }\n }\n\n if (isValid(align) || isValid(subtextStyle?.align)) {\n const subTitleAlign = subtextStyle?.align ? subtextStyle?.align : align;\n const subTitleWidth = subtextStyle?.width ?? subtextWidth;\n if (subTitleAlign === 'left') {\n this._subTitle?.setAttribute('x', 0);\n this._subTitle?.setAttribute('textAlign', 'left');\n } else if (subTitleAlign === 'center') {\n this._subTitle?.setAttribute('x', subTitleWidth / 2);\n this._subTitle?.setAttribute('textAlign', 'center');\n } else if (subTitleAlign === 'right') {\n this._subTitle?.setAttribute('x', subTitleWidth);\n this._subTitle?.setAttribute('textAlign', 'right');\n }\n }\n\n if (isValid(verticalAlign) || isValid(textStyle?.verticalAlign)) {\n const subTitleVerticalAlign = subtextStyle?.verticalAlign ? subtextStyle?.verticalAlign : verticalAlign;\n const subTitleYStart = maintextHeight;\n const subTitleHeight = subtextStyle?.height ?? 0;\n if (subTitleVerticalAlign === 'top') {\n this._subTitle?.setAttribute('y', subTitleYStart);\n this._subTitle?.setAttribute('textBaseline', 'top');\n } else if (subTitleVerticalAlign === 'middle') {\n this._subTitle?.setAttribute('y', subTitleYStart + subTitleHeight / 2);\n this._subTitle?.setAttribute('textBaseline', 'middle');\n } else if (subTitleVerticalAlign === 'bottom') {\n this._subTitle?.setAttribute('y', subTitleYStart + subTitleHeight);\n this._subTitle?.setAttribute('textBaseline', 'bottom');\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/title/title.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,OAAO,KAAM,SAAQ,iBAAuC;IAyBhE,YAAY,UAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAzBxD,SAAI,GAAG,OAAO,CAAC;IA0Bf,CAAC;IAES,MAAM;;QACd,MAAM,EACJ,IAAI,EACJ,SAAS,EACT,OAAO,EACP,YAAY,EACZ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,EACL,aAAa,EACb,OAAO,GAAG,CAAC,EACZ,GAAG,IAAI,CAAC,SAAuB,CAAC;QAEjC,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CACpC,iBAAiB,EACjB,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EACvD,OAAO,CACE,CAAC;QAEZ,IAAI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,M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AAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;aACrD;iBAAM,IAAI,qBAAqB,KAAK,QAAQ,EAAE;gBAC7C,OAAA,IAAI,CAAC,SAAS,4CAAE,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC;gBACvE,OAAA,IAAI,CAAC,SAAS,4CAAE,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;aACxD;iBAAM,IAAI,qBAAqB,KAAK,QAAQ,EAAE;gBAC7C,OAAA,IAAI,CAAC,SAAS,4CAAE,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;gBACnE,OAAA,IAAI,CAAC,SAAS,4CAAE,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;aACxD;SACF;IACH,CAAC;;AA7NM,uBAAiB,GAAwB;IAC9C,SAAS,EAAE;QACT,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,KAAK;KACpB;CACF,CAAC","file":"title.js","sourcesContent":["/**\n * @description 标题组件\n */\nimport type { IGroup, IText, IRichText } from '@visactor/vrender-core';\nimport { merge, isValid, normalizePadding } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { TitleAttrs } from './type';\n\nexport class Title extends AbstractComponent<Required<TitleAttrs>> {\n name = 'title';\n\n private _mainTitle?: IText | IRichText;\n private _subTitle?: IText | IRichText;\n\n static defaultAttributes: Partial<TitleAttrs> = {\n textStyle: {\n ellipsis: '...',\n fill: '#333',\n fontSize: 20,\n fontWeight: 'bold',\n textAlign: 'left',\n textBaseline: 'top'\n },\n subtextStyle: {\n ellipsis: '...',\n fill: '#6F6F6F',\n fontSize: 16,\n fontWeight: 'normal',\n textAlign: 'left',\n textBaseline: 'top'\n }\n };\n\n constructor(attributes: TitleAttrs) {\n super(merge({}, Title.defaultAttributes, attributes));\n }\n\n protected render() {\n const {\n text,\n textStyle,\n subtext,\n subtextStyle,\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n align,\n verticalAlign,\n padding = 0\n } = this.attribute as TitleAttrs;\n\n const parsedPadding = normalizePadding(padding);\n\n const group = this.createOrUpdateChild(\n 'title-container',\n { x: parsedPadding[3], y: parsedPadding[0], zIndex: 1 },\n 'group'\n ) as IGroup;\n\n if (this.attribute?.visible !== false && textStyle?.visible !== false) {\n if (textStyle && isValid(textStyle?.character)) {\n const attr = {\n x: textStyle.x ?? 0,\n y: textStyle.y ?? 0,\n width: textStyle.width ?? width ?? 0,\n height: textStyle.height ?? height ?? 0,\n ellipsis: textStyle.ellipsis ?? true,\n wordBreak: textStyle.wordBreak ?? 'break-word',\n maxHeight: textStyle.maxHeight,\n maxWidth: textStyle.maxWidth,\n textConfig: textStyle.character\n };\n this._mainTitle = group.createOrUpdateChild('mainTitle', attr, 'richtext') as IRichText;\n } else if (isValid(text)) {\n this._mainTitle = group.createOrUpdateChild(\n 'mainTitle',\n {\n text: [text as string],\n ...textStyle,\n maxLineWidth: textStyle?.maxLineWidth ?? width,\n heightLimit: textStyle?.heightLimit,\n lineClamp: textStyle?.lineClamp,\n ellipsis: textStyle?.ellipsis ?? true,\n x: 0,\n y: 0\n },\n 'wrapText'\n ) as IText;\n }\n }\n\n const maintextHeight = this._mainTitle ? this._mainTitle?.AABBBounds.height() : 0;\n const maintextWidth = this._mainTitle ? this._mainTitle?.AABBBounds.width() : 0;\n\n if (this.attribute?.visible !== false && subtextStyle?.visible !== false) {\n if (subtextStyle && isValid(subtextStyle?.character)) {\n const attr = {\n x: subtextStyle.x ?? 0,\n y: subtextStyle.y ?? maintextHeight,\n width: subtextStyle.width ?? width ?? 0,\n height: subtextStyle.height ?? height ?? 0,\n ellipsis: subtextStyle.ellipsis ?? true,\n wordBreak: subtextStyle.wordBreak ?? 'break-word',\n maxHeight: subtextStyle.maxHeight,\n maxWidth: subtextStyle.maxWidth,\n textConfig: subtextStyle.character\n };\n this._subTitle = group.createOrUpdateChild('subTitle', attr, 'richtext') as IRichText;\n } else if (isValid(subtext)) {\n this._subTitle = group.createOrUpdateChild(\n 'subTitle',\n {\n text: [subtext as string],\n ...subtextStyle,\n maxLineWidth: subtextStyle?.maxLineWidth ?? width,\n heightLimit: subtextStyle?.heightLimit,\n lineClamp: subtextStyle?.lineClamp,\n ellipsis: subtextStyle?.ellipsis ?? true,\n x: 0,\n y: maintextHeight\n },\n 'wrapText'\n ) as IText;\n }\n }\n\n const subtextHeight = this._subTitle ? this._subTitle?.AABBBounds.height() : 0;\n const subtextWidth = this._subTitle ? this._subTitle?.AABBBounds.width() : 0;\n\n // 设置宽高\n let titleWidth = Math.max(maintextWidth, subtextWidth);\n let titleHeight = maintextHeight + (subtextStyle?.height ?? subtextHeight);\n\n if (isValid(width)) {\n titleWidth = width;\n this._mainTitle?.setAttribute('maxLineWidth', width);\n this._subTitle?.setAttribute('maxLineWidth', width);\n }\n\n if (isValid(height)) {\n titleHeight = height;\n }\n\n if (isValid(minWidth) && titleWidth < minWidth) {\n titleWidth = minWidth;\n }\n if (isValid(maxWidth)) {\n this._mainTitle?.setAttribute('maxLineWidth', maxWidth);\n this._subTitle?.setAttribute('maxLineWidth', maxWidth);\n this._mainTitle?.setAttribute('maxWidth', maxWidth);\n this._subTitle?.setAttribute('maxWidth', maxWidth);\n if (titleWidth > maxWidth) {\n titleWidth = maxWidth;\n }\n }\n\n if (isValid(minHeight) && titleHeight < minHeight) {\n titleHeight = minHeight;\n }\n if (isValid(maxHeight)) {\n this._mainTitle?.setAttribute('maxHeight', maxHeight);\n this._subTitle?.setAttribute('maxHeight', maxHeight - maintextHeight);\n if (titleHeight > maxHeight) {\n titleHeight = maxHeight;\n }\n }\n\n group.attribute.width = titleWidth;\n group.attribute.height = titleHeight;\n group.attribute.boundsPadding = parsedPadding;\n\n // 设置对齐\n if (isValid(align) || isValid(textStyle?.align)) {\n const mainTitleAlign = textStyle?.align ? textStyle?.align : align;\n const mainTitleWidth = textStyle?.width ?? maintextWidth;\n if (mainTitleAlign === 'left') {\n this._mainTitle?.setAttribute('x', 0);\n this._mainTitle?.setAttribute('textAlign', 'left');\n } else if (mainTitleAlign === 'center') {\n this._mainTitle?.setAttribute('x', mainTitleWidth / 2);\n this._mainTitle?.setAttribute('textAlign', 'center');\n } else if (mainTitleAlign === 'right') {\n this._mainTitle?.setAttribute('x', mainTitleWidth);\n this._mainTitle?.setAttribute('textAlign', 'right');\n }\n }\n\n if (isValid(verticalAlign) || isValid(textStyle?.verticalAlign)) {\n const mainTitleVerticalAlign = textStyle?.verticalAlign ? textStyle?.verticalAlign : verticalAlign;\n const mainTitleHeight = textStyle?.height ? textStyle?.height : titleHeight;\n if (mainTitleVerticalAlign === 'top') {\n this._mainTitle?.setAttribute('y', 0);\n this._mainTitle?.setAttribute('textBaseline', 'top');\n } else if (mainTitleVerticalAlign === 'middle') {\n this._mainTitle?.setAttribute('y', mainTitleHeight / 2);\n this._mainTitle?.setAttribute('textBaseline', 'middle');\n } else if (mainTitleVerticalAlign === 'bottom') {\n this._mainTitle?.setAttribute('y', mainTitleHeight);\n this._mainTitle?.setAttribute('textBaseline', 'bottom');\n }\n }\n\n if (isValid(align) || isValid(subtextStyle?.align)) {\n const subTitleAlign = subtextStyle?.align ? subtextStyle?.align : align;\n const subTitleWidth = subtextStyle?.width ?? subtextWidth;\n if (subTitleAlign === 'left') {\n this._subTitle?.setAttribute('x', 0);\n this._subTitle?.setAttribute('textAlign', 'left');\n } else if (subTitleAlign === 'center') {\n this._subTitle?.setAttribute('x', subTitleWidth / 2);\n this._subTitle?.setAttribute('textAlign', 'center');\n } else if (subTitleAlign === 'right') {\n this._subTitle?.setAttribute('x', subTitleWidth);\n this._subTitle?.setAttribute('textAlign', 'right');\n }\n }\n\n if (isValid(verticalAlign) || isValid(textStyle?.verticalAlign)) {\n const subTitleVerticalAlign = subtextStyle?.verticalAlign ? subtextStyle?.verticalAlign : verticalAlign;\n const subTitleYStart = maintextHeight;\n const subTitleHeight = subtextStyle?.height ?? 0;\n if (subTitleVerticalAlign === 'top') {\n this._subTitle?.setAttribute('y', subTitleYStart);\n this._subTitle?.setAttribute('textBaseline', 'top');\n } else if (subTitleVerticalAlign === 'middle') {\n this._subTitle?.setAttribute('y', subTitleYStart + subTitleHeight / 2);\n this._subTitle?.setAttribute('textBaseline', 'middle');\n } else if (subTitleVerticalAlign === 'bottom') {\n this._subTitle?.setAttribute('y', subTitleYStart + subTitleHeight);\n this._subTitle?.setAttribute('textBaseline', 'bottom');\n }\n }\n }\n}\n"]}
|
package/es/title/type.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { IGroupGraphicAttribute, ITextGraphicAttribute,
|
|
1
|
+
import type { IGroupGraphicAttribute, ITextGraphicAttribute, IRichTextCharacter, RichTextWordBreak } from '@visactor/vrender-core';
|
|
2
2
|
import type { Padding } from '../core/type';
|
|
3
3
|
export interface TitleAttrs extends IGroupGraphicAttribute {
|
|
4
|
-
text?: string | number | string[] | number[]
|
|
5
|
-
|
|
6
|
-
subtext?: string | number | string[] | number[] | IRichTextCharacter[];
|
|
7
|
-
subtextType?: string;
|
|
4
|
+
text?: string | number | string[] | number[];
|
|
5
|
+
subtext?: string | number | string[] | number[];
|
|
8
6
|
width?: number;
|
|
9
7
|
height?: number;
|
|
10
8
|
minWidth?: number;
|
|
@@ -12,8 +10,6 @@ export interface TitleAttrs extends IGroupGraphicAttribute {
|
|
|
12
10
|
minHeight?: number;
|
|
13
11
|
maxHeight?: number;
|
|
14
12
|
padding?: Padding;
|
|
15
|
-
x?: number;
|
|
16
|
-
y?: number;
|
|
17
13
|
align?: string;
|
|
18
14
|
verticalAlign?: string;
|
|
19
15
|
textStyle?: {
|
|
@@ -28,8 +24,7 @@ export interface TitleAttrs extends IGroupGraphicAttribute {
|
|
|
28
24
|
heightLimit?: number;
|
|
29
25
|
lineClamp?: number;
|
|
30
26
|
character?: IRichTextCharacter[];
|
|
31
|
-
|
|
32
|
-
} & Partial<ITextGraphicAttribute> & Partial<IRichTextGraphicAttribute>;
|
|
27
|
+
} & Partial<ITextGraphicAttribute>;
|
|
33
28
|
subtextStyle?: {
|
|
34
29
|
width?: number;
|
|
35
30
|
height?: number;
|
|
@@ -42,5 +37,5 @@ export interface TitleAttrs extends IGroupGraphicAttribute {
|
|
|
42
37
|
heightLimit?: number;
|
|
43
38
|
lineClamp?: number;
|
|
44
39
|
character?: IRichTextCharacter[];
|
|
45
|
-
} & Partial<ITextGraphicAttribute
|
|
40
|
+
} & Partial<ITextGraphicAttribute>;
|
|
46
41
|
}
|
package/es/title/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/title/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n
|
|
1
|
+
{"version":3,"sources":["../src/title/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n IRichTextCharacter,\n RichTextWordBreak\n} from '@visactor/vrender-core';\nimport type { Padding } from '../core/type';\n\nexport interface TitleAttrs extends IGroupGraphicAttribute {\n /**\n * 主标题文本内容\n */\n text?: string | number | string[] | number[];\n /**\n * 副标题文本内容\n */\n subtext?: string | number | string[] | number[];\n /**\n * 指定宽度,像素值\n */\n width?: number;\n /**\n * 指定高度,像素值\n */\n height?: number;\n /**\n * 最小宽度,像素值\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n /**\n * 最小高度,像素值\n */\n minHeight?: number;\n /**\n * 最大高度,像素值\n */\n maxHeight?: number;\n /**\n * 内部边距\n */\n padding?: Padding;\n /**\n * 整体(包括 text 和 subtext)的水平对齐\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 整体(包括 text 和 subtext)的垂直对齐\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 主标题样式\n */\n textStyle?: {\n /** 指定宽度 */\n width?: number;\n /** 指定高度 */\n height?: number;\n /** 最大宽度 */\n maxWidth?: number;\n /** 最大高度 */\n maxHeight?: number;\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 折行方式\n * 'break-word' | 'break-all'\n */\n wordBreak?: RichTextWordBreak;\n /**\n * 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 默认设置为title宽度\n */\n maxLineWidth?: number;\n /**\n * 高度限制控制显示内容及省略号(heightLimit)\n */\n heightLimit?: number;\n /**\n * 按照行数限制显示内容及省略号(lineClamp)\n */\n lineClamp?: number;\n /**\n * 富文本配置\n */\n character?: IRichTextCharacter[];\n } & Partial<ITextGraphicAttribute>;\n /**\n * 副标题样式\n */\n subtextStyle?: {\n /** 指定宽度 */\n width?: number;\n /** 指定高度 */\n height?: number;\n /** 最大宽度 */\n maxWidth?: number;\n /** 最大高度 */\n maxHeight?: number;\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 折行方式\n * 'break-word' | 'break-all'\n */\n wordBreak?: RichTextWordBreak;\n /**\n * 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 默认设置为title宽度\n */\n maxLineWidth?: number;\n /**\n * 高度限制控制显示内容及省略号(heightLimit)\n */\n heightLimit?: number;\n /**\n * 按照行数限制显示内容及省略号(lineClamp)\n */\n lineClamp?: number;\n /**\n * 富文本配置\n */\n character?: IRichTextCharacter[];\n } & Partial<ITextGraphicAttribute>;\n}\n"]}
|
package/es/tooltip/tooltip.js
CHANGED
|
@@ -19,7 +19,6 @@ export class Tooltip extends AbstractComponent {
|
|
|
19
19
|
super(merge({}, Tooltip.defaultAttributes, attributes)), this.name = "tooltip";
|
|
20
20
|
}
|
|
21
21
|
render() {
|
|
22
|
-
var _a;
|
|
23
22
|
const {visible: visible, content: content, panel: panel, keyWidth: keyWidth, valueWidth: valueWidth, hasContentShape: hasContentShape, autoCalculatePosition: autoCalculatePosition, autoMeasure: autoMeasure} = this.attribute;
|
|
24
23
|
if (!visible) return void this.hideAll();
|
|
25
24
|
autoMeasure && Tooltip.measureTooltip(this.attribute), autoCalculatePosition && Tooltip.calculateTooltipPosition(this.attribute);
|
|
@@ -36,30 +35,12 @@ export class Tooltip extends AbstractComponent {
|
|
|
36
35
|
symbolType: "circle"
|
|
37
36
|
}, titleAttr.shape, {
|
|
38
37
|
visible: isVisible(titleAttr) && isVisible(titleAttr.shape)
|
|
39
|
-
}), "symbol"),
|
|
38
|
+
}), "symbol"), titleAttr.value.multiLine ? this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild("tooltip-title-value", Object.assign({
|
|
40
39
|
visible: isVisible(titleAttr) && isVisible(titleAttr.value)
|
|
41
40
|
}, getRichTextAttribute(titleAttr.value)), "richtext") : this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild("tooltip-title-value", Object.assign({
|
|
42
|
-
text:
|
|
41
|
+
text: "",
|
|
43
42
|
visible: isVisible(titleAttr) && isVisible(titleAttr.value)
|
|
44
|
-
}, titleAttr.value), "text")
|
|
45
|
-
visible: isVisible(titleAttr) && isVisible(titleAttr.value)
|
|
46
|
-
}, getRichTextAttribute(titleAttr.value)), "richtext") : "html" === titleAttr.value.text.type && (this._tooltipTitle = this._tooltipTitleContainer.createOrUpdateChild("tooltip-title-value", Object.assign({
|
|
47
|
-
html: Object.assign({
|
|
48
|
-
dom: titleAttr.value.text.text,
|
|
49
|
-
container: "",
|
|
50
|
-
width: 30,
|
|
51
|
-
height: 30,
|
|
52
|
-
style: {}
|
|
53
|
-
}, titleAttr.value),
|
|
54
|
-
visible: isVisible(titleAttr) && isVisible(titleAttr.value),
|
|
55
|
-
width: titleAttr.value.width,
|
|
56
|
-
height: titleAttr.value.height,
|
|
57
|
-
wordBreak: titleAttr.value.wordBreak,
|
|
58
|
-
textAlign: titleAttr.value.textAlign,
|
|
59
|
-
textBaseline: titleAttr.value.textBaseline,
|
|
60
|
-
singleLine: !1,
|
|
61
|
-
textConfig: []
|
|
62
|
-
}, titleAttr.value), "richtext"));
|
|
43
|
+
}, titleAttr.value), "text");
|
|
63
44
|
const titlePaddingLeft = isVisible(titleAttr.shape) ? titleAttr.shape.size + titleAttr.shape.spacing : 0, {textAlign: textAlign, textBaseline: textBaseline} = titleAttr.value, contentWidth = panel.width - padding[3] - padding[0] - titlePaddingLeft;
|
|
64
45
|
"center" === textAlign ? this._tooltipTitle.setAttribute("x", titlePaddingLeft + contentWidth / 2) : "right" === textAlign || "end" === textAlign ? this._tooltipTitle.setAttribute("x", titlePaddingLeft + contentWidth) : this._tooltipTitle.setAttribute("x", titlePaddingLeft),
|
|
65
46
|
"bottom" === textBaseline ? this._tooltipTitle.setAttribute("y", titleAttr.height) : "middle" === textBaseline ? this._tooltipTitle.setAttribute("y", titleAttr.height / 2) : this._tooltipTitle.setAttribute("y", 0);
|
|
@@ -70,7 +51,7 @@ export class Tooltip extends AbstractComponent {
|
|
|
70
51
|
this._tooltipContent.setAttribute("x", padding[3]), this._tooltipContent.setAttribute("y", padding[0] + titleHeight);
|
|
71
52
|
let lastYPos = 0;
|
|
72
53
|
content.forEach(((item, i) => {
|
|
73
|
-
var _a
|
|
54
|
+
var _a;
|
|
74
55
|
const itemAttr = Tooltip.getContentAttr(this.attribute, i);
|
|
75
56
|
if (!isVisible(itemAttr)) return;
|
|
76
57
|
const itemGroupName = `tooltip-content-${i}`, itemGroup = this._tooltipContent.createOrUpdateChild(itemGroupName, {
|
|
@@ -90,24 +71,11 @@ export class Tooltip extends AbstractComponent {
|
|
|
90
71
|
visible: !0
|
|
91
72
|
}, getRichTextAttribute(itemAttr.key)), {
|
|
92
73
|
textBaseline: "top"
|
|
93
|
-
}), "richtext") :
|
|
94
|
-
visible: !0,
|
|
95
|
-
text: null !== (_b = itemAttr.key.text) && void 0 !== _b ? _b : ""
|
|
96
|
-
}, itemAttr.key), {
|
|
97
|
-
textBaseline: "top"
|
|
98
|
-
}), "text") : "rich" === itemAttr.key.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
|
|
74
|
+
}), "richtext") : itemGroup.createOrUpdateChild(`${itemGroupName}-key`, Object.assign(Object.assign({
|
|
99
75
|
visible: !0
|
|
100
|
-
},
|
|
76
|
+
}, itemAttr.key), {
|
|
101
77
|
textBaseline: "top"
|
|
102
|
-
}), "
|
|
103
|
-
html: Object.assign({
|
|
104
|
-
dom: itemAttr.key.text.text,
|
|
105
|
-
container: "",
|
|
106
|
-
width: 30,
|
|
107
|
-
height: 30,
|
|
108
|
-
style: {}
|
|
109
|
-
}, itemAttr.key)
|
|
110
|
-
}, "richtext");
|
|
78
|
+
}), "text");
|
|
111
79
|
const {textAlign: textAlign} = itemAttr.key;
|
|
112
80
|
"center" === textAlign ? element.setAttribute("x", x + keyWidth / 2) : "right" === textAlign || "end" === textAlign ? element.setAttribute("x", x + keyWidth) : element.setAttribute("x", x),
|
|
113
81
|
element.setAttribute("y", 0), x += keyWidth + itemAttr.key.spacing;
|
|
@@ -118,24 +86,11 @@ export class Tooltip extends AbstractComponent {
|
|
|
118
86
|
visible: !0
|
|
119
87
|
}, getRichTextAttribute(itemAttr.value)), {
|
|
120
88
|
textBaseline: "top"
|
|
121
|
-
}), "richtext") :
|
|
122
|
-
visible: !0,
|
|
123
|
-
text: null !== (_c = itemAttr.value.text) && void 0 !== _c ? _c : ""
|
|
124
|
-
}, itemAttr.value), {
|
|
125
|
-
textBaseline: "top"
|
|
126
|
-
}), "text") : "rich" === itemAttr.value.text.type ? itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
|
|
89
|
+
}), "richtext") : itemGroup.createOrUpdateChild(`${itemGroupName}-value`, Object.assign(Object.assign({
|
|
127
90
|
visible: !0
|
|
128
|
-
},
|
|
91
|
+
}, itemAttr.value), {
|
|
129
92
|
textBaseline: "top"
|
|
130
|
-
}), "
|
|
131
|
-
html: Object.assign({
|
|
132
|
-
dom: itemAttr.value.text.text,
|
|
133
|
-
container: "",
|
|
134
|
-
width: 30,
|
|
135
|
-
height: 30,
|
|
136
|
-
style: {}
|
|
137
|
-
}, itemAttr.value)
|
|
138
|
-
}, "richtext");
|
|
93
|
+
}), "text");
|
|
139
94
|
let textAlign = "right";
|
|
140
95
|
isValid(itemAttr.value.textAlign) ? textAlign = itemAttr.value.textAlign : isVisible(itemAttr.key) || (textAlign = "left"),
|
|
141
96
|
element.setAttribute("textAlign", textAlign), "center" === textAlign ? element.setAttribute("x", x + valueWidth / 2) : "right" === textAlign || "end" === textAlign ? element.setAttribute("x", x + valueWidth) : element.setAttribute("x", x),
|
|
@@ -167,7 +122,7 @@ export class Tooltip extends AbstractComponent {
|
|
|
167
122
|
const {content: content, contentStyle: contentStyle} = attribute, padding = normalizePadding(attribute.padding), titleAttr = Tooltip.getTitleAttr(attribute);
|
|
168
123
|
let maxWidth = 0, containerHeight = padding[0] + padding[2], titleMaxHeight = 0;
|
|
169
124
|
const {value: titleValue, shape: titleShape} = titleAttr, {visible: titleHasShape = !1, symbolType: titleShapeType = ""} = null != titleShape ? titleShape : {};
|
|
170
|
-
if (isValid(titleValue)
|
|
125
|
+
if (isValid(titleValue)) {
|
|
171
126
|
const {width: width, height: height} = initTextMeasure(titleValue).quickMeasure(titleValue.text);
|
|
172
127
|
maxWidth = width, titleMaxHeight = height;
|
|
173
128
|
}
|