import type { IRectMarkSpec, ISymbolMarkSpec, ITextMarkSpec } from '../../../typings/visual'; import type { DiscreteLegendAttrs, LegendItemDatum, LegendItem, LegendPagerAttributes, LegendScrollbarAttributes } from '@visactor/vrender-components'; import type { ILegendCommonSpec, NoVisibleMarkStyle } from '../interface'; import type { IFormatMethod, StringOrNumber } from '../../../typings'; import type { IBaseScale } from '@visactor/vscale'; import type { IGlobalScale } from '../../../scale/interface'; import type { ComponentThemeWithDirection } from '../../interface'; export type formatterCallback = IFormatMethod<[text: StringOrNumber, item: LegendItemDatum, index: number]>; export type LegendItemStyleValue = T | ((item: LegendItemDatum, isSelected: boolean, index: number, allItems: LegendItemDatum[]) => T); export type LegendItemStyle = { style?: T; state?: { selected?: T; unSelected?: T; selectedHover?: T; unSelectedHover?: T; }; }; export type IItem = { align?: 'left' | 'right'; background?: { visible?: boolean; } & LegendItemStyle>>; shape?: { visible?: boolean; space?: number; } & LegendItemStyle>>>; label?: { widthRatio?: number; space?: number; formatMethod?: formatterCallback; formatter?: string; } & LegendItemStyle>>; value?: { widthRatio?: number; space?: number; alignRight?: boolean; formatMethod?: formatterCallback; formatter?: string | string[]; } & LegendItemStyle>>; focusIconStyle?: NoVisibleMarkStyle; maxWidth?: number | string; width?: number | string; height?: number | string; autoEllipsisStrategy?: 'labelFirst' | 'valueFirst' | 'none'; } & Omit; export type IPager = { textStyle?: Partial>; handler?: { space?: number; preShape?: string; nextShape?: string; style?: Omit, 'symbolType'>; state?: { hover?: Omit, 'symbolType'>; disable?: Omit, 'symbolType'>; }; }; } & Omit; export type ILegendScrollbar = { type: 'scrollbar'; railStyle?: Omit>, 'width' | 'height'>; sliderStyle?: Omit>, 'width' | 'height'>; } & Omit; export type IDiscreteLegendSpec = ILegendCommonSpec & { type?: 'discrete'; data?: (data: LegendItemDatum[], colorScale: IBaseScale, globalScale: IGlobalScale) => LegendItemDatum[]; item?: IItem; pager?: IPager | ILegendScrollbar; scale?: string; scaleName?: string; field?: string; defaultSelected?: string[]; } & Omit; export type IDiscreteLegendCommonTheme = Omit; export type IDiscreteLegendTheme = ComponentThemeWithDirection;