@visactor/vrender-components 0.16.17-alpha.4 → 0.16.17-alpha.8

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.
Files changed (97) hide show
  1. package/cjs/axis/base.js +19 -12
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/axis/circle.d.ts +1 -2
  4. package/cjs/axis/circle.js.map +1 -1
  5. package/cjs/axis/line.js +1 -1
  6. package/cjs/axis/line.js.map +1 -1
  7. package/cjs/axis/type.d.ts +5 -6
  8. package/cjs/axis/type.js.map +1 -1
  9. package/cjs/constant.d.ts +6 -0
  10. package/cjs/constant.js +6 -1
  11. package/cjs/constant.js.map +1 -1
  12. package/cjs/core/type.d.ts +15 -0
  13. package/cjs/core/type.js.map +1 -1
  14. package/cjs/index.d.ts +1 -1
  15. package/cjs/index.js +1 -1
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/indicator/indicator.js +43 -7
  18. package/cjs/indicator/indicator.js.map +1 -1
  19. package/cjs/indicator/type.d.ts +2 -1
  20. package/cjs/indicator/type.js.map +1 -1
  21. package/cjs/label/arc.d.ts +4 -3
  22. package/cjs/label/arc.js.map +1 -1
  23. package/cjs/label/base.d.ts +11 -11
  24. package/cjs/label/base.js +15 -1
  25. package/cjs/label/base.js.map +1 -1
  26. package/cjs/label/type.d.ts +8 -4
  27. package/cjs/label/type.js.map +1 -1
  28. package/cjs/marker/area.js.map +1 -1
  29. package/cjs/marker/line.js.map +1 -1
  30. package/cjs/marker/point.d.ts +1 -1
  31. package/cjs/marker/point.js.map +1 -1
  32. package/cjs/marker/type.d.ts +14 -14
  33. package/cjs/marker/type.js.map +1 -1
  34. package/cjs/tag/tag.js +87 -41
  35. package/cjs/tag/tag.js.map +1 -1
  36. package/cjs/tag/type.d.ts +4 -5
  37. package/cjs/tag/type.js.map +1 -1
  38. package/cjs/title/title.js +85 -53
  39. package/cjs/title/title.js.map +1 -1
  40. package/cjs/title/type.d.ts +10 -5
  41. package/cjs/title/type.js.map +1 -1
  42. package/cjs/tooltip/tooltip.js +49 -12
  43. package/cjs/tooltip/tooltip.js.map +1 -1
  44. package/cjs/tooltip/type.d.ts +7 -2
  45. package/cjs/tooltip/type.js.map +1 -1
  46. package/cjs/tooltip/util.js +9 -1
  47. package/cjs/tooltip/util.js.map +1 -1
  48. package/dist/index.js +291 -163
  49. package/dist/index.min.js +1 -1
  50. package/es/axis/base.js +21 -11
  51. package/es/axis/base.js.map +1 -1
  52. package/es/axis/circle.d.ts +1 -2
  53. package/es/axis/circle.js.map +1 -1
  54. package/es/axis/line.js +1 -1
  55. package/es/axis/line.js.map +1 -1
  56. package/es/axis/type.d.ts +5 -6
  57. package/es/axis/type.js.map +1 -1
  58. package/es/constant.d.ts +6 -0
  59. package/es/constant.js +7 -0
  60. package/es/constant.js.map +1 -1
  61. package/es/core/type.d.ts +15 -0
  62. package/es/core/type.js.map +1 -1
  63. package/es/index.d.ts +1 -1
  64. package/es/index.js +1 -1
  65. package/es/index.js.map +1 -1
  66. package/es/indicator/indicator.js +44 -6
  67. package/es/indicator/indicator.js.map +1 -1
  68. package/es/indicator/type.d.ts +2 -1
  69. package/es/indicator/type.js.map +1 -1
  70. package/es/label/arc.d.ts +4 -3
  71. package/es/label/arc.js.map +1 -1
  72. package/es/label/base.d.ts +11 -11
  73. package/es/label/base.js +17 -1
  74. package/es/label/base.js.map +1 -1
  75. package/es/label/type.d.ts +8 -4
  76. package/es/label/type.js.map +1 -1
  77. package/es/marker/area.js.map +1 -1
  78. package/es/marker/line.js.map +1 -1
  79. package/es/marker/point.d.ts +1 -1
  80. package/es/marker/point.js.map +1 -1
  81. package/es/marker/type.d.ts +14 -14
  82. package/es/marker/type.js.map +1 -1
  83. package/es/tag/tag.js +86 -38
  84. package/es/tag/tag.js.map +1 -1
  85. package/es/tag/type.d.ts +4 -5
  86. package/es/tag/type.js.map +1 -1
  87. package/es/title/title.js +84 -50
  88. package/es/title/title.js.map +1 -1
  89. package/es/title/type.d.ts +10 -5
  90. package/es/title/type.js.map +1 -1
  91. package/es/tooltip/tooltip.js +50 -11
  92. package/es/tooltip/tooltip.js.map +1 -1
  93. package/es/tooltip/type.d.ts +7 -2
  94. package/es/tooltip/type.js.map +1 -1
  95. package/es/tooltip/util.js +9 -1
  96. package/es/tooltip/util.js.map +1 -1
  97. package/package.json +6 -6
@@ -37,16 +37,16 @@ export type IMarkBackgroundAttributes = {
37
37
  autoHeight?: boolean;
38
38
  autoWidth?: boolean;
39
39
  } & Partial<SymbolAttributes>;
40
- export interface IMarkLabel extends Omit<TagAttributes, 'x' | 'y' | 'panel'> {
40
+ export type IMarkLabel = Omit<TagAttributes, 'x' | 'y' | 'panel'> & {
41
41
  panel?: IMarkBackgroundAttributes;
42
- }
43
- export interface IMarkRef {
42
+ };
43
+ export type IMarkRef = {
44
44
  autoRotate?: boolean;
45
45
  refX?: number;
46
46
  refY?: number;
47
47
  refAngle?: number;
48
- }
49
- export interface MarkerAttrs extends IGroupGraphicAttribute {
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 interface MarkLineAttrs extends MarkerAttrs, SegmentAttributes {
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 interface MarkAreaAttrs extends MarkerAttrs {
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 interface IItemContent extends IMarkRef {
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 interface MarkPointAttrs extends Omit<MarkerAttrs, 'labelStyle'> {
97
+ export type MarkPointAttrs = Omit<MarkerAttrs, 'labelStyle'> & {
98
98
  position: Point;
99
99
  itemLine?: IItemLine;
100
100
  itemContent?: IItemContent;
101
- }
101
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAYA,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,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAED,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,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAED,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,GAAtB,8BAAsB,KAAtB,8BAAsB,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 interface IMarkLabel extends Omit<TagAttributes, 'x' | 'y' | 'panel'> {\n /**\n * 标签的背景面板配置\n */\n panel?: IMarkBackgroundAttributes;\n}\n\nexport interface 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 interface MarkerAttrs extends 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 interface MarkLineAttrs extends MarkerAttrs, 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 interface MarkAreaAttrs extends 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 interface IItemContent extends IMarkRef {\n /**\n * 标注类型\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 */\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 interface MarkPointAttrs extends 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"]}
1
+ {"version":3,"sources":["../src/marker/type.ts"],"names":[],"mappings":";;;AAYA,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,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAED,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,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAED,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,GAAtB,8BAAsB,KAAtB,8BAAsB,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/cjs/tag/tag.js CHANGED
@@ -14,15 +14,15 @@ Object.defineProperty(exports, "__esModule", {
14
14
  value: !0
15
15
  }), exports.Tag = void 0;
16
16
 
17
- const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), util_1 = require("../util");
17
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), util_1 = require("../util"), constant_1 = require("../constant");
18
18
 
19
19
  class Tag extends base_1.AbstractComponent {
20
20
  constructor(attributes) {
21
21
  super((0, vutils_1.merge)({}, Tag.defaultAttributes, attributes)), this.name = "tag";
22
22
  }
23
23
  render() {
24
- var _a;
25
- 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 = (0,
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 = (0,
26
26
  vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("tag-content", {
27
27
  x: 0,
28
28
  y: 0,
@@ -44,44 +44,90 @@ class Tag extends base_1.AbstractComponent {
44
44
  }), "symbol"), (0, vutils_1.isEmpty)(null == state ? void 0 : state.shape) || (symbol.states = state.shape),
45
45
  shapeVisible && (symbolPlaceWidth = maxSize + space);
46
46
  }
47
- tagWidth += symbolPlaceWidth, textX += symbolPlaceWidth;
48
- const textAttrs = Object.assign(Object.assign({
49
- text: text,
50
- visible: (0, vutils_1.isValid)(text) && !1 !== visible,
51
- lineHeight: null == textStyle ? void 0 : textStyle.fontSize
52
- }, textStyle), {
53
- x: textX,
54
- y: 0
55
- });
56
- (0, vutils_1.isNil)(textAttrs.lineHeight) && (textAttrs.lineHeight = textAttrs.fontSize);
57
- const textShape = group.createOrUpdateChild("tag-text", textAttrs, "text");
58
- (0, vutils_1.isEmpty)(null == state ? void 0 : state.text) || (textShape.states = state.text);
59
- const textBounds = (0, util_1.measureTextSize)(textAttrs.text, textStyle), textWidth = textBounds.width, textHeight = textBounds.height;
60
- tagWidth += textWidth;
61
- const size = null !== (_a = shape.size) && void 0 !== _a ? _a : 10, maxSize = (0,
62
- vutils_1.isNumber)(size) ? size : Math.max(size[0], size[1]);
63
- tagHeight += Math.max(textHeight, (null == shape ? void 0 : shape.visible) ? maxSize : 0);
64
- const {textAlign: textAlign, textBaseline: textBaseline} = textStyle;
65
- ((0, vutils_1.isValid)(minWidth) || (0, vutils_1.isValid)(maxWidth)) && ((0, vutils_1.isValid)(minWidth) && tagWidth < minWidth && (tagWidth = minWidth),
66
- (0, vutils_1.isValid)(maxWidth) && tagWidth > maxWidth && (tagWidth = maxWidth,
67
- textShape.setAttribute("maxLineWidth", maxWidth - parsedPadding[1] - parsedPadding[2])));
68
- let x = 0, y = 0;
69
- "center" === textAlign ? (x -= tagWidth / 2, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth / 2),
70
- group.setAttribute("x", -symbolPlaceWidth / 2)) : "right" === textAlign || "end" === textAlign ? (x -= tagWidth,
71
- symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth), group.setAttribute("x", -parsedPadding[1] - symbolPlaceWidth)) : "left" !== textAlign && "start" !== textAlign || group.setAttribute("x", parsedPadding[3]),
72
- "middle" === textBaseline ? (y -= tagHeight / 2, symbol && symbol.setAttribute("y", 0)) : "bottom" === textBaseline ? (y -= tagHeight,
73
- symbol && symbol.setAttribute("y", -textHeight / 2), group.setAttribute("y", -parsedPadding[2])) : "top" === textBaseline && (group.setAttribute("y", parsedPadding[0]),
74
- symbol && symbol.setAttribute("y", textHeight / 2));
75
- const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
76
- if (visible && (0, vutils_1.isBoolean)(bgVisible)) {
77
- const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
78
- visible: bgVisible && !!text,
79
- x: x,
80
- y: y,
81
- width: tagWidth,
82
- height: tagHeight
83
- }), "rect");
84
- (0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
47
+ let textShape;
48
+ if (tagWidth += symbolPlaceWidth, textX += symbolPlaceWidth, "rich" === type) {
49
+ const richTextAttrs = Object.assign(Object.assign({
50
+ textConfig: text,
51
+ visible: (0, vutils_1.isValid)(text) && !1 !== visible
52
+ }, textStyle), {
53
+ x: textX,
54
+ y: 0,
55
+ width: null !== (_a = textStyle.width) && void 0 !== _a ? _a : 0,
56
+ height: null !== (_b = textStyle.height) && void 0 !== _b ? _b : 0
57
+ });
58
+ textShape = group.createOrUpdateChild("tag-text", richTextAttrs, "richtext");
59
+ const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
60
+ if (visible && (0, vutils_1.isBoolean)(bgVisible)) {
61
+ const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
62
+ visible: bgVisible && !!text,
63
+ x: textShape.AABBBounds.x1,
64
+ y: textShape.AABBBounds.y1,
65
+ width: textShape.AABBBounds.width(),
66
+ height: textShape.AABBBounds.height()
67
+ }), "rect");
68
+ (0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
69
+ }
70
+ } else if ("html" === type) {
71
+ const richTextAttrs = Object.assign(Object.assign({
72
+ textConfig: [],
73
+ visible: (0, vutils_1.isValid)(text) && !1 !== visible,
74
+ html: Object.assign(Object.assign({
75
+ dom: text
76
+ }, constant_1.DEFAULT_HTML_TEXT_SPEC), textStyle)
77
+ }, textStyle), {
78
+ x: textX,
79
+ y: 0
80
+ });
81
+ textShape = group.createOrUpdateChild("tag-text", richTextAttrs, "richtext");
82
+ const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
83
+ if (visible && (0, vutils_1.isBoolean)(bgVisible)) {
84
+ const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
85
+ visible: bgVisible && !!text,
86
+ x: textShape.AABBBounds.x1,
87
+ y: textShape.AABBBounds.y1,
88
+ width: textShape.AABBBounds.width(),
89
+ height: textShape.AABBBounds.height()
90
+ }), "rect");
91
+ (0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
92
+ }
93
+ } else {
94
+ const textAttrs = Object.assign(Object.assign({
95
+ text: text,
96
+ visible: (0, vutils_1.isValid)(text) && !1 !== visible,
97
+ lineHeight: null == textStyle ? void 0 : textStyle.fontSize
98
+ }, textStyle), {
99
+ x: textX,
100
+ y: 0
101
+ });
102
+ (0, vutils_1.isNil)(textAttrs.lineHeight) && (textAttrs.lineHeight = textStyle.fontSize),
103
+ textShape = group.createOrUpdateChild("tag-text", textAttrs, "text"), (0, vutils_1.isEmpty)(null == state ? void 0 : state.text) || (textShape.states = state.text);
104
+ const textBounds = (0, util_1.measureTextSize)(textAttrs.text, textStyle), textWidth = textBounds.width, textHeight = textBounds.height;
105
+ tagWidth += textWidth;
106
+ const size = null !== (_c = shape.size) && void 0 !== _c ? _c : 10, maxSize = (0,
107
+ vutils_1.isNumber)(size) ? size : Math.max(size[0], size[1]);
108
+ tagHeight += Math.max(textHeight, (null == shape ? void 0 : shape.visible) ? maxSize : 0);
109
+ const {textAlign: textAlign, textBaseline: textBaseline} = textStyle;
110
+ ((0, vutils_1.isValid)(minWidth) || (0, vutils_1.isValid)(maxWidth)) && ((0, vutils_1.isValid)(minWidth) && tagWidth < minWidth && (tagWidth = minWidth),
111
+ (0, vutils_1.isValid)(maxWidth) && tagWidth > maxWidth && (tagWidth = maxWidth,
112
+ textShape.setAttribute("maxLineWidth", maxWidth - parsedPadding[1] - parsedPadding[2])));
113
+ let x = 0, y = 0;
114
+ "center" === textAlign ? (x -= tagWidth / 2, symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth / 2),
115
+ group.setAttribute("x", -symbolPlaceWidth / 2)) : "right" === textAlign || "end" === textAlign ? (x -= tagWidth,
116
+ symbol && symbol.setAttribute("x", (symbol.attribute.x || 0) - textWidth), group.setAttribute("x", -parsedPadding[1] - symbolPlaceWidth)) : "left" !== textAlign && "start" !== textAlign || group.setAttribute("x", parsedPadding[3]),
117
+ "middle" === textBaseline ? (y -= tagHeight / 2, symbol && symbol.setAttribute("y", 0)) : "bottom" === textBaseline ? (y -= tagHeight,
118
+ symbol && symbol.setAttribute("y", -textHeight / 2), group.setAttribute("y", -parsedPadding[2])) : "top" === textBaseline && (group.setAttribute("y", parsedPadding[0]),
119
+ symbol && symbol.setAttribute("y", textHeight / 2));
120
+ const {visible: bgVisible} = panel, backgroundStyle = __rest(panel, [ "visible" ]);
121
+ if (visible && (0, vutils_1.isBoolean)(bgVisible)) {
122
+ const bgRect = this.createOrUpdateChild("tag-panel", Object.assign(Object.assign({}, backgroundStyle), {
123
+ visible: bgVisible && !!text,
124
+ x: x,
125
+ y: y,
126
+ width: tagWidth,
127
+ height: tagHeight
128
+ }), "rect");
129
+ (0, vutils_1.isEmpty)(null == state ? void 0 : state.panel) || (bgRect.states = state.panel);
130
+ }
85
131
  }
86
132
  }
87
133
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tag/tag.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,6CAAyG;AACzG,uCAAiD;AACjD,kCAA0C;AAI1C,MAAa,GAAI,SAAQ,wBAA0C;IAmBjE,YAAY,UAAyB;QACnC,KAAK,CAAC,IAAA,cAAK,EAAC,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,SAAS,GAAG,EAA2B,EACvC,KAAK,GAAG,EAAwB,EAChC,KAAK,GAAG,EAA0B,EAClC,KAAK,GAAG,CAAC,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,OAAO,EACP,KAAK,EACN,GAAG,IAAI,CAAC,SAA0B,CAAC;QACpC,MAAM,aAAa,GAAG,IAAA,yBAAgB,EAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,CAAW,CAAC;QAEpG,IAAI,MAAM,CAAC;QACX,IAAI,QAAQ,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C,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,EAAE;gBAC1B,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;aAC7B;SACF;IACH,CAAC;;AAzKH,kBA0KC;AAvKQ,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 { 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,6CAAyG;AACzG,uCAAiD;AACjD,kCAA0C;AAG1C,0CAAqD;AAErD,MAAa,GAAI,SAAQ,wBAA0C;IAmBjE,YAAY,UAAyB;QACnC,KAAK,CAAC,IAAA,cAAK,EAAC,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,SAAS,G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,EAAE;gBACnC,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CACrC,WAAW,kCAEN,eAAe,KAClB,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC,IAAI,EAC5B,CAAC;oBACD,CAAC,EACD,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,KAEnB,MAAM,CACE,CAAC;gBACX,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,EAAE;oBAC1B,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;iBAC7B;aACF;SACF;IACH,CAAC;;AA9OH,kBA+OC;AA5OQ,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/cjs/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
- text?: string | string[] | number | number[];
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>;
@@ -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 /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n */\n text?: string | string[] | number | number[];\n /** 文本样式 */\n textStyle?: Partial<ITextGraphicAttribute>;\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\nexport type TagShapeAttributes = {\n /**\n * 是否展示 shape\n */\n visible: boolean;\n} & Partial<ISymbolGraphicAttribute>;\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"]}
@@ -4,23 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Title = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base");
7
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), constant_1 = require("../constant");
8
8
 
9
9
  class Title extends base_1.AbstractComponent {
10
10
  constructor(attributes) {
11
11
  super((0, vutils_1.merge)({}, Title.defaultAttributes, attributes)), this.name = "title";
12
12
  }
13
13
  render() {
14
- 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;
15
- 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 = (0,
14
+ 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;
15
+ 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 = (0,
16
16
  vutils_1.normalizePadding)(padding), group = this.createOrUpdateChild("title-container", {
17
17
  x: parsedPadding[3],
18
18
  y: parsedPadding[0],
19
19
  zIndex: 1
20
20
  }, "group");
21
- if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if (textStyle && (0,
22
- vutils_1.isValid)(null == textStyle ? void 0 : textStyle.character)) {
23
- const attr = {
21
+ if (!1 !== (null === (_a = this.attribute) || void 0 === _a ? void 0 : _a.visible) && !1 !== (null == textStyle ? void 0 : textStyle.visible)) if ("rich" === textType || (0,
22
+ vutils_1.isValid)(textStyle.character)) {
23
+ const attr = Object.assign({
24
24
  x: null !== (_b = textStyle.x) && void 0 !== _b ? _b : 0,
25
25
  y: null !== (_c = textStyle.y) && void 0 !== _c ? _c : 0,
26
26
  width: null !== (_e = null !== (_d = textStyle.width) && void 0 !== _d ? _d : width) && void 0 !== _e ? _e : 0,
@@ -29,85 +29,117 @@ class Title extends base_1.AbstractComponent {
29
29
  wordBreak: null !== (_j = textStyle.wordBreak) && void 0 !== _j ? _j : "break-word",
30
30
  maxHeight: textStyle.maxHeight,
31
31
  maxWidth: textStyle.maxWidth,
32
- textConfig: textStyle.character
33
- };
32
+ textConfig: null !== (_k = textStyle.character) && void 0 !== _k ? _k : text
33
+ }, textStyle);
34
+ this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
35
+ } else if ("html" === textType) {
36
+ const attr = Object.assign({
37
+ html: Object.assign(Object.assign({
38
+ dom: text
39
+ }, constant_1.DEFAULT_HTML_TEXT_SPEC), textStyle),
40
+ x: null !== (_l = textStyle.x) && void 0 !== _l ? _l : 0,
41
+ y: null !== (_m = textStyle.y) && void 0 !== _m ? _m : 0,
42
+ width: null !== (_p = null !== (_o = textStyle.width) && void 0 !== _o ? _o : width) && void 0 !== _p ? _p : 0,
43
+ height: null !== (_r = null !== (_q = textStyle.height) && void 0 !== _q ? _q : height) && void 0 !== _r ? _r : 0,
44
+ ellipsis: null === (_s = textStyle.ellipsis) || void 0 === _s || _s,
45
+ wordBreak: null !== (_t = textStyle.wordBreak) && void 0 !== _t ? _t : "break-word",
46
+ maxHeight: textStyle.maxHeight,
47
+ maxWidth: textStyle.maxWidth,
48
+ textConfig: []
49
+ }, textStyle);
34
50
  this._mainTitle = group.createOrUpdateChild("mainTitle", attr, "richtext");
35
51
  } else (0, vutils_1.isValid)(text) && (this._mainTitle = group.createOrUpdateChild("mainTitle", Object.assign(Object.assign({
36
52
  text: [ text ]
37
53
  }, textStyle), {
38
- maxLineWidth: null !== (_k = null == textStyle ? void 0 : textStyle.maxLineWidth) && void 0 !== _k ? _k : width,
54
+ maxLineWidth: null !== (_u = null == textStyle ? void 0 : textStyle.maxLineWidth) && void 0 !== _u ? _u : width,
39
55
  heightLimit: null == textStyle ? void 0 : textStyle.heightLimit,
40
56
  lineClamp: null == textStyle ? void 0 : textStyle.lineClamp,
41
- ellipsis: null === (_l = null == textStyle ? void 0 : textStyle.ellipsis) || void 0 === _l || _l,
57
+ ellipsis: null === (_v = null == textStyle ? void 0 : textStyle.ellipsis) || void 0 === _v || _v,
42
58
  x: 0,
43
59
  y: 0
44
60
  }), "wrapText"));
45
- 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;
46
- if (!1 !== (null === (_p = this.attribute) || void 0 === _p ? void 0 : _p.visible) && !1 !== (null == subtextStyle ? void 0 : subtextStyle.visible)) if (subtextStyle && (0,
47
- vutils_1.isValid)(null == subtextStyle ? void 0 : subtextStyle.character)) {
48
- const attr = {
49
- x: null !== (_q = subtextStyle.x) && void 0 !== _q ? _q : 0,
50
- y: null !== (_r = subtextStyle.y) && void 0 !== _r ? _r : maintextHeight,
51
- width: null !== (_t = null !== (_s = subtextStyle.width) && void 0 !== _s ? _s : width) && void 0 !== _t ? _t : 0,
52
- height: null !== (_v = null !== (_u = subtextStyle.height) && void 0 !== _u ? _u : height) && void 0 !== _v ? _v : 0,
53
- ellipsis: null === (_w = subtextStyle.ellipsis) || void 0 === _w || _w,
54
- wordBreak: null !== (_x = subtextStyle.wordBreak) && void 0 !== _x ? _x : "break-word",
61
+ 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;
62
+ if (!1 !== (null === (_y = this.attribute) || void 0 === _y ? void 0 : _y.visible) && !1 !== (null == subtextStyle ? void 0 : subtextStyle.visible)) if ("rich" === subtextType || (0,
63
+ vutils_1.isValid)(subtextStyle.character)) {
64
+ const attr = Object.assign({
65
+ x: null !== (_z = subtextStyle.x) && void 0 !== _z ? _z : 0,
66
+ y: null !== (_0 = subtextStyle.y) && void 0 !== _0 ? _0 : 0,
67
+ width: null !== (_2 = null !== (_1 = subtextStyle.width) && void 0 !== _1 ? _1 : width) && void 0 !== _2 ? _2 : 0,
68
+ height: null !== (_4 = null !== (_3 = subtextStyle.height) && void 0 !== _3 ? _3 : height) && void 0 !== _4 ? _4 : 0,
69
+ ellipsis: null === (_5 = subtextStyle.ellipsis) || void 0 === _5 || _5,
70
+ wordBreak: null !== (_6 = subtextStyle.wordBreak) && void 0 !== _6 ? _6 : "break-word",
71
+ maxHeight: subtextStyle.maxHeight,
72
+ maxWidth: subtextStyle.maxWidth,
73
+ textConfig: null !== (_7 = subtextStyle.character) && void 0 !== _7 ? _7 : subtext
74
+ }, subtextStyle);
75
+ this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
76
+ } else if ("html" === subtextType) {
77
+ const attr = Object.assign({
78
+ html: Object.assign(Object.assign({
79
+ dom: subtext
80
+ }, constant_1.DEFAULT_HTML_TEXT_SPEC), subtextStyle),
81
+ x: null !== (_8 = subtextStyle.x) && void 0 !== _8 ? _8 : 0,
82
+ y: null !== (_9 = subtextStyle.y) && void 0 !== _9 ? _9 : 0,
83
+ width: null !== (_11 = null !== (_10 = subtextStyle.width) && void 0 !== _10 ? _10 : width) && void 0 !== _11 ? _11 : 0,
84
+ height: null !== (_13 = null !== (_12 = subtextStyle.height) && void 0 !== _12 ? _12 : height) && void 0 !== _13 ? _13 : 0,
85
+ ellipsis: null === (_14 = subtextStyle.ellipsis) || void 0 === _14 || _14,
86
+ wordBreak: null !== (_15 = subtextStyle.wordBreak) && void 0 !== _15 ? _15 : "break-word",
55
87
  maxHeight: subtextStyle.maxHeight,
56
88
  maxWidth: subtextStyle.maxWidth,
57
- textConfig: subtextStyle.character
58
- };
89
+ textConfig: []
90
+ }, subtextStyle);
59
91
  this._subTitle = group.createOrUpdateChild("subTitle", attr, "richtext");
60
92
  } else (0, vutils_1.isValid)(subtext) && (this._subTitle = group.createOrUpdateChild("subTitle", Object.assign(Object.assign({
61
93
  text: [ subtext ]
62
94
  }, subtextStyle), {
63
- maxLineWidth: null !== (_y = null == subtextStyle ? void 0 : subtextStyle.maxLineWidth) && void 0 !== _y ? _y : width,
95
+ maxLineWidth: null !== (_16 = null == subtextStyle ? void 0 : subtextStyle.maxLineWidth) && void 0 !== _16 ? _16 : width,
64
96
  heightLimit: null == subtextStyle ? void 0 : subtextStyle.heightLimit,
65
97
  lineClamp: null == subtextStyle ? void 0 : subtextStyle.lineClamp,
66
- ellipsis: null === (_z = null == subtextStyle ? void 0 : subtextStyle.ellipsis) || void 0 === _z || _z,
98
+ ellipsis: null === (_17 = null == subtextStyle ? void 0 : subtextStyle.ellipsis) || void 0 === _17 || _17,
67
99
  x: 0,
68
100
  y: maintextHeight
69
101
  }), "wrapText"));
70
- 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;
71
- let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_2 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _2 ? _2 : subtextHeight);
72
- if ((0, vutils_1.isValid)(width) && (titleWidth = width, null === (_3 = this._mainTitle) || void 0 === _3 || _3.setAttribute("maxLineWidth", width),
73
- null === (_4 = this._subTitle) || void 0 === _4 || _4.setAttribute("maxLineWidth", width)),
102
+ 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;
103
+ let titleWidth = Math.max(maintextWidth, subtextWidth), titleHeight = maintextHeight + (null !== (_20 = null == subtextStyle ? void 0 : subtextStyle.height) && void 0 !== _20 ? _20 : subtextHeight);
104
+ if ((0, vutils_1.isValid)(width) && (titleWidth = width, null === (_21 = this._mainTitle) || void 0 === _21 || _21.setAttribute("maxLineWidth", width),
105
+ null === (_22 = this._subTitle) || void 0 === _22 || _22.setAttribute("maxLineWidth", width)),
74
106
  (0, vutils_1.isValid)(height) && (titleHeight = height), (0, vutils_1.isValid)(minWidth) && titleWidth < minWidth && (titleWidth = minWidth),
75
- (0, vutils_1.isValid)(maxWidth) && (null === (_5 = this._mainTitle) || void 0 === _5 || _5.setAttribute("maxLineWidth", maxWidth),
76
- null === (_6 = this._subTitle) || void 0 === _6 || _6.setAttribute("maxLineWidth", maxWidth),
77
- null === (_7 = this._mainTitle) || void 0 === _7 || _7.setAttribute("maxWidth", maxWidth),
78
- null === (_8 = this._subTitle) || void 0 === _8 || _8.setAttribute("maxWidth", maxWidth),
107
+ (0, vutils_1.isValid)(maxWidth) && (null === (_23 = this._mainTitle) || void 0 === _23 || _23.setAttribute("maxLineWidth", maxWidth),
108
+ null === (_24 = this._subTitle) || void 0 === _24 || _24.setAttribute("maxLineWidth", maxWidth),
109
+ null === (_25 = this._mainTitle) || void 0 === _25 || _25.setAttribute("maxWidth", maxWidth),
110
+ null === (_26 = this._subTitle) || void 0 === _26 || _26.setAttribute("maxWidth", maxWidth),
79
111
  titleWidth > maxWidth && (titleWidth = maxWidth)), (0, vutils_1.isValid)(minHeight) && titleHeight < minHeight && (titleHeight = minHeight),
80
- (0, vutils_1.isValid)(maxHeight) && (null === (_9 = this._mainTitle) || void 0 === _9 || _9.setAttribute("maxHeight", maxHeight),
81
- null === (_10 = this._subTitle) || void 0 === _10 || _10.setAttribute("maxHeight", maxHeight - maintextHeight),
112
+ (0, vutils_1.isValid)(maxHeight) && (null === (_27 = this._mainTitle) || void 0 === _27 || _27.setAttribute("maxHeight", maxHeight),
113
+ null === (_28 = this._subTitle) || void 0 === _28 || _28.setAttribute("maxHeight", maxHeight - maintextHeight),
82
114
  titleHeight > maxHeight && (titleHeight = maxHeight)), group.attribute.width = titleWidth,
83
115
  group.attribute.height = titleHeight, group.attribute.boundsPadding = parsedPadding,
84
116
  (0, vutils_1.isValid)(align) || (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.align)) {
85
- 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;
86
- "left" === mainTitleAlign ? (null === (_12 = this._mainTitle) || void 0 === _12 || _12.setAttribute("x", 0),
87
- 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),
88
- null === (_15 = this._mainTitle) || void 0 === _15 || _15.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (null === (_16 = this._mainTitle) || void 0 === _16 || _16.setAttribute("x", mainTitleWidth),
89
- null === (_17 = this._mainTitle) || void 0 === _17 || _17.setAttribute("textAlign", "right"));
117
+ 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;
118
+ "left" === mainTitleAlign ? (null === (_30 = this._mainTitle) || void 0 === _30 || _30.setAttribute("x", 0),
119
+ 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),
120
+ null === (_33 = this._mainTitle) || void 0 === _33 || _33.setAttribute("textAlign", "center")) : "right" === mainTitleAlign && (null === (_34 = this._mainTitle) || void 0 === _34 || _34.setAttribute("x", mainTitleWidth),
121
+ null === (_35 = this._mainTitle) || void 0 === _35 || _35.setAttribute("textAlign", "right"));
90
122
  }
91
123
  if ((0, vutils_1.isValid)(verticalAlign) || (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.verticalAlign)) {
92
124
  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;
93
- "top" === mainTitleVerticalAlign ? (null === (_18 = this._mainTitle) || void 0 === _18 || _18.setAttribute("y", 0),
94
- 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),
95
- null === (_21 = this._mainTitle) || void 0 === _21 || _21.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (null === (_22 = this._mainTitle) || void 0 === _22 || _22.setAttribute("y", mainTitleHeight),
96
- null === (_23 = this._mainTitle) || void 0 === _23 || _23.setAttribute("textBaseline", "bottom"));
125
+ "top" === mainTitleVerticalAlign ? (null === (_36 = this._mainTitle) || void 0 === _36 || _36.setAttribute("y", 0),
126
+ 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),
127
+ null === (_39 = this._mainTitle) || void 0 === _39 || _39.setAttribute("textBaseline", "middle")) : "bottom" === mainTitleVerticalAlign && (null === (_40 = this._mainTitle) || void 0 === _40 || _40.setAttribute("y", mainTitleHeight),
128
+ null === (_41 = this._mainTitle) || void 0 === _41 || _41.setAttribute("textBaseline", "bottom"));
97
129
  }
98
130
  if ((0, vutils_1.isValid)(align) || (0, vutils_1.isValid)(null == subtextStyle ? void 0 : subtextStyle.align)) {
99
- 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;
100
- "left" === subTitleAlign ? (null === (_25 = this._subTitle) || void 0 === _25 || _25.setAttribute("x", 0),
101
- 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),
102
- null === (_28 = this._subTitle) || void 0 === _28 || _28.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (null === (_29 = this._subTitle) || void 0 === _29 || _29.setAttribute("x", subTitleWidth),
103
- null === (_30 = this._subTitle) || void 0 === _30 || _30.setAttribute("textAlign", "right"));
131
+ 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;
132
+ "left" === subTitleAlign ? (null === (_43 = this._subTitle) || void 0 === _43 || _43.setAttribute("x", 0),
133
+ 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),
134
+ null === (_46 = this._subTitle) || void 0 === _46 || _46.setAttribute("textAlign", "center")) : "right" === subTitleAlign && (null === (_47 = this._subTitle) || void 0 === _47 || _47.setAttribute("x", subTitleWidth),
135
+ null === (_48 = this._subTitle) || void 0 === _48 || _48.setAttribute("textAlign", "right"));
104
136
  }
105
137
  if ((0, vutils_1.isValid)(verticalAlign) || (0, vutils_1.isValid)(null == textStyle ? void 0 : textStyle.verticalAlign)) {
106
- 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;
107
- "top" === subTitleVerticalAlign ? (null === (_32 = this._subTitle) || void 0 === _32 || _32.setAttribute("y", subTitleYStart),
108
- 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),
109
- 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),
110
- null === (_37 = this._subTitle) || void 0 === _37 || _37.setAttribute("textBaseline", "bottom"));
138
+ 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;
139
+ "top" === subTitleVerticalAlign ? (null === (_50 = this._subTitle) || void 0 === _50 || _50.setAttribute("y", subTitleYStart),
140
+ 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),
141
+ 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),
142
+ null === (_55 = this._subTitle) || void 0 === _55 || _55.setAttribute("textBaseline", "bottom"));
111
143
  }
112
144
  }
113
145
  }