Skip to content

Commit

Permalink
feat(line): remove prop-types as we're supposed to rely on TS
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed May 1, 2024
1 parent 12f54c7 commit 26c9135
Show file tree
Hide file tree
Showing 17 changed files with 2 additions and 419 deletions.
3 changes: 1 addition & 2 deletions packages/line/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"@nivo/tooltip": "workspace:*",
"@nivo/voronoi": "workspace:*",
"@react-spring/web": "9.4.5 || ^9.7.2",
"d3-shape": "^1.3.5",
"prop-types": "^15.7.2"
"d3-shape": "^1.3.5"
},
"peerDependencies": {
"react": ">= 16.14.0 < 19.0.0"
Expand Down
26 changes: 1 addition & 25 deletions packages/line/src/Areas.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo } from 'react'
import PropTypes from 'prop-types'
import { useSpring, animated } from '@react-spring/web'
import { useAnimatedPath, useMotionConfig, blendModePropType } from '@nivo/core'
import { useAnimatedPath, useMotionConfig } from '@nivo/core'

const AreaPath = ({ areaBlendMode, areaOpacity, color, fill, path }) => {
const { animate, config: springConfig } = useMotionConfig()
Expand All @@ -34,14 +25,6 @@ const AreaPath = ({ areaBlendMode, areaOpacity, color, fill, path }) => {
)
}

AreaPath.propTypes = {
areaBlendMode: blendModePropType.isRequired,
areaOpacity: PropTypes.number.isRequired,
color: PropTypes.string,
fill: PropTypes.string,
path: PropTypes.string.isRequired,
}

const Areas = ({ areaGenerator, areaOpacity, areaBlendMode, lines }) => {
const computedLines = lines.slice(0).reverse()

Expand All @@ -58,11 +41,4 @@ const Areas = ({ areaGenerator, areaOpacity, areaBlendMode, lines }) => {
)
}

Areas.propTypes = {
areaGenerator: PropTypes.func.isRequired,
areaOpacity: PropTypes.number.isRequired,
areaBlendMode: blendModePropType.isRequired,
lines: PropTypes.arrayOf(PropTypes.object).isRequired,
}

export default memo(Areas)
11 changes: 0 additions & 11 deletions packages/line/src/Line.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Fragment, useState } from 'react'
import {
bindDefs,
Expand All @@ -20,7 +12,6 @@ import { Axes, Grid } from '@nivo/axes'
import { BoxLegendSvg } from '@nivo/legends'
import { Crosshair } from '@nivo/tooltip'
import { useLine } from './hooks'
import { LinePropTypes } from './props'
import Areas from './Areas'
import Lines from './Lines'
import Slices from './Slices'
Expand Down Expand Up @@ -358,6 +349,4 @@ const Line = props => {
)
}

Line.propTypes = LinePropTypes

export default withContainer(Line)
11 changes: 0 additions & 11 deletions packages/line/src/LineCanvas.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { createElement, useRef, useEffect, useState, useCallback, forwardRef } from 'react'
import {
withContainer,
Expand All @@ -18,7 +10,6 @@ import { renderAxesToCanvas, renderGridLinesToCanvas } from '@nivo/axes'
import { renderLegendToCanvas } from '@nivo/legends'
import { useTooltip } from '@nivo/tooltip'
import { useVoronoiMesh, renderVoronoiToCanvas, renderVoronoiCellToCanvas } from '@nivo/voronoi'
import { LineCanvasPropTypes } from './props'
import { useLine } from './hooks'
import PointTooltip from './PointTooltip'

Expand Down Expand Up @@ -345,8 +336,6 @@ const LineCanvas = props => {
)
}

LineCanvas.propTypes = LineCanvasPropTypes

const LineCanvasWithContainer = withContainer(LineCanvas)

export default forwardRef((props, ref) => <LineCanvasWithContainer {...props} canvasRef={ref} />)
40 changes: 0 additions & 40 deletions packages/line/src/Lines.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo } from 'react'
import PropTypes from 'prop-types'
import LinesItem from './LinesItem'

const Lines = ({ lines, lineGenerator, lineWidth }) => {
Expand All @@ -26,35 +17,4 @@ const Lines = ({ lines, lineGenerator, lineWidth }) => {
))
}

Lines.propTypes = {
lines: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
color: PropTypes.string.isRequired,
data: PropTypes.arrayOf(
PropTypes.shape({
data: PropTypes.shape({
x: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Date),
]),
y: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Date),
]),
}).isRequired,
position: PropTypes.shape({
x: PropTypes.number,
y: PropTypes.number,
}).isRequired,
})
).isRequired,
})
).isRequired,
lineWidth: PropTypes.number.isRequired,
lineGenerator: PropTypes.func.isRequired,
}

export default memo(Lines)
21 changes: 0 additions & 21 deletions packages/line/src/LinesItem.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo, useMemo } from 'react'
import PropTypes from 'prop-types'
import { animated } from '@react-spring/web'
import { useAnimatedPath } from '@nivo/core'

Expand All @@ -18,16 +9,4 @@ const LinesItem = ({ lineGenerator, points, color, thickness }) => {
return <animated.path d={animatedPath} fill="none" strokeWidth={thickness} stroke={color} />
}

LinesItem.propTypes = {
points: PropTypes.arrayOf(
PropTypes.shape({
x: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
y: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
})
),
lineGenerator: PropTypes.func.isRequired,
color: PropTypes.string.isRequired,
thickness: PropTypes.number.isRequired,
}

export default memo(LinesItem)
26 changes: 0 additions & 26 deletions packages/line/src/Mesh.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { createElement, memo, useCallback } from 'react'
import PropTypes from 'prop-types'
import { useTooltip } from '@nivo/tooltip'
import { Mesh as BaseMesh } from '@nivo/voronoi'

Expand Down Expand Up @@ -125,21 +116,4 @@ const Mesh = ({
)
}

Mesh.propTypes = {
points: PropTypes.arrayOf(PropTypes.object).isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
margin: PropTypes.object.isRequired,
setCurrent: PropTypes.func.isRequired,
onMouseEnter: PropTypes.func,
onMouseMove: PropTypes.func,
onMouseLeave: PropTypes.func,
onClick: PropTypes.func,
onTouchStart: PropTypes.func,
onTouchMove: PropTypes.func,
onTouchEnd: PropTypes.func,
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
debug: PropTypes.bool.isRequired,
}

export default memo(Mesh)
13 changes: 0 additions & 13 deletions packages/line/src/PointTooltip.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo } from 'react'
import PropTypes from 'prop-types'
import { BasicTooltip } from '@nivo/tooltip'

const LinePointTooltip = ({ point }) => {
Expand All @@ -25,8 +16,4 @@ const LinePointTooltip = ({ point }) => {
)
}

LinePointTooltip.propTypes = {
point: PropTypes.object.isRequired,
}

export default memo(LinePointTooltip)
21 changes: 0 additions & 21 deletions packages/line/src/Points.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo } from 'react'
import PropTypes from 'prop-types'
import { getLabelGenerator, DotsItem, useTheme } from '@nivo/core'

const Points = ({ points, symbol, size, borderWidth, enableLabel, label, labelYOffset }) => {
Expand Down Expand Up @@ -57,16 +48,4 @@ const Points = ({ points, symbol, size, borderWidth, enableLabel, label, labelYO
)
}

Points.propTypes = {
points: PropTypes.arrayOf(PropTypes.object),
symbol: PropTypes.func,
size: PropTypes.number.isRequired,
color: PropTypes.func.isRequired,
borderWidth: PropTypes.number.isRequired,
borderColor: PropTypes.func.isRequired,
enableLabel: PropTypes.bool.isRequired,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,
labelYOffset: PropTypes.number,
}

export default memo(Points)
8 changes: 0 additions & 8 deletions packages/line/src/ResponsiveLine.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { ResponsiveWrapper } from '@nivo/core'
import Line from './Line'

Expand Down
8 changes: 0 additions & 8 deletions packages/line/src/ResponsiveLineCanvas.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { forwardRef } from 'react'
import { ResponsiveWrapper } from '@nivo/core'
import LineCanvas from './LineCanvas'
Expand Down
14 changes: 0 additions & 14 deletions packages/line/src/SliceTooltip.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo } from 'react'
import PropTypes from 'prop-types'
import { useTheme } from '@nivo/core'
import { Chip, TableTooltip } from '@nivo/tooltip'

Expand All @@ -28,9 +19,4 @@ const SliceTooltip = ({ slice, axis }) => {
)
}

SliceTooltip.propTypes = {
slice: PropTypes.object.isRequired,
axis: PropTypes.oneOf(['x', 'y']).isRequired,
}

export default memo(SliceTooltip)
37 changes: 0 additions & 37 deletions packages/line/src/Slices.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { memo } from 'react'
import PropTypes from 'prop-types'
import SlicesItem from './SlicesItem'

const Slices = ({
Expand Down Expand Up @@ -48,32 +39,4 @@ const Slices = ({
))
}

Slices.propTypes = {
slices: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.instanceOf(Date),
]).isRequired,
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
points: PropTypes.arrayOf(PropTypes.object).isRequired,
})
).isRequired,
axis: PropTypes.oneOf(['x', 'y']).isRequired,
debug: PropTypes.bool.isRequired,
height: PropTypes.number.isRequired,
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
current: PropTypes.object,
setCurrent: PropTypes.func.isRequired,
onMouseEnter: PropTypes.func,
onMouseMove: PropTypes.func,
onMouseLeave: PropTypes.func,
onClick: PropTypes.func,
onTouchStart: PropTypes.func,
onTouchMove: PropTypes.func,
onTouchEnd: PropTypes.func,
}

export default memo(Slices)
Loading

0 comments on commit 26c9135

Please sign in to comment.