@visactor/vchart 1.1.0-beta.4 → 1.1.0-beta.6

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 (142) hide show
  1. package/README.md +8 -8
  2. package/build/index.js +230 -92
  3. package/build/index.min.js +2 -2
  4. package/cjs/chart/box-plot/box-plot.js +3 -8
  5. package/cjs/chart/box-plot/box-plot.js.map +1 -1
  6. package/cjs/component/brush/brush.d.ts +8 -0
  7. package/cjs/component/brush/brush.js +19 -3
  8. package/cjs/component/brush/brush.js.map +1 -1
  9. package/cjs/component/brush/interface.d.ts +8 -0
  10. package/cjs/component/brush/interface.js +7 -1
  11. package/cjs/component/brush/interface.js.map +1 -1
  12. package/cjs/component/tooltip/handler/base.js +1 -3
  13. package/cjs/component/tooltip/handler/base.js.map +1 -1
  14. package/cjs/component/tooltip/handler/constants.d.ts +1 -1
  15. package/cjs/component/tooltip/handler/constants.js +2 -2
  16. package/cjs/component/tooltip/handler/constants.js.map +1 -1
  17. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -1
  18. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  19. package/cjs/component/tooltip/handler/dom/interface.d.ts +3 -2
  20. package/cjs/component/tooltip/handler/dom/interface.js.map +1 -1
  21. package/cjs/component/tooltip/handler/dom/model/content-column-model.d.ts +3 -0
  22. package/cjs/component/tooltip/handler/dom/model/content-column-model.js +34 -33
  23. package/cjs/component/tooltip/handler/dom/model/content-column-model.js.map +1 -1
  24. package/cjs/component/tooltip/handler/dom/model/interface.d.ts +2 -0
  25. package/cjs/component/tooltip/handler/dom/model/interface.js.map +1 -1
  26. package/cjs/component/tooltip/handler/dom/model/shape-model.d.ts +1 -0
  27. package/cjs/component/tooltip/handler/dom/model/shape-model.js +3 -3
  28. package/cjs/component/tooltip/handler/dom/model/shape-model.js.map +1 -1
  29. package/cjs/component/tooltip/handler/dom/model/text-model.d.ts +1 -1
  30. package/cjs/component/tooltip/handler/dom/model/text-model.js +3 -2
  31. package/cjs/component/tooltip/handler/dom/model/text-model.js.map +1 -1
  32. package/cjs/component/tooltip/handler/dom/model/title-model.js +3 -3
  33. package/cjs/component/tooltip/handler/dom/model/title-model.js.map +1 -1
  34. package/cjs/component/tooltip/handler/dom/util.d.ts +1 -0
  35. package/cjs/component/tooltip/handler/dom/util.js +27 -28
  36. package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
  37. package/cjs/component/tooltip/handler/interface/style.d.ts +10 -9
  38. package/cjs/component/tooltip/handler/interface/style.js.map +1 -1
  39. package/cjs/component/tooltip/handler/utils/attribute.d.ts +9 -2
  40. package/cjs/component/tooltip/handler/utils/attribute.js +58 -9
  41. package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
  42. package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
  43. package/cjs/component/tooltip/handler/utils/style.d.ts +2 -2
  44. package/cjs/component/tooltip/handler/utils/style.js +5 -2
  45. package/cjs/component/tooltip/handler/utils/style.js.map +1 -1
  46. package/cjs/component/tooltip/interface/spec.d.ts +1 -3
  47. package/cjs/component/tooltip/interface/spec.js.map +1 -1
  48. package/cjs/component/tooltip/interface/theme.d.ts +4 -2
  49. package/cjs/component/tooltip/interface/theme.js.map +1 -1
  50. package/cjs/component/tooltip/tooltip.js +4 -2
  51. package/cjs/component/tooltip/tooltip.js.map +1 -1
  52. package/cjs/component/tooltip/utils/show-tooltip.js +9 -4
  53. package/cjs/component/tooltip/utils/show-tooltip.js.map +1 -1
  54. package/cjs/constant/event.d.ts +2 -0
  55. package/cjs/constant/event.js +4 -3
  56. package/cjs/constant/event.js.map +1 -1
  57. package/cjs/core/index.d.ts +1 -1
  58. package/cjs/core/index.js +1 -1
  59. package/cjs/core/index.js.map +1 -1
  60. package/cjs/core/instance-manager.d.ts +2 -1
  61. package/cjs/core/instance-manager.js +7 -2
  62. package/cjs/core/instance-manager.js.map +1 -1
  63. package/cjs/core/interface.d.ts +3 -0
  64. package/cjs/core/interface.js.map +1 -1
  65. package/cjs/core/vchart.d.ts +3 -2
  66. package/cjs/core/vchart.js +5 -3
  67. package/cjs/core/vchart.js.map +1 -1
  68. package/cjs/series/range-column/rangeColumn.js +5 -5
  69. package/cjs/series/range-column/rangeColumn.js.map +1 -1
  70. package/cjs/util/text.d.ts +4 -0
  71. package/cjs/util/text.js +9 -1
  72. package/cjs/util/text.js.map +1 -1
  73. package/esm/chart/box-plot/box-plot.js +2 -9
  74. package/esm/chart/box-plot/box-plot.js.map +1 -1
  75. package/esm/component/brush/brush.d.ts +8 -0
  76. package/esm/component/brush/brush.js +19 -3
  77. package/esm/component/brush/brush.js.map +1 -1
  78. package/esm/component/brush/interface.d.ts +8 -0
  79. package/esm/component/brush/interface.js +7 -1
  80. package/esm/component/brush/interface.js.map +1 -1
  81. package/esm/component/tooltip/handler/base.js +1 -3
  82. package/esm/component/tooltip/handler/base.js.map +1 -1
  83. package/esm/component/tooltip/handler/constants.d.ts +1 -1
  84. package/esm/component/tooltip/handler/constants.js +1 -1
  85. package/esm/component/tooltip/handler/constants.js.map +1 -1
  86. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -1
  87. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  88. package/esm/component/tooltip/handler/dom/interface.d.ts +3 -2
  89. package/esm/component/tooltip/handler/dom/interface.js.map +1 -1
  90. package/esm/component/tooltip/handler/dom/model/content-column-model.d.ts +3 -0
  91. package/esm/component/tooltip/handler/dom/model/content-column-model.js +33 -31
  92. package/esm/component/tooltip/handler/dom/model/content-column-model.js.map +1 -1
  93. package/esm/component/tooltip/handler/dom/model/interface.d.ts +2 -0
  94. package/esm/component/tooltip/handler/dom/model/interface.js.map +1 -1
  95. package/esm/component/tooltip/handler/dom/model/shape-model.d.ts +1 -0
  96. package/esm/component/tooltip/handler/dom/model/shape-model.js +3 -3
  97. package/esm/component/tooltip/handler/dom/model/shape-model.js.map +1 -1
  98. package/esm/component/tooltip/handler/dom/model/text-model.d.ts +1 -1
  99. package/esm/component/tooltip/handler/dom/model/text-model.js +3 -2
  100. package/esm/component/tooltip/handler/dom/model/text-model.js.map +1 -1
  101. package/esm/component/tooltip/handler/dom/model/title-model.js +3 -3
  102. package/esm/component/tooltip/handler/dom/model/title-model.js.map +1 -1
  103. package/esm/component/tooltip/handler/dom/util.d.ts +1 -0
  104. package/esm/component/tooltip/handler/dom/util.js +9 -8
  105. package/esm/component/tooltip/handler/dom/util.js.map +1 -1
  106. package/esm/component/tooltip/handler/interface/style.d.ts +10 -9
  107. package/esm/component/tooltip/handler/interface/style.js.map +1 -1
  108. package/esm/component/tooltip/handler/utils/attribute.d.ts +9 -2
  109. package/esm/component/tooltip/handler/utils/attribute.js +56 -8
  110. package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
  111. package/esm/component/tooltip/handler/utils/common.js.map +1 -1
  112. package/esm/component/tooltip/handler/utils/style.d.ts +2 -2
  113. package/esm/component/tooltip/handler/utils/style.js +5 -2
  114. package/esm/component/tooltip/handler/utils/style.js.map +1 -1
  115. package/esm/component/tooltip/interface/spec.d.ts +1 -3
  116. package/esm/component/tooltip/interface/spec.js.map +1 -1
  117. package/esm/component/tooltip/interface/theme.d.ts +4 -2
  118. package/esm/component/tooltip/interface/theme.js.map +1 -1
  119. package/esm/component/tooltip/tooltip.js +5 -1
  120. package/esm/component/tooltip/tooltip.js.map +1 -1
  121. package/esm/component/tooltip/utils/show-tooltip.js +9 -4
  122. package/esm/component/tooltip/utils/show-tooltip.js.map +1 -1
  123. package/esm/constant/event.d.ts +2 -0
  124. package/esm/constant/event.js +4 -3
  125. package/esm/constant/event.js.map +1 -1
  126. package/esm/core/index.d.ts +1 -1
  127. package/esm/core/index.js +1 -1
  128. package/esm/core/index.js.map +1 -1
  129. package/esm/core/instance-manager.d.ts +2 -1
  130. package/esm/core/instance-manager.js +7 -2
  131. package/esm/core/instance-manager.js.map +1 -1
  132. package/esm/core/interface.d.ts +3 -0
  133. package/esm/core/interface.js.map +1 -1
  134. package/esm/core/vchart.d.ts +3 -2
  135. package/esm/core/vchart.js +5 -3
  136. package/esm/core/vchart.js.map +1 -1
  137. package/esm/series/range-column/rangeColumn.js +5 -5
  138. package/esm/series/range-column/rangeColumn.js.map +1 -1
  139. package/esm/util/text.d.ts +4 -0
  140. package/esm/util/text.js +7 -1
  141. package/esm/util/text.js.map +1 -1
  142. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { FontWeight, TextAlign } from '../../../../typings/visual';\n\nexport interface IDomTooltipStyle {\n panel: IPadding &\n IBorder & {\n width?: string;\n height?: string;\n backgroundColor?: string;\n boxShadow?: string;\n maxWidth?: string;\n minWidth?: string;\n pointerEvents?: 'auto' | 'none';\n transitionDuration?: string;\n transitionProperty?: string;\n transitionTimingFunction?: string;\n };\n title: ILabelStyle;\n content: IMargin;\n shapeColumn: IMargin & {\n width?: string;\n item?: IShapeStyle;\n };\n keyColumn: IMargin & {\n width?: string;\n item?: ILabelStyle;\n };\n valueColumn: IMargin & {\n width?: string;\n item?: ILabelStyle;\n };\n spaceRow: string;\n}\n\nexport interface ILabelStyle extends IMargin {\n fontFamily?: string;\n fontSize?: string;\n color?: string;\n textAlign?: TextAlign;\n lineHeight?: string;\n fontWeight?: FontWeight;\n}\n\nexport interface IShapeStyle extends IMargin {\n width?: string;\n height?: string;\n}\n\nexport interface IMargin {\n marginLeft?: string;\n marginRight?: string;\n marginTop?: string;\n marginBottom?: string;\n}\n\nexport interface IPadding {\n paddingTop?: string;\n paddingRight?: string;\n paddingBottom?: string;\n paddingLeft?: string;\n}\n\nexport interface IBorder {\n borderColor?: string;\n borderWidth?: string;\n borderRadius?: string;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { FontWeight, TextAlign } from '../../../../typings/visual';\n\nexport interface IDomTooltipStyle {\n panel: IPadding &\n IBorder & {\n width?: string;\n height?: string;\n backgroundColor?: string;\n boxShadow?: string;\n pointerEvents?: 'auto' | 'none';\n transitionDuration?: string;\n transitionProperty?: string;\n transitionTimingFunction?: string;\n };\n title: ILabelStyle;\n content: IMargin;\n shapeColumn: IMargin & {\n width?: string;\n item?: IShapeStyle;\n };\n keyColumn: IMargin & {\n width?: string;\n item?: ILabelStyle;\n };\n valueColumn: IMargin & {\n width?: string;\n item?: ILabelStyle;\n };\n spaceRow: string;\n}\n\nexport interface ILabelStyle extends IMargin {\n fontFamily?: string;\n fontSize?: string;\n color?: string;\n textAlign?: TextAlign;\n lineHeight?: string;\n fontWeight?: FontWeight;\n whiteSpace?: string;\n wordBreak?: string;\n maxWidth?: string;\n}\n\nexport interface IShapeStyle extends IMargin {\n width?: string;\n height?: string;\n}\n\nexport interface IMargin {\n marginLeft?: string;\n marginRight?: string;\n marginTop?: string;\n marginBottom?: string;\n}\n\nexport interface IPadding {\n paddingTop?: string;\n paddingRight?: string;\n paddingBottom?: string;\n paddingLeft?: string;\n}\n\nexport interface IBorder {\n borderColor?: string;\n borderWidth?: string;\n borderRadius?: string;\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  import { BaseTooltipModel } from './base-tooltip-model';
2
2
  import type { ITooltipModelOption } from './interface';
3
+ import type { IShapeSvgOption } from './shape-model';
4
+ import type { IToolTipLineActual } from '../../../../../typings';
3
5
  export type ContentColumnType = 'shape-box' | 'key-box' | 'value-box';
4
6
  export declare class ContentColumnModel extends BaseTooltipModel {
5
7
  readonly className: ContentColumnType;
@@ -19,4 +21,5 @@ export declare class ContentColumnModel extends BaseTooltipModel {
19
21
  width?: string;
20
22
  item?: import("../interface").IShapeStyle;
21
23
  };
24
+ protected _getShapeSvgOption(line: IToolTipLineActual): IShapeSvgOption;
22
25
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.ContentColumnModel = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), style_constants_1 = require("./style-constants"), base_tooltip_model_1 = require("./base-tooltip-model"), shape_model_1 = require("./shape-model"), text_model_1 = require("./text-model"), constants_1 = require("../../constants");
7
+ const vutils_1 = require("@visactor/vutils"), style_constants_1 = require("./style-constants"), base_tooltip_model_1 = require("./base-tooltip-model"), shape_model_1 = require("./shape-model"), text_model_1 = require("./text-model"), constants_1 = require("../../constants"), util_1 = require("../util");
8
8
 
9
9
  class ContentColumnModel extends base_tooltip_model_1.BaseTooltipModel {
10
10
  constructor(parent, option, className, childIndex) {
@@ -33,58 +33,47 @@ class ContentColumnModel extends base_tooltip_model_1.BaseTooltipModel {
33
33
  }));
34
34
  }
35
35
  setStyle() {
36
- var _a, _b;
36
+ var _a, _b, _c, _d;
37
37
  const tooltipStyle = this._option.getTooltipStyle();
38
38
  super.setStyle((0, vutils_1.merge)({}, style_constants_1.defaultContentColumnStyle, tooltipStyle.content, this._getContentColumnStyle()));
39
- const renderContent = null !== (_b = null === (_a = this._option.getTooltipActual()) || void 0 === _a ? void 0 : _a.content) && void 0 !== _b ? _b : [];
39
+ const renderContent = null !== (_b = null === (_a = this._option.getTooltipActual()) || void 0 === _a ? void 0 : _a.content) && void 0 !== _b ? _b : [], contentAttributes = null !== (_d = null === (_c = this._option.getTooltipAttributes()) || void 0 === _c ? void 0 : _c.content) && void 0 !== _d ? _d : [];
40
40
  renderContent.forEach(((line, i) => {
41
- var _a, _b, _c;
41
+ var _a, _b;
42
42
  let childStyle = {};
43
43
  if ("key-box" === this.className) {
44
44
  const {key: key, isKeyAdaptive: isKeyAdaptive} = line;
45
45
  childStyle = (0, vutils_1.merge)({}, isKeyAdaptive ? style_constants_1.defaultAdaptiveKeyStyle : style_constants_1.defaultKeyStyle, Object.assign({
46
- height: 100 / renderContent.length + "%"
46
+ height: (0, util_1.getPixelPropertyStr)(contentAttributes[i].height)
47
47
  }, tooltipStyle.keyColumn.item));
48
48
  (0, vutils_1.isString)(key) && "" !== (null === (_a = null == key ? void 0 : key.trim) || void 0 === _a ? void 0 : _a.call(key)) || (0,
49
49
  vutils_1.isNumber)(key) || childStyle.visibility ? childStyle.visibility = "visible" : childStyle.visibility = "hidden",
50
50
  this.children[i].setStyle(childStyle);
51
- } else if ("value-box" === this.className) childStyle = (0, vutils_1.merge)({}, style_constants_1.defaultValueStyle, Object.assign({
52
- height: 100 / renderContent.length + "%"
53
- }, tooltipStyle.valueColumn.item)), this.children[i].setStyle(childStyle); else if ("shape-box" === this.className) {
54
- childStyle = (0, vutils_1.merge)({}, style_constants_1.defaultShapeStyle, tooltipStyle.shapeColumn.item);
55
- const childContent = {
56
- hasShape: line.hasShape,
57
- shapeType: line.shapeType,
58
- size: null === (_b = tooltipStyle.shapeColumn.item) || void 0 === _b ? void 0 : _b.width,
59
- color: line.shapeColor,
60
- hollow: line.shapeHollow
61
- };
62
- null === (_c = this.children[i]) || void 0 === _c || _c.setStyle(childStyle, childContent);
63
- }
51
+ } else "value-box" === this.className ? (childStyle = (0, vutils_1.merge)({}, style_constants_1.defaultValueStyle, Object.assign({
52
+ height: (0, util_1.getPixelPropertyStr)(contentAttributes[i].height)
53
+ }, tooltipStyle.valueColumn.item)), this.children[i].setStyle(childStyle)) : "shape-box" === this.className && (childStyle = (0,
54
+ vutils_1.merge)({}, style_constants_1.defaultShapeStyle, Object.assign({
55
+ height: (0, util_1.getPixelPropertyStr)(contentAttributes[i].height)
56
+ }, tooltipStyle.shapeColumn.item)), null === (_b = this.children[i]) || void 0 === _b || _b.setStyle(childStyle, this._getShapeSvgOption(line)));
64
57
  }));
65
58
  }
66
59
  setContent() {
67
- var _a, _b;
68
- const tooltipStyle = this._option.getTooltipStyle();
69
- (null !== (_b = null === (_a = this._option.getTooltipActual()) || void 0 === _a ? void 0 : _a.content) && void 0 !== _b ? _b : []).forEach(((line, i) => {
70
- var _a, _b, _c, _d;
60
+ var _a, _b, _c, _d;
61
+ const renderContent = null !== (_b = null === (_a = this._option.getTooltipActual()) || void 0 === _a ? void 0 : _a.content) && void 0 !== _b ? _b : [], contentAttributes = null !== (_d = null === (_c = this._option.getTooltipAttributes()) || void 0 === _c ? void 0 : _c.content) && void 0 !== _d ? _d : [];
62
+ renderContent.forEach(((line, i) => {
63
+ var _a, _b, _c, _d, _e, _f, _g;
71
64
  let childContent;
72
65
  if ("key-box" === this.className) {
73
66
  const keyContent = line.key;
74
67
  childContent = (0, vutils_1.isString)(keyContent) && "" !== (null === (_a = null == keyContent ? void 0 : keyContent.trim) || void 0 === _a ? void 0 : _a.call(keyContent)) || (0,
75
- vutils_1.isNumber)(keyContent) ? keyContent : constants_1.TOOLTIP_EMPTY_STRING;
68
+ vutils_1.isNumber)(keyContent) ? keyContent : constants_1.TOOLTIP_EMPTY_STRING,
69
+ null === (_b = this.children[i]) || void 0 === _b || _b.setContent(childContent, null === (_c = contentAttributes[i].value) || void 0 === _c ? void 0 : _c.multiLine);
76
70
  } else if ("value-box" === this.className) {
77
71
  const valueContent = line.value;
78
- childContent = (0, vutils_1.isString)(valueContent) && "" !== (null === (_b = null == valueContent ? void 0 : valueContent.trim) || void 0 === _b ? void 0 : _b.call(valueContent)) || (0,
79
- vutils_1.isNumber)(valueContent) ? valueContent : constants_1.TOOLTIP_EMPTY_STRING;
80
- } else "shape-box" === this.className && (childContent = {
81
- hasShape: line.hasShape,
82
- shapeType: line.shapeType,
83
- size: null === (_c = tooltipStyle.shapeColumn.item) || void 0 === _c ? void 0 : _c.width,
84
- color: line.shapeColor,
85
- hollow: line.shapeHollow
86
- });
87
- null === (_d = this.children[i]) || void 0 === _d || _d.setContent(childContent);
72
+ childContent = (0, vutils_1.isString)(valueContent) && "" !== (null === (_d = null == valueContent ? void 0 : valueContent.trim) || void 0 === _d ? void 0 : _d.call(valueContent)) || (0,
73
+ vutils_1.isNumber)(valueContent) ? valueContent : constants_1.TOOLTIP_EMPTY_STRING,
74
+ null === (_e = this.children[i]) || void 0 === _e || _e.setContent(childContent, null === (_f = contentAttributes[i].value) || void 0 === _f ? void 0 : _f.multiLine);
75
+ } else "shape-box" === this.className && (childContent = this._getShapeSvgOption(line),
76
+ null === (_g = this.children[i]) || void 0 === _g || _g.setContent(childContent));
88
77
  }));
89
78
  }
90
79
  _getContentColumnStyle() {
@@ -104,6 +93,18 @@ class ContentColumnModel extends base_tooltip_model_1.BaseTooltipModel {
104
93
  return tooltipStyle.valueColumn;
105
94
  }
106
95
  }
96
+ _getShapeSvgOption(line) {
97
+ var _a, _b, _c, _d, _e, _f, _g;
98
+ const tooltipStyle = this._option.getTooltipStyle();
99
+ return {
100
+ hasShape: line.hasShape,
101
+ shapeType: line.shapeType,
102
+ size: null === (_a = tooltipStyle.shapeColumn.item) || void 0 === _a ? void 0 : _a.width,
103
+ color: line.shapeColor,
104
+ hollow: line.shapeHollow,
105
+ marginTop: `calc((${null !== (_e = null !== (_c = null === (_b = tooltipStyle.keyColumn.item) || void 0 === _b ? void 0 : _b.lineHeight) && void 0 !== _c ? _c : null === (_d = tooltipStyle.keyColumn.item) || void 0 === _d ? void 0 : _d.fontSize) && void 0 !== _e ? _e : "18px"} - ${null !== (_g = null === (_f = tooltipStyle.shapeColumn.item) || void 0 === _f ? void 0 : _f.width) && void 0 !== _g ? _g : "8px"}) / 2)`
106
+ };
107
+ }
107
108
  }
108
109
 
109
110
  exports.ContentColumnModel = ContentColumnModel;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/model/content-column-model.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AACvE,uDAM2B;AAC3B,6DAAwD;AAIxD,+CAA2C;AAC3C,6CAAyC;AACzC,+CAAuD;AAIvD,MAAa,kBAAmB,SAAQ,qCAAgB;IAGtD,YACE,MAAsC,EACtC,MAA2B,EAC3B,SAA4B,EAC5B,UAAmB;QAEnB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;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S,CAAC;YAChC,KAAK,WAAW;gBACd,OAAO,YAAY,CAAC,WAAW,CAAC;SACnC;IACH,CAAC;CACF;AAhJD,gDAgJC","file":"content-column-model.js","sourcesContent":["import { isNumber, isString, merge, toNumber } from '@visactor/vutils';\nimport {\n defaultKeyStyle,\n defaultContentColumnStyle,\n defaultValueStyle,\n defaultAdaptiveKeyStyle,\n defaultShapeStyle\n} from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport type { ITooltipModelOption } from './interface';\nimport type { IShapeSvgOption } from './shape-model';\n// eslint-disable-next-line no-duplicate-imports\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\nimport { TOOLTIP_EMPTY_STRING } from '../../constants';\n\nexport type ContentColumnType = 'shape-box' | 'key-box' | 'value-box';\n\nexport class ContentColumnModel extends BaseTooltipModel {\n readonly className: ContentColumnType;\n\n constructor(\n parent: BaseTooltipModel | HTMLElement,\n option: ITooltipModelOption,\n className: ContentColumnType,\n childIndex?: number\n ) {\n super(parent, option, childIndex);\n this.className = className;\n }\n\n init(): void {\n if (!this.product) {\n this.product = this.createElement('div', [this.className]);\n }\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n\n if (this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)) {\n // 当有一行配有形状的时候,其他行要对齐。如果没有一行配有形状,则删除所有的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n this.children[i].release();\n delete this.children[i];\n });\n } else {\n // 删除多余的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n if (i >= renderContent.length) {\n this.children[i].release();\n delete this.children[i];\n }\n });\n // 新增没有的行\n for (let i = 0; i < renderContent.length; i++) {\n if (!this.children[i]) {\n if (this.className === 'key-box' || this.className === 'value-box') {\n const text = new TextModel(this.product!, this._option, i);\n text.init([this.className.substring(0, this.className.indexOf('-'))], undefined, 'div');\n this.children[i] = text;\n } else if (this.className === 'shape-box') {\n const shape = new ShapeModel(this.product!, this._option, i);\n shape.init(['shape'], undefined, 'div');\n this.children[i] = shape;\n }\n }\n }\n }\n }\n\n setStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n super.setStyle(merge({}, defaultContentColumnStyle, tooltipStyle.content, this._getContentColumnStyle()));\n\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childStyle: any = {};\n if (this.className === 'key-box') {\n const { key, isKeyAdaptive } = line;\n childStyle = merge({}, isKeyAdaptive ? defaultAdaptiveKeyStyle : defaultKeyStyle, {\n height: `${100 / renderContent.length}%`,\n ...tooltipStyle.keyColumn.item\n });\n const hasContent = (isString(key) && key?.trim?.() !== '') || isNumber(key);\n if (!hasContent && !childStyle.visibility) {\n childStyle.visibility = 'hidden';\n } else {\n childStyle.visibility = 'visible';\n }\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'value-box') {\n childStyle = merge({}, defaultValueStyle, {\n height: `${100 / renderContent.length}%`,\n ...tooltipStyle.valueColumn.item\n });\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'shape-box') {\n childStyle = merge({}, defaultShapeStyle, tooltipStyle.shapeColumn.item);\n const childContent = {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: line.shapeColor,\n hollow: line.shapeHollow\n } as IShapeSvgOption;\n (this.children[i] as ShapeModel)?.setStyle(childStyle, childContent);\n }\n });\n }\n\n setContent(): void {\n const tooltipStyle = this._option.getTooltipStyle();\n\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childContent: any;\n if (this.className === 'key-box') {\n const keyContent = line.key;\n if ((isString(keyContent) && keyContent?.trim?.() !== '') || isNumber(keyContent)) {\n childContent = keyContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n } else if (this.className === 'value-box') {\n const valueContent = line.value;\n if ((isString(valueContent) && valueContent?.trim?.() !== '') || isNumber(valueContent)) {\n childContent = valueContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n } else if (this.className === 'shape-box') {\n childContent = {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: line.shapeColor,\n hollow: line.shapeHollow\n } as IShapeSvgOption;\n }\n this.children[i]?.setContent(childContent);\n });\n }\n\n protected _getContentColumnStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n switch (this.className) {\n case 'shape-box':\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n return {\n ...tooltipStyle.shapeColumn,\n ...(this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)\n ? { display: 'none' }\n : {})\n };\n case 'key-box':\n return tooltipStyle.keyColumn;\n case 'value-box':\n return tooltipStyle.valueColumn;\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/model/content-column-model.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AACvE,uDAM2B;AAC3B,6DAAwD;AAIxD,+CAA2C;AAC3C,6CAAyC;AACzC,+CAAuD;AACvD,kCAA8C;AAK9C,MAAa,kBAAmB,SAAQ,qCAAgB;IAGtD,YACE,MAAsC,EACtC,MAA2B,EAC3B,SAA4B,EAC5B,UAAmB;QAEnB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAI;;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;SAC5D;QACD,MAAM,aAAa,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,0CAAE,OAAO,mCAAI,EAAE,CAAC;QAErE,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,aAAa,CAA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EAAE,CAAC;QACpD,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,MAAA,YAAY,CAAC,WAAW,CAAC,IAAI,0CAAE,KAAK;YAC1C,KAAK,EAAE,IAAI,CAAC,UAAU;YACtB,MAAM,EAAE,IAAI,CAAC,WAAW;YACxB,SAAS,EAAE,SACT,MAAA,MAAA,MAAA,YAAY,CAAC,SAAS,CAAC,IAAI,0CAAE,UAAU,mCAAI,MAAA,YAAY,CAAC,SAAS,CAAC,IAAI,0CAAE,QAAQ,mCAAI,MACtF,MAAM,MAAA,MAAA,YAAY,CAAC,WAAW,CAAC,IAAI,0CAAE,KAAK,mCAAI,KAAK,QAAQ;SACzC,CAAC;IACvB,CAAC;CACF;AAxJD,gDAwJC","file":"content-column-model.js","sourcesContent":["import { isNumber, isString, merge, toNumber } from '@visactor/vutils';\nimport {\n defaultKeyStyle,\n defaultContentColumnStyle,\n defaultValueStyle,\n defaultAdaptiveKeyStyle,\n defaultShapeStyle\n} from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport type { ITooltipModelOption } from './interface';\nimport type { IShapeSvgOption } from './shape-model';\n// eslint-disable-next-line no-duplicate-imports\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\nimport { TOOLTIP_EMPTY_STRING } from '../../constants';\nimport { getPixelPropertyStr } from '../util';\nimport type { IToolTipLineActual } from '../../../../../typings';\n\nexport type ContentColumnType = 'shape-box' | 'key-box' | 'value-box';\n\nexport class ContentColumnModel extends BaseTooltipModel {\n readonly className: ContentColumnType;\n\n constructor(\n parent: BaseTooltipModel | HTMLElement,\n option: ITooltipModelOption,\n className: ContentColumnType,\n childIndex?: number\n ) {\n super(parent, option, childIndex);\n this.className = className;\n }\n\n init(): void {\n if (!this.product) {\n this.product = this.createElement('div', [this.className]);\n }\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n\n if (this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)) {\n // 当有一行配有形状的时候,其他行要对齐。如果没有一行配有形状,则删除所有的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n this.children[i].release();\n delete this.children[i];\n });\n } else {\n // 删除多余的行\n Object.keys(this.children).forEach(key => {\n const i = toNumber(key);\n if (i >= renderContent.length) {\n this.children[i].release();\n delete this.children[i];\n }\n });\n // 新增没有的行\n for (let i = 0; i < renderContent.length; i++) {\n if (!this.children[i]) {\n if (this.className === 'key-box' || this.className === 'value-box') {\n const text = new TextModel(this.product!, this._option, i);\n text.init([this.className.substring(0, this.className.indexOf('-'))], undefined, 'div');\n this.children[i] = text;\n } else if (this.className === 'shape-box') {\n const shape = new ShapeModel(this.product!, this._option, i);\n shape.init(['shape'], undefined, 'div');\n this.children[i] = shape;\n }\n }\n }\n }\n }\n\n setStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n super.setStyle(merge({}, defaultContentColumnStyle, tooltipStyle.content, this._getContentColumnStyle()));\n\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n const contentAttributes = this._option.getTooltipAttributes()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childStyle: any = {};\n if (this.className === 'key-box') {\n const { key, isKeyAdaptive } = line;\n childStyle = merge({}, isKeyAdaptive ? defaultAdaptiveKeyStyle : defaultKeyStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.keyColumn.item\n });\n const hasContent = (isString(key) && key?.trim?.() !== '') || isNumber(key);\n if (!hasContent && !childStyle.visibility) {\n childStyle.visibility = 'hidden';\n } else {\n childStyle.visibility = 'visible';\n }\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'value-box') {\n childStyle = merge({}, defaultValueStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.valueColumn.item\n });\n (this.children[i] as TextModel).setStyle(childStyle);\n } else if (this.className === 'shape-box') {\n childStyle = merge({}, defaultShapeStyle, {\n height: getPixelPropertyStr(contentAttributes[i].height),\n ...tooltipStyle.shapeColumn.item\n });\n (this.children[i] as ShapeModel)?.setStyle(childStyle, this._getShapeSvgOption(line));\n }\n });\n }\n\n setContent(): void {\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n const contentAttributes = this._option.getTooltipAttributes()?.content ?? [];\n renderContent.forEach((line, i) => {\n let childContent: any;\n if (this.className === 'key-box') {\n const keyContent = line.key;\n if ((isString(keyContent) && keyContent?.trim?.() !== '') || isNumber(keyContent)) {\n childContent = keyContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n // FIXME: vrender 发版后去掉 any\n (this.children[i] as TextModel)?.setContent(childContent, (contentAttributes[i].value as any)?.multiLine);\n } else if (this.className === 'value-box') {\n const valueContent = line.value;\n if ((isString(valueContent) && valueContent?.trim?.() !== '') || isNumber(valueContent)) {\n childContent = valueContent;\n } else {\n childContent = TOOLTIP_EMPTY_STRING;\n }\n // FIXME: vrender 发版后去掉 any\n (this.children[i] as TextModel)?.setContent(childContent, (contentAttributes[i].value as any)?.multiLine);\n } else if (this.className === 'shape-box') {\n childContent = this._getShapeSvgOption(line);\n this.children[i]?.setContent(childContent);\n }\n });\n }\n\n protected _getContentColumnStyle() {\n const tooltipStyle = this._option.getTooltipStyle();\n\n switch (this.className) {\n case 'shape-box':\n const renderContent = this._option.getTooltipActual()?.content ?? [];\n return {\n ...tooltipStyle.shapeColumn,\n ...(this.className === 'shape-box' && !renderContent.some(c => c.hasShape && c.shapeType)\n ? { display: 'none' }\n : {})\n };\n case 'key-box':\n return tooltipStyle.keyColumn;\n case 'value-box':\n return tooltipStyle.valueColumn;\n }\n }\n\n protected _getShapeSvgOption(line: IToolTipLineActual): IShapeSvgOption {\n const tooltipStyle = this._option.getTooltipStyle();\n return {\n hasShape: line.hasShape,\n shapeType: line.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: line.shapeColor,\n hollow: line.shapeHollow,\n marginTop: `calc((${\n tooltipStyle.keyColumn.item?.lineHeight ?? tooltipStyle.keyColumn.item?.fontSize ?? '18px'\n } - ${tooltipStyle.shapeColumn.item?.width ?? '8px'}) / 2)`\n } as IShapeSvgOption;\n }\n}\n"]}
@@ -1,7 +1,9 @@
1
+ import type { TooltipAttributes } from '@visactor/vrender-components';
1
2
  import type { IToolTipActual } from '../../../../../typings';
2
3
  import type { IDomTooltipStyle } from '../interface';
3
4
  export interface ITooltipModelOption {
4
5
  valueToHtml: (value: any) => string;
5
6
  getTooltipStyle: () => IDomTooltipStyle;
6
7
  getTooltipActual: () => IToolTipActual;
8
+ getTooltipAttributes: () => TooltipAttributes;
7
9
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/model/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IToolTipActual } from '../../../../../typings';\nimport type { IDomTooltipStyle } from '../interface';\n\nexport interface ITooltipModelOption {\n valueToHtml: (value: any) => string;\n getTooltipStyle: () => IDomTooltipStyle;\n getTooltipActual: () => IToolTipActual;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/model/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { TooltipAttributes } from '@visactor/vrender-components';\nimport type { IToolTipActual } from '../../../../../typings';\nimport type { IDomTooltipStyle } from '../interface';\n\nexport interface ITooltipModelOption {\n valueToHtml: (value: any) => string;\n getTooltipStyle: () => IDomTooltipStyle;\n getTooltipActual: () => IToolTipActual;\n getTooltipAttributes: () => TooltipAttributes;\n}\n"]}
@@ -7,6 +7,7 @@ export interface IShapeSvgOption {
7
7
  size?: string;
8
8
  color?: string | IGradientColor;
9
9
  hollow?: boolean;
10
+ marginTop?: string;
10
11
  }
11
12
  export declare class ShapeModel extends BaseTooltipModel {
12
13
  svg: SVGElement;
@@ -31,15 +31,15 @@ class ShapeModel extends base_tooltip_model_1.BaseTooltipModel {
31
31
  function getSvgHtml(option) {
32
32
  var _a, _b, _c, _d, _e, _f, _g;
33
33
  if (!(null == option ? void 0 : option.hasShape) || !option.shapeType || !vrender_1.builtinSymbolsMap[option.shapeType]) return "";
34
- const {shapeType: shapeType, size: size, color: color, hollow: hollow = !1} = option, path = vrender_1.builtinSymbolsMap[shapeType].pathStr;
34
+ const {shapeType: shapeType, size: size, color: color, hollow: hollow = !1, marginTop: marginTop = "0px"} = option, path = vrender_1.builtinSymbolsMap[shapeType].pathStr;
35
35
  let fill = "currentColor";
36
36
  if (!color || (0, util_1.isString)(color) || hollow) return fill = hollow ? "none" : null !== (_a = color) && void 0 !== _a ? _a : "currentColor",
37
- `\n <svg width="${size}"\n height="${size}" viewBox="-0.5 -0.5 1 1" style="display: inline-block; vertical-align: middle;">\n <path fill="${fill}" d="${path}" style="fill: ${fill};">\n </path>\n </svg>`;
37
+ `\n <svg width="${size}" height="${size}" viewBox="-0.5 -0.5 1 1"\n style="display: inline-block; vertical-align: middle; margin-top: ${marginTop};">\n <path fill="${fill}" d="${path}" style="fill: ${fill};">\n </path>\n </svg>`;
38
38
  if ((0, util_1.isObject)(color)) {
39
39
  fill = "gradientColor";
40
40
  let gradient = "";
41
41
  return "radial" === color.gradient ? gradient = `\n <radialGradient id="${fill}" cx="50%" cy="50%" r="50%" fx="0%" fy="0%">\n ${(null !== (_b = color.stops) && void 0 !== _b ? _b : []).map((s => `<stop offset="${s.offset}" stop-color="${s.color}"/>`))}\n \t</radialGradient>\n ` : "linear" === color.gradient && (gradient = `\n <linearGradient id="${fill}" x1="${100 * (null !== (_c = color.x0) && void 0 !== _c ? _c : 0)}%" y1="${100 * (null !== (_d = color.y0) && void 0 !== _d ? _d : 0)}%" x2="${100 * (null !== (_e = color.x1) && void 0 !== _e ? _e : 0)}%" y2="${100 * (null !== (_f = color.y1) && void 0 !== _f ? _f : 0)}%">\n ${(null !== (_g = color.stops) && void 0 !== _g ? _g : []).map((s => `<stop offset="${s.offset}" stop-color="${s.color}"/>`))}\n </linearGradient>\n `),
42
- `\n <svg width="${size}" height="${size}"\n viewBox="-0.5 -0.5 1 1" style="display: inline-block; vertical-align: middle;">\n ${gradient}\n <path fill="url(#${fill})" d="${path}" style="fill: url(#${fill});">\n </path>\n </svg>`;
42
+ `\n <svg width="${size}" height="${size}" viewBox="-0.5 -0.5 1 1"\n style="display: inline-block; vertical-align: middle; margin-top: ${marginTop};">\n ${gradient}\n <path fill="url(#${fill})" d="${path}" style="fill: url(#${fill});">\n </path>\n </svg>`;
43
43
  }
44
44
  return "";
45
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/model/shape-model.ts"],"names":[],"mappings":";;;AAEA,+CAAsD;AAEtD,8CAAyD;AAEzD,6DAAwD;AAUxD,MAAa,UAAW,SAAQ,qCAAgB;IAK9C,IAAI,CAAC,SAAoB,EAAE,EAAW,EAAE,GAAiC;QACvE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,KAAK,EAAE,CAAC,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;YACnG,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;SAC1B;IACH,CAAC;IAED,QAAQ,CAAC,KAAoC,EAAE,MAAwB;QACrE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,UAAU,CAAC,MAAuB;QAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,MAAwB;QAC7B,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC,aAAa,EAAE;YAC/C,IAAI,CAAC,a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,MAAM,iBAAiB,CAAC,CAAC,KAAK,KAAK,CAC5D;;OAEF,CAAC;SACH;aAAM,IAAK,KAAwB,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC1D,QAAQ,GAAG;4BACW,IAAI,SAAS,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GAAG,UACvF,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GACrD,UAAU,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GAAG,UAC9D,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GACrD;UACI,CAAC,MAAC,KAAyB,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,MAAM,iBAAiB,CAAC,CAAC,KAAK,KAAK,CAAC;;OAE5G,CAAC;SACH;QACD,OAAO;kBACO,IAAI,aAAa,IAAI;;QAE/B,QAAQ;yBACS,IAAI,SAAS,IAAI,uBAAuB,IAAI;;WAE1D,CAAC;KACT;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","file":"shape-model.js","sourcesContent":["import type { IGradientColor, ILinearGradient } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nimport { isObject, isString } from '../../../../../util';\nimport type { ShapeType } from '../../../../../typings';\nimport { BaseTooltipModel } from './base-tooltip-model';\n\nexport interface IShapeSvgOption {\n hasShape?: boolean;\n shapeType?: ShapeType;\n size?: string;\n color?: string | IGradientColor;\n hollow?: boolean;\n}\n\nexport class ShapeModel extends BaseTooltipModel {\n svg: SVGElement;\n\n private _svgHtmlCache: string;\n\n init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void {\n if (!this.product) {\n const container = this.createElement(tag ?? 'div', [...(classList ?? []), 'shape'], undefined, id);\n this.product = container;\n }\n }\n\n setStyle(style?: Partial<CSSStyleDeclaration>, option?: IShapeSvgOption): void {\n super.setStyle(style);\n this.setSvg(option);\n }\n\n setContent(option: IShapeSvgOption) {\n this.setSvg(option);\n }\n\n setSvg(option?: IShapeSvgOption) {\n const html = getSvgHtml(option);\n if (this.product && html !== this._svgHtmlCache) {\n this._svgHtmlCache = html;\n this.product.innerHTML = html;\n }\n }\n\n release(): void {\n super.release();\n this._svgHtmlCache = '';\n }\n}\n\nfunction getSvgHtml(option?: IShapeSvgOption) {\n if (!option?.hasShape || !option.shapeType || !builtinSymbolsMap[option.shapeType]) {\n return '';\n }\n\n const { shapeType, size, color, hollow = false } = option;\n\n // FIXME 通过 VRender 获取symbol path\n const path = builtinSymbolsMap[shapeType].pathStr;\n let fill: string = 'currentColor';\n if (!color || isString(color) || hollow) {\n fill = hollow ? 'none' : (color as string) ?? 'currentColor';\n return `\n <svg width=\"${size}\"\n height=\"${size}\" viewBox=\"-0.5 -0.5 1 1\" style=\"display: inline-block; vertical-align: middle;\">\n <path fill=\"${fill}\" d=\"${path}\" style=\"fill: ${fill};\">\n </path>\n </svg>`;\n }\n if (isObject(color)) {\n fill = 'gradientColor';\n let gradient = '';\n if ((color as IGradientColor).gradient === 'radial') {\n gradient = `\n <radialGradient id=\"${fill}\" cx=\"50%\" cy=\"50%\" r=\"50%\" fx=\"0%\" fy=\"0%\">\n ${(((color as IGradientColor).stops as any[]) ?? []).map(\n s => `<stop offset=\"${s.offset}\" stop-color=\"${s.color}\"/>`\n )}\n \t</radialGradient>\n `;\n } else if ((color as IGradientColor).gradient === 'linear') {\n gradient = `\n <linearGradient id=\"${fill}\" x1=\"${(((color as ILinearGradient).x0 as number) ?? 0) * 100}%\" y1=\"${\n (((color as ILinearGradient).y0 as number) ?? 0) * 100\n }%\" x2=\"${(((color as ILinearGradient).x1 as number) ?? 0) * 100}%\" y2=\"${\n (((color as ILinearGradient).y1 as number) ?? 0) * 100\n }%\">\n ${((color as ILinearGradient).stops ?? []).map(s => `<stop offset=\"${s.offset}\" stop-color=\"${s.color}\"/>`)}\n </linearGradient>\n `;\n }\n return `\n <svg width=\"${size}\" height=\"${size}\"\n viewBox=\"-0.5 -0.5 1 1\" style=\"display: inline-block; vertical-align: middle;\">\n ${gradient}\n <path fill=\"url(#${fill})\" d=\"${path}\" style=\"fill: url(#${fill});\">\n </path>\n </svg>`;\n }\n\n return '';\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/model/shape-model.ts"],"names":[],"mappings":";;;AAEA,+CAAsD;AAEtD,8CAAyD;AAEzD,6DAAwD;AAWxD,MAAa,UAAW,SAAQ,qCAAgB;IAK9C,IAAI,CAAC,SAAoB,EAAE,EAAW,EAAE,GAAiC;QACvE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,KAAK,EAAE,CAAC,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;YACnG,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;SAC1B;IACH,CAAC;IAED,QAAQ,CAAC,KAAoC,EAAE,MAAwB;QACrE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,UAAU,CAAC,MAAuB;QAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,MAAwB;QAC7B,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC,aAAa,EAAE;YAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,IAAI,CAAC,OAAO,CAAC,S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CAAC,CAAC,KAAK,KAAK,CAC5D;;OAEF,CAAC;SACH;aAAM,IAAK,KAAwB,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC1D,QAAQ,GAAG;4BACW,IAAI,SAAS,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GAAG,UACvF,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GACrD,UAAU,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GAAG,UAC9D,CAAC,MAAE,KAAyB,CAAC,EAAa,mCAAI,CAAC,CAAC,GAAG,GACrD;UACI,CAAC,MAAC,KAAyB,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,MAAM,iBAAiB,CAAC,CAAC,KAAK,KAAK,CAAC;;OAE5G,CAAC;SACH;QACD,OAAO;kBACO,IAAI,aAAa,IAAI;0EACmC,SAAS;QAC3E,QAAQ;yBACS,IAAI,SAAS,IAAI,uBAAuB,IAAI;;WAE1D,CAAC;KACT;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","file":"shape-model.js","sourcesContent":["import type { IGradientColor, ILinearGradient } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { builtinSymbolsMap } from '@visactor/vrender';\n\nimport { isObject, isString } from '../../../../../util';\nimport type { ShapeType } from '../../../../../typings';\nimport { BaseTooltipModel } from './base-tooltip-model';\n\nexport interface IShapeSvgOption {\n hasShape?: boolean;\n shapeType?: ShapeType;\n size?: string;\n color?: string | IGradientColor;\n hollow?: boolean;\n marginTop?: string;\n}\n\nexport class ShapeModel extends BaseTooltipModel {\n svg: SVGElement;\n\n private _svgHtmlCache: string;\n\n init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void {\n if (!this.product) {\n const container = this.createElement(tag ?? 'div', [...(classList ?? []), 'shape'], undefined, id);\n this.product = container;\n }\n }\n\n setStyle(style?: Partial<CSSStyleDeclaration>, option?: IShapeSvgOption): void {\n super.setStyle(style);\n this.setSvg(option);\n }\n\n setContent(option: IShapeSvgOption) {\n this.setSvg(option);\n }\n\n setSvg(option?: IShapeSvgOption) {\n const html = getSvgHtml(option);\n if (this.product && html !== this._svgHtmlCache) {\n this._svgHtmlCache = html;\n this.product.innerHTML = html;\n }\n }\n\n release(): void {\n super.release();\n this._svgHtmlCache = '';\n }\n}\n\nfunction getSvgHtml(option?: IShapeSvgOption) {\n if (!option?.hasShape || !option.shapeType || !builtinSymbolsMap[option.shapeType]) {\n return '';\n }\n\n const { shapeType, size, color, hollow = false, marginTop = '0px' } = option;\n\n // FIXME 通过 VRender 获取symbol path\n const path = builtinSymbolsMap[shapeType].pathStr;\n let fill: string = 'currentColor';\n if (!color || isString(color) || hollow) {\n fill = hollow ? 'none' : (color as string) ?? 'currentColor';\n return `\n <svg width=\"${size}\" height=\"${size}\" viewBox=\"-0.5 -0.5 1 1\"\n style=\"display: inline-block; vertical-align: middle; margin-top: ${marginTop};\">\n <path fill=\"${fill}\" d=\"${path}\" style=\"fill: ${fill};\">\n </path>\n </svg>`;\n }\n if (isObject(color)) {\n fill = 'gradientColor';\n let gradient = '';\n if ((color as IGradientColor).gradient === 'radial') {\n gradient = `\n <radialGradient id=\"${fill}\" cx=\"50%\" cy=\"50%\" r=\"50%\" fx=\"0%\" fy=\"0%\">\n ${(((color as IGradientColor).stops as any[]) ?? []).map(\n s => `<stop offset=\"${s.offset}\" stop-color=\"${s.color}\"/>`\n )}\n \t</radialGradient>\n `;\n } else if ((color as IGradientColor).gradient === 'linear') {\n gradient = `\n <linearGradient id=\"${fill}\" x1=\"${(((color as ILinearGradient).x0 as number) ?? 0) * 100}%\" y1=\"${\n (((color as ILinearGradient).y0 as number) ?? 0) * 100\n }%\" x2=\"${(((color as ILinearGradient).x1 as number) ?? 0) * 100}%\" y2=\"${\n (((color as ILinearGradient).y1 as number) ?? 0) * 100\n }%\">\n ${((color as ILinearGradient).stops ?? []).map(s => `<stop offset=\"${s.offset}\" stop-color=\"${s.color}\"/>`)}\n </linearGradient>\n `;\n }\n return `\n <svg width=\"${size}\" height=\"${size}\" viewBox=\"-0.5 -0.5 1 1\"\n style=\"display: inline-block; vertical-align: middle; margin-top: ${marginTop};\">\n ${gradient}\n <path fill=\"url(#${fill})\" d=\"${path}\" style=\"fill: url(#${fill});\">\n </path>\n </svg>`;\n }\n\n return '';\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { BaseTooltipModel } from './base-tooltip-model';
2
2
  export declare class TextModel extends BaseTooltipModel {
3
3
  init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void;
4
- setContent(content?: any): void;
4
+ setContent(content?: any, multiLine?: boolean): void;
5
5
  }
@@ -10,9 +10,10 @@ class TextModel extends base_tooltip_model_1.BaseTooltipModel {
10
10
  init(classList, id, tag) {
11
11
  this.product || (this.product = this.createElement(null != tag ? tag : "span", classList, void 0, id));
12
12
  }
13
- setContent(content) {
13
+ setContent(content, multiLine) {
14
14
  if (!this.product) return;
15
- this._option.valueToHtml(content) !== this.product.innerHTML && (this.product.innerHTML = this._option.valueToHtml(content));
15
+ let html = this._option.valueToHtml(content);
16
+ multiLine && (html = html.replaceAll("\n", "<br>")), html !== this.product.innerHTML && (this.product.innerHTML = html);
16
17
  }
17
18
  }
18
19
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/model/text-model.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AAExD,MAAa,SAAU,SAAQ,qCAAgB;IAC7C,IAAI,CAAC,SAAoB,EAAE,EAAW,EAAE,GAAiC;QACvE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;SAC5E;IACH,CAAC;IAED,UAAU,CAAC,OAAa;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO;SACR;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACnC,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SAC5D;IACH,CAAC;CACF;AAhBD,8BAgBC","file":"text-model.js","sourcesContent":["import { BaseTooltipModel } from './base-tooltip-model';\n\nexport class TextModel extends BaseTooltipModel {\n init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void {\n if (!this.product) {\n this.product = this.createElement(tag ?? 'span', classList, undefined, id);\n }\n }\n\n setContent(content?: any): void {\n if (!this.product) {\n return;\n }\n const html = this._option.valueToHtml(content);\n if (html !== this.product.innerHTML) {\n this.product.innerHTML = this._option.valueToHtml(content);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/model/text-model.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AAExD,MAAa,SAAU,SAAQ,qCAAgB;IAC7C,IAAI,CAAC,SAAoB,EAAE,EAAW,EAAE,GAAiC;QACvE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;SAC5E;IACH,CAAC;IAED,UAAU,CAAC,OAAa,EAAE,SAAmB;QAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO;SACR;QACD,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,SAAS,EAAE;YACb,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SACtC;QACD,IAAI,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACnC,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;SAC/B;IACH,CAAC;CACF;AAnBD,8BAmBC","file":"text-model.js","sourcesContent":["import { BaseTooltipModel } from './base-tooltip-model';\n\nexport class TextModel extends BaseTooltipModel {\n init(classList?: string[], id?: string, tag?: keyof HTMLElementTagNameMap): void {\n if (!this.product) {\n this.product = this.createElement(tag ?? 'span', classList, undefined, id);\n }\n }\n\n setContent(content?: any, multiLine?: boolean): void {\n if (!this.product) {\n return;\n }\n let html = this._option.valueToHtml(content);\n if (multiLine) {\n html = html.replaceAll('\\n', '<br>');\n }\n if (html !== this.product.innerHTML) {\n this.product.innerHTML = html;\n }\n }\n}\n"]}
@@ -41,15 +41,15 @@ class TitleModel extends base_tooltip_model_1.BaseTooltipModel {
41
41
  });
42
42
  }
43
43
  setContent() {
44
- var _a, _b, _c;
45
- const tooltipStyle = this._option.getTooltipStyle(), tooltipActual = this._option.getTooltipActual(), {title: title} = tooltipActual;
44
+ var _a, _b, _c, _d, _e;
45
+ const tooltipStyle = this._option.getTooltipStyle(), tooltipActual = this._option.getTooltipActual(), tooltipAttributes = this._option.getTooltipAttributes(), {title: title} = tooltipActual;
46
46
  this.init(), null === (_a = this.shape) || void 0 === _a || _a.setStyle(void 0, {
47
47
  hasShape: null == title ? void 0 : title.hasShape,
48
48
  shapeType: null == title ? void 0 : title.shapeType,
49
49
  size: null === (_b = tooltipStyle.shapeColumn.item) || void 0 === _b ? void 0 : _b.width,
50
50
  color: null == title ? void 0 : title.shapeColor,
51
51
  hollow: null == title ? void 0 : title.shapeHollow
52
- }), null === (_c = this.textSpan) || void 0 === _c || _c.setContent(null == title ? void 0 : title.value);
52
+ }), null === (_c = this.textSpan) || void 0 === _c || _c.setContent(null == title ? void 0 : title.value, null === (_e = null === (_d = tooltipAttributes.title) || void 0 === _d ? void 0 : _d.value) || void 0 === _e ? void 0 : _e.multiLine);
53
53
  }
54
54
  release() {
55
55
  super.release(), this.shape = null, this.textSpan = null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/model/title-model.ts"],"names":[],"mappings":";;;AAEA,6CAAyC;AACzC,uDAAmD;AACnD,6DAAwD;AACxD,+CAA2C;AAC3C,6CAAyC;AAEzC,MAAa,UAAW,SAAQ,qCAAgB;IAI9C,IAAI;QACF,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAEtD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;SACzC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAChC,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAA,EAAE;YACvC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACf,IAAI,CAAC,UAAU,EAAE,CAAC;aACnB;SACF;aAAM,IAAI,IAAI,CAAC,KAAK,EAAE;YACrB,IAAI,CAAC,aAAa,EAAE,CAAC;SACtB;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,aAAa,EAAE,CAAC;SACtB;IACH,CAAC;IAEO,UAAU;QAChB,MAAM,KAAK,GAAG,IAAI,wBAAU,CAAC,IAAI,CAAC,OAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7D,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,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YAC1C,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU;YACxB,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW;SAC3B,CACF,CAAC;IACJ,CAAC;IAED,UAAU;;QACR,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QACpD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAEtD,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,MAAA,IAAI,CAAC,KAAK,0CAAE,QAAQ,CAAC,SAAS,EAAE;YAC9B,QAAQ,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ;YACzB,SAAS,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS;YAC3B,IAAI,EAAE,MAAA,YAAY,CAAC,WAAW,CAAC,IAAI,0CAAE,KAAK;YAC1C,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU;YACxB,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW;SAC3B,CAAC,CAAC;QACH,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AA1FD,gCA0FC","file":"title-model.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { merge } from '@visactor/vutils';\nimport { defaultH2Style } from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\n\nexport class TitleModel extends BaseTooltipModel {\n shape: Maybe<ShapeModel>;\n textSpan: Maybe<TextModel>;\n\n init(): void {\n const tooltipActual = this._option.getTooltipActual();\n\n if (!this.product) {\n this.product = this.createElement('h2');\n }\n\n const { title } = tooltipActual;\n if (title?.hasShape && title?.shapeType) {\n if (!this.shape) {\n this._initShape();\n }\n } else if (this.shape) {\n this._releaseShape();\n }\n\n if (!this.textSpan) {\n this._initTextSpan();\n }\n }\n\n private _initShape() {\n const shape = new ShapeModel(this.product!, this._option, 0);\n shape.init();\n this.shape = shape;\n this.children[shape.childIndex] = shape;\n }\n\n private _releaseShape() {\n if (!this.shape) {\n return;\n }\n this.shape.release();\n delete this.children[this.shape.childIndex];\n this.shape = null;\n }\n\n private _initTextSpan() {\n const textSpan = new TextModel(this.product!, this._option, 1);\n textSpan.init();\n this.textSpan = textSpan;\n this.children[textSpan.childIndex] = textSpan;\n }\n\n setStyle(style?: Partial<CSSStyleDeclaration>): void {\n const tooltipStyle = this._option.getTooltipStyle();\n const tooltipActual = this._option.getTooltipActual();\n\n const { title } = tooltipActual;\n super.setStyle(merge({}, defaultH2Style, tooltipStyle.title, style));\n\n this.shape?.setStyle(\n {\n paddingRight: tooltipStyle.shapeColumn.item?.marginRight\n },\n {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n }\n );\n }\n\n setContent(): void {\n const tooltipStyle = this._option.getTooltipStyle();\n const tooltipActual = this._option.getTooltipActual();\n\n const { title } = tooltipActual;\n this.init();\n this.shape?.setStyle(undefined, {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n });\n this.textSpan?.setContent(title?.value);\n }\n\n release(): void {\n super.release();\n this.shape = null;\n this.textSpan = null;\n }\n}\n"]}
1
+ {"version":3,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AY,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QACpD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;QAE9D,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,MAAA,IAAI,CAAC,KAAK,0CAAE,QAAQ,CAAC,SAAS,EAAE;YAC9B,QAAQ,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ;YACzB,SAAS,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS;YAC3B,IAAI,EAAE,MAAA,YAAY,CAAC,WAAW,CAAC,IAAI,0CAAE,KAAK;YAC1C,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU;YACxB,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW;SAC3B,CAAC,CAAC;QAEH,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,EAAE,MAAC,MAAA,iBAAiB,CAAC,KAAK,0CAAE,KAAa,0CAAE,SAAS,CAAC,CAAC;IAC9F,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AA5FD,gCA4FC","file":"title-model.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { merge } from '@visactor/vutils';\nimport { defaultH2Style } from './style-constants';\nimport { BaseTooltipModel } from './base-tooltip-model';\nimport { ShapeModel } from './shape-model';\nimport { TextModel } from './text-model';\n\nexport class TitleModel extends BaseTooltipModel {\n shape: Maybe<ShapeModel>;\n textSpan: Maybe<TextModel>;\n\n init(): void {\n const tooltipActual = this._option.getTooltipActual();\n\n if (!this.product) {\n this.product = this.createElement('h2');\n }\n\n const { title } = tooltipActual;\n if (title?.hasShape && title?.shapeType) {\n if (!this.shape) {\n this._initShape();\n }\n } else if (this.shape) {\n this._releaseShape();\n }\n\n if (!this.textSpan) {\n this._initTextSpan();\n }\n }\n\n private _initShape() {\n const shape = new ShapeModel(this.product!, this._option, 0);\n shape.init();\n this.shape = shape;\n this.children[shape.childIndex] = shape;\n }\n\n private _releaseShape() {\n if (!this.shape) {\n return;\n }\n this.shape.release();\n delete this.children[this.shape.childIndex];\n this.shape = null;\n }\n\n private _initTextSpan() {\n const textSpan = new TextModel(this.product!, this._option, 1);\n textSpan.init();\n this.textSpan = textSpan;\n this.children[textSpan.childIndex] = textSpan;\n }\n\n setStyle(style?: Partial<CSSStyleDeclaration>): void {\n const tooltipStyle = this._option.getTooltipStyle();\n const tooltipActual = this._option.getTooltipActual();\n\n const { title } = tooltipActual;\n super.setStyle(merge({}, defaultH2Style, tooltipStyle.title, style));\n\n this.shape?.setStyle(\n {\n paddingRight: tooltipStyle.shapeColumn.item?.marginRight\n },\n {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n }\n );\n }\n\n setContent(): void {\n const tooltipStyle = this._option.getTooltipStyle();\n const tooltipActual = this._option.getTooltipActual();\n const tooltipAttributes = this._option.getTooltipAttributes();\n\n const { title } = tooltipActual;\n this.init();\n this.shape?.setStyle(undefined, {\n hasShape: title?.hasShape,\n shapeType: title?.shapeType,\n size: tooltipStyle.shapeColumn.item?.width,\n color: title?.shapeColor,\n hollow: title?.shapeHollow\n });\n // FIXME: vrender 发版后去掉 any\n this.textSpan?.setContent(title?.value, (tooltipAttributes.title?.value as any)?.multiLine);\n }\n\n release(): void {\n super.release();\n this.shape = null;\n this.textSpan = null;\n }\n}\n"]}
@@ -2,4 +2,5 @@ import type { Maybe } from '@visactor/vutils';
2
2
  import type { ITooltipStyle } from '../interface';
3
3
  import type { IDomTooltipStyle } from './interface';
4
4
  import type { TooltipAttributes } from '@visactor/vrender-components';
5
+ export declare const getPixelPropertyStr: (num?: number | number[], defaultStr?: string) => string;
5
6
  export declare function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle;
@@ -2,28 +2,26 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.getDomStyles = void 0;
5
+ }), exports.getDomStyles = exports.getPixelPropertyStr = void 0;
6
6
 
7
7
  const util_1 = require("../../../../util"), DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING = 0, getPixelPropertyStr = (num, defaultStr) => (0,
8
8
  util_1.isValid)(num) ? (0, util_1.isArray)(num) ? num.map((n => `${n}px`)).join(" ") : `${num}px` : null != defaultStr ? defaultStr : "initial";
9
9
 
10
10
  function getDomStyles(style, attributeCache) {
11
11
  var _a, _b, _c, _d, _e, _f, _g;
12
- const {panel: {fill: fillColor, shadow: shadow, shadowBlur: shadowBlur, shadowColor: shadowColor, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowSpread: shadowSpread, cornerRadius: cornerRadius, stroke: strokeColor, lineWidth: lineWidth = 0}, padding: padding, key: key, value: value, title: title, shape: shape, maxWidth: maxWidth, minWidth: minWidth, enterable: enterable, spaceRow: spaceRow, transitionDuration: transitionDuration} = style, backgroundColor = fillColor, styles = {
12
+ const {panel: {fill: fillColor, shadow: shadow, shadowBlur: shadowBlur, shadowColor: shadowColor, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowSpread: shadowSpread, cornerRadius: cornerRadius, stroke: strokeColor, lineWidth: lineWidth = 0}, padding: padding, key: key, value: value, title: title, shape: shape, enterable: enterable, spaceRow: spaceRow, transitionDuration: transitionDuration} = style, backgroundColor = fillColor, styles = {
13
13
  panel: {
14
- width: getPixelPropertyStr((null !== (_b = null === (_a = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _a ? void 0 : _a.width) && void 0 !== _b ? _b : 0) + 2 * lineWidth),
15
- height: getPixelPropertyStr((null !== (_d = null === (_c = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _c ? void 0 : _c.height) && void 0 !== _d ? _d : 0) + 2 * lineWidth),
16
- paddingBottom: getPixelPropertyStr(padding.bottom),
17
- paddingLeft: getPixelPropertyStr(padding.left),
18
- paddingRight: getPixelPropertyStr(padding.right),
19
- paddingTop: getPixelPropertyStr(padding.top),
14
+ width: (0, exports.getPixelPropertyStr)((null !== (_b = null === (_a = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _a ? void 0 : _a.width) && void 0 !== _b ? _b : 0) + 2 * lineWidth),
15
+ height: (0, exports.getPixelPropertyStr)((null !== (_d = null === (_c = null == attributeCache ? void 0 : attributeCache.panel) || void 0 === _c ? void 0 : _c.height) && void 0 !== _d ? _d : 0) + 2 * lineWidth),
16
+ paddingBottom: (0, exports.getPixelPropertyStr)(padding.bottom),
17
+ paddingLeft: (0, exports.getPixelPropertyStr)(padding.left),
18
+ paddingRight: (0, exports.getPixelPropertyStr)(padding.right),
19
+ paddingTop: (0, exports.getPixelPropertyStr)(padding.top),
20
20
  borderColor: strokeColor,
21
- borderWidth: getPixelPropertyStr(lineWidth),
22
- borderRadius: getPixelPropertyStr(cornerRadius),
21
+ borderWidth: (0, exports.getPixelPropertyStr)(lineWidth),
22
+ borderRadius: (0, exports.getPixelPropertyStr)(cornerRadius),
23
23
  backgroundColor: backgroundColor ? `${backgroundColor}` : "transparent",
24
24
  boxShadow: shadow ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}` : "initial",
25
- maxWidth: getPixelPropertyStr(maxWidth),
26
- minWidth: getPixelPropertyStr(minWidth),
27
25
  pointerEvents: enterable ? "auto" : "none",
28
26
  transitionDuration: transitionDuration ? `${transitionDuration}ms` : "initial",
29
27
  transitionProperty: transitionDuration ? "transform" : "initial",
@@ -33,26 +31,26 @@ function getDomStyles(style, attributeCache) {
33
31
  content: {},
34
32
  shapeColumn: {
35
33
  item: getShapeStyle(shape),
36
- width: getPixelPropertyStr(shape.size),
37
- marginRight: getPixelPropertyStr(null !== (_e = shape.spacing) && void 0 !== _e ? _e : 8)
34
+ width: (0, exports.getPixelPropertyStr)(shape.size),
35
+ marginRight: (0, exports.getPixelPropertyStr)(null !== (_e = shape.spacing) && void 0 !== _e ? _e : 8)
38
36
  },
39
37
  keyColumn: {
40
38
  item: getLabelStyle(key),
41
- width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.keyWidth),
42
- marginRight: getPixelPropertyStr(null !== (_f = key.spacing) && void 0 !== _f ? _f : 26)
39
+ width: (0, exports.getPixelPropertyStr)(null == attributeCache ? void 0 : attributeCache.keyWidth),
40
+ marginRight: (0, exports.getPixelPropertyStr)(null !== (_f = key.spacing) && void 0 !== _f ? _f : 26)
43
41
  },
44
42
  valueColumn: {
45
43
  item: getLabelStyle(value),
46
- width: getPixelPropertyStr(null == attributeCache ? void 0 : attributeCache.valueWidth),
47
- marginRight: getPixelPropertyStr(null !== (_g = value.spacing) && void 0 !== _g ? _g : 0)
44
+ width: (0, exports.getPixelPropertyStr)(null == attributeCache ? void 0 : attributeCache.valueWidth),
45
+ marginRight: (0, exports.getPixelPropertyStr)(null !== (_g = value.spacing) && void 0 !== _g ? _g : 0)
48
46
  },
49
- spaceRow: getPixelPropertyStr(spaceRow)
47
+ spaceRow: (0, exports.getPixelPropertyStr)(spaceRow)
50
48
  };
51
49
  if ((0, util_1.isValid)(spaceRow)) {
52
50
  const gapUnit = spaceRow / 2;
53
51
  [ styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item ].forEach((obj => {
54
- obj.marginTop = getPixelPropertyStr(gapUnit), obj.marginBottom = obj.marginTop;
55
- })), styles.content.marginTop = getPixelPropertyStr(-gapUnit), styles.content.marginBottom = styles.content.marginTop;
52
+ obj.marginTop = (0, exports.getPixelPropertyStr)(gapUnit), obj.marginBottom = obj.marginTop;
53
+ })), styles.content.marginTop = (0, exports.getPixelPropertyStr)(-gapUnit), styles.content.marginBottom = styles.content.marginTop;
56
54
  } else [ styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item ].forEach((obj => {
57
55
  obj.marginTop = "initial", obj.marginBottom = "initial";
58
56
  }));
@@ -61,19 +59,20 @@ function getDomStyles(style, attributeCache) {
61
59
 
62
60
  function getLabelStyle(labelStyle, defaultStyle) {
63
61
  if (!labelStyle) return;
64
- const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight} = (0,
62
+ const {fontFamily: labelFont, fontSize: labelFontSize, fill: labelColor, textAlign: textAlign, lineHeight: lineHeight, fontWeight: fontWeight, multiLine: multiLine, wordBreak: wordBreak, maxWidth: maxWidth} = (0,
65
63
  util_1.merge)({}, defaultStyle, labelStyle), styleObj = {};
66
- return styleObj.fontFamily = labelFont, styleObj.fontSize = getPixelPropertyStr(labelFontSize),
67
- styleObj.color = labelColor, styleObj.textAlign = textAlign, styleObj.lineHeight = getPixelPropertyStr(lineHeight),
68
- styleObj.fontWeight = fontWeight, styleObj;
64
+ return styleObj.fontFamily = labelFont, styleObj.fontSize = (0, exports.getPixelPropertyStr)(labelFontSize),
65
+ styleObj.color = labelColor, styleObj.textAlign = textAlign, styleObj.lineHeight = (0,
66
+ exports.getPixelPropertyStr)(lineHeight), styleObj.fontWeight = fontWeight, styleObj.whiteSpace = multiLine ? "initial" : "nowrap",
67
+ styleObj.wordBreak = wordBreak, styleObj.maxWidth = (0, exports.getPixelPropertyStr)(maxWidth),
68
+ styleObj;
69
69
  }
70
70
 
71
71
  function getShapeStyle(shapeStyle, defaultStyle) {
72
72
  if (!shapeStyle) return;
73
73
  const {size: size} = (0, util_1.merge)({}, defaultStyle, shapeStyle), styleObj = {};
74
- return styleObj.width = getPixelPropertyStr(size), styleObj.height = styleObj.width,
75
- styleObj;
74
+ return styleObj.width = (0, exports.getPixelPropertyStr)(size), styleObj;
76
75
  }
77
76
 
78
- exports.getDomStyles = getDomStyles;
77
+ exports.getPixelPropertyStr = getPixelPropertyStr, exports.getDomStyles = getDomStyles;
79
78
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":";;;AAEA,2CAA2D;AAM3D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAC3E,IAAI,IAAA,cAAO,EAAC,GAAG,CAAC,EAAE;QAChB,IAAI,IAAA,cAAO,EAAC,GAAG,CAAC,EAAE;YAChB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,GAAG,IAAI,CAAC;KACnB;IACD,OAAO,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,SAAS,CAAC;AACjC,CAAC,CAAC;AAEF,SAAgB,YAAY,CAAC,KAAoB,EAAE,cAAyC;;IAC1F,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,SAAS,EACf,MAAM,EACN,UAAU,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,MAAM,EAAE,WAAW,EACnB,SAAS,GAAG,CAAC,EACd,EACD,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ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ACtD,QAAQ,CAAC,UAAU,GAAG,UAAwB,CAAC;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CACpB,UAAmC,EACnC,YAA8C;IAE9C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,YAAK,EAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"util.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\nimport type { FontWeight, TextAlign } from '../../../../typings';\nimport { isValid, merge, isArray } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITextStyle, ITooltipStyle } from '../interface';\nimport type { ILabelStyle, IMargin, IShapeStyle, IDomTooltipStyle } from './interface';\nimport type { TooltipAttributes } from '@visactor/vrender-components';\n\nconst DEFAULT_SHAPE_SPACING = 8;\nconst DEFAULT_KEY_SPACING = 26;\nconst DEFAULT_VALUE_SPACING = 0;\n\nconst getPixelPropertyStr = (num?: number | number[], defaultStr?: string) => {\n if (isValid(num)) {\n if (isArray(num)) {\n return num.map(n => `${n}px`).join(' ');\n }\n return `${num}px`;\n }\n return defaultStr ?? 'initial';\n};\n\nexport function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle {\n const {\n panel: {\n fill: fillColor,\n shadow,\n shadowBlur,\n shadowColor,\n shadowOffsetX,\n shadowOffsetY,\n shadowSpread,\n cornerRadius,\n stroke: strokeColor,\n lineWidth = 0\n },\n padding,\n key,\n value,\n title,\n shape,\n maxWidth,\n minWidth,\n enterable,\n spaceRow,\n transitionDuration\n } = style;\n\n const backgroundColor = fillColor as string;\n\n const styles = {\n panel: {\n width: getPixelPropertyStr((attributeCache?.panel?.width ?? 0) + lineWidth * 2),\n height: getPixelPropertyStr((attributeCache?.panel?.height ?? 0) + lineWidth * 2),\n paddingBottom: getPixelPropertyStr(padding.bottom),\n paddingLeft: getPixelPropertyStr(padding.left),\n paddingRight: getPixelPropertyStr(padding.right),\n paddingTop: getPixelPropertyStr(padding.top),\n borderColor: strokeColor,\n borderWidth: getPixelPropertyStr(lineWidth),\n borderRadius: getPixelPropertyStr(cornerRadius),\n backgroundColor: backgroundColor ? `${backgroundColor}` : 'transparent',\n boxShadow: shadow\n ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}`\n : 'initial',\n maxWidth: getPixelPropertyStr(maxWidth),\n minWidth: getPixelPropertyStr(minWidth),\n pointerEvents: enterable ? 'auto' : 'none',\n transitionDuration: transitionDuration ? `${transitionDuration}ms` : 'initial',\n transitionProperty: transitionDuration ? 'transform' : 'initial',\n transitionTimingFunction: transitionDuration ? 'ease-out' : 'initial'\n },\n title: getLabelStyle(title),\n content: {},\n shapeColumn: {\n item: getShapeStyle(shape),\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING)\n },\n keyColumn: {\n item: getLabelStyle(key),\n width: getPixelPropertyStr(attributeCache?.keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n item: getLabelStyle(value),\n width: getPixelPropertyStr(attributeCache?.valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\n },\n spaceRow: getPixelPropertyStr(spaceRow)\n } as IDomTooltipStyle;\n\n if (isValid(spaceRow)) {\n const gapUnit = spaceRow / 2;\n ([styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(obj => {\n obj.marginTop = getPixelPropertyStr(gapUnit);\n obj.marginBottom = obj.marginTop;\n });\n styles.content.marginTop = getPixelPropertyStr(-gapUnit);\n styles.content.marginBottom = styles.content.marginTop;\n } else {\n ([styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(\n obj => {\n obj.marginTop = 'initial';\n obj.marginBottom = 'initial';\n }\n );\n }\n return styles;\n}\n\nfunction getLabelStyle(labelStyle?: ITextStyle, defaultStyle?: Partial<ITextStyle>): ILabelStyle | undefined {\n if (!labelStyle) {\n return undefined;\n }\n const {\n fontFamily: labelFont,\n fontSize: labelFontSize,\n fill: labelColor,\n textAlign,\n lineHeight,\n fontWeight\n } = merge({}, defaultStyle, labelStyle) as ITextStyle;\n const styleObj: ILabelStyle = {};\n\n styleObj.fontFamily = labelFont;\n styleObj.fontSize = getPixelPropertyStr(labelFontSize);\n styleObj.color = labelColor as string;\n styleObj.textAlign = textAlign as TextAlign;\n styleObj.lineHeight = getPixelPropertyStr(lineHeight);\n styleObj.fontWeight = fontWeight as FontWeight;\n return styleObj;\n}\n\nfunction getShapeStyle(\n shapeStyle?: ITooltipTheme['shape'],\n defaultStyle?: Partial<ITooltipTheme['shape']>\n): IShapeStyle | undefined {\n if (!shapeStyle) {\n return undefined;\n }\n const { size } = merge({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n styleObj.height = styleObj.width;\n return styleObj;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":";;;AAEA,2CAA2D;AAM3D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAClF,IAAI,IAAA,cAAO,EAAC,GAAG,CAAC,EAAE;QAChB,IAAI,IAAA,cAAO,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AAmB,EAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC;AAClB,CAAC","file":"util.js","sourcesContent":["import type { Maybe } from '@visactor/vutils';\nimport type { FontWeight, TextAlign } from '../../../../typings';\nimport { isValid, merge, isArray } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITooltipTextStyle, ITooltipStyle } from '../interface';\nimport type { ILabelStyle, IMargin, IShapeStyle, IDomTooltipStyle } from './interface';\nimport type { TooltipAttributes } from '@visactor/vrender-components';\n\nconst DEFAULT_SHAPE_SPACING = 8;\nconst DEFAULT_KEY_SPACING = 26;\nconst DEFAULT_VALUE_SPACING = 0;\n\nexport const getPixelPropertyStr = (num?: number | number[], defaultStr?: string) => {\n if (isValid(num)) {\n if (isArray(num)) {\n return num.map(n => `${n}px`).join(' ');\n }\n return `${num}px`;\n }\n return defaultStr ?? 'initial';\n};\n\nexport function getDomStyles(style: ITooltipStyle, attributeCache?: Maybe<TooltipAttributes>): IDomTooltipStyle {\n const {\n panel: {\n fill: fillColor,\n shadow,\n shadowBlur,\n shadowColor,\n shadowOffsetX,\n shadowOffsetY,\n shadowSpread,\n cornerRadius,\n stroke: strokeColor,\n lineWidth = 0\n },\n padding,\n key,\n value,\n title,\n shape,\n enterable,\n spaceRow,\n transitionDuration\n } = style;\n\n const backgroundColor = fillColor as string;\n\n const styles = {\n panel: {\n width: getPixelPropertyStr((attributeCache?.panel?.width ?? 0) + lineWidth * 2),\n height: getPixelPropertyStr((attributeCache?.panel?.height ?? 0) + lineWidth * 2),\n paddingBottom: getPixelPropertyStr(padding.bottom),\n paddingLeft: getPixelPropertyStr(padding.left),\n paddingRight: getPixelPropertyStr(padding.right),\n paddingTop: getPixelPropertyStr(padding.top),\n borderColor: strokeColor,\n borderWidth: getPixelPropertyStr(lineWidth),\n borderRadius: getPixelPropertyStr(cornerRadius),\n backgroundColor: backgroundColor ? `${backgroundColor}` : 'transparent',\n boxShadow: shadow\n ? `${shadowOffsetX}px ${shadowOffsetY}px ${shadowBlur}px ${shadowSpread}px ${shadowColor}`\n : 'initial',\n pointerEvents: enterable ? 'auto' : 'none',\n transitionDuration: transitionDuration ? `${transitionDuration}ms` : 'initial',\n transitionProperty: transitionDuration ? 'transform' : 'initial',\n transitionTimingFunction: transitionDuration ? 'ease-out' : 'initial'\n },\n title: getLabelStyle(title),\n content: {},\n shapeColumn: {\n item: getShapeStyle(shape),\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING)\n },\n keyColumn: {\n item: getLabelStyle(key),\n width: getPixelPropertyStr(attributeCache?.keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n item: getLabelStyle(value),\n width: getPixelPropertyStr(attributeCache?.valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\n },\n spaceRow: getPixelPropertyStr(spaceRow)\n } as IDomTooltipStyle;\n\n if (isValid(spaceRow)) {\n const gapUnit = spaceRow / 2;\n ([styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(obj => {\n obj.marginTop = getPixelPropertyStr(gapUnit);\n obj.marginBottom = obj.marginTop;\n });\n styles.content.marginTop = getPixelPropertyStr(-gapUnit);\n styles.content.marginBottom = styles.content.marginTop;\n } else {\n ([styles.content, styles.shapeColumn.item, styles.keyColumn.item, styles.valueColumn.item] as IMargin[]).forEach(\n obj => {\n obj.marginTop = 'initial';\n obj.marginBottom = 'initial';\n }\n );\n }\n return styles;\n}\n\nfunction getLabelStyle(\n labelStyle?: ITooltipTextStyle,\n defaultStyle?: Partial<ITooltipTextStyle>\n): ILabelStyle | undefined {\n if (!labelStyle) {\n return undefined;\n }\n const {\n fontFamily: labelFont,\n fontSize: labelFontSize,\n fill: labelColor,\n textAlign,\n lineHeight,\n fontWeight,\n multiLine,\n wordBreak,\n maxWidth\n } = merge({}, defaultStyle, labelStyle) as ITooltipTextStyle;\n const styleObj: ILabelStyle = {};\n\n styleObj.fontFamily = labelFont;\n styleObj.fontSize = getPixelPropertyStr(labelFontSize);\n styleObj.color = labelColor as string;\n styleObj.textAlign = textAlign as TextAlign;\n styleObj.lineHeight = getPixelPropertyStr(lineHeight);\n styleObj.fontWeight = fontWeight as FontWeight;\n styleObj.whiteSpace = multiLine ? 'initial' : 'nowrap';\n styleObj.wordBreak = wordBreak;\n styleObj.maxWidth = getPixelPropertyStr(maxWidth);\n return styleObj;\n}\n\nfunction getShapeStyle(\n shapeStyle?: ITooltipTheme['shape'],\n defaultStyle?: Partial<ITooltipTheme['shape']>\n): IShapeStyle | undefined {\n if (!shapeStyle) {\n return undefined;\n }\n const { size } = merge({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n return styleObj;\n}\n"]}
@@ -1,25 +1,26 @@
1
- import type { ITextAttribute, IFillStyle, IRectGraphicAttribute } from '@visactor/vrender';
1
+ import type { ITextAttribute, IFillStyle, IRectGraphicAttribute, RichTextWordBreak } from '@visactor/vrender';
2
2
  import type { IPadding } from '../../../../typings';
3
- export interface ITextStyle extends Partial<ITextAttribute & IFillStyle> {
3
+ export interface ITooltipTextStyle extends Partial<ITextAttribute & IFillStyle> {
4
4
  spacing: number;
5
+ multiLine: boolean;
6
+ maxWidth?: number;
7
+ wordBreak?: RichTextWordBreak;
5
8
  }
6
- export interface IPanelStyle extends Partial<IRectGraphicAttribute> {
9
+ export interface ITooltipPanelStyle extends Partial<IRectGraphicAttribute> {
7
10
  shadow: boolean;
8
11
  shadowSpread?: number;
9
12
  }
10
13
  export interface ITooltipStyle {
11
- panel: IPanelStyle;
12
- title: ITextStyle;
14
+ panel: ITooltipPanelStyle;
15
+ title: ITooltipTextStyle;
13
16
  shape: {
14
17
  fill: boolean;
15
18
  size: number;
16
19
  spacing: number;
17
20
  };
18
- key: ITextStyle;
19
- value: ITextStyle;
21
+ key: ITooltipTextStyle;
22
+ value: ITooltipTextStyle;
20
23
  padding: IPadding;
21
- minWidth: number;
22
- maxWidth: number;
23
24
  spaceRow: number;
24
25
  enterable: boolean;
25
26
  transitionDuration: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/interface/style.ts"],"names":[],"mappings":"","file":"style.js","sourcesContent":["import type { ITextAttribute, IFillStyle, IRectGraphicAttribute } from '@visactor/vrender';\nimport type { IPadding } from '../../../../typings';\n\nexport interface ITextStyle extends Partial<ITextAttribute & IFillStyle> {\n spacing: number;\n}\n\nexport interface IPanelStyle extends Partial<IRectGraphicAttribute> {\n shadow: boolean;\n shadowSpread?: number;\n}\n\nexport interface ITooltipStyle {\n panel: IPanelStyle;\n title: ITextStyle;\n shape: {\n fill: boolean;\n size: number;\n spacing: number;\n };\n key: ITextStyle;\n value: ITextStyle;\n padding: IPadding;\n minWidth: number;\n maxWidth: number;\n spaceRow: number;\n enterable: boolean;\n transitionDuration: number;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/interface/style.ts"],"names":[],"mappings":"","file":"style.js","sourcesContent":["import type { ITextAttribute, IFillStyle, IRectGraphicAttribute, RichTextWordBreak } from '@visactor/vrender';\nimport type { IPadding } from '../../../../typings';\n\nexport interface ITooltipTextStyle extends Partial<ITextAttribute & IFillStyle> {\n /** 和相邻元素的水平间距 */\n spacing: number;\n /** 是否支持换行 */\n multiLine: boolean;\n /** 文本元素的最大宽度 */\n maxWidth?: number;\n /** 换行模式 */\n wordBreak?: RichTextWordBreak;\n}\n\nexport interface ITooltipPanelStyle extends Partial<IRectGraphicAttribute> {\n shadow: boolean;\n shadowSpread?: number;\n}\n\nexport interface ITooltipStyle {\n panel: ITooltipPanelStyle;\n title: ITooltipTextStyle;\n shape: {\n fill: boolean;\n size: number;\n spacing: number;\n };\n key: ITooltipTextStyle;\n value: ITooltipTextStyle;\n padding: IPadding;\n spaceRow: number;\n enterable: boolean;\n transitionDuration: number;\n}\n"]}
@@ -1,4 +1,11 @@
1
1
  import type { TooltipAttributes } from '@visactor/vrender-components';
2
- import type { IToolTipActual } from '../../../../typings';
3
- import type { ITooltipStyle } from '../interface';
2
+ import type { IToolTipActual, MaybeArray } from '../../../../typings';
3
+ import type { ITooltipStyle, ITooltipTextStyle } from '../interface';
4
4
  export declare const getTooltipAttributes: (actualTooltip: IToolTipActual, style: ITooltipStyle) => TooltipAttributes;
5
+ interface ITooltipTextInfo {
6
+ width: number;
7
+ height: number;
8
+ text: MaybeArray<number> | MaybeArray<string>;
9
+ }
10
+ export declare const measureTooltipText: (text: string, style: ITooltipTextStyle) => ITooltipTextInfo;
11
+ export {};