Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(line): remove prop-types as we're supposed to rely on TS #2576

Merged
merged 5 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/annotations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
"@nivo/colors": "workspace:*",
"@nivo/core": "workspace:*",
"@react-spring/web": "9.4.5 || ^9.7.2",
"@types/prop-types": "^15.7.2",
"lodash": "^4.17.21",
"prop-types": "^15.7.2"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">= 16.14.0 < 19.0.0"
Expand Down
4 changes: 1 addition & 3 deletions packages/axes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
"@react-spring/web": "9.4.5 || ^9.7.2",
"@types/d3-format": "^1.4.1",
"@types/d3-time-format": "^2.3.1",
"@types/prop-types": "^15.7.2",
"d3-format": "^1.4.4",
"d3-time-format": "^3.0.0",
"prop-types": "^15.7.2"
"d3-time-format": "^3.0.0"
},
"peerDependencies": {
"react": ">= 16.14.0 < 19.0.0"
Expand Down
28 changes: 0 additions & 28 deletions packages/axes/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
import PropTypes from 'prop-types'

export const axisPropTypes = {
ticksPosition: PropTypes.oneOf(['before', 'after']),
tickValues: PropTypes.oneOfType([
PropTypes.number,
PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.instanceOf(Date)])
),
PropTypes.string,
]),
rotateOnTickLength: PropTypes.shape({
angle: PropTypes.number,
length: PropTypes.number,
}),
tickSize: PropTypes.number,
tickPadding: PropTypes.number,
tickRotation: PropTypes.number,
format: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
renderTick: PropTypes.func,
legend: PropTypes.node,
legendPosition: PropTypes.oneOf(['start', 'middle', 'end']),
legendOffset: PropTypes.number,
ariaHidden: PropTypes.bool,
}

export const axisPropType = PropTypes.shape(axisPropTypes)

export const positions = ['top', 'right', 'bottom', 'left'] as const
4 changes: 1 addition & 3 deletions packages/legends/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
"@nivo/colors": "workspace:*",
"@nivo/core": "workspace:*",
"@types/d3-scale": "^4.0.8",
"@types/prop-types": "^15.7.2",
"d3-scale": "^4.0.2",
"prop-types": "^15.7.2"
"d3-scale": "^4.0.2"
},
"peerDependencies": {
"react": ">= 16.14.0 < 19.0.0"
Expand Down
1 change: 0 additions & 1 deletion packages/legends/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './svg'
export * from './canvas'
export * from './defaults'
export * from './hooks'
export * from './props'
export * from './types'
export * from './compute'
export * from './defaults'
76 changes: 0 additions & 76 deletions packages/legends/src/props.ts

This file was deleted.

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)
Loading
Loading