From 9b08a0e11a83a8b16be1f0d420097499bc97d702 Mon Sep 17 00:00:00 2001 From: Dougal Graham Date: Thu, 6 May 2021 11:05:17 +0700 Subject: [PATCH] fix(types) Export cbs and their parameter types --- src/component/tooltip/TooltipModel.ts | 2 +- src/export/all.ts | 2 +- src/export/option.ts | 35 ++++++++++++++++++++++++--- src/util/types.ts | 4 +-- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/component/tooltip/TooltipModel.ts b/src/component/tooltip/TooltipModel.ts index 94c2776c428..2d9c929985c 100644 --- a/src/component/tooltip/TooltipModel.ts +++ b/src/component/tooltip/TooltipModel.ts @@ -30,7 +30,7 @@ import { import {AxisPointerOption} from '../axisPointer/AxisPointerModel'; -type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[]; +export type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[]; export interface TooltipOption extends CommonTooltipOption, ComponentOption { mainType?: 'tooltip' diff --git a/src/export/all.ts b/src/export/all.ts index 41b74206a73..8778a8bb232 100644 --- a/src/export/all.ts +++ b/src/export/all.ts @@ -20,4 +20,4 @@ // This file is for providing types when import whole module. export * from './core'; -export * from './option'; \ No newline at end of file +export * from './option'; diff --git a/src/export/option.ts b/src/export/option.ts index 39ac46b4f31..f693b4af9b9 100644 --- a/src/export/option.ts +++ b/src/export/option.ts @@ -34,7 +34,10 @@ import type {ParallelAxisOption as ParallelAxisComponentOption} from '../coord/p import type {ParallelCoordinateSystemOption as ParallelComponentOption} from '../coord/parallel/ParallelModel'; import type {CalendarOption as CalendarComponentOption} from '../coord/calendar/CalendarModel'; import type {ToolboxOption} from '../component/toolbox/ToolboxModel'; -import type {TooltipOption as TooltipComponentOption} from '../component/tooltip/TooltipModel'; +import type { + TooltipOption as TooltipComponentOption, + TopLevelFormatterParams +} from '../component/tooltip/TooltipModel'; import type {AxisPointerOption as AxisPointerComponentOption} from '../component/axisPointer/AxisPointerModel'; import type {BrushOption as BrushComponentOption} from '../component/brush/BrushModel'; import type {TitleOption as TitleComponentOption} from '../component/title/install'; @@ -97,7 +100,20 @@ import type {ToolboxSaveAsImageFeatureOption} from '../component/toolbox/feature import type {ToolboxFeatureOption} from '../component/toolbox/featureManager'; -import type { ECBasicOption, SeriesTooltipOption, AriaOption as AriaComponentOption } from '../util/types'; +import type { + ECBasicOption, + SeriesTooltipOption, + AriaOption as AriaComponentOption, + TooltipFormatterCallback, + LabelFormatterCallback, + CallbackDataParams, + AnimationDurationCallback, + AnimationDelayCallback, + AnimationDelayCallbackParam, + LabelLayoutOptionCallbackParams, + LabelLayoutOptionCallback, + PositionCallback +} from '../util/types'; interface ToolboxComponentOption extends ToolboxOption { feature?: { @@ -234,4 +250,17 @@ export interface EChartsOption extends ECBasicOption { options?: EChartsOption[]; baseOption?: EChartsOption; -} \ No newline at end of file +} + +export { + TooltipFormatterCallback as TooltipComponentFormatterCallback, + TopLevelFormatterParams as TooltipComponentFormatterParams, + LabelFormatterCallback, + CallbackDataParams as DefaultLabelFormatterParams, + AnimationDurationCallback, + AnimationDelayCallback, + AnimationDelayCallbackParam as AnimationDelayCallbackParams, + LabelLayoutOptionCallbackParams, + LabelLayoutOptionCallback, + PositionCallback +}; diff --git a/src/util/types.ts b/src/util/types.ts index 62ddb56ef5e..5dc4562c894 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -1214,7 +1214,7 @@ export interface LabelLayoutOption { export type LabelLayoutOptionCallback = (params: LabelLayoutOptionCallbackParams) => LabelLayoutOption; -interface TooltipFormatterCallback { +export interface TooltipFormatterCallback { /** * For sync callback * params will be an array on axis trigger. @@ -1235,7 +1235,7 @@ type TooltipBoxLayoutOption = Pick< /** * Position relative to the hoverred element. Only available when trigger is item. */ -interface PositionCallback { +export interface PositionCallback { ( point: [number, number], /**