Skip to content

Commit

Permalink
Merge pull request apache#14871 from dougalg/fix-14277
Browse files Browse the repository at this point in the history
fix(types) Export cbs and their parameter types
  • Loading branch information
pissang authored May 18, 2021
2 parents e112417 + 531c77f commit 7c4c93c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/component/tooltip/TooltipModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import {AxisPointerOption} from '../axisPointer/AxisPointerModel';


type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[];
export type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[];

export interface TooltipOption extends CommonTooltipOption<TopLevelFormatterParams>, ComponentOption {
mainType?: 'tooltip'
Expand Down
2 changes: 1 addition & 1 deletion src/export/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
// This file is for providing types when import whole module.

export * from './core';
export * from './option';
export * from './option';
37 changes: 34 additions & 3 deletions src/export/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -97,7 +100,21 @@ 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,
TooltipPositionCallback,
TooltipPositionCallbackParams
} from '../util/types';

interface ToolboxComponentOption extends ToolboxOption {
feature?: {
Expand Down Expand Up @@ -234,4 +251,18 @@ export interface EChartsOption extends ECBasicOption {

options?: EChartsOption[];
baseOption?: EChartsOption;
}
}

export {
AnimationDurationCallback,
AnimationDelayCallback,
AnimationDelayCallbackParam as AnimationDelayCallbackParams,
LabelFormatterCallback,
CallbackDataParams as DefaultLabelFormatterCallbackParams,
LabelLayoutOptionCallbackParams,
LabelLayoutOptionCallback,
TooltipFormatterCallback as TooltipComponentFormatterCallback,
TopLevelFormatterParams as TooltipComponentFormatterCallbackParams,
TooltipPositionCallback as TooltipComponentPositionCallback,
TooltipPositionCallbackParams as TooltipComponentPositionCallbackParams
};
11 changes: 7 additions & 4 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ export interface LabelLayoutOption {
export type LabelLayoutOptionCallback = (params: LabelLayoutOptionCallbackParams) => LabelLayoutOption;


interface TooltipFormatterCallback<T> {
export interface TooltipFormatterCallback<T> {
/**
* For sync callback
* params will be an array on axis trigger.
Expand All @@ -1232,16 +1232,19 @@ type TooltipBuiltinPosition = 'inside' | 'top' | 'left' | 'right' | 'bottom';
type TooltipBoxLayoutOption = Pick<
BoxLayoutOptionMixin, 'top' | 'left' | 'right' | 'bottom'
>;

export type TooltipPositionCallbackParams = CallbackDataParams | CallbackDataParams[];

/**
* Position relative to the hoverred element. Only available when trigger is item.
*/
interface PositionCallback {
export interface TooltipPositionCallback {
(
point: [number, number],
/**
* params will be an array on axis trigger.
*/
params: CallbackDataParams | CallbackDataParams[],
params: TooltipPositionCallbackParams,
/**
* Will be HTMLDivElement when renderMode is html
* Otherwise it's graphic.Text
Expand Down Expand Up @@ -1288,7 +1291,7 @@ export interface CommonTooltipOption<FormatterParams> {
*
* Support to be a callback
*/
position?: (number | string)[] | TooltipBuiltinPosition | PositionCallback | TooltipBoxLayoutOption
position?: (number | string)[] | TooltipBuiltinPosition | TooltipPositionCallback | TooltipBoxLayoutOption

confine?: boolean

Expand Down

0 comments on commit 7c4c93c

Please sign in to comment.