Skip to content

Commit

Permalink
fix(bar): Fix BarItemProps types (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
eggei committed Oct 22, 2020
1 parent 259e037 commit 7f19561
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions packages/bar/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ declare module '@nivo/bar' {
value: number
index: number
indexValue: Value
color: string
data: BarDatum
}

Expand All @@ -51,19 +50,18 @@ declare module '@nivo/bar' {

export type ValueFormatter = (value: number) => string | number

export type BarMouseEventHandler<T = HTMLCanvasElement> = (
type GraphicsContainer = HTMLCanvasElement | SVGRectElement

export type BarMouseEventHandler<T = GraphicsContainer> = (
datum: BarExtendedDatum,
event: React.MouseEvent<T>
) => void

export type TooltipProp = React.StatelessComponent<BarExtendedDatum>
export type BarTooltipDatum = BarExtendedDatum & { color: string }
export type TooltipProp = React.FC<BarTooltipDatum>

export interface BarItemProps {
data: {
id: string | number
value: number
indexValue: string | number
}
data: BarExtendedDatum
x: number
y: number
width: number
Expand All @@ -80,7 +78,7 @@ declare module '@nivo/bar' {
onMouseLeave: BarMouseEventHandler
tooltipFormat: string | ValueFormatter
tooltip: TooltipProp
showTooltip: (tooltip: React.ReactNode, event: React.MouseEvent<HTMLCanvasElement>) => void
showTooltip: (tooltip: React.ReactNode, event: React.MouseEvent<GraphicsContainer>) => void
hideTooltip: () => void
theme: Theme
}
Expand Down Expand Up @@ -109,7 +107,7 @@ declare module '@nivo/bar' {
enableGridY: boolean
gridYValues: GridValues<Value>

barComponent: React.StatelessComponent<BarItemProps>
barComponent: React.FC<BarItemProps>

enableLabel: boolean
label: string | AccessorFunc
Expand Down
2 changes: 1 addition & 1 deletion packages/swarmplot/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ declare module '@nivo/swarmplot' {
Axes = 'axes',
Nodes = 'nodes',
Mesh = 'mesh',
Annotations = 'annotations'
Annotations = 'annotations',
}

type DatumAccessor<Datum, T> = (datum: Datum) => T
Expand Down

0 comments on commit 7f19561

Please sign in to comment.