@visactor/vchart 1.5.1-alpha.2 → 1.5.1-alpha.3

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 (103) hide show
  1. package/build/es5/index.js +2 -2
  2. package/build/index.js +73145 -47075
  3. package/build/index.min.js +2 -2
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/compile/util.js.map +1 -1
  6. package/cjs/component/tooltip/handler/base.d.ts +2 -4
  7. package/cjs/component/tooltip/handler/base.js +15 -38
  8. package/cjs/component/tooltip/handler/base.js.map +1 -1
  9. package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
  10. package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
  11. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
  12. package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  13. package/cjs/component/tooltip/handler/dom/util.d.ts +1 -2
  14. package/cjs/component/tooltip/handler/dom/util.js +14 -13
  15. package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
  16. package/cjs/component/tooltip/handler/interface/style.d.ts +4 -23
  17. package/cjs/component/tooltip/handler/interface/style.js.map +1 -1
  18. package/cjs/component/tooltip/handler/utils/attribute.d.ts +9 -11
  19. package/cjs/component/tooltip/handler/utils/attribute.js +136 -126
  20. package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
  21. package/cjs/component/tooltip/handler/utils/common.d.ts +8 -0
  22. package/cjs/component/tooltip/handler/utils/common.js +42 -2
  23. package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
  24. package/cjs/component/tooltip/handler/utils/index.d.ts +0 -1
  25. package/cjs/component/tooltip/handler/utils/index.js +1 -2
  26. package/cjs/component/tooltip/handler/utils/index.js.map +1 -1
  27. package/cjs/component/tooltip/interface/theme.d.ts +5 -3
  28. package/cjs/component/tooltip/interface/theme.js.map +1 -1
  29. package/cjs/core/index.d.ts +1 -1
  30. package/cjs/core/index.js +1 -1
  31. package/cjs/core/index.js.map +1 -1
  32. package/cjs/core/vchart.js +1 -1
  33. package/cjs/core/vchart.js.map +1 -1
  34. package/cjs/env/env.d.ts +7 -0
  35. package/cjs/env/env.js +48 -0
  36. package/cjs/env/env.js.map +1 -0
  37. package/cjs/env/index.d.ts +1 -0
  38. package/cjs/env/index.js +21 -0
  39. package/cjs/env/index.js.map +1 -0
  40. package/cjs/index.d.ts +1 -0
  41. package/cjs/index.js +2 -1
  42. package/cjs/index.js.map +1 -1
  43. package/cjs/interaction/interaction.js +1 -2
  44. package/cjs/interaction/trigger.js +2 -1
  45. package/cjs/mark/arc.js +1 -1
  46. package/cjs/mark/area.js +1 -1
  47. package/cjs/vchart-all.js +3 -2
  48. package/cjs/vchart-all.js.map +1 -1
  49. package/cjs/vchart-simple.js +3 -2
  50. package/cjs/vchart-simple.js.map +1 -1
  51. package/esm/compile/util.js.map +1 -1
  52. package/esm/component/tooltip/handler/base.d.ts +2 -4
  53. package/esm/component/tooltip/handler/base.js +14 -39
  54. package/esm/component/tooltip/handler/base.js.map +1 -1
  55. package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
  56. package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
  57. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
  58. package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
  59. package/esm/component/tooltip/handler/dom/util.d.ts +1 -2
  60. package/esm/component/tooltip/handler/dom/util.js +14 -14
  61. package/esm/component/tooltip/handler/dom/util.js.map +1 -1
  62. package/esm/component/tooltip/handler/interface/style.d.ts +4 -23
  63. package/esm/component/tooltip/handler/interface/style.js.map +1 -1
  64. package/esm/component/tooltip/handler/utils/attribute.d.ts +9 -11
  65. package/esm/component/tooltip/handler/utils/attribute.js +131 -123
  66. package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
  67. package/esm/component/tooltip/handler/utils/common.d.ts +8 -0
  68. package/esm/component/tooltip/handler/utils/common.js +41 -1
  69. package/esm/component/tooltip/handler/utils/common.js.map +1 -1
  70. package/esm/component/tooltip/handler/utils/index.d.ts +0 -1
  71. package/esm/component/tooltip/handler/utils/index.js +0 -2
  72. package/esm/component/tooltip/handler/utils/index.js.map +1 -1
  73. package/esm/component/tooltip/interface/theme.d.ts +5 -3
  74. package/esm/component/tooltip/interface/theme.js.map +1 -1
  75. package/esm/core/index.d.ts +1 -1
  76. package/esm/core/index.js +1 -1
  77. package/esm/core/index.js.map +1 -1
  78. package/esm/core/vchart.js +3 -3
  79. package/esm/core/vchart.js.map +1 -1
  80. package/esm/env/env.d.ts +7 -0
  81. package/esm/env/env.js +32 -0
  82. package/esm/env/env.js.map +1 -0
  83. package/esm/env/index.d.ts +1 -0
  84. package/esm/env/index.js +2 -0
  85. package/esm/env/index.js.map +1 -0
  86. package/esm/index.d.ts +1 -0
  87. package/esm/index.js +2 -0
  88. package/esm/index.js.map +1 -1
  89. package/esm/interaction/interaction.js +1 -2
  90. package/esm/interaction/trigger.js +2 -1
  91. package/esm/mark/arc.js +1 -1
  92. package/esm/mark/area.js +1 -1
  93. package/esm/vchart-all.js +4 -1
  94. package/esm/vchart-all.js.map +1 -1
  95. package/esm/vchart-simple.js +4 -1
  96. package/esm/vchart-simple.js.map +1 -1
  97. package/package.json +8 -8
  98. package/cjs/component/tooltip/handler/utils/style.d.ts +0 -4
  99. package/cjs/component/tooltip/handler/utils/style.js +0 -32
  100. package/cjs/component/tooltip/handler/utils/style.js.map +0 -1
  101. package/esm/component/tooltip/handler/utils/style.d.ts +0 -4
  102. package/esm/component/tooltip/handler/utils/style.js +0 -26
  103. package/esm/component/tooltip/handler/utils/style.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { isValid, mergeSpec, isArray } from "../../../../util";
1
+ import { isValid, mergeSpec, isArray, normalizeLayoutPaddingSpec } from "../../../../util";
2
2
 
3
3
  const DEFAULT_SHAPE_SPACING = 8, DEFAULT_KEY_SPACING = 26, DEFAULT_VALUE_SPACING = 0;
4
4
 
@@ -9,17 +9,17 @@ export const pixelPropertyStrToNumber = str => {
9
9
  return 1 === numArr.length ? numArr[0] : numArr;
10
10
  };
11
11
 
12
- export function getDomStyles(style, attributeCache) {
13
- var _a, _b, _c, _d, _e, _f, _g;
14
- 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, transitionDuration: transitionDuration} = style, {panel: panelAttribute, title: titleAttribute, content: contentAttribute, keyWidth: keyWidth, valueWidth: valueWidth} = null != attributeCache ? attributeCache : {}, backgroundColor = fillColor, shapeStyle = getShapeStyle(shape), keyStyle = getLabelStyle(key), valueStyle = getLabelStyle(value);
12
+ export function getDomStyles(attributes) {
13
+ var _a, _b, _c, _d, _e;
14
+ const {panel: panel = {}, title: titleAttribute, content: contentAttribute, titleStyle: titleStyle = {}, contentStyle: contentStyle = {}, padding: padding, keyWidth: keyWidth, valueWidth: valueWidth, enterable: enterable, transitionDuration: transitionDuration} = null != attributes ? attributes : {}, {fill: backgroundColor, shadow: shadow, shadowBlur: shadowBlur, shadowColor: shadowColor, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowSpread: shadowSpread, cornerRadius: cornerRadius, stroke: strokeColor, lineWidth: lineWidth = 0, width: width = 0, height: height = 0} = panel, {value: title = {}} = titleStyle, {shape: shape = {}, key: key = {}, value: value = {}} = contentStyle, shapeStyle = getShapeStyle(shape), keyStyle = getLabelStyle(key), valueStyle = getLabelStyle(value), {bottom: bottom, left: left, right: right, top: top} = normalizeLayoutPaddingSpec(padding);
15
15
  return {
16
16
  panel: {
17
- width: getPixelPropertyStr((null !== (_a = null == panelAttribute ? void 0 : panelAttribute.width) && void 0 !== _a ? _a : 0) + 2 * lineWidth),
18
- minHeight: getPixelPropertyStr((null !== (_b = null == panelAttribute ? void 0 : panelAttribute.height) && void 0 !== _b ? _b : 0) + 2 * lineWidth),
19
- paddingBottom: getPixelPropertyStr(padding.bottom),
20
- paddingLeft: getPixelPropertyStr(padding.left),
21
- paddingRight: getPixelPropertyStr(padding.right),
22
- paddingTop: getPixelPropertyStr(padding.top),
17
+ width: getPixelPropertyStr(width + 2 * lineWidth),
18
+ minHeight: getPixelPropertyStr(height + 2 * lineWidth),
19
+ paddingBottom: getPixelPropertyStr(bottom),
20
+ paddingLeft: getPixelPropertyStr(left),
21
+ paddingRight: getPixelPropertyStr(right),
22
+ paddingTop: getPixelPropertyStr(top),
23
23
  borderColor: strokeColor,
24
24
  borderWidth: getPixelPropertyStr(lineWidth),
25
25
  borderRadius: getPixelPropertyStr(cornerRadius),
@@ -39,8 +39,8 @@ export function getDomStyles(style, attributeCache) {
39
39
  common: shapeStyle,
40
40
  items: [],
41
41
  width: getPixelPropertyStr(shape.size),
42
- marginRight: getPixelPropertyStr(null !== (_c = shape.spacing) && void 0 !== _c ? _c : 8),
43
- marginBottom: getPixelPropertyStr(-(null !== (_e = null === (_d = null == contentAttribute ? void 0 : contentAttribute[(null == contentAttribute ? void 0 : contentAttribute.length) - 1]) || void 0 === _d ? void 0 : _d.spaceRow) && void 0 !== _e ? _e : 0))
42
+ marginRight: getPixelPropertyStr(null !== (_a = shape.spacing) && void 0 !== _a ? _a : 8),
43
+ marginBottom: getPixelPropertyStr(-(null !== (_c = null === (_b = null == contentAttribute ? void 0 : contentAttribute[(null == contentAttribute ? void 0 : contentAttribute.length) - 1]) || void 0 === _b ? void 0 : _b.spaceRow) && void 0 !== _c ? _c : 0))
44
44
  },
45
45
  keyColumn: {
46
46
  common: keyStyle,
@@ -51,7 +51,7 @@ export function getDomStyles(style, attributeCache) {
51
51
  width: getPixelPropertyStr(Math.ceil(key.width))
52
52
  } : void 0))),
53
53
  width: getPixelPropertyStr(keyWidth),
54
- marginRight: getPixelPropertyStr(null !== (_f = key.spacing) && void 0 !== _f ? _f : 26)
54
+ marginRight: getPixelPropertyStr(null !== (_d = key.spacing) && void 0 !== _d ? _d : 26)
55
55
  },
56
56
  valueColumn: {
57
57
  common: valueStyle,
@@ -62,7 +62,7 @@ export function getDomStyles(style, attributeCache) {
62
62
  width: getPixelPropertyStr(Math.ceil(value.width))
63
63
  } : void 0))),
64
64
  width: getPixelPropertyStr(valueWidth),
65
- marginRight: getPixelPropertyStr(null !== (_g = value.spacing) && void 0 !== _g ? _g : 0)
65
+ marginRight: getPixelPropertyStr(null !== (_e = value.spacing) && void 0 !== _e ? _e : 0)
66
66
  }
67
67
  };
68
68
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM/D,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAClF,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,OAAO,CAAC,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,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAqB,EAAE;IACzE,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,C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AAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACT,GAAG,SAAS,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAsB,CAAC;IACjE,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,QAAQ,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACvD,QAAQ,CAAC,KAAK,GAAG,UAAoB,CAAC;IACtC,QAAQ,CAAC,SAAS,GAAG,SAAsB,CAAC;IAC5C,QAAQ,CAAC,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,GAAG,UAAwB,CAAC;IAC/C,QAAQ,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvD,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAClD,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,SAAS,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,KAAK,GAAG,mBAAmB,CAAC,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, mergeSpec, isArray } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITooltipTextStyle, ITooltipStyle } from '../interface';\nimport type { ILabelStyle, 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 const pixelPropertyStrToNumber = (str: string): number | number[] => {\n const strArr = str.split(' ');\n const numArr = strArr.map(n => {\n if (!Number.isNaN(n)) {\n return Number.parseFloat(n);\n }\n return Number.parseFloat(n.substring(0, n.length - 2));\n });\n if (numArr.length === 1) {\n return numArr[0];\n }\n return numArr;\n};\n\nexport function getDomStyles(\n style: Partial<ITooltipStyle>,\n attributeCache?: Maybe<TooltipAttributes>\n): 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 transitionDuration\n } = style;\n\n const {\n panel: panelAttribute,\n title: titleAttribute,\n content: contentAttribute,\n keyWidth,\n valueWidth\n } = attributeCache ?? {};\n\n const backgroundColor = fillColor as string;\n\n const shapeStyle = getShapeStyle(shape);\n const keyStyle = getLabelStyle(key);\n const valueStyle = getLabelStyle(value);\n\n const styles: IDomTooltipStyle = {\n panel: {\n width: getPixelPropertyStr((panelAttribute?.width ?? 0) + lineWidth * 2),\n minHeight: getPixelPropertyStr((panelAttribute?.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 as string,\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: {\n marginTop: '0px',\n marginBottom: contentAttribute?.length ? getPixelPropertyStr(titleAttribute?.spaceRow) : '0px',\n ...getLabelStyle(mergeSpec({}, title, titleAttribute?.value))\n },\n content: {},\n shapeColumn: {\n common: shapeStyle,\n items: [],\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING),\n marginBottom: getPixelPropertyStr(-(contentAttribute?.[contentAttribute?.length - 1]?.spaceRow ?? 0))\n },\n keyColumn: {\n common: keyStyle,\n items: contentAttribute?.map(\n ({ key, spaceRow }, i) =>\n ({\n marginTop: '0px',\n marginBottom: i < contentAttribute.length - 1 ? getPixelPropertyStr(spaceRow) : '0px',\n ...keyStyle,\n ...getLabelStyle(key as ITooltipTextStyle),\n ...(key?.multiLine ? { width: getPixelPropertyStr(Math.ceil(key.width)) } : undefined) // 对多行文本使用定宽\n } as ILabelStyle)\n ),\n width: getPixelPropertyStr(keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n common: valueStyle,\n items: contentAttribute?.map(\n ({ value, spaceRow }, i) =>\n ({\n marginTop: '0px',\n marginBottom: i < contentAttribute.length - 1 ? getPixelPropertyStr(spaceRow) : '0px',\n ...valueStyle,\n ...getLabelStyle(value as ITooltipTextStyle),\n ...(value?.multiLine ? { width: getPixelPropertyStr(Math.ceil(value.width)) } : undefined) // 对多行文本使用定宽\n } as ILabelStyle)\n ),\n width: getPixelPropertyStr(valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\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 } = mergeSpec({}, 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 } = mergeSpec({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n return styleObj;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/dom/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAM3F,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAuB,EAAE,UAAmB,EAAE,EAAE;IAClF,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AmC,EACnC,YAA8C;IAE9C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,QAAQ,CAAC,KAAK,GAAG,mBAAmB,CAAC,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, mergeSpec, isArray, normalizeLayoutPaddingSpec } from '../../../../util';\nimport type { ITooltipTheme } from '../../interface';\nimport type { ITooltipTextStyle } from '../interface';\nimport type { ILabelStyle, 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 const pixelPropertyStrToNumber = (str: string): number | number[] => {\n const strArr = str.split(' ');\n const numArr = strArr.map(n => {\n if (!Number.isNaN(n)) {\n return Number.parseFloat(n);\n }\n return Number.parseFloat(n.substring(0, n.length - 2));\n });\n if (numArr.length === 1) {\n return numArr[0];\n }\n return numArr;\n};\n\nexport function getDomStyles(attributes?: Maybe<TooltipAttributes>): IDomTooltipStyle {\n const {\n panel = {},\n title: titleAttribute,\n content: contentAttribute,\n titleStyle = {},\n contentStyle = {},\n padding,\n keyWidth,\n valueWidth,\n enterable,\n transitionDuration\n } = attributes ?? {};\n\n const {\n fill: backgroundColor,\n shadow,\n shadowBlur,\n shadowColor,\n shadowOffsetX,\n shadowOffsetY,\n shadowSpread,\n cornerRadius,\n stroke: strokeColor,\n lineWidth = 0,\n width = 0,\n height = 0\n } = panel;\n\n const { value: title = {} } = titleStyle;\n const { shape = {}, key = {}, value = {} } = contentStyle;\n\n const shapeStyle = getShapeStyle(shape);\n const keyStyle = getLabelStyle(key);\n const valueStyle = getLabelStyle(value);\n const { bottom, left, right, top } = normalizeLayoutPaddingSpec(padding);\n\n const styles: IDomTooltipStyle = {\n panel: {\n width: getPixelPropertyStr(width + lineWidth * 2),\n minHeight: getPixelPropertyStr(height + lineWidth * 2),\n paddingBottom: getPixelPropertyStr(bottom as number),\n paddingLeft: getPixelPropertyStr(left as number),\n paddingRight: getPixelPropertyStr(right as number),\n paddingTop: getPixelPropertyStr(top as number),\n borderColor: strokeColor as string,\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: {\n marginTop: '0px',\n marginBottom: contentAttribute?.length ? getPixelPropertyStr(titleAttribute?.spaceRow) : '0px',\n ...getLabelStyle(mergeSpec({}, title, titleAttribute?.value))\n },\n content: {},\n shapeColumn: {\n common: shapeStyle,\n items: [],\n width: getPixelPropertyStr(shape.size),\n marginRight: getPixelPropertyStr(shape.spacing ?? DEFAULT_SHAPE_SPACING),\n marginBottom: getPixelPropertyStr(-(contentAttribute?.[contentAttribute?.length - 1]?.spaceRow ?? 0))\n },\n keyColumn: {\n common: keyStyle,\n items: contentAttribute?.map(\n ({ key, spaceRow }, i) =>\n ({\n marginTop: '0px',\n marginBottom: i < contentAttribute.length - 1 ? getPixelPropertyStr(spaceRow) : '0px',\n ...keyStyle,\n ...getLabelStyle(key as ITooltipTextStyle),\n ...(key?.multiLine ? { width: getPixelPropertyStr(Math.ceil(key.width)) } : undefined) // 对多行文本使用定宽\n } as ILabelStyle)\n ),\n width: getPixelPropertyStr(keyWidth),\n marginRight: getPixelPropertyStr(key.spacing ?? DEFAULT_KEY_SPACING)\n },\n valueColumn: {\n common: valueStyle,\n items: contentAttribute?.map(\n ({ value, spaceRow }, i) =>\n ({\n marginTop: '0px',\n marginBottom: i < contentAttribute.length - 1 ? getPixelPropertyStr(spaceRow) : '0px',\n ...valueStyle,\n ...getLabelStyle(value as ITooltipTextStyle),\n ...(value?.multiLine ? { width: getPixelPropertyStr(Math.ceil(value.width)) } : undefined) // 对多行文本使用定宽\n } as ILabelStyle)\n ),\n width: getPixelPropertyStr(valueWidth),\n marginRight: getPixelPropertyStr(value.spacing ?? DEFAULT_VALUE_SPACING)\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 } = mergeSpec({}, 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 } = mergeSpec({}, defaultStyle, shapeStyle);\n const styleObj: IShapeStyle = {};\n\n styleObj.width = getPixelPropertyStr(size);\n return styleObj;\n}\n"]}
@@ -1,27 +1,8 @@
1
- import type { ITextAttribute, IFillStyle, IRectGraphicAttribute, RichTextWordBreak } from '@visactor/vrender-core';
2
- import type { IPadding } from '../../../../typings';
1
+ import type { ITextAttribute, IFillStyle, RichTextWordBreak } from '@visactor/vrender-core';
3
2
  export interface ITooltipTextStyle extends Partial<ITextAttribute & IFillStyle> {
4
- spacing: number;
5
- multiLine: boolean;
3
+ spacing?: number;
4
+ multiLine?: boolean;
6
5
  maxWidth?: number;
7
6
  wordBreak?: RichTextWordBreak;
8
- }
9
- export interface ITooltipPanelStyle extends Partial<IRectGraphicAttribute> {
10
- shadow: boolean;
11
- shadowSpread?: number;
12
- }
13
- export interface ITooltipStyle {
14
- panel: ITooltipPanelStyle;
15
- title: ITooltipTextStyle;
16
- shape: {
17
- fill: boolean;
18
- size: number;
19
- spacing: number;
20
- };
21
- key: ITooltipTextStyle;
22
- value: ITooltipTextStyle;
23
- padding: IPadding;
24
- spaceRow: number;
25
- enterable: boolean;
26
- transitionDuration: number;
7
+ autoWidth?: boolean;
27
8
  }
@@ -1 +1 @@
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-core';\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
+ {"version":3,"sources":["../src/component/tooltip/handler/interface/style.ts"],"names":[],"mappings":"","file":"style.js","sourcesContent":["import type { ITextAttribute, IFillStyle, RichTextWordBreak } from '@visactor/vrender-core';\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 autoWidth?: boolean;\n}\n"]}
@@ -1,11 +1,9 @@
1
- import type { TooltipAttributes } from '@visactor/vrender-components';
2
- import type { IToolTipActual, MaybeArray } from '../../../../typings';
3
- import type { ITooltipStyle, ITooltipTextStyle } from '../interface';
4
- export declare const getTooltipAttributes: (actualTooltip: IToolTipActual, style: Partial<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 {};
1
+ import type { TooltipAttributes, TooltipPanelAttrs } from '@visactor/vrender-components';
2
+ import type { IToolTipActual } from '../../../../typings';
3
+ import type { ITooltipTextStyle } from '../interface';
4
+ import type { ITooltipSpec } from '../../interface/spec';
5
+ import type { ITheme } from '../../../../theme';
6
+ import type { ITooltipTextTheme, ITooltipTheme } from '../../interface/theme';
7
+ export declare function getTextAttributes(style?: ITooltipTextTheme, globalTheme?: ITheme, defaultAttributes?: Partial<ITooltipTextStyle>): ITooltipTextStyle;
8
+ export declare const getPanelAttributes: (style: ITooltipTheme['panel']) => TooltipPanelAttrs;
9
+ export declare const getTooltipAttributes: (actualTooltip: IToolTipActual, spec: ITooltipSpec, globalTheme: ITheme) => TooltipAttributes;
@@ -1,13 +1,59 @@
1
- import { isValid } from "@visactor/vutils";
1
+ import { isValid, normalizePadding } from "@visactor/vutils";
2
2
 
3
- import { initTextMeasure, mergeSpec } from "../../../../util";
3
+ import { mergeSpec, normalizeLayoutPaddingSpec } from "../../../../util";
4
4
 
5
- import { builtinSymbolsMap, getRichTextBounds } from "@visactor/vrender-core";
5
+ import { THEME_CONSTANTS } from "../../../../theme/builtin/common/constants";
6
6
 
7
- import { getTextAttributes } from "./style";
7
+ import { measureTooltipText } from "./common";
8
8
 
9
- export const getTooltipAttributes = (actualTooltip, style) => {
10
- const {spaceRow: commonSpaceRow, padding: padding, title: titleStyle, shape: shapeStyle, key: keyStyle, value: valueStyle} = style, attribute = Object.assign(Object.assign({}, style), {
9
+ const DEFAULT_TEXT_ATTRIBUTES = {
10
+ fontFamily: THEME_CONSTANTS.defaultFontFamily,
11
+ spacing: 10,
12
+ wordBreak: "break-word"
13
+ };
14
+
15
+ export function getTextAttributes(style = {}, globalTheme, defaultAttributes) {
16
+ var _a, _b;
17
+ return Object.assign(Object.assign({}, null != defaultAttributes ? defaultAttributes : DEFAULT_TEXT_ATTRIBUTES), {
18
+ fill: null !== (_a = style.fill) && void 0 !== _a ? _a : style.fontColor,
19
+ textAlign: style.textAlign,
20
+ textBaseline: style.textBaseline,
21
+ fontFamily: null !== (_b = style.fontFamily) && void 0 !== _b ? _b : null == globalTheme ? void 0 : globalTheme.fontFamily,
22
+ fontSize: style.fontSize,
23
+ fontWeight: style.fontWeight,
24
+ lineHeight: style.lineHeight,
25
+ spacing: style.spacing,
26
+ multiLine: style.multiLine,
27
+ maxWidth: style.maxWidth,
28
+ wordBreak: style.wordBreak,
29
+ autoWidth: style.autoWidth
30
+ });
31
+ }
32
+
33
+ export const getPanelAttributes = style => {
34
+ var _a;
35
+ const {backgroundColor: backgroundColor, border: border, shadow: shadow} = style, panelAttrs = {
36
+ lineWidth: null !== (_a = null == border ? void 0 : border.width) && void 0 !== _a ? _a : 0,
37
+ shadow: !!shadow
38
+ };
39
+ (null == border ? void 0 : border.color) && (panelAttrs.stroke = border.color),
40
+ backgroundColor && (panelAttrs.fill = backgroundColor), shadow && (panelAttrs.shadowColor = shadow.color,
41
+ panelAttrs.shadowBlur = shadow.blur, panelAttrs.shadowOffsetX = shadow.x, panelAttrs.shadowOffsetY = shadow.y,
42
+ panelAttrs.shadowSpread = shadow.spread);
43
+ const {radius: radius} = null != border ? border : {};
44
+ return isValid(radius) && (panelAttrs.cornerRadius = [ radius, radius, radius, radius ]),
45
+ panelAttrs;
46
+ };
47
+
48
+ export const getTooltipAttributes = (actualTooltip, spec, globalTheme) => {
49
+ var _a, _b, _c, _d, _e;
50
+ const {style: style = {}, enterable: enterable, transitionDuration: transitionDuration} = spec, {panel: panel = {}, titleLabel: titleLabel, shape: shape, keyLabel: keyLabel, valueLabel: valueLabel, spaceRow: commonSpaceRow} = style, padding = normalizePadding(panel.padding), paddingSpec = normalizeLayoutPaddingSpec(panel.padding), titleStyle = getTextAttributes(titleLabel, globalTheme), keyStyle = getTextAttributes(keyLabel, globalTheme), valueStyle = getTextAttributes(valueLabel, globalTheme), shapeStyle = {
51
+ fill: !0,
52
+ size: null !== (_a = null == shape ? void 0 : shape.size) && void 0 !== _a ? _a : 8,
53
+ spacing: null !== (_b = null == shape ? void 0 : shape.spacing) && void 0 !== _b ? _b : 6
54
+ }, attributes = {
55
+ panel: getPanelAttributes(panel),
56
+ padding: padding,
11
57
  title: {},
12
58
  content: [],
13
59
  titleStyle: {
@@ -22,126 +68,88 @@ export const getTooltipAttributes = (actualTooltip, style) => {
22
68
  },
23
69
  hasContentShape: !1,
24
70
  keyWidth: 0,
25
- valueWidth: 0
26
- });
27
- [ "key", "value", "shape" ].forEach((key => {
28
- delete attribute[key];
29
- }));
30
- const {title: title = {}, content: content = []} = actualTooltip;
31
- let maxWidth = 0, containerHeight = padding.top + padding.bottom, titleMaxHeight = 0;
32
- const {visible: titleVisible = !0, value: titleValue = "", valueStyle: titleValueStyle, hasShape: titleHasShape, shapeType: titleShapeType = "", shapeHollow: titleShapeHollow, shapeColor: titleShapeColor, spaceRow: titleSpaceRow} = title;
33
- if (attribute.title.visible = titleVisible, attribute.title.spaceRow = null != titleSpaceRow ? titleSpaceRow : commonSpaceRow,
34
- titleVisible) {
35
- const lineTitleStyle = mergeSpec({}, titleStyle, getTextAttributes(titleValueStyle, void 0, {})), {text: text, width: width, height: height} = measureTooltipText(titleValue, lineTitleStyle);
36
- if (attribute.title.value = Object.assign(Object.assign({
37
- width: width,
38
- height: height
39
- }, lineTitleStyle), {
40
- text: text
41
- }), maxWidth = width, titleMaxHeight = height, titleHasShape && builtinSymbolsMap[titleShapeType]) {
42
- const titleShapeAttrs = {
43
- symbolType: titleShapeType
71
+ valueWidth: 0,
72
+ enterable: enterable,
73
+ transitionDuration: transitionDuration
74
+ }, {title: title = {}, content: content = []} = actualTooltip;
75
+ let containerWidth = paddingSpec.left + paddingSpec.right, containerHeight = paddingSpec.top + paddingSpec.bottom, contentMaxWidth = 0;
76
+ const filteredContent = content.filter((item => (item.key || item.value) && !1 !== item.visible)), hasContent = !!filteredContent.length;
77
+ let maxKeyWidth = 0, maxAdaptiveKeyWidth = 0, maxValueWidth = 0, maxShapeWidth = 0;
78
+ if (hasContent) {
79
+ const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [], shapeWidths = [];
80
+ attributes.content = filteredContent.map(((item, i) => {
81
+ let itemHeight = 0;
82
+ const {hasShape: actualHasShape, key: actualKey, shapeType: actualShapeType = "", shapeFill: actualShapeFill, shapeStroke: actualShapeStroke, shapeLineWidth: actualShapeLineWidth, shapeSize: actualShapeSize, value: actualValue, isKeyAdaptive: actualIsKeyAdaptive, spaceRow: actualSpaceRow, keyStyle: actualKeyStyle, valueStyle: actualValueStyle, shapeColor: actualShapeColor, shapeHollow: actualShapeHollow} = item, itemAttrs = {
83
+ height: 0,
84
+ spaceRow: null != actualSpaceRow ? actualSpaceRow : commonSpaceRow
44
85
  };
45
- titleShapeHollow ? titleShapeAttrs.stroke = titleShapeColor : titleShapeAttrs.fill = titleShapeColor,
46
- attribute.title.shape = titleShapeAttrs, maxWidth += shapeStyle.size + shapeStyle.spacing,
47
- titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);
48
- }
49
- attribute.title.width = maxWidth, attribute.title.height = titleMaxHeight, containerHeight += titleMaxHeight;
50
- }
51
- if (content.length) {
52
- const filteredContent = content.filter((item => (item.key || item.value) && !1 !== item.visible));
53
- if (filteredContent.length) {
54
- titleVisible && (containerHeight += attribute.title.spaceRow);
55
- const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [], shapeWidths = [];
56
- attribute.content = filteredContent.map(((item, i) => {
57
- let itemHeight = 0;
58
- const {hasShape: hasShape, key: key, shapeColor: shapeColor, shapeHollow: shapeHollow, shapeType: shapeType = "", shapeFill: shapeFill, shapeStroke: shapeStroke, shapeLineWidth: shapeLineWidth, shapeSize: shapeSize, value: value, isKeyAdaptive: isKeyAdaptive, spaceRow: lineSpaceRow} = item, itemAttrs = {
59
- height: 0,
60
- spaceRow: null != lineSpaceRow ? lineSpaceRow : commonSpaceRow
61
- };
62
- if (isValid(key)) {
63
- const lineKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(item.keyStyle, void 0, {})), {width: width, height: height, text: text} = measureTooltipText(key, lineKeyStyle);
64
- itemAttrs.key = Object.assign(Object.assign({
65
- width: width,
66
- height: height
67
- }, lineKeyStyle), {
68
- text: text
69
- }), isKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width), itemHeight = Math.max(itemHeight, height);
70
- }
71
- if (isValid(value)) {
72
- const lineValueStyle = mergeSpec({}, valueStyle, getTextAttributes(item.valueStyle, void 0, {})), {width: width, height: height, text: text} = measureTooltipText(value, lineValueStyle);
73
- itemAttrs.value = Object.assign(Object.assign({
74
- width: width,
75
- height: height
76
- }, lineValueStyle), {
77
- text: text
78
- }), valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
79
- }
80
- if (hasShape) {
81
- const shape = {
82
- visible: !0,
83
- symbolType: shapeType
84
- }, adaptiveShapeFill = null != shapeFill ? shapeFill : shapeColor;
85
- shapeHollow ? shape.stroke = adaptiveShapeFill : shape.fill = adaptiveShapeFill,
86
- shape.stroke = null != shapeStroke ? shapeStroke : adaptiveShapeFill, shape.lineWidth = shapeLineWidth,
87
- itemAttrs.shape = shape;
88
- const shapeWidth = null != shapeSize ? shapeSize : shapeStyle.size;
89
- itemHeight = Math.max(shapeWidth, itemHeight), shapeWidths.push(shapeWidth);
90
- } else itemAttrs.shape = {
91
- visible: !1
92
- };
93
- return itemAttrs.height = itemHeight, containerHeight += itemHeight, i < filteredContent.length - 1 && (containerHeight += itemAttrs.spaceRow),
94
- itemAttrs;
95
- }));
96
- const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0, maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0, shapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0;
97
- maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth, maxAdaptiveKeyWidth + shapeWidth, maxWidth),
98
- attribute.hasContentShape = !!shapeWidths.length, attribute.keyWidth = maxKeyWidth,
99
- attribute.valueWidth = maxValueWidth;
100
- }
86
+ if (isValid(actualKey)) {
87
+ const itemKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(actualKeyStyle, void 0, {})), {width: width, height: height, text: text} = measureTooltipText(actualKey, itemKeyStyle);
88
+ itemAttrs.key = Object.assign(Object.assign({
89
+ width: width,
90
+ height: height
91
+ }, itemKeyStyle), {
92
+ text: text
93
+ }), actualIsKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width),
94
+ itemHeight = Math.max(itemHeight, height);
95
+ }
96
+ if (isValid(actualValue)) {
97
+ const itemValueStyle = mergeSpec({}, valueStyle, getTextAttributes(actualValueStyle, void 0, {})), {width: width, height: height, text: text} = measureTooltipText(actualValue, itemValueStyle);
98
+ itemAttrs.value = Object.assign(Object.assign({
99
+ width: width,
100
+ height: height
101
+ }, itemValueStyle), {
102
+ text: text
103
+ }), valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
104
+ }
105
+ if (actualHasShape) {
106
+ const shape = {
107
+ visible: !0,
108
+ symbolType: actualShapeType
109
+ }, adaptiveShapeFill = null != actualShapeFill ? actualShapeFill : actualShapeColor;
110
+ actualShapeHollow ? shape.stroke = adaptiveShapeFill : shape.fill = adaptiveShapeFill,
111
+ shape.stroke = null != actualShapeStroke ? actualShapeStroke : adaptiveShapeFill,
112
+ shape.lineWidth = actualShapeLineWidth, itemAttrs.shape = shape;
113
+ const shapeWidth = null != actualShapeSize ? actualShapeSize : shapeStyle.size;
114
+ itemHeight = Math.max(shapeWidth, itemHeight), shapeWidths.push(shapeWidth);
115
+ } else itemAttrs.shape = {
116
+ visible: !1
117
+ };
118
+ return itemAttrs.height = itemHeight, containerHeight += itemHeight, i < filteredContent.length - 1 && (containerHeight += itemAttrs.spaceRow),
119
+ itemAttrs;
120
+ })), maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0,
121
+ maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0, maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0,
122
+ contentMaxWidth = Math.max(maxShapeWidth + maxKeyWidth + keyStyle.spacing + maxValueWidth + valueStyle.spacing, maxShapeWidth + maxAdaptiveKeyWidth, contentMaxWidth),
123
+ attributes.hasContentShape = !!shapeWidths.length, attributes.keyWidth = maxKeyWidth,
124
+ attributes.valueWidth = maxValueWidth;
101
125
  }
102
- const containerSize = {
103
- width: maxWidth + padding.left + padding.right,
104
- height: containerHeight
105
- };
106
- return attribute.panel.width = containerSize.width, attribute.panel.height = containerSize.height,
107
- attribute;
108
- };
109
-
110
- export const measureTooltipText = (text, style) => {
111
- var _a;
112
- text = (null != text ? text : "").toString();
113
- const measure = initTextMeasure(style);
114
- if (!style.multiLine) {
115
- const {width: width, height: height} = measure.fullMeasure(text);
116
- return {
117
- width: width,
118
- height: height,
126
+ let titleMaxWidth = 0, titleMaxHeight = 0;
127
+ const {visible: actualTitleVisible = !0, value: actualTitleValue = "", valueStyle: actualTitleValueStyle, spaceRow: actualTitleSpaceRow} = title;
128
+ attributes.title.visible = actualTitleVisible, attributes.title.spaceRow = null != actualTitleSpaceRow ? actualTitleSpaceRow : commonSpaceRow;
129
+ let titleValueStyle = {};
130
+ const isAutoWidthMode = () => titleValueStyle.autoWidth && !1 !== titleValueStyle.multiLine;
131
+ if (actualTitleVisible) {
132
+ titleValueStyle = mergeSpec({}, titleStyle, getTextAttributes(actualTitleValueStyle, void 0, {})),
133
+ isAutoWidthMode() && (titleValueStyle.multiLine = null === (_c = titleValueStyle.multiLine) || void 0 === _c || _c,
134
+ titleValueStyle.maxWidth = null !== (_d = titleValueStyle.maxWidth) && void 0 !== _d ? _d : hasContent ? Math.ceil(contentMaxWidth) : void 0);
135
+ const {text: text, width: width, height: height} = measureTooltipText(actualTitleValue, titleValueStyle);
136
+ attributes.title.value = Object.assign(Object.assign({
137
+ width: isAutoWidthMode() ? Math.min(width, null !== (_e = titleValueStyle.maxWidth) && void 0 !== _e ? _e : Number.MAX_VALUE) : width,
138
+ height: height
139
+ }, titleValueStyle), {
119
140
  text: text
120
- };
141
+ }), titleMaxWidth = attributes.title.value.width, titleMaxHeight = attributes.title.value.height,
142
+ containerHeight += titleMaxHeight + (hasContent ? attributes.title.spaceRow : 0);
121
143
  }
122
- let textLines = text.split("\n");
123
- textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line));
124
- const {width: width, height: height} = measure.fullMeasure(textLines);
125
- if (style.maxWidth && style.maxWidth <= width) {
126
- const bound = getRichTextBounds({
127
- wordBreak: null !== (_a = style.wordBreak) && void 0 !== _a ? _a : "break-word",
128
- maxWidth: style.maxWidth,
129
- width: 0,
130
- height: 0,
131
- textConfig: textLines.map(((line, i) => Object.assign(Object.assign({}, style), {
132
- text: line
133
- })))
134
- });
135
- return {
136
- width: bound.width(),
137
- height: bound.height(),
138
- text: textLines
139
- };
140
- }
141
- return {
142
- width: width,
143
- height: height,
144
- text: textLines
145
- };
144
+ return attributes.title.width = titleMaxWidth, attributes.title.height = titleMaxHeight,
145
+ isAutoWidthMode() ? containerWidth += contentMaxWidth || titleMaxWidth : containerWidth += Math.max(titleMaxWidth, contentMaxWidth),
146
+ hasContent && attributes.content.forEach((item => {
147
+ var _a;
148
+ const value = item.value;
149
+ value && (null === (_a = value.autoWidth) || void 0 === _a || _a) && (value.width = containerWidth - paddingSpec.left - paddingSpec.right - maxShapeWidth - maxKeyWidth - keyStyle.spacing - valueStyle.spacing,
150
+ value.multiLine = !0, value.maxWidth || (value.maxWidth = Math.ceil(value.width)),
151
+ attributes.valueWidth = Math.max(attributes.valueWidth, value.width));
152
+ })), attributes.panel.width = containerWidth, attributes.panel.height = containerHeight,
153
+ attributes;
146
154
  };
147
155
  //# sourceMappingURL=attribute.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAA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EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAEzD,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,EAAE;QAE7C,MAAM,KAAK,GAAG,iBAAiB,CAAC;YAC9B,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,YAAY;YAC1C,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,UAAU,EAAE,SAAS,CAAC,GAAG,CACvB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CACV,CAAC,gCACI,KAAK,KACR,IAAI,EAAE,IAAI,GACgC,CAAA,CAC/C;SACF,CAAC,CAAC;QACH,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;YACtB,IAAI,EAAE,SAAS;SAChB,CAAC;KACH;IAED,OAAO;QACL,KAAK;QACL,MAAM;QACN,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipRowAttrs,\n TooltipSymbolAttrs\n} from '@visactor/vrender-components';\nimport type { IToolTipActual, MaybeArray } from '../../../../typings';\nimport type { ITooltipStyle, ITooltipTextStyle } from '../interface';\nimport { isValid } from '@visactor/vutils';\nimport { initTextMeasure, mergeSpec } from '../../../../util';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { builtinSymbolsMap, getRichTextBounds } from '@visactor/vrender-core';\nimport { getTextAttributes } from './style';\n\nexport const getTooltipAttributes = (\n actualTooltip: IToolTipActual,\n style: Partial<ITooltipStyle>\n): TooltipAttributes => {\n const {\n spaceRow: commonSpaceRow,\n padding,\n title: titleStyle,\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle\n } = style;\n\n const attribute: TooltipAttributes = {\n ...style,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow: commonSpaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow: commonSpaceRow\n },\n\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0\n };\n (['key', 'value', 'shape'] as (keyof ITooltipStyle)[]).forEach(key => {\n delete attribute[key];\n });\n\n const { title = {}, content = [] } = actualTooltip;\n\n let maxWidth = 0;\n let containerHeight = padding.top + padding.bottom;\n\n // calculate title\n let titleMaxHeight = 0;\n const {\n visible: titleVisible = true,\n value: titleValue = '',\n valueStyle: titleValueStyle,\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor,\n spaceRow: titleSpaceRow\n } = title;\n attribute.title.visible = titleVisible;\n attribute.title.spaceRow = titleSpaceRow ?? commonSpaceRow;\n if (titleVisible) {\n const lineTitleStyle = mergeSpec({}, titleStyle, getTextAttributes(titleValueStyle, undefined, {}));\n const { text, width, height } = measureTooltipText(titleValue, lineTitleStyle);\n attribute.title.value = {\n width,\n height,\n ...lineTitleStyle,\n text\n };\n maxWidth = width;\n titleMaxHeight = height;\n\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n const titleShapeAttrs: TooltipSymbolAttrs = {\n symbolType: titleShapeType\n };\n if (titleShapeHollow) {\n titleShapeAttrs.stroke = titleShapeColor;\n } else {\n titleShapeAttrs.fill = titleShapeColor;\n }\n attribute.title.shape = titleShapeAttrs;\n maxWidth += shapeStyle.size + shapeStyle.spacing;\n titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n containerHeight += titleMaxHeight;\n }\n\n // calculate content\n if (content.length) {\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n if (filteredContent.length) {\n if (titleVisible) {\n containerHeight += attribute.title.spaceRow; // title 与 content 之前的间隔\n }\n\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n const shapeWidths: number[] = [];\n\n attribute.content = filteredContent.map((item, i) => {\n let itemHeight = 0;\n const {\n hasShape,\n key,\n shapeColor,\n shapeHollow,\n shapeType = '',\n shapeFill,\n shapeStroke,\n shapeLineWidth,\n shapeSize,\n value,\n isKeyAdaptive,\n spaceRow: lineSpaceRow\n } = item;\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow: lineSpaceRow ?? commonSpaceRow };\n if (isValid(key)) {\n const lineKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(item.keyStyle, undefined, {}));\n const { width, height, text } = measureTooltipText(key, lineKeyStyle);\n itemAttrs.key = {\n width,\n height,\n ...lineKeyStyle,\n text\n };\n if (!isKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(value)) {\n const lineValueStyle = mergeSpec({}, valueStyle, getTextAttributes(item.valueStyle, undefined, {}));\n const { width, height, text } = measureTooltipText(value, lineValueStyle);\n itemAttrs.value = {\n width,\n height,\n ...lineValueStyle,\n text\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (hasShape) {\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: shapeType\n };\n const adaptiveShapeFill = shapeFill ?? shapeColor;\n if (shapeHollow) {\n shape.stroke = adaptiveShapeFill;\n } else {\n shape.fill = adaptiveShapeFill;\n }\n shape.stroke = shapeStroke ?? adaptiveShapeFill;\n shape.lineWidth = shapeLineWidth;\n itemAttrs.shape = shape;\n\n const shapeWidth = shapeSize ?? shapeStyle.size;\n itemHeight = Math.max(shapeWidth, itemHeight);\n shapeWidths.push(shapeWidth);\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += itemAttrs.spaceRow;\n }\n\n return itemAttrs;\n });\n\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n const shapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0; // shape 列宽度\n maxWidth = Math.max(\n maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth,\n maxAdaptiveKeyWidth + shapeWidth,\n maxWidth\n );\n attribute.hasContentShape = !!shapeWidths.length;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n const containerSize: IContainerSize = {\n width: maxWidth + padding.left + padding.right,\n height: containerHeight\n };\n\n attribute.panel.width = containerSize.width;\n attribute.panel.height = containerSize.height;\n return attribute;\n};\n\ninterface ITooltipTextInfo {\n width: number;\n height: number;\n text: MaybeArray<number> | MaybeArray<string>;\n}\n\nexport const measureTooltipText = (text: string, style: ITooltipTextStyle): ITooltipTextInfo => {\n text = (text ?? '').toString();\n const measure = initTextMeasure(style as any);\n if (!style.multiLine) {\n // 单行文本\n const { width, height } = measure.fullMeasure(text);\n return {\n width,\n height,\n text\n };\n }\n // 多行文本\n let textLines = text.split('\\n');\n textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\\n' : line));\n const { width, height } = measure.fullMeasure(textLines);\n\n if (style.maxWidth && style.maxWidth <= width) {\n // 允许自动换行的情况,改用 richText 测量\n const bound = getRichTextBounds({\n wordBreak: style.wordBreak ?? 'break-word',\n maxWidth: style.maxWidth,\n width: 0,\n height: 0,\n textConfig: textLines.map(\n (line, i) =>\n ({\n ...style,\n text: line\n } as unknown as IRichTextParagraphCharacter)\n )\n });\n return {\n width: bound.width(),\n height: bound.height(),\n text: textLines\n };\n }\n\n return {\n width,\n height,\n text: textLines\n };\n};\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAIzE,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,uBAAuB,GAA+B;IAC1D,UAAU,EAAE,eAAe,CAAC,iBAAiB;IAC7C,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,YAAY;CACxB,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAC/B,QAA2B,EAAE,EAC7B,WAAoB,EACpB,iBAA8C;;IAE9C,MAAM,KAAK,mCACN,CAAC,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,uBAAuB,CAAC,KACjD,IAAI,EAAE,CAAC,MAAA,KAAK,CAAC,IAAI,mCAAI,KAAK,CAAC,SAAS,CAAW,EAC/C,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,UAAU,EAAE,MAAA,KAAK,CAAC,UAAU,mCAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,EACvD,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,UAAU,EAAE,KAAK,CAAC,UAAiB,EACnC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,GAC3B,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;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AAC,CAAC,CAAC,aAAa,CAAC;KACrE;SAAM;QACL,cAAc,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;KAC5D;IAGD,IAAI,UAAU,EAAE;QACd,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;;YAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAA6C,CAAC;YAEjE,IAAI,KAAK,IAAI,CAAC,MAAA,KAAK,CAAC,SAAS,mCAAI,IAAI,CAAC,EAAE;gBACtC,KAAK,CAAC,KAAK;oBACT,cAAc;wBACd,WAAW,CAAC,IAAI;wBAChB,WAAW,CAAC,KAAK;wBACjB,aAAa;wBACb,WAAW;wBACX,QAAQ,CAAC,OAAO;wBAChB,UAAU,CAAC,OAAO,CAAC;gBACrB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;gBACvB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACnB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACzC;gBACD,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;aACtE;QACH,CAAC,CAAC,CAAC;KACJ;IAED,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,cAAc,CAAC;IACxC,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC;IAE1C,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipPanelAttrs,\n TooltipRowAttrs,\n TooltipRowStyleAttrs,\n TooltipSymbolAttrs,\n TooltipTextAttrs\n} from '@visactor/vrender-components';\nimport type { IPadding, IToolTipActual } from '../../../../typings';\nimport type { ITooltipTextStyle } from '../interface';\nimport { isValid, normalizePadding } from '@visactor/vutils';\nimport { mergeSpec, normalizeLayoutPaddingSpec } from '../../../../util';\nimport type { ITooltipSpec } from '../../interface/spec';\nimport type { ITheme } from '../../../../theme';\nimport type { ITooltipTextTheme, ITooltipTheme } from '../../interface/theme';\nimport { THEME_CONSTANTS } from '../../../../theme/builtin/common/constants';\nimport { measureTooltipText } from './common';\n\nconst DEFAULT_TEXT_ATTRIBUTES: Partial<ITooltipTextStyle> = {\n fontFamily: THEME_CONSTANTS.defaultFontFamily,\n spacing: 10,\n wordBreak: 'break-word'\n};\n\nexport function getTextAttributes(\n style: ITooltipTextTheme = {},\n globalTheme?: ITheme,\n defaultAttributes?: Partial<ITooltipTextStyle>\n): ITooltipTextStyle {\n const attrs: ITooltipTextStyle = {\n ...(defaultAttributes ?? DEFAULT_TEXT_ATTRIBUTES),\n fill: (style.fill ?? style.fontColor) as string,\n textAlign: style.textAlign,\n textBaseline: style.textBaseline,\n fontFamily: style.fontFamily ?? globalTheme?.fontFamily,\n fontSize: style.fontSize,\n fontWeight: style.fontWeight,\n lineHeight: style.lineHeight as any, // FIXME: vrender 支持行高字符串后删除 any\n spacing: style.spacing,\n multiLine: style.multiLine,\n maxWidth: style.maxWidth,\n wordBreak: style.wordBreak,\n autoWidth: style.autoWidth\n };\n return attrs;\n}\n\nexport const getPanelAttributes = (style: ITooltipTheme['panel']): TooltipPanelAttrs => {\n const { backgroundColor, border, shadow } = style;\n const panelAttrs: TooltipPanelAttrs = {\n lineWidth: border?.width ?? 0,\n shadow: !!shadow\n };\n if (border?.color) {\n panelAttrs.stroke = border.color as string;\n }\n if (backgroundColor) {\n panelAttrs.fill = backgroundColor as string;\n }\n if (shadow) {\n panelAttrs.shadowColor = shadow.color as string;\n panelAttrs.shadowBlur = shadow.blur;\n panelAttrs.shadowOffsetX = shadow.x;\n panelAttrs.shadowOffsetY = shadow.y;\n panelAttrs.shadowSpread = shadow.spread;\n }\n const { radius } = border ?? {};\n if (isValid(radius)) {\n panelAttrs.cornerRadius = [radius, radius, radius, radius];\n }\n return panelAttrs;\n};\n\nexport const getTooltipAttributes = (\n actualTooltip: IToolTipActual,\n spec: ITooltipSpec,\n globalTheme: ITheme\n): TooltipAttributes => {\n const { style = {}, enterable, transitionDuration } = spec;\n const { panel = {}, titleLabel, shape, keyLabel, valueLabel, spaceRow: commonSpaceRow } = style;\n const padding = normalizePadding(panel.padding);\n const paddingSpec = normalizeLayoutPaddingSpec(panel.padding) as IPadding;\n\n const titleStyle = getTextAttributes(titleLabel, globalTheme);\n const keyStyle = getTextAttributes(keyLabel, globalTheme);\n const valueStyle = getTextAttributes(valueLabel, globalTheme);\n const shapeStyle: TooltipRowStyleAttrs['shape'] = {\n fill: true,\n size: shape?.size ?? 8,\n spacing: shape?.spacing ?? 6\n };\n\n const attributes: TooltipAttributes = {\n panel: getPanelAttributes(panel),\n padding,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow: commonSpaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow: commonSpaceRow\n },\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0,\n\n enterable,\n transitionDuration\n };\n\n const { title = {}, content = [] } = actualTooltip;\n\n let containerWidth = paddingSpec.left + paddingSpec.right;\n let containerHeight = paddingSpec.top + paddingSpec.bottom;\n\n // calculate content\n let contentMaxWidth = 0;\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n const hasContent = !!filteredContent.length;\n let maxKeyWidth = 0;\n let maxAdaptiveKeyWidth = 0;\n let maxValueWidth = 0;\n let maxShapeWidth = 0;\n\n if (hasContent) {\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n const shapeWidths: number[] = [];\n\n attributes.content = filteredContent.map((item, i) => {\n let itemHeight = 0;\n const {\n hasShape: actualHasShape,\n key: actualKey,\n shapeType: actualShapeType = '',\n shapeFill: actualShapeFill,\n shapeStroke: actualShapeStroke,\n shapeLineWidth: actualShapeLineWidth,\n shapeSize: actualShapeSize,\n value: actualValue,\n isKeyAdaptive: actualIsKeyAdaptive,\n spaceRow: actualSpaceRow,\n keyStyle: actualKeyStyle,\n valueStyle: actualValueStyle,\n // 弃用的属性,做下兼容\n shapeColor: actualShapeColor,\n shapeHollow: actualShapeHollow\n } = item;\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow: actualSpaceRow ?? commonSpaceRow };\n if (isValid(actualKey)) {\n const itemKeyStyle: ITooltipTextStyle = mergeSpec(\n {},\n keyStyle,\n getTextAttributes(actualKeyStyle, undefined, {})\n );\n const { width, height, text } = measureTooltipText(actualKey, itemKeyStyle);\n itemAttrs.key = {\n width,\n height,\n ...itemKeyStyle,\n text\n };\n if (!actualIsKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(actualValue)) {\n const itemValueStyle: ITooltipTextStyle = mergeSpec(\n {},\n valueStyle,\n getTextAttributes(actualValueStyle, undefined, {})\n );\n const { width, height, text } = measureTooltipText(actualValue, itemValueStyle);\n itemAttrs.value = {\n width,\n height,\n ...itemValueStyle,\n text\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (actualHasShape) {\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: actualShapeType\n };\n const adaptiveShapeFill = actualShapeFill ?? actualShapeColor;\n if (actualShapeHollow) {\n shape.stroke = adaptiveShapeFill;\n } else {\n shape.fill = adaptiveShapeFill;\n }\n shape.stroke = actualShapeStroke ?? adaptiveShapeFill;\n shape.lineWidth = actualShapeLineWidth;\n itemAttrs.shape = shape;\n\n const shapeWidth = actualShapeSize ?? shapeStyle.size;\n itemHeight = Math.max(shapeWidth, itemHeight);\n shapeWidths.push(shapeWidth);\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += itemAttrs.spaceRow;\n }\n\n return itemAttrs;\n });\n\n maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0; // shape 列宽度\n contentMaxWidth = Math.max(\n maxShapeWidth + maxKeyWidth + keyStyle.spacing + maxValueWidth + valueStyle.spacing,\n maxShapeWidth + maxAdaptiveKeyWidth,\n contentMaxWidth\n );\n attributes.hasContentShape = !!shapeWidths.length;\n attributes.keyWidth = maxKeyWidth;\n attributes.valueWidth = maxValueWidth;\n }\n\n // calculate title\n let titleMaxWidth = 0;\n let titleMaxHeight = 0;\n const {\n visible: actualTitleVisible = true,\n value: actualTitleValue = '',\n valueStyle: actualTitleValueStyle,\n spaceRow: actualTitleSpaceRow\n } = title;\n attributes.title.visible = actualTitleVisible;\n attributes.title.spaceRow = actualTitleSpaceRow ?? commonSpaceRow;\n\n let titleValueStyle: ITooltipTextStyle = {};\n // 当前是否处于自适应宽度模式\n const isAutoWidthMode = () => titleValueStyle.autoWidth && titleValueStyle.multiLine !== false;\n if (actualTitleVisible) {\n titleValueStyle = mergeSpec({}, titleStyle, getTextAttributes(actualTitleValueStyle, undefined, {}));\n // 标题默认优化策略:如果 autoWidth 为 true,则宽度默认跟随 content 宽度并开启自动换行\n if (isAutoWidthMode()) {\n titleValueStyle.multiLine = titleValueStyle.multiLine ?? true;\n titleValueStyle.maxWidth = titleValueStyle.maxWidth ?? (hasContent ? Math.ceil(contentMaxWidth) : undefined);\n }\n\n const { text, width, height } = measureTooltipText(actualTitleValue, titleValueStyle);\n attributes.title.value = {\n width: isAutoWidthMode() ? Math.min(width, titleValueStyle.maxWidth ?? Number.MAX_VALUE) : width,\n height,\n ...titleValueStyle,\n text\n };\n titleMaxWidth = attributes.title.value.width;\n titleMaxHeight = attributes.title.value.height;\n\n containerHeight += titleMaxHeight + (hasContent ? attributes.title.spaceRow : 0);\n }\n attributes.title.width = titleMaxWidth;\n attributes.title.height = titleMaxHeight;\n\n if (isAutoWidthMode()) {\n containerWidth += contentMaxWidth ? contentMaxWidth : titleMaxWidth;\n } else {\n containerWidth += Math.max(titleMaxWidth, contentMaxWidth);\n }\n\n // 处理 content 的自动宽度模式\n if (hasContent) {\n attributes.content.forEach(item => {\n const value = item.value as ITooltipTextStyle & TooltipTextAttrs;\n // 最后一列默认自适应宽度\n if (value && (value.autoWidth ?? true)) {\n value.width =\n containerWidth -\n paddingSpec.left -\n paddingSpec.right -\n maxShapeWidth -\n maxKeyWidth -\n keyStyle.spacing -\n valueStyle.spacing;\n value.multiLine = true;\n if (!value.maxWidth) {\n value.maxWidth = Math.ceil(value.width);\n }\n attributes.valueWidth = Math.max(attributes.valueWidth, value.width);\n }\n });\n }\n\n attributes.panel.width = containerWidth;\n attributes.panel.height = containerHeight;\n\n return attributes;\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Datum } from '@visactor/vgrammar-core';
2
2
  import type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';
3
3
  import type { TooltipHandlerParams } from '../../interface';
4
+ import type { ITooltipTextStyle } from '../interface/style';
4
5
  export declare function escapeHTML(value: any): string;
5
6
  export declare const getTooltipContentValue: <T>(field?: TooltipContentProperty<T>, datum?: any, params?: TooltipHandlerParams) => T;
6
7
  export declare const getTooltipPatternValue: <T>(field?: MaybeArray<TooltipPatternProperty<T>>, data?: TooltipData, params?: TooltipHandlerParams) => MaybeArray<TooltipPatternProperty<T>> extends TooltipPatternProperty<T>[] ? MaybeArray<T> : T;
@@ -8,3 +9,10 @@ export declare function getFirstDatumFromTooltipData(data: TooltipData): Datum;
8
9
  export declare function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined;
9
10
  export declare function convertToColorString(color: any, defaultColor?: string): string;
10
11
  export declare const getScale: (element: HTMLElement, boundingClientRect?: DOMRect) => number;
12
+ interface ITooltipTextInfo {
13
+ width: number;
14
+ height: number;
15
+ text: MaybeArray<number> | MaybeArray<string>;
16
+ }
17
+ export declare const measureTooltipText: (text: string, style: ITooltipTextStyle) => ITooltipTextInfo;
18
+ export {};