@visactor/vrender-components 1.0.47-alpha.0 → 1.1.0-alpha.1

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/cjs/axis/base.js +9 -9
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/axis/circle.js +3 -3
  4. package/cjs/axis/circle.js.map +1 -1
  5. package/cjs/axis/grid/base.js +5 -5
  6. package/cjs/axis/grid/base.js.map +1 -1
  7. package/cjs/axis/line.js +6 -6
  8. package/cjs/axis/line.js.map +1 -1
  9. package/cjs/brush/brush.js +2 -2
  10. package/cjs/brush/brush.js.map +1 -1
  11. package/cjs/brush/config.js +2 -1
  12. package/cjs/checkbox/index.js +1 -2
  13. package/cjs/core/base.js +2 -2
  14. package/cjs/core/base.js.map +1 -1
  15. package/cjs/crosshair/sector.js +1 -2
  16. package/cjs/data-zoom/config.js +2 -1
  17. package/cjs/data-zoom/renderer.js.map +1 -1
  18. package/cjs/empty-tip/empty-tip.js.map +1 -1
  19. package/cjs/index.d.ts +1 -1
  20. package/cjs/index.js +1 -1
  21. package/cjs/index.js.map +1 -1
  22. package/cjs/label/arc.js +1 -1
  23. package/cjs/label/base.js +2 -2
  24. package/cjs/label/base.js.map +1 -1
  25. package/cjs/label-item/index.js +1 -1
  26. package/cjs/legend/base.js +2 -2
  27. package/cjs/legend/base.js.map +1 -1
  28. package/cjs/legend/discrete/discrete.js +10 -10
  29. package/cjs/legend/discrete/discrete.js.map +1 -1
  30. package/cjs/legend/size/size.js +3 -3
  31. package/cjs/legend/size/size.js.map +1 -1
  32. package/cjs/marker/arc-area.js +2 -2
  33. package/cjs/marker/arc-area.js.map +1 -1
  34. package/cjs/marker/area.js +2 -2
  35. package/cjs/marker/area.js.map +1 -1
  36. package/cjs/marker/base.js +4 -4
  37. package/cjs/marker/base.js.map +1 -1
  38. package/cjs/marker/point.d.ts +1 -1
  39. package/cjs/marker/point.js +6 -6
  40. package/cjs/marker/point.js.map +1 -1
  41. package/cjs/pager/pager.js +5 -5
  42. package/cjs/pager/pager.js.map +1 -1
  43. package/cjs/poptip/contribution.js +3 -10
  44. package/cjs/poptip/contribution.js.map +1 -1
  45. package/cjs/poptip/index.d.ts +1 -1
  46. package/cjs/poptip/index.js +2 -11
  47. package/cjs/poptip/index.js.map +1 -1
  48. package/cjs/poptip/module.d.ts +2 -2
  49. package/cjs/poptip/module.js +17 -10
  50. package/cjs/poptip/module.js.map +1 -1
  51. package/cjs/poptip/poptip-plugin.js +5 -12
  52. package/cjs/poptip/poptip-plugin.js.map +1 -1
  53. package/cjs/poptip/register.js.map +1 -1
  54. package/cjs/scrollbar/module.d.ts +2 -2
  55. package/cjs/scrollbar/module.js +13 -6
  56. package/cjs/scrollbar/module.js.map +1 -1
  57. package/cjs/scrollbar/scrollbar-plugin.js +5 -12
  58. package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
  59. package/cjs/segment/arc-segment.js +2 -2
  60. package/cjs/segment/arc-segment.js.map +1 -1
  61. package/cjs/segment/segment.js +5 -5
  62. package/cjs/segment/segment.js.map +1 -1
  63. package/cjs/slider/slider.d.ts +0 -1
  64. package/cjs/slider/slider.js +25 -20
  65. package/cjs/slider/slider.js.map +1 -1
  66. package/cjs/util/graphic-creator.d.ts +14 -0
  67. package/cjs/util/graphic-creator.js +22 -0
  68. package/cjs/util/graphic-creator.js.map +1 -0
  69. package/cjs/util/text.js +3 -3
  70. package/cjs/util/text.js.map +1 -1
  71. package/dist/index.es.js +11618 -11248
  72. package/es/axis/base.js +3 -1
  73. package/es/axis/base.js.map +1 -1
  74. package/es/axis/circle.js +1 -1
  75. package/es/axis/circle.js.map +1 -1
  76. package/es/axis/grid/base.js +1 -1
  77. package/es/axis/grid/base.js.map +1 -1
  78. package/es/axis/line.js +1 -1
  79. package/es/axis/line.js.map +1 -1
  80. package/es/brush/brush.js +1 -1
  81. package/es/brush/brush.js.map +1 -1
  82. package/es/brush/config.js +2 -1
  83. package/es/checkbox/index.js +1 -2
  84. package/es/core/base.js +2 -2
  85. package/es/core/base.js.map +1 -1
  86. package/es/crosshair/sector.js +1 -2
  87. package/es/data-zoom/config.js +2 -1
  88. package/es/data-zoom/renderer.js.map +1 -1
  89. package/es/empty-tip/empty-tip.js.map +1 -1
  90. package/es/index.d.ts +1 -1
  91. package/es/index.js +1 -1
  92. package/es/index.js.map +1 -1
  93. package/es/label/arc.js +1 -1
  94. package/es/label/base.js +3 -1
  95. package/es/label/base.js.map +1 -1
  96. package/es/label-item/index.js +1 -1
  97. package/es/legend/base.js +1 -1
  98. package/es/legend/base.js.map +1 -1
  99. package/es/legend/discrete/discrete.js +1 -1
  100. package/es/legend/discrete/discrete.js.map +1 -1
  101. package/es/legend/size/size.js +1 -1
  102. package/es/legend/size/size.js.map +1 -1
  103. package/es/marker/arc-area.js +1 -1
  104. package/es/marker/arc-area.js.map +1 -1
  105. package/es/marker/area.js +1 -1
  106. package/es/marker/area.js.map +1 -1
  107. package/es/marker/base.js +1 -1
  108. package/es/marker/base.js.map +1 -1
  109. package/es/marker/point.d.ts +1 -1
  110. package/es/marker/point.js +1 -1
  111. package/es/marker/point.js.map +1 -1
  112. package/es/pager/pager.js +1 -1
  113. package/es/pager/pager.js.map +1 -1
  114. package/es/poptip/contribution.js +2 -14
  115. package/es/poptip/contribution.js.map +1 -1
  116. package/es/poptip/index.d.ts +1 -1
  117. package/es/poptip/index.js +1 -1
  118. package/es/poptip/index.js.map +1 -1
  119. package/es/poptip/module.d.ts +2 -2
  120. package/es/poptip/module.js +14 -8
  121. package/es/poptip/module.js.map +1 -1
  122. package/es/poptip/poptip-plugin.js +5 -19
  123. package/es/poptip/poptip-plugin.js.map +1 -1
  124. package/es/poptip/register.js.map +1 -1
  125. package/es/scrollbar/module.d.ts +2 -2
  126. package/es/scrollbar/module.js +11 -5
  127. package/es/scrollbar/module.js.map +1 -1
  128. package/es/scrollbar/scrollbar-plugin.js +5 -13
  129. package/es/scrollbar/scrollbar-plugin.js.map +1 -1
  130. package/es/segment/arc-segment.js +1 -1
  131. package/es/segment/arc-segment.js.map +1 -1
  132. package/es/segment/segment.js +1 -1
  133. package/es/segment/segment.js.map +1 -1
  134. package/es/slider/slider.d.ts +0 -1
  135. package/es/slider/slider.js +15 -8
  136. package/es/slider/slider.js.map +1 -1
  137. package/es/util/graphic-creator.d.ts +14 -0
  138. package/es/util/graphic-creator.js +18 -0
  139. package/es/util/graphic-creator.js.map +1 -0
  140. package/es/util/text.js +3 -1
  141. package/es/util/text.js.map +1 -1
  142. package/package.json +11 -10
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.graphicCreator = void 0;
6
+
7
+ const vrender_core_1 = require("@visactor/vrender-core"), createGraphic = vrender_core_1.createGraphic;
8
+
9
+ exports.graphicCreator = {
10
+ arc: attributes => createGraphic("arc", attributes),
11
+ circle: attributes => createGraphic("circle", attributes),
12
+ group: attributes => createGraphic("group", attributes),
13
+ image: attributes => createGraphic("image", attributes),
14
+ line: attributes => createGraphic("line", attributes),
15
+ path: attributes => createGraphic("path", attributes),
16
+ polygon: attributes => createGraphic("polygon", attributes),
17
+ rect: attributes => createGraphic("rect", attributes),
18
+ richtext: attributes => createGraphic("richtext", attributes),
19
+ symbol: attributes => createGraphic("symbol", attributes),
20
+ text: attributes => createGraphic("text", attributes)
21
+ };
22
+ //# sourceMappingURL=graphic-creator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/util/graphic-creator.ts"],"names":[],"mappings":";;;AAwBA,yDAA4E;AAE5E,MAAM,aAAa,GAAG,4BAA+F,CAAC;AAEzG,QAAA,cAAc,GAAG;IAC5B,GAAG,EAAE,CAAC,UAAgC,EAAQ,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC;IACjF,MAAM,EAAE,CAAC,UAAmC,EAAW,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC7F,KAAK,EAAE,CAAC,UAAkC,EAAU,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC;IACzF,KAAK,EAAE,CAAC,UAAkC,EAAU,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC;IACzF,IAAI,EAAE,CAAC,UAAiC,EAAS,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC;IACrF,IAAI,EAAE,CAAC,UAAiC,EAAS,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC;IACrF,OAAO,EAAE,CAAC,UAAoC,EAAY,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC;IACjG,IAAI,EAAE,CAAC,UAAiC,EAAS,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC;IACrF,QAAQ,EAAE,CAAC,UAAqC,EAAa,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC;IACrG,MAAM,EAAE,CAAC,UAAmC,EAAW,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC7F,IAAI,EAAE,CAAC,UAAiC,EAAS,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC;CACtF,CAAC","file":"graphic-creator.js","sourcesContent":["import type {\n IArc,\n IArcGraphicAttribute,\n ICircle,\n ICircleGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImage,\n IImageGraphicAttribute,\n ILine,\n ILineGraphicAttribute,\n IPath,\n IPathGraphicAttribute,\n IPolygon,\n IPolygonGraphicAttribute,\n IRect,\n IRectGraphicAttribute,\n IRichText,\n IRichTextGraphicAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n IText,\n ITextGraphicAttribute\n} from '@visactor/vrender-core';\nimport { createGraphic as createCoreGraphic } from '@visactor/vrender-core';\n\nconst createGraphic = createCoreGraphic as <TGraphic, TAttributes>(type: string, attributes: TAttributes) => TGraphic;\n\nexport const graphicCreator = {\n arc: (attributes: IArcGraphicAttribute): IArc => createGraphic('arc', attributes),\n circle: (attributes: ICircleGraphicAttribute): ICircle => createGraphic('circle', attributes),\n group: (attributes: IGroupGraphicAttribute): IGroup => createGraphic('group', attributes),\n image: (attributes: IImageGraphicAttribute): IImage => createGraphic('image', attributes),\n line: (attributes: ILineGraphicAttribute): ILine => createGraphic('line', attributes),\n path: (attributes: IPathGraphicAttribute): IPath => createGraphic('path', attributes),\n polygon: (attributes: IPolygonGraphicAttribute): IPolygon => createGraphic('polygon', attributes),\n rect: (attributes: IRectGraphicAttribute): IRect => createGraphic('rect', attributes),\n richtext: (attributes: IRichTextGraphicAttribute): IRichText => createGraphic('richtext', attributes),\n symbol: (attributes: ISymbolGraphicAttribute): ISymbol => createGraphic('symbol', attributes),\n text: (attributes: ITextGraphicAttribute): IText => createGraphic('text', attributes)\n};\n"]}
package/cjs/util/text.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.alignTextInLine = exports.createTextGraphicByType = exports.reactAttributeTransform = exports.htmlAttributeTransform = exports.richTextAttributeTransform = exports.getTextType = exports.isRichText = exports.measureTextSize = exports.initTextMeasure = void 0;
6
6
 
7
- const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), constant_1 = require("../constant"), initTextMeasure = (textSpec, option, useNaiveCanvas, defaultFontParams) => new vutils_1.TextMeasure(Object.assign({
7
+ const vrender_core_1 = require("@visactor/vrender-core"), graphic_creator_1 = require("./graphic-creator"), vutils_1 = require("@visactor/vutils"), constant_1 = require("../constant"), initTextMeasure = (textSpec, option, useNaiveCanvas, defaultFontParams) => new vutils_1.TextMeasure(Object.assign({
8
8
  defaultFontParams: Object.assign({
9
9
  fontFamily: constant_1.DEFAULT_TEXT_FONT_FAMILY,
10
10
  fontSize: constant_1.DEFAULT_TEXT_FONT_SIZE
@@ -66,8 +66,8 @@ function reactAttributeTransform(attributes) {
66
66
 
67
67
  function createTextGraphicByType(textAttributes, typeKey = "type") {
68
68
  const textType = getTextType(textAttributes, typeKey);
69
- return "rich" === textType ? vrender_core_1.graphicCreator.richtext(richTextAttributeTransform(textAttributes)) : ("html" === textType ? textAttributes = htmlAttributeTransform(textAttributes) : "react" === textType && (textAttributes = reactAttributeTransform(textAttributes)),
70
- vrender_core_1.graphicCreator.text(textAttributes));
69
+ return "rich" === textType ? graphic_creator_1.graphicCreator.richtext(richTextAttributeTransform(textAttributes)) : ("html" === textType ? textAttributes = htmlAttributeTransform(textAttributes) : "react" === textType && (textAttributes = reactAttributeTransform(textAttributes)),
70
+ graphic_creator_1.graphicCreator.text(textAttributes));
71
71
  }
72
72
 
73
73
  function alignTextInLine(layoutAlign, graphic, textAlign, pos, textWidth) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":";;;AAQA,yDAAuE;AAGvE,6CAAkE;AAClE,0CAA+E;AAGxE,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACxB,iBAAkD,EACd,EAAE;IACtC,OAAO,IAAI,oBAAW,iBAElB,iBAAiB,kBACf,UAAU,EAAE,mCAAwB,EACpC,QAAQ,EAAE,iCAAsB,IAC7B,iBAAiB,GAEtB,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,4BAAa,EACzD,cAAc,EAAE,cAAc,GAAG,oBAAW,CAAC,iBAAiB,GAAG,oBAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B;AAGF,SAAgB,eAAe,CAC7B,IAA2C,EAC3C,QAAwC,EACxC,mBAAmD,EAAE;IAErD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EA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AAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAChC;KACF;AACH,CAAC;AA5BD,0CA4BC","file":"text.js","sourcesContent":["import type {\n IRichText,\n IRichTextAttribute,\n IText,\n ITextGraphicAttribute,\n TextAlignType\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds, graphicCreator } from '@visactor/vrender-core';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure, isObject, isValid } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\nimport type { HTMLTextContent, ReactTextContent, TextContent } from '../core/type';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean,\n defaultFontParams?: Partial<ITextGraphicAttribute>\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE,\n ...defaultFontParams\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(\n text: string | number | string[] | number[],\n textSpec: Partial<ITextGraphicAttribute>,\n defaultTextTheme: Partial<ITextGraphicAttribute> = {}\n) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily || defaultTextTheme.fontFamily || DEFAULT_TEXT_FONT_FAMILY,\n fontSize: textSpec.fontSize || defaultTextTheme.fontSize || 12,\n fontWeight: textSpec.fontWeight || defaultTextTheme.fontWeight,\n textAlign: textSpec.textAlign || 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || defaultTextTheme.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n\nexport function isRichText(attributes: TextContent, typeKey = 'type') {\n return getTextType(attributes, typeKey) === 'rich';\n}\n\nexport function getTextType(attributes: TextContent, typeKey = 'type') {\n if (isObject(attributes.text) && 'type' in attributes.text) {\n return attributes.text.type ?? 'text';\n }\n\n if (typeKey in attributes) {\n return attributes[typeKey] ?? 'text';\n }\n\n return 'text';\n}\n\nexport function richTextAttributeTransform(attributes: ITextGraphicAttribute & IRichTextAttribute & TextContent) {\n if (isValid(attributes.maxLineWidth)) {\n attributes.maxWidth = attributes.maxLineWidth;\n delete attributes.maxLineWidth;\n }\n\n attributes.width = attributes.width ?? 0;\n attributes.height = attributes.height ?? 0;\n attributes.textConfig = (attributes.text as unknown as any).text || attributes.text;\n return attributes;\n}\n\nexport function htmlAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as HTMLTextContent;\n const { text: html } = text;\n\n attributes.html = html;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 html,则不绘制原始文字\n return attributes;\n}\n\nexport function reactAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as ReactTextContent;\n const { text: react } = text;\n\n attributes.react = react;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 react,则不绘制原始文字\n\n return attributes;\n}\n\nexport function createTextGraphicByType(textAttributes: ITextGraphicAttribute, typeKey = 'type') {\n const textType = getTextType(textAttributes, typeKey);\n if (textType === 'rich') {\n return graphicCreator.richtext(richTextAttributeTransform(textAttributes as IRichTextAttribute));\n }\n\n if (textType === 'html') {\n textAttributes = htmlAttributeTransform(textAttributes);\n } else if (textType === 'react') {\n textAttributes = reactAttributeTransform(textAttributes);\n }\n\n return graphicCreator.text(textAttributes as ITextGraphicAttribute);\n}\n\nexport function alignTextInLine(\n layoutAlign: 'left' | 'right',\n graphic: IText | IRichText,\n textAlign: TextAlignType,\n pos: number,\n textWidth: number\n) {\n if (layoutAlign === 'right') {\n if (textAlign === 'center') {\n graphic.setAttribute('x', pos - textWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n graphic.setAttribute('x', pos);\n } else {\n // 默认左对齐\n graphic.setAttribute('x', pos - textWidth);\n }\n } else {\n if (textAlign === 'center') {\n graphic.setAttribute('x', pos + textWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n graphic.setAttribute('x', pos + textWidth);\n } else {\n // 默认左对齐\n graphic.setAttribute('x', pos);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":";;;AAQA,yDAAuD;AACvD,uDAAmD;AAGnD,6CAAkE;AAClE,0CAA+E;AAGxE,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACxB,iBAAkD,EACd,EAAE;IACtC,OAAO,IAAI,oBAAW,iBAElB,iBAAiB,kBACf,UAAU,EAAE,mCAAwB,EACpC,QAAQ,EAAE,iCAAsB,IAC7B,iBAAiB,GAEtB,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,4BAAa,EACzD,cAAc,EAAE,cAAc,GAAG,oBAAW,CAAC,iBAAiB,GAAG,oBAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B;AAGF,SAAgB,eAAe,CAC7B,IAA2C,EAC3C,QAAwC,EACxC,mBAAmD,EAAE;IAErD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAA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EL,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAChC;KACF;AACH,CAAC;AA5BD,0CA4BC","file":"text.js","sourcesContent":["import type {\n IRichText,\n IRichTextAttribute,\n IText,\n ITextGraphicAttribute,\n TextAlignType\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds } from '@visactor/vrender-core';\nimport { graphicCreator } from './graphic-creator';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure, isObject, isValid } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\nimport type { HTMLTextContent, ReactTextContent, TextContent } from '../core/type';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean,\n defaultFontParams?: Partial<ITextGraphicAttribute>\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE,\n ...defaultFontParams\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(\n text: string | number | string[] | number[],\n textSpec: Partial<ITextGraphicAttribute>,\n defaultTextTheme: Partial<ITextGraphicAttribute> = {}\n) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily || defaultTextTheme.fontFamily || DEFAULT_TEXT_FONT_FAMILY,\n fontSize: textSpec.fontSize || defaultTextTheme.fontSize || 12,\n fontWeight: textSpec.fontWeight || defaultTextTheme.fontWeight,\n textAlign: textSpec.textAlign || 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || defaultTextTheme.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n\nexport function isRichText(attributes: TextContent, typeKey = 'type') {\n return getTextType(attributes, typeKey) === 'rich';\n}\n\nexport function getTextType(attributes: TextContent, typeKey = 'type') {\n if (isObject(attributes.text) && 'type' in attributes.text) {\n return attributes.text.type ?? 'text';\n }\n\n if (typeKey in attributes) {\n return attributes[typeKey] ?? 'text';\n }\n\n return 'text';\n}\n\nexport function richTextAttributeTransform(attributes: ITextGraphicAttribute & IRichTextAttribute & TextContent) {\n if (isValid(attributes.maxLineWidth)) {\n attributes.maxWidth = attributes.maxLineWidth;\n delete attributes.maxLineWidth;\n }\n\n attributes.width = attributes.width ?? 0;\n attributes.height = attributes.height ?? 0;\n attributes.textConfig = (attributes.text as unknown as any).text || attributes.text;\n return attributes;\n}\n\nexport function htmlAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as HTMLTextContent;\n const { text: html } = text;\n\n attributes.html = html;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 html,则不绘制原始文字\n return attributes;\n}\n\nexport function reactAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as ReactTextContent;\n const { text: react } = text;\n\n attributes.react = react;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 react,则不绘制原始文字\n\n return attributes;\n}\n\nexport function createTextGraphicByType(textAttributes: ITextGraphicAttribute, typeKey = 'type') {\n const textType = getTextType(textAttributes, typeKey);\n if (textType === 'rich') {\n return graphicCreator.richtext(richTextAttributeTransform(textAttributes as IRichTextAttribute));\n }\n\n if (textType === 'html') {\n textAttributes = htmlAttributeTransform(textAttributes);\n } else if (textType === 'react') {\n textAttributes = reactAttributeTransform(textAttributes);\n }\n\n return graphicCreator.text(textAttributes as ITextGraphicAttribute);\n}\n\nexport function alignTextInLine(\n layoutAlign: 'left' | 'right',\n graphic: IText | IRichText,\n textAlign: TextAlignType,\n pos: number,\n textWidth: number\n) {\n if (layoutAlign === 'right') {\n if (textAlign === 'center') {\n graphic.setAttribute('x', pos - textWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n graphic.setAttribute('x', pos);\n } else {\n // 默认左对齐\n graphic.setAttribute('x', pos - textWidth);\n }\n } else {\n if (textAlign === 'center') {\n graphic.setAttribute('x', pos + textWidth / 2);\n } else if (textAlign === 'right' || textAlign === 'end') {\n // 右对齐\n graphic.setAttribute('x', pos + textWidth);\n } else {\n // 默认左对齐\n graphic.setAttribute('x', pos);\n }\n }\n}\n"]}