/
types.ts
138 lines (117 loc) · 3.58 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { FunctionComponent, MouseEvent } from 'react'
import { Theme, Box, Dimensions, ModernMotionProps } from '@nivo/core'
import { OrdinalColorScaleConfig, InheritedColorConfig } from '@nivo/colors'
import { AxisProps } from '@nivo/axes'
export interface BumpDatum {
x: number | string
y: number | null
}
export interface DefaultBumpDatum {
x: string
y: number
}
export interface BumpSerie<D extends BumpDatum> {
id: string
data: D[]
}
export interface BumpSeriePoint<D extends BumpDatum> {
id: string
serie: BumpSerie<D>
data: D
x: number
y: number | null
}
export interface BumpPoint<D extends BumpDatum> extends BumpSeriePoint<D> {
isActive: boolean
isInactive: boolean
color: string
borderColor: string
style: {
size: number
borderWidth: number
}
}
export type BumpPointComponent<D extends BumpDatum> = FunctionComponent<{
point: BumpPoint<D>
}>
export interface BumpComputedSerie<D extends BumpDatum> extends BumpSerie<D> {
color: string
style: {
lineWidth: number
opacity: number
}
points: BumpSeriePoint<D>[]
linePoints: [number, number | null][]
}
export type BumpDataProps<D extends BumpDatum> = {
data: BumpSerie<D>[]
}
export type BumpInterpolation = 'smooth' | 'linear'
export type BumpLabel<D extends BumpDatum> = ((serie: BumpComputedSerie<D>) => string) | boolean
export interface BumpLabelData<D extends BumpDatum> {
serie: BumpComputedSerie<D>
id: BumpSerie<D>['id']
label: string
x: number
y: number
color: string
opacity: number
textAnchor: 'start' | 'end'
}
export type BumpMouseHandler<D extends BumpDatum> = (
serie: BumpComputedSerie<D>,
event: MouseEvent<SVGPathElement>
) => void
export type BumpLayerId = 'grid' | 'axes' | 'labels' | 'lines' | 'points'
export interface BumpCustomLayerProps {}
export type BumpCustomLayer = FunctionComponent<BumpCustomLayerProps>
export type BumpCommonProps<D extends BumpDatum> = {
margin: Box
interpolation: BumpInterpolation
xPadding: number
xOuterPadding: number
yOuterPadding: number
theme: Theme
colors: OrdinalColorScaleConfig<Omit<BumpComputedSerie<D>, 'color' | 'style'>>
lineWidth: number
activeLineWidth: number
inactiveLineWidth: number
opacity: number
activeOpacity: number
inactiveOpacity: number
startLabel: BumpLabel<D>
startLabelPadding: number
startLabelTextColor: InheritedColorConfig<BumpComputedSerie<D>>
endLabel: BumpLabel<D>
endLabelPadding: number
endLabelTextColor: InheritedColorConfig<BumpComputedSerie<D>>
pointSize: number
activePointSize: number
inactivePointSize: number
pointColor: InheritedColorConfig<any>
pointBorderWidth: number
activePointBorderWidth: number
inactivePointBorderWidth: number
pointBorderColor: InheritedColorConfig<any>
enableGridX: boolean
enableGridY: boolean
axisBottom: AxisProps | null
axisLeft: AxisProps | null
axisRight: AxisProps | null
axisTop: AxisProps | null
isInteractive: boolean
defaultActiveSerieIds: string[]
onMouseEnter: BumpMouseHandler<D>
onMouseMove: BumpMouseHandler<D>
onMouseLeave: BumpMouseHandler<D>
onClick: BumpMouseHandler<D>
tooltip: FunctionComponent<{ serie: BumpComputedSerie<D> }>
role: string
layers: (BumpLayerId | BumpCustomLayer)[]
renderWrapper: boolean
}
export type BumpSvgProps<D extends BumpDatum> = Partial<BumpCommonProps<D>> &
BumpDataProps<D> & {
pointComponent?: BumpPointComponent<D>
} & Dimensions &
ModernMotionProps