@visactor/react-vchart 1.10.0-alpha.0 → 1.10.0-alpha.10

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 (130) hide show
  1. package/cjs/VChart.js.map +1 -1
  2. package/cjs/charts/BaseChart.d.ts +2 -1
  3. package/cjs/charts/BaseChart.js +37 -23
  4. package/cjs/charts/BaseChart.js.map +1 -1
  5. package/cjs/charts/RoseChart.js +2 -1
  6. package/cjs/charts/ScatterChart.js +1 -2
  7. package/cjs/components/BaseComponent.d.ts +1 -0
  8. package/cjs/components/BaseComponent.js +9 -35
  9. package/cjs/components/BaseComponent.js.map +1 -1
  10. package/cjs/components/Mark.d.ts +4 -14
  11. package/cjs/components/Mark.js +2 -61
  12. package/cjs/components/Mark.js.map +1 -1
  13. package/cjs/components/Region.js +2 -1
  14. package/cjs/components/Title.js +1 -2
  15. package/cjs/components/index.d.ts +1 -1
  16. package/cjs/components/index.js +1 -1
  17. package/cjs/components/index.js.map +1 -1
  18. package/cjs/components/tooltip/Tooltip.d.ts +2 -0
  19. package/cjs/components/{Tooltip.js → tooltip/Tooltip.js} +2 -2
  20. package/cjs/components/tooltip/Tooltip.js.map +1 -0
  21. package/cjs/components/tooltip/constant.d.ts +1 -0
  22. package/cjs/components/tooltip/constant.js +10 -0
  23. package/cjs/components/tooltip/constant.js.map +1 -0
  24. package/cjs/components/tooltip/index.d.ts +3 -0
  25. package/cjs/components/tooltip/index.js +22 -0
  26. package/cjs/components/tooltip/index.js.map +1 -0
  27. package/cjs/components/tooltip/interface.d.ts +14 -0
  28. package/cjs/components/tooltip/interface.js +6 -0
  29. package/cjs/components/tooltip/interface.js.map +1 -0
  30. package/cjs/components/tooltip/util.d.ts +5 -0
  31. package/cjs/components/tooltip/util.js +47 -0
  32. package/cjs/components/tooltip/util.js.map +1 -0
  33. package/cjs/containers/withContainer.d.ts +1 -1
  34. package/cjs/containers/withContainer.js.map +1 -1
  35. package/cjs/context/chart.d.ts +0 -1
  36. package/cjs/context/chart.js.map +1 -1
  37. package/cjs/index.d.ts +1 -1
  38. package/cjs/index.js +1 -1
  39. package/cjs/index.js.map +1 -1
  40. package/cjs/series/Area.d.ts +1 -0
  41. package/cjs/series/Bar.d.ts +1 -0
  42. package/cjs/series/BaseSeries.d.ts +1 -0
  43. package/cjs/series/BaseSeries.js +29 -55
  44. package/cjs/series/BaseSeries.js.map +1 -1
  45. package/cjs/series/BoxPlot.d.ts +1 -0
  46. package/cjs/series/CircularProgress.d.ts +1 -0
  47. package/cjs/series/Dot.d.ts +1 -0
  48. package/cjs/series/Funnel.d.ts +1 -0
  49. package/cjs/series/Line.d.ts +1 -0
  50. package/cjs/series/LinearProgress.d.ts +1 -0
  51. package/cjs/series/LinearProgress.js +2 -1
  52. package/cjs/series/Link.d.ts +1 -0
  53. package/cjs/series/Link.js +1 -2
  54. package/cjs/series/Map.d.ts +1 -0
  55. package/cjs/series/Pie.d.ts +1 -0
  56. package/cjs/series/Radar.d.ts +1 -0
  57. package/cjs/series/RangeColumn.d.ts +1 -0
  58. package/cjs/series/Rose.d.ts +1 -0
  59. package/cjs/series/Scatter.d.ts +1 -0
  60. package/cjs/series/Series.d.ts +1 -0
  61. package/cjs/series/Series.js +1 -1
  62. package/cjs/series/WordCloud.d.ts +1 -0
  63. package/esm/VChart.js.map +1 -1
  64. package/esm/charts/BaseChart.d.ts +2 -1
  65. package/esm/charts/BaseChart.js +37 -24
  66. package/esm/charts/BaseChart.js.map +1 -1
  67. package/esm/charts/RoseChart.js +2 -1
  68. package/esm/charts/ScatterChart.js +1 -2
  69. package/esm/components/BaseComponent.d.ts +1 -0
  70. package/esm/components/BaseComponent.js +9 -36
  71. package/esm/components/BaseComponent.js.map +1 -1
  72. package/esm/components/Mark.d.ts +4 -14
  73. package/esm/components/Mark.js +2 -39
  74. package/esm/components/Mark.js.map +1 -1
  75. package/esm/components/Region.js +2 -1
  76. package/esm/components/Title.js +1 -2
  77. package/esm/components/index.d.ts +1 -1
  78. package/esm/components/index.js +1 -1
  79. package/esm/components/index.js.map +1 -1
  80. package/esm/components/tooltip/Tooltip.d.ts +2 -0
  81. package/esm/components/tooltip/Tooltip.js +4 -0
  82. package/esm/components/tooltip/Tooltip.js.map +1 -0
  83. package/esm/components/tooltip/constant.d.ts +1 -0
  84. package/esm/components/tooltip/constant.js +4 -0
  85. package/esm/components/tooltip/constant.js.map +1 -0
  86. package/esm/components/tooltip/index.d.ts +3 -0
  87. package/esm/components/tooltip/index.js +6 -0
  88. package/esm/components/tooltip/index.js.map +1 -0
  89. package/esm/components/tooltip/interface.d.ts +14 -0
  90. package/esm/components/tooltip/interface.js +2 -0
  91. package/esm/components/tooltip/interface.js.map +1 -0
  92. package/esm/components/tooltip/util.d.ts +5 -0
  93. package/esm/components/tooltip/util.js +40 -0
  94. package/esm/components/tooltip/util.js.map +1 -0
  95. package/esm/containers/withContainer.d.ts +1 -1
  96. package/esm/containers/withContainer.js.map +1 -1
  97. package/esm/context/chart.d.ts +0 -1
  98. package/esm/context/chart.js.map +1 -1
  99. package/esm/index.d.ts +1 -1
  100. package/esm/index.js +1 -1
  101. package/esm/index.js.map +1 -1
  102. package/esm/series/Area.d.ts +1 -0
  103. package/esm/series/Bar.d.ts +1 -0
  104. package/esm/series/BaseSeries.d.ts +1 -0
  105. package/esm/series/BaseSeries.js +29 -56
  106. package/esm/series/BaseSeries.js.map +1 -1
  107. package/esm/series/BoxPlot.d.ts +1 -0
  108. package/esm/series/CircularProgress.d.ts +1 -0
  109. package/esm/series/Dot.d.ts +1 -0
  110. package/esm/series/Funnel.d.ts +1 -0
  111. package/esm/series/Line.d.ts +1 -0
  112. package/esm/series/LinearProgress.d.ts +1 -0
  113. package/esm/series/LinearProgress.js +2 -1
  114. package/esm/series/Link.d.ts +1 -0
  115. package/esm/series/Link.js +1 -2
  116. package/esm/series/Map.d.ts +1 -0
  117. package/esm/series/Pie.d.ts +1 -0
  118. package/esm/series/Radar.d.ts +1 -0
  119. package/esm/series/RangeColumn.d.ts +1 -0
  120. package/esm/series/Rose.d.ts +1 -0
  121. package/esm/series/Scatter.d.ts +1 -0
  122. package/esm/series/Series.d.ts +1 -0
  123. package/esm/series/Series.js +1 -1
  124. package/esm/series/WordCloud.d.ts +1 -0
  125. package/package.json +8 -8
  126. package/cjs/components/Tooltip.d.ts +0 -4
  127. package/cjs/components/Tooltip.js.map +0 -1
  128. package/esm/components/Tooltip.d.ts +0 -4
  129. package/esm/components/Tooltip.js +0 -4
  130. package/esm/components/Tooltip.js.map +0 -1
package/cjs/VChart.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/VChart.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;AAEjE,8DAA0C;AACjC,qBADF,gBAAU,CACE;AAIN,QAAA,MAAM,GAAG,IAAA,uBAAW,EAAc,QAAQ,EAAE;IACvD,kBAAkB,EAAE,gBAAU;CAC/B,CAAC,CAAC","file":"VChart.js","sourcesContent":["import { BaseChartProps, createChart } from './charts/BaseChart';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport VChartCore from '@visactor/vchart';\nexport { VChartCore };\n\nexport type VChartProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'type'>;\n\nexport const VChart = createChart<VChartProps>('VChart', {\n vchartConstrouctor: VChartCore\n});\n"]}
1
+ {"version":3,"sources":["../src/VChart.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;AACjE,8DAA0C;AACjC,qBADF,gBAAU,CACE;AAIN,QAAA,MAAM,GAAG,IAAA,uBAAW,EAAc,QAAQ,EAAE;IACvD,kBAAkB,EAAE,gBAAU;CAC/B,CAAC,CAAC","file":"VChart.js","sourcesContent":["import { BaseChartProps, createChart } from './charts/BaseChart';\nimport VChartCore from '@visactor/vchart';\nexport { VChartCore };\n\nexport type VChartProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'type'>;\n\nexport const VChart = createChart<VChartProps>('VChart', {\n vchartConstrouctor: VChartCore\n});\n"]}
@@ -2,8 +2,9 @@ import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@vi
2
2
  import React from 'react';
3
3
  import { ContainerProps } from '../containers/withContainer';
4
4
  import { EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps } from '../eventsUtils';
5
+ import { IReactTooltipProps } from '../components/tooltip/interface';
5
6
  export type ChartOptions = Omit<IInitOption, 'dom'>;
6
- export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps {
7
+ export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps, IReactTooltipProps {
7
8
  vchartConstrouctor?: IVChartConstructor;
8
9
  type?: string;
9
10
  container?: HTMLDivElement;
@@ -33,18 +33,32 @@ Object.defineProperty(exports, "__esModule", {
33
33
  value: !0
34
34
  }), exports.createChart = void 0;
35
35
 
36
- const react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), chart_1 = __importDefault(require("../context/chart")), vutils_1 = require("@visactor/vutils"), view_1 = __importDefault(require("../context/view")), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), notSpecKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.CHART_EVENTS_KEYS, "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], BaseChart = react_1.default.forwardRef(((props, ref) => {
37
- const [updateId, setUpdateId] = (0, react_1.useState)(0), chartContext = (0, react_1.useRef)({
38
- specFromChildren: {}
39
- });
36
+ const react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), chart_1 = __importDefault(require("../context/chart")), vutils_1 = require("@visactor/vutils"), view_1 = __importDefault(require("../context/view")), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), util_2 = require("../components/tooltip/util"), notSpecKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.CHART_EVENTS_KEYS, "vchartConstrouctor", "useSyncRender", "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], getComponentId = (child, index) => `${child && child.type && (child.type.displayName || child.type.name)}-${index}`, parseSpecFromChildren = props => {
37
+ const specFromChildren = {};
38
+ return (0, util_1.toArray)(props.children).map(((child, index) => {
39
+ const parseSpec = child && child.type && child.type.parseSpec;
40
+ if (parseSpec && child.props) {
41
+ const specResult = parseSpec((0, vutils_1.isNil)(child.props.componentId) ? Object.assign(Object.assign({}, child.props), {
42
+ componentId: getComponentId(child, index)
43
+ }) : child.props);
44
+ specResult.isSingle ? specFromChildren[specResult.specName] = specResult.spec : (specFromChildren[specResult.specName] || (specFromChildren[specResult.specName] = []),
45
+ specFromChildren[specResult.specName].push(specResult.spec));
46
+ }
47
+ })), specFromChildren;
48
+ }, BaseChart = react_1.default.forwardRef(((props, ref) => {
49
+ const [updateId, setUpdateId] = (0, react_1.useState)(0), chartContext = (0, react_1.useRef)({});
40
50
  (0, react_1.useImperativeHandle)(ref, (() => {
41
51
  var _a;
42
52
  return null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart;
43
53
  }));
44
54
  const hasSpec = !!props.spec, [view, setView] = (0, react_1.useState)(null), isUnmount = (0,
45
- react_1.useRef)(!1), prevSpec = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseSpec = props => {
46
- var _a;
47
- return hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.specFromChildren);
55
+ react_1.useRef)(!1), prevSpec = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)), specFromChildren = (0,
56
+ react_1.useRef)(null), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, [tooltipNode, setTooltipNode] = (0,
57
+ react_1.useState)(null), parseSpec = props => {
58
+ let spec;
59
+ return spec = hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), specFromChildren.current),
60
+ spec.tooltip = (0, util_2.initCustomTooltip)(setTooltipNode, props, spec.tooltip),
61
+ spec;
48
62
  }, handleChartRender = () => {
49
63
  if (!isUnmount.current) {
50
64
  if (!chartContext.current || !chartContext.current.chart) return;
@@ -56,7 +70,9 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
56
70
  };
57
71
  return (0, react_1.useEffect)((() => {
58
72
  var _a;
59
- if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return (props => {
73
+ const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);
74
+ if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return hasSpec || (specFromChildren.current = newSpecFromChildren),
75
+ (props => {
60
76
  const cs = new props.vchartConstrouctor(parseSpec(props), Object.assign(Object.assign({}, props.options), {
61
77
  onError: props.onError,
62
78
  autoFit: !0,
@@ -64,13 +80,10 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
64
80
  }));
65
81
  chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
66
82
  chart: cs
67
- });
83
+ }), isUnmount.current = !1;
68
84
  })(props), chartContext.current.chart && (chartContext.current.chart.renderSync({
69
85
  reuse: !1
70
- }), handleChartRender()), (0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, null, eventsUtils_1.CHART_EVENTS),
71
- chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
72
- isChildrenUpdated: !1
73
- }), void (eventsBinded.current = props);
86
+ }), handleChartRender()), void (eventsBinded.current = props);
74
87
  if (hasSpec) return void ((0, vutils_1.isEqual)(eventsBinded.current.spec, props.spec, {
75
88
  skipFunction: skipFunctionDiff
76
89
  }) || (eventsBinded.current = props, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
@@ -80,27 +93,28 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
80
93
  const newSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
81
94
  (0, vutils_1.isEqual)(newSpec, prevSpec.current, {
82
95
  skipFunction: skipFunctionDiff
83
- }) && !chartContext.current.isChildrenUpdated || (prevSpec.current = newSpec, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
96
+ }) && (0, vutils_1.isEqual)(newSpecFromChildren, specFromChildren.current) || (prevSpec.current = newSpec,
97
+ specFromChildren.current = newSpecFromChildren, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
84
98
  morph: !1,
85
99
  enableExitAnimation: !1
86
- }), handleChartRender()), chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
87
- isChildrenUpdated: !1
88
- });
100
+ }), handleChartRender());
89
101
  }), [ props ]), (0, react_1.useEffect)((() => () => {
90
- chartContext && (chartContext.current.chart && chartContext.current.chart.release(),
91
- chartContext.current = null), isUnmount.current = !0;
102
+ chartContext && chartContext.current && chartContext.current.chart && (chartContext.current.chart.release(),
103
+ chartContext.current.chart = null), eventsBinded.current = null, isUnmount.current = !0;
92
104
  }), []), react_1.default.createElement(chart_1.default.Provider, {
93
105
  value: chartContext.current
94
106
  }, react_1.default.createElement(view_1.default.Provider, {
95
107
  value: view
96
108
  }, (0, util_1.toArray)(props.children).map(((child, index) => {
97
- var _a, _b, _c;
109
+ if ("string" == typeof child) return;
110
+ const childId = getComponentId(child, index);
98
111
  return react_1.default.createElement(react_1.default.Fragment, {
99
- key: null !== (_c = null !== (_b = null === (_a = null == child ? void 0 : child.props) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : null == child ? void 0 : child.id) && void 0 !== _c ? _c : `child-${index}`
112
+ key: childId
100
113
  }, react_1.default.cloneElement(child, {
101
- updateId: updateId
114
+ updateId: updateId,
115
+ componentId: childId
102
116
  }));
103
- }))));
117
+ })), tooltipNode));
104
118
  })), createChart = (componentName, defaultProps, callback) => {
105
119
  const Com = (0, withContainer_1.default)(BaseChart, componentName, (props => callback ? callback(props, defaultProps) : defaultProps ? Object.assign(props, defaultProps) : props));
106
120
  return Com.displayName = componentName, Com;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAgF;AAChF,gFAA4E;AAC5E,6DAAsE;AAEtE,6CAAwD;AACxD,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AAEnD,gDAawB;AA+CxB,MAAM,WAAW,GAAG;IAClB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,MAAM;IACN,WAAW;IACX,SAAS;CACV,CAAC;AAEF,MAAM,SAAS,GAAoB,eAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAmB;QAC5C,gBAAgB,EAAE,EAAE;KACrB,CAAC,CAAC;IACH,IAAA,2BAAmB,EAAC,GAAG,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,YAAY,CAAC,OAAO,0CAAE,KAAK,CAAA,EAAA,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAQ,IAAI,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAA,cAAM,EAAU,KAAK,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,IAAA,oBAAW,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,EAAE;;YAC5C,OAAO,CACL,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,MAAA,MAAA,MAAC,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,KAAK,0CAAE,EAAE,mCAAK,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,EAAE,mCAAI,SAAS,KAAK,EAAE,IACrF,eAAK,CAAC,YAAY,CAAC,KAAqB,EAAE;gBACzC,QAAQ,EAAE,QAAQ;aACnB,CAAC,CACa,CAClB,CAAC;QACJ,CAAC,CAAC,CACmB,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,QAAqD,EACrD,EAAE;IACF,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtC;QAED,IAAI,YAAY,EAAE;YAChB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,WAAW,eAiBtB","file":"BaseChart.js","sourcesContent":["import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport { IMarkElement } from '../components';\nimport {\n bindEventsToChart,\n EventsProps,\n CHART_EVENTS_KEYS,\n CHART_EVENTS,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps\n extends EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps {\n vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\n /** 图表渲染完成事件 */\n onReady?: (instance: IVChart, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n /**\n * use sync render\n *\n * @since 1.8.3\n * @deprecated 1.9.0\n **/\n useSyncRender?: boolean;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [\n ...REACT_PRIVATE_PROPS,\n ...CHART_EVENTS_KEYS,\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options'\n];\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({\n specFromChildren: {}\n });\n useImperativeHandle(ref, () => chartContext.current?.chart);\n const hasSpec = !!props.spec;\n const [view, setView] = useState<IView>(null);\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n\n const parseSpec = (props: Props) => {\n if (hasSpec && props.spec) {\n return props.spec;\n }\n\n return {\n ...prevSpec.current,\n ...chartContext.current?.specFromChildren\n };\n };\n\n const createChart = (props: Props) => {\n const cs = new props.vchartConstrouctor(parseSpec(props), {\n ...props.options,\n onError: props.onError,\n autoFit: true,\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n };\n\n const handleChartRender = () => {\n // rebind events after render\n if (!isUnmount.current) {\n if (!chartContext.current || !chartContext.current.chart) {\n return;\n }\n\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n const newView = chartContext.current.chart.getCompiler().getVGrammarView();\n\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n setView(newView);\n }\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n chartContext.current.chart.renderSync({\n reuse: false\n });\n handleChartRender();\n }\n };\n\n useEffect(() => {\n if (!chartContext.current?.chart) {\n createChart(props);\n renderChart();\n bindEventsToChart(chartContext.current.chart, props, null, CHART_EVENTS);\n chartContext.current = {\n ...chartContext.current,\n isChildrenUpdated: false\n };\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n chartContext.current.isChildrenUpdated\n ) {\n prevSpec.current = newSpec;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n chartContext.current = {\n ...chartContext.current,\n isChildrenUpdated: false\n };\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current.chart) {\n chartContext.current.chart.release();\n }\n chartContext.current = null;\n }\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n <ViewContext.Provider value={view}>\n {toArray(props.children).map((child, index) => {\n return (\n <React.Fragment key={(child as any)?.props?.id ?? (child as any)?.id ?? `child-${index}`}>\n {React.cloneElement(child as IMarkElement, {\n updateId: updateId\n })}\n </React.Fragment>\n );\n })}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T, defaultProps?: Partial<T>) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (callback) {\n return callback(props, defaultProps);\n }\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
1
+ {"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAA2F;AAC3F,gFAA4E;AAC5E,6DAAsE;AAEtE,6CAA+D;AAC/D,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AACnD,gDAawB;AAExB,qDAA+D;AAgD/D,MAAM,WAAW,GAAG;IAClB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,MAAM;IACN,WAAW;IACX,SAAS;CACV,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAE,KAAa,EAAE,EAAE;IAC/D,MAAM,aAAa,GAAG,KAAK,IAAK,KAAa,CAAC,IAAI,IAAI,CAAE,KAAa,CAAC,IAAI,CAAC,WAAW,IAAK,KAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpH,OAAO,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,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AAC,CAAC;YACD,WAAW,CACS,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,QAAqD,EACrD,EAAE;IACF,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtC;QAED,IAAI,YAAY,EAAE;YAChB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,WAAW,eAiBtB","file":"BaseChart.js","sourcesContent":["import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle, ReactNode } from 'react';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, isNil, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport {\n bindEventsToChart,\n EventsProps,\n CHART_EVENTS_KEYS,\n CHART_EVENTS,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\nimport { IReactTooltipProps } from '../components/tooltip/interface';\nimport { initCustomTooltip } from '../components/tooltip/util';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps\n extends EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps,\n IReactTooltipProps {\n vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\n /** 图表渲染完成事件 */\n onReady?: (instance: IVChart, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n /**\n * use sync render\n *\n * @since 1.8.3\n * @deprecated 1.9.0\n **/\n useSyncRender?: boolean;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [\n ...REACT_PRIVATE_PROPS,\n ...CHART_EVENTS_KEYS,\n 'vchartConstrouctor',\n 'useSyncRender',\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options'\n];\n\nconst getComponentId = (child: React.ReactNode, index: number) => {\n const componentName = child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n return `${componentName}-${index}`;\n};\n\nconst parseSpecFromChildren = (props: Props) => {\n const specFromChildren: Omit<ISpec, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map((child, index) => {\n const parseSpec = child && (child as any).type && (child as any).type.parseSpec;\n\n if (parseSpec && (child as any).props) {\n const childProps = isNil((child as any).props.componentId)\n ? {\n ...(child as any).props,\n componentId: getComponentId(child, index)\n }\n : (child as any).props;\n\n const specResult = parseSpec(childProps);\n\n if (specResult.isSingle) {\n specFromChildren[specResult.specName] = specResult.spec;\n } else {\n if (!specFromChildren[specResult.specName]) {\n specFromChildren[specResult.specName] = [];\n }\n\n specFromChildren[specResult.specName].push(specResult.spec);\n }\n }\n });\n\n return specFromChildren;\n};\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({});\n useImperativeHandle(ref, () => chartContext.current?.chart);\n const hasSpec = !!props.spec;\n const [view, setView] = useState<IView>(null);\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const specFromChildren = useRef<Omit<ISpec, 'type' | 'data' | 'width' | 'height'>>(null);\n const eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n const [tooltipNode, setTooltipNode] = useState<ReactNode>(null);\n\n const parseSpec = (props: Props) => {\n let spec: ISpec = undefined;\n\n if (hasSpec && props.spec) {\n spec = props.spec;\n } else {\n spec = {\n ...prevSpec.current,\n ...specFromChildren.current\n } as ISpec;\n }\n\n spec.tooltip = initCustomTooltip(setTooltipNode, props, spec.tooltip);\n return spec;\n };\n\n const createChart = (props: Props) => {\n const cs = new props.vchartConstrouctor(parseSpec(props), {\n ...props.options,\n onError: props.onError,\n autoFit: true,\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n isUnmount.current = false;\n };\n\n const handleChartRender = () => {\n // rebind events after render\n if (!isUnmount.current) {\n if (!chartContext.current || !chartContext.current.chart) {\n return;\n }\n\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n const newView = chartContext.current.chart.getCompiler().getVGrammarView();\n\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n setView(newView);\n }\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n chartContext.current.chart.renderSync({\n reuse: false\n });\n handleChartRender();\n }\n };\n\n useEffect(() => {\n const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);\n\n if (!chartContext.current?.chart) {\n if (!hasSpec) {\n specFromChildren.current = newSpecFromChildren;\n }\n\n createChart(props);\n renderChart();\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n !isEqual(newSpecFromChildren, specFromChildren.current)\n ) {\n prevSpec.current = newSpec;\n specFromChildren.current = newSpecFromChildren;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current && chartContext.current.chart) {\n chartContext.current.chart.release();\n chartContext.current.chart = null;\n }\n }\n eventsBinded.current = null;\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n <ViewContext.Provider value={view}>\n {toArray(props.children).map((child, index) => {\n if (typeof child === 'string') {\n return;\n }\n\n const childId = getComponentId(child, index);\n\n return (\n <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\n })}\n </React.Fragment>\n );\n })}\n {tooltipNode}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T, defaultProps?: Partial<T>) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (callback) {\n return callback(props, defaultProps);\n }\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
@@ -15,4 +15,5 @@ const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = req
15
15
  exports.RoseChart = (0, BaseChart_1.createChart)("RoseChart", {
16
16
  type: "rose",
17
17
  vchartConstrouctor: vchart_1.default
18
- });
18
+ });
19
+ //# sourceMappingURL=RoseChart.js.map
@@ -15,5 +15,4 @@ const vchart_1 = __importDefault(require("@visactor/vchart")), BaseChart_1 = req
15
15
  exports.ScatterChart = (0, BaseChart_1.createChart)("ScatterChart", {
16
16
  type: "scatter",
17
17
  vchartConstrouctor: vchart_1.default
18
- });
19
- //# sourceMappingURL=ScatterChart.js.map
18
+ });
@@ -4,6 +4,7 @@ export interface BaseComponentProps {
4
4
  }
5
5
  type ComponentProps = BaseComponentProps & {
6
6
  updateId?: number;
7
+ componentId?: number;
7
8
  };
8
9
  export declare const createComponent: <T extends ComponentProps>(componentName: string, specName: string, supportedEvents?: Record<string, string> | null, isSingle?: boolean) => React.FC<T>;
9
10
  export {};
@@ -33,49 +33,23 @@ Object.defineProperty(exports, "__esModule", {
33
33
  value: !0
34
34
  }), exports.createComponent = void 0;
35
35
 
36
- const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), chart_1 = __importDefault(require("../context/chart")), eventsUtils_1 = require("../eventsUtils"), util_1 = require("../util"), createComponent = (componentName, specName, supportedEvents, isSingle) => {
37
- const ignoreKeys = [ "id", "updateId" ], notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
38
- const context = (0, react_1.useContext)(chart_1.default), id = react_1.default.useRef((0,
39
- vutils_1.isNil)(props.id) ? (0, util_1.uid)(specName) : props.id), eventsBinded = react_1.default.useRef(null), updateId = react_1.default.useRef(props.updateId), componentSpec = react_1.default.useRef();
36
+ const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), chart_1 = __importDefault(require("../context/chart")), eventsUtils_1 = require("../eventsUtils"), createComponent = (componentName, specName, supportedEvents, isSingle) => {
37
+ const ignoreKeys = [ "id", "updateId", "componentId" ], notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
38
+ const context = (0, react_1.useContext)(chart_1.default), eventsBinded = react_1.default.useRef(null), updateId = react_1.default.useRef(props.updateId);
40
39
  if (props.updateId !== updateId.current) {
41
40
  updateId.current = props.updateId;
42
41
  !!supportedEvents && (0, eventsUtils_1.bindEventsToChart)(context.chart, props, eventsBinded.current, supportedEvents) && (eventsBinded.current = props);
43
- } else {
44
- const newComponentSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
45
- (0, vutils_1.isEqual)(newComponentSpec, componentSpec.current) || (componentSpec.current = newComponentSpec,
46
- updateToContext(context, id.current, specName, isSingle, newComponentSpec));
47
42
  }
48
43
  return (0, react_1.useEffect)((() => () => {
49
- supportedEvents && (0, eventsUtils_1.bindEventsToChart)(context.chart, null, eventsBinded.current, supportedEvents),
50
- deleteToContext(context, id.current, specName, isSingle);
44
+ supportedEvents && (0, eventsUtils_1.bindEventsToChart)(context.chart, null, eventsBinded.current, supportedEvents);
51
45
  }), []), null;
52
46
  };
53
- return Comp.displayName = componentName, Comp;
47
+ return Comp.displayName = componentName, Comp.parseSpec = props => ({
48
+ spec: (0, vutils_1.pickWithout)(props, notSpecKeys),
49
+ specName: specName,
50
+ isSingle: isSingle
51
+ }), Comp;
54
52
  };
55
53
 
56
54
  exports.createComponent = createComponent;
57
-
58
- const updateToContext = (context, id, specName, isSingle, props) => {
59
- if (context.specFromChildren) {
60
- if (isSingle) context.specFromChildren[specName] = Object.assign({}, props); else {
61
- context.specFromChildren[specName] || (context.specFromChildren[specName] = []);
62
- const comps = context.specFromChildren[specName], index = comps.findIndex((entry => entry.id === id));
63
- index >= 0 ? comps[index] = Object.assign({
64
- id: id
65
- }, props) : context.specFromChildren[specName].push(Object.assign({
66
- id: id
67
- }, props));
68
- }
69
- context.isChildrenUpdated = !0;
70
- }
71
- }, deleteToContext = (context, id, specName, isSingle) => {
72
- var _a;
73
- if (context.specFromChildren) if (isSingle) context.specFromChildren[specName] = null; else {
74
- const comps = null !== (_a = context.specFromChildren[specName]) && void 0 !== _a ? _a : [], index = comps.findIndex((entry => entry.id === id));
75
- if (index >= 0) {
76
- const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));
77
- context.specFromChildren[specName] = newComps, context.isChildrenUpdated = !0;
78
- }
79
- }
80
- };
81
55
  //# sourceMappingURL=BaseComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/BaseComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,6CAA+D;AAE/D,6DAAsE;AACtE,gDAAmD;AACnD,kCAA8B;AAQvB,MAAM,eAAe,GAAG,CAC7B,aAAqB,EACrB,QAAgB,EAChB,eAA+C,EAC/C,QAAkB,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAEnG,MAAM,IAAI,GAAgB,CAAC,KAAQ,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,eAAgB,CAAC,CAAC;QAC7C,MAAM,EAAE,GAAG,eAAK,CAAC,MAAM,CAAkB,IAAA,cAAK,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,UAAG,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAErF,MAAM,YAAY,GAAG,eAAK,CAAC,MAAM,CAAI,IAAI,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAS,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,aAAa,GAAG,eAAK,CAAC,MAAM,EAAc,CAAC;QAEjD,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,EAAE;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E/D,IAAI,KAAK,IAAI,CAAC,EAAE;YACd,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YAE1E,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;YAC9C,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;SAClC;KACF;AACH,CAAC,CAAC","file":"BaseComponent.js","sourcesContent":["import React, { useContext, useEffect } from 'react';\nimport { isEqual, isNil, pickWithout } from '@visactor/vutils';\n\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport { bindEventsToChart } from '../eventsUtils';\nimport { uid } from '../util';\n\nexport interface BaseComponentProps {\n id?: string | number;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n specName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId'];\n const notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp: React.FC<T> = (props: T) => {\n const context = useContext(RootChartContext);\n const id = React.useRef<string | number>(isNil(props.id) ? uid(specName) : props.id);\n\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n const componentSpec = React.useRef<Partial<T>>();\n\n if (props.updateId !== updateId.current) {\n // update triggered by chart when chart is rendered\n updateId.current = props.updateId;\n\n // rebind events after chart render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToChart(context.chart, props, eventsBinded.current, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n } else {\n const newComponentSpec: Partial<T> = pickWithout<T>(props, notSpecKeys);\n\n if (!isEqual(newComponentSpec, componentSpec.current)) {\n componentSpec.current = newComponentSpec;\n updateToContext(context, id.current, specName, isSingle, newComponentSpec);\n }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToChart(context.chart, null, eventsBinded.current, supportedEvents);\n }\n deleteToContext(context, id.current, specName, isSingle);\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n return Comp;\n};\n\nconst updateToContext = (\n context: ChartContextType,\n id: string | number,\n specName: string,\n isSingle: boolean,\n props: Partial<ComponentProps>\n) => {\n if (!context.specFromChildren) {\n return;\n }\n\n if (isSingle) {\n context.specFromChildren[specName] = { ...props };\n } else {\n if (!context.specFromChildren[specName]) {\n context.specFromChildren[specName] = [];\n }\n\n const comps = context.specFromChildren[specName];\n const index = comps.findIndex((entry: any) => entry.id === id);\n\n if (index >= 0) {\n comps[index] = {\n id,\n ...props\n };\n } else {\n context.specFromChildren[specName].push({\n id,\n ...props\n });\n }\n }\n context.isChildrenUpdated = true;\n};\n\nconst deleteToContext = (context: ChartContextType, id: string | number, specName: string, isSingle: boolean) => {\n if (!context.specFromChildren) {\n return;\n }\n\n if (isSingle) {\n context.specFromChildren[specName] = null;\n } else {\n const comps = context.specFromChildren[specName] ?? [];\n const index = comps.findIndex((entry: any) => entry.id === id);\n\n if (index >= 0) {\n const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));\n\n context.specFromChildren[specName] = newComps;\n context.isChildrenUpdated = true;\n }\n }\n};\n"]}
1
+ {"version":3,"sources":["../src/components/BaseComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,6CAA+C;AAE/C,6DAAgD;AAChD,gDAAmD;AAQ5C,MAAM,eAAe,GAAG,CAC7B,aAAqB,EACrB,QAAgB,EAChB,eAA+C,EAC/C,QAAkB,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAA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tB,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAjDW,QAAA,eAAe,mBAiD1B","file":"BaseComponent.js","sourcesContent":["import React, { useContext, useEffect } from 'react';\nimport { pickWithout } from '@visactor/vutils';\n\nimport RootChartContext from '../context/chart';\nimport { bindEventsToChart } from '../eventsUtils';\n\nexport interface BaseComponentProps {\n id?: string | number;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number; componentId?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n specName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId', 'componentId'];\n const notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp: React.FC<T> = (props: T) => {\n const context = useContext(RootChartContext);\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n if (props.updateId !== updateId.current) {\n // update triggered by chart when chart is rendered\n updateId.current = props.updateId;\n\n // rebind events after chart render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToChart(context.chart, props, eventsBinded.current, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToChart(context.chart, null, eventsBinded.current, supportedEvents);\n }\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n (Comp as any).parseSpec = (props: T & { updateId?: number; componentId?: string }) => {\n const newComponentSpec: Partial<T> = pickWithout<T>(props, notSpecKeys);\n\n return {\n spec: newComponentSpec,\n specName,\n isSingle\n };\n };\n\n return Comp;\n};\n"]}
@@ -1,14 +1,4 @@
1
- import React from 'react';
2
- import type { MarkSpec } from '@visactor/vgrammar-core';
3
- export interface MarkProps extends Omit<MarkSpec, 'name' | 'id'> {
4
- id?: string | number;
5
- glyphType?: string;
6
- }
7
- export interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {
8
- id: string | number;
9
- }
10
- type Props = MarkProps & {
11
- updateId?: number;
12
- };
13
- export declare const Mark: React.FC<Props>;
14
- export {};
1
+ import type { ICustomMarkSpec, EnableMarkType } from '@visactor/vchart';
2
+ import { BaseComponentProps } from './BaseComponent';
3
+ export type MarkProps = ICustomMarkSpec<EnableMarkType> & BaseComponentProps;
4
+ export declare const Mark: import("react").FC<MarkProps>;
@@ -1,69 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
- void 0 === k2 && (k2 = k);
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
- enumerable: !0,
8
- get: function() {
9
- return m[k];
10
- }
11
- }), Object.defineProperty(o, k2, desc);
12
- } : function(o, m, k, k2) {
13
- void 0 === k2 && (k2 = k), o[k2] = m[k];
14
- }), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
15
- Object.defineProperty(o, "default", {
16
- enumerable: !0,
17
- value: v
18
- });
19
- } : function(o, v) {
20
- o.default = v;
21
- }), __importStar = this && this.__importStar || function(mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
25
- return __setModuleDefault(result, mod), result;
26
- }, __rest = this && this.__rest || function(s, e) {
27
- var t = {};
28
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
29
- if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
30
- var i = 0;
31
- for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
32
- }
33
- return t;
34
- }, __importDefault = this && this.__importDefault || function(mod) {
35
- return mod && mod.__esModule ? mod : {
36
- default: mod
37
- };
38
- };
39
-
40
3
  Object.defineProperty(exports, "__esModule", {
41
4
  value: !0
42
5
  }), exports.Mark = void 0;
43
6
 
44
- const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), view_1 = __importDefault(require("../context/view")), util_1 = require("../util"), Mark = props => {
45
- const context = (0, react_1.useContext)(view_1.default), id = react_1.default.useRef((0,
46
- vutils_1.isNil)(props.id) ? (0, util_1.uid)("mark") : props.id), updateId = react_1.default.useRef(props.updateId);
47
- return props.updateId !== updateId.current && (updateId.current = props.updateId,
48
- context && addOrUpdateMark(context, id.current, props)), (0, react_1.useEffect)((() => () => {
49
- context && removeMark(context, id.current);
50
- }), []), null;
51
- };
52
-
53
- exports.Mark = Mark;
7
+ const BaseComponent_1 = require("./BaseComponent");
54
8
 
55
- const addOrUpdateMark = (view, id, props) => {
56
- var _a;
57
- if (!view.renderer) return;
58
- let mark = view.getMarkById(id);
59
- const {group: group, glyphType: glyphType, updateId: updateId} = props, others = __rest(props, [ "group", "glyphType", "updateId" ]);
60
- mark || (mark = view.mark(props.type, null !== (_a = props.group) && void 0 !== _a ? _a : view.rootMark, props.glyphType ? {
61
- glyphType: props.glyphType
62
- } : null).name(id)), mark.parse(others), view.run();
63
- }, removeMark = (view, id) => {
64
- if (view.renderer) {
65
- view.getMarkById(id);
66
- view.removeGrammar(id);
67
- }
68
- };
9
+ exports.Mark = (0, BaseComponent_1.createComponent)("Mark", "customMark");
69
10
  //# sourceMappingURL=Mark.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Mark.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,6CAAyC;AAGzC,2DAA0C;AAC1C,kCAA8B;AAavB,MAAM,IAAI,GAAoB,CAAC,KAAY,EAAE,EAAE;IACpD,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,cAA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AC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aACvG,IAAI,CAAC,EAAE,CAAC,CAAC;KACb;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,IAAI,CAAC,GAAG,EAAE,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,IAAW,EAAE,EAAU,EAAE,EAAE;IAC7C,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACjC,IAAY,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;KACjC;AACH,CAAC,CAAC","file":"Mark.js","sourcesContent":["import React, { useContext, useEffect } from 'react';\nimport { isNil } from '@visactor/vutils';\nimport type { IView, MarkSpec } from '@visactor/vgrammar-core';\n\nimport ViewContext from '../context/view';\nimport { uid } from '../util';\n\nexport interface MarkProps extends Omit<MarkSpec, 'name' | 'id'> {\n id?: string | number;\n glyphType?: string;\n}\n\nexport interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {\n id: string | number;\n}\n\ntype Props = MarkProps & { updateId?: number };\n\nexport const Mark: React.FC<Props> = (props: Props) => {\n const context = useContext(ViewContext);\n const id = React.useRef<string | number>(isNil(props.id) ? uid('mark') : props.id);\n const updateId = React.useRef<number>(props.updateId);\n\n if (props.updateId !== updateId.current) {\n // only update mark when chart finished render\n updateId.current = props.updateId;\n if (context) {\n addOrUpdateMark(context, id.current as string, props);\n }\n }\n\n useEffect(() => {\n return () => {\n if (context) {\n removeMark(context, id.current as string);\n }\n };\n }, []);\n\n return null;\n};\n\nconst addOrUpdateMark = (view: IView, id: string, props: Props) => {\n if (!view.renderer) {\n // view has been released\n return;\n }\n\n let mark = view.getMarkById(id);\n const { group, glyphType, updateId, ...others } = props;\n if (!mark) {\n mark = (view as any)\n .mark(props.type, props.group ?? view.rootMark, props.glyphType ? { glyphType: props.glyphType } : null)\n .name(id);\n }\n\n mark.parse(others);\n view.run();\n};\n\nconst removeMark = (view: IView, id: string) => {\n if (view.renderer) {\n const mark = view.getMarkById(id);\n (view as any).removeGrammar(id);\n }\n};\n"]}
1
+ {"version":3,"sources":["../src/components/Mark.tsx"],"names":[],"mappings":";;;AACA,mDAAsE;AAIzD,QAAA,IAAI,GAAG,IAAA,+BAAe,EAAY,MAAM,EAAE,YAAY,CAAC,CAAC","file":"Mark.js","sourcesContent":["import type { ICustomMarkSpec, EnableMarkType } from '@visactor/vchart';\nimport { BaseComponentProps, createComponent } from './BaseComponent';\n\nexport type MarkProps = ICustomMarkSpec<EnableMarkType> & BaseComponentProps;\n\nexport const Mark = createComponent<MarkProps>('Mark', 'customMark');\n"]}
@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  const BaseComponent_1 = require("./BaseComponent");
8
8
 
9
- exports.Region = (0, BaseComponent_1.createComponent)("Region", "region");
9
+ exports.Region = (0, BaseComponent_1.createComponent)("Region", "region");
10
+ //# sourceMappingURL=Region.js.map
@@ -6,5 +6,4 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  const BaseComponent_1 = require("./BaseComponent");
8
8
 
9
- exports.Title = (0, BaseComponent_1.createComponent)("Title", "title", null, !0);
10
- //# sourceMappingURL=Title.js.map
9
+ exports.Title = (0, BaseComponent_1.createComponent)("Title", "title", null, !0);
@@ -9,7 +9,7 @@ export * from './MarkLine';
9
9
  export * from './MarkArea';
10
10
  export * from './MarkPoint';
11
11
  export * from './ScrollBar';
12
- export * from './Tooltip';
12
+ export * from './tooltip';
13
13
  export * from './Player';
14
14
  export * from './Indicator';
15
15
  export * from './Title';
@@ -22,7 +22,7 @@ __exportStar(require("./Region"), exports), __exportStar(require("./Legend"), ex
22
22
  __exportStar(require("./Brush"), exports), __exportStar(require("./Crosshair"), exports),
23
23
  __exportStar(require("./DataZoom"), exports), __exportStar(require("./MarkLine"), exports),
24
24
  __exportStar(require("./MarkArea"), exports), __exportStar(require("./MarkPoint"), exports),
25
- __exportStar(require("./ScrollBar"), exports), __exportStar(require("./Tooltip"), exports),
25
+ __exportStar(require("./ScrollBar"), exports), __exportStar(require("./tooltip"), exports),
26
26
  __exportStar(require("./Player"), exports), __exportStar(require("./Indicator"), exports),
27
27
  __exportStar(require("./Title"), exports);
28
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,6CAA2B;AAC3B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB","file":"index.js","sourcesContent":["export * from './Axis';\nexport * from './Mark';\nexport * from './Region';\nexport * from './Legend';\nexport * from './Brush';\nexport * from './Crosshair';\nexport * from './DataZoom';\nexport * from './MarkLine';\nexport * from './MarkArea';\nexport * from './MarkPoint';\nexport * from './ScrollBar';\nexport * from './Tooltip';\nexport * from './Player';\nexport * from './Indicator';\nexport * from './Title';\n"]}
1
+ {"version":3,"sources":["../src/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,6CAA2B;AAC3B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,4CAA0B;AAC1B,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB","file":"index.js","sourcesContent":["export * from './Axis';\nexport * from './Mark';\nexport * from './Region';\nexport * from './Legend';\nexport * from './Brush';\nexport * from './Crosshair';\nexport * from './DataZoom';\nexport * from './MarkLine';\nexport * from './MarkArea';\nexport * from './MarkPoint';\nexport * from './ScrollBar';\nexport * from './tooltip';\nexport * from './Player';\nexport * from './Indicator';\nexport * from './Title';\n"]}
@@ -0,0 +1,2 @@
1
+ import { TooltipProps } from './interface';
2
+ export declare const Tooltip: import("react").FC<TooltipProps>;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Tooltip = void 0;
6
6
 
7
- const BaseComponent_1 = require("./BaseComponent");
7
+ const BaseComponent_1 = require("../BaseComponent");
8
8
 
9
9
  exports.Tooltip = (0, BaseComponent_1.createComponent)("Tooltip", "tooltip", null, !0);
10
- //# sourceMappingURL=Tooltip.js.map
10
+ //# sourceMappingURL=Tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;AAAA,oDAAmD;AAGtC,QAAA,OAAO,GAAG,IAAA,+BAAe,EAAe,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC","file":"Tooltip.js","sourcesContent":["import { createComponent } from '../BaseComponent';\nimport { TooltipProps } from './interface';\n\nexport const Tooltip = createComponent<TooltipProps>('Tooltip', 'tooltip', null, true);\n"]}
@@ -0,0 +1 @@
1
+ export declare const REACT_TOOLTIP_ClASS_NAME: string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.REACT_TOOLTIP_ClASS_NAME = void 0;
6
+
7
+ const vchart_1 = require("@visactor/vchart");
8
+
9
+ exports.REACT_TOOLTIP_ClASS_NAME = `${vchart_1.PREFIX}_REACT_TOOLTIP`;
10
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/tooltip/constant.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE7B,QAAA,wBAAwB,GAAG,GAAG,eAAM,gBAAgB,CAAC","file":"constant.js","sourcesContent":["import { PREFIX } from '@visactor/vchart';\n\nexport const REACT_TOOLTIP_ClASS_NAME = `${PREFIX}_REACT_TOOLTIP`;\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './Tooltip';
2
+ export * from './interface';
3
+ export * from './constant';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __exportStar = this && this.__exportStar || function(m, exports) {
15
+ for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
16
+ };
17
+
18
+ Object.defineProperty(exports, "__esModule", {
19
+ value: !0
20
+ }), __exportStar(require("./Tooltip"), exports), __exportStar(require("./interface"), exports),
21
+ __exportStar(require("./constant"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/tooltip/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,6CAA2B","file":"index.js","sourcesContent":["export * from './Tooltip';\nexport * from './interface';\nexport * from './constant';\n"]}
@@ -0,0 +1,14 @@
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ import { BaseComponentProps } from '../BaseComponent';
3
+ import type { ITooltipSpec, ITooltipActual, TooltipHandlerParams } from '@visactor/vchart';
4
+ export type TooltipProps = PropsWithChildren<ITooltipSpec & IReactTooltipProps & BaseComponentProps>;
5
+ export interface ITooltipRenderProps {
6
+ tooltipElement: HTMLElement;
7
+ actualTooltip: ITooltipActual;
8
+ params: TooltipHandlerParams;
9
+ }
10
+ export type TooltipRender = (tooltipElement: HTMLElement, actualTooltip: ITooltipActual, params: TooltipHandlerParams) => ReactNode;
11
+ export interface IReactTooltipProps {
12
+ tooltipRender?: TooltipRender;
13
+ reserveDefaultTooltip?: boolean;
14
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/tooltip/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import { PropsWithChildren, ReactNode } from 'react';\nimport { BaseComponentProps } from '../BaseComponent';\nimport type { ITooltipSpec, ITooltipActual, TooltipHandlerParams } from '@visactor/vchart';\n\nexport type TooltipProps = PropsWithChildren<ITooltipSpec & IReactTooltipProps & BaseComponentProps>;\n\nexport interface ITooltipRenderProps {\n tooltipElement: HTMLElement;\n actualTooltip: ITooltipActual;\n params: TooltipHandlerParams;\n}\n\nexport type TooltipRender = (\n tooltipElement: HTMLElement,\n actualTooltip: ITooltipActual,\n params: TooltipHandlerParams\n) => ReactNode;\n\nexport interface IReactTooltipProps {\n /**\n * tooltip 自定义渲染器\n * @since 1.10.0\n */\n tooltipRender?: TooltipRender;\n /**\n * 在应用 `tooltipRender` 配置时,是否保留默认 tooltip dom 元素的显示\n * @since 1.10.0\n */\n reserveDefaultTooltip?: boolean;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { BaseChartProps } from '../../charts/BaseChart';
3
+ import { TooltipProps } from './interface';
4
+ import { ITooltipSpec } from '@visactor/vchart';
5
+ export declare const initCustomTooltip: (setTooltipNode: React.Dispatch<React.SetStateAction<React.ReactNode>>, props: BaseChartProps, spec?: TooltipProps) => ITooltipSpec;