Skip to content

Commit 8b78234

Browse files
committed
feat(bump): migrate @nivo/bump to TypeScript
1 parent fe2652f commit 8b78234

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2272
-1790
lines changed

packages/bump/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@
2222
],
2323
"main": "./dist/nivo-bump.cjs.js",
2424
"module": "./dist/nivo-bump.es.js",
25-
"typings": "./index.d.ts",
25+
"typings": "./dist/types/index.d.ts",
2626
"files": [
2727
"README.md",
2828
"LICENSE.md",
29-
"index.d.ts",
30-
"dist/"
29+
"dist/",
30+
"!dist/tsconfig.tsbuildinfo"
3131
],
3232
"dependencies": {
3333
"@nivo/axes": "0.75.0",
3434
"@nivo/colors": "0.75.0",
3535
"@nivo/legends": "0.75.0",
36+
"@nivo/scales": "0.75.0",
3637
"@nivo/tooltip": "0.75.0",
3738
"@react-spring/web": "9.3.1",
3839
"d3-shape": "^1.3.5"
@@ -42,7 +43,6 @@
4243
},
4344
"peerDependencies": {
4445
"@nivo/core": "0.75.0",
45-
"prop-types": ">= 15.5.10 < 16.0.0",
4646
"react": ">= 16.14.0 < 18.0.0"
4747
},
4848
"publishConfig": {
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
import { memo } from 'react'
2-
import PropTypes from 'prop-types'
31
import { useSpring, animated } from '@react-spring/web'
4-
import { useAnimatedPath, useMotionConfig, blendModePropType } from '@nivo/core'
5-
import { useSerieHandlers } from './hooks'
2+
import { useAnimatedPath, useMotionConfig } from '@nivo/core'
3+
import { useAreaBumpSerieHandlers } from './hooks'
4+
import {
5+
AreaBumpAreaGenerator,
6+
AreaBumpCommonProps,
7+
AreaBumpComputedSerie,
8+
AreaBumpDatum,
9+
} from './types'
610

7-
const Area = ({
11+
interface AreaProps<D extends AreaBumpDatum> {
12+
serie: AreaBumpComputedSerie<D>
13+
areaGenerator: AreaBumpAreaGenerator
14+
blendMode: AreaBumpCommonProps<D>['blendMode']
15+
isInteractive: AreaBumpCommonProps<D>['isInteractive']
16+
onMouseEnter?: AreaBumpCommonProps<D>['onMouseEnter']
17+
onMouseMove?: AreaBumpCommonProps<D>['onMouseMove']
18+
onMouseLeave?: AreaBumpCommonProps<D>['onMouseLeave']
19+
onClick?: AreaBumpCommonProps<D>['onClick']
20+
setCurrentSerie: any
21+
tooltip: AreaBumpCommonProps<D>['tooltip']
22+
}
23+
24+
export const Area = <D extends AreaBumpDatum>({
825
serie,
926
areaGenerator,
1027
blendMode,
@@ -15,8 +32,8 @@ const Area = ({
1532
onClick,
1633
setCurrentSerie,
1734
tooltip,
18-
}) => {
19-
const handlers = useSerieHandlers({
35+
}: AreaProps<D>) => {
36+
const handlers = useAreaBumpSerieHandlers<D>({
2037
serie,
2138
isInteractive,
2239
onMouseEnter,
@@ -29,8 +46,13 @@ const Area = ({
2946

3047
const { animate, config: springConfig } = useMotionConfig()
3148

32-
const animatedPath = useAnimatedPath(areaGenerator(serie.areaPoints))
33-
const animatedProps = useSpring({
49+
const animatedPath = useAnimatedPath(areaGenerator(serie.areaPoints)!)
50+
const animatedProps = useSpring<{
51+
color: string
52+
fillOpacity: number
53+
stroke: string
54+
strokeOpacity: number
55+
}>({
3456
color: serie.color,
3557
fillOpacity: serie.style.fillOpacity,
3658
stroke: serie.style.borderColor,
@@ -55,29 +77,3 @@ const Area = ({
5577
/>
5678
)
5779
}
58-
59-
Area.propTypes = {
60-
serie: PropTypes.shape({
61-
id: PropTypes.string.isRequired,
62-
color: PropTypes.string.isRequired,
63-
fill: PropTypes.string,
64-
areaPoints: PropTypes.array.isRequired,
65-
style: PropTypes.shape({
66-
fillOpacity: PropTypes.number.isRequired,
67-
borderWidth: PropTypes.number.isRequired,
68-
borderColor: PropTypes.string.isRequired,
69-
borderOpacity: PropTypes.number.isRequired,
70-
}).isRequired,
71-
}).isRequired,
72-
areaGenerator: PropTypes.func.isRequired,
73-
blendMode: blendModePropType.isRequired,
74-
isInteractive: PropTypes.bool.isRequired,
75-
onMouseEnter: PropTypes.func,
76-
onMouseMove: PropTypes.func,
77-
onMouseLeave: PropTypes.func,
78-
onClick: PropTypes.func,
79-
setCurrentSerie: PropTypes.func.isRequired,
80-
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
81-
}
82-
83-
export default memo(Area)

packages/bump/src/area-bump/AreaBump.js

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)