diff --git a/packages/tooltip/index.d.ts b/packages/tooltip/index.d.ts deleted file mode 100644 index 7daeef13b..000000000 --- a/packages/tooltip/index.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -import * as React from 'react' -import { Theme } from '@nivo/core' - -declare module '@nivo/tooltip' { - export interface BasicTooltipProps { - id: React.ReactNode - value?: string | number - enableChip?: boolean - color: string - format?: (value: number | string) => number | string - renderContent?: () => React.ReactNode - } - - export class BasicTooltip extends React.Component {} - - export interface ChipProps { - color: string - size?: number - style?: Partial - } - - export class Chip extends React.Component {} - - export interface TableTooltipProps { - title?: React.ReactNode - rows: React.ReactNode[][] - renderContent?: () => React.ReactNode - } - - export class TableTooltip extends React.Component {} - - export type CrosshairType = - | 'x' - | 'y' - | 'top-left' - | 'top' - | 'top-right' - | 'right' - | 'bottom-right' - | 'bottom' - | 'bottom-left' - | 'left' - | 'cross' - - export type TooltipAnchor = 'top' | 'right' | 'bottom' | 'left' | 'center' - - export function useTooltip(): { - showTooltipAt: ( - content: JSX.Element, - position: [number, number], - anchor?: TooltipAnchor - ) => void - showTooltipFromEvent: (content: JSX.Element, event: Event) => void - hideTooltip: () => void - } -} diff --git a/packages/tooltip/src/Crosshair.js b/packages/tooltip/src/Crosshair.tsx similarity index 79% rename from packages/tooltip/src/Crosshair.js rename to packages/tooltip/src/Crosshair.tsx index 3bb60d05d..7e72230fa 100644 --- a/packages/tooltip/src/Crosshair.js +++ b/packages/tooltip/src/Crosshair.tsx @@ -1,7 +1,16 @@ import React, { memo } from 'react' import { CrosshairLine } from './CrosshairLine' +import { CrosshairType } from './types' -export const Crosshair = memo(({ width, height, type, x, y }) => { +interface CrosshairProps { + width: number + height: number + type: CrosshairType + x: number + y: number +} + +export const Crosshair = memo(({ width, height, type, x, y }: CrosshairProps) => { let xLine let yLine if (type === 'cross') { @@ -40,19 +49,3 @@ export const Crosshair = memo(({ width, height, type, x, y }) => { ) }) - -/* -Crosshair.displayName = 'Crosshair' -Crosshair.propTypes = { - width: PropTypes.number.isRequired, - height: PropTypes.number.isRequired, - x: PropTypes.number.isRequired, - y: PropTypes.number.isRequired, - type: crosshairPropTypes.type.isRequired, -} -Crosshair.defaultProps = { - type: 'cross', -} - -export default Crosshair -*/ diff --git a/packages/tooltip/src/CrosshairLine.js b/packages/tooltip/src/CrosshairLine.tsx similarity index 67% rename from packages/tooltip/src/CrosshairLine.js rename to packages/tooltip/src/CrosshairLine.tsx index 4e394e321..15c7be98a 100644 --- a/packages/tooltip/src/CrosshairLine.js +++ b/packages/tooltip/src/CrosshairLine.tsx @@ -1,8 +1,16 @@ import React, { memo, useMemo } from 'react' import { useSpring, animated } from 'react-spring' +// @ts-ignore import { useTheme, useMotionConfig } from '@nivo/core' -export const CrosshairLine = memo(({ x0, x1, y0, y1 }) => { +interface CrosshairLineProps { + x0: number + x1: number + y0: number + y1: number +} + +export const CrosshairLine = memo(({ x0, x1, y0, y1 }: CrosshairLineProps) => { const theme = useTheme() const { animate, config: springConfig } = useMotionConfig() const style = useMemo( @@ -24,15 +32,3 @@ export const CrosshairLine = memo(({ x0, x1, y0, y1 }) => { return }) - -/* -CrosshairLine.displayName = 'CrosshairLine' -CrosshairLine.propTypes = { - x0: PropTypes.number.isRequired, - x1: PropTypes.number.isRequired, - y0: PropTypes.number.isRequired, - y1: PropTypes.number.isRequired, -} - -export default CrosshairLine -*/